performance optimization – Why does NonlinearModelFit repeat assessments of identical functions?

If you look at how NonlinearModelFit you find that the model is evaluated with the same parameters over and over again. I have a very expensive model so it wastes a lot of time.

Here is the example of version 12.1 help.

data = {{6.47, 3.65}, {7.43, 
    3.45}, {3.9, -2.94}, {4.8, -1.29}, {2.48, -0.35}, {6.32, 
    3.16}, {2.59, -1.19}, {9.13, -2.}, {3.81, -3.04}, {3.33, -2.68}};

model(a_?NumberQ, b_?NumberQ, c_?NumberQ) :=  Module({y, x},
  Sow({a, b, c}); 
  First(y /. 
    NDSolve({y''(x) + a y(x) == 0, y(0) == b, y'(0) == c}, 
     y, {x, 0, 10})))

t1 = Timing(
  r1 = Reap(
     nlm1 = NonlinearModelFit(data, model(a, b, c)(x), {a, b, c}, x, 
       Method -> "Gradient"));)

(* {4.375, Null}  *)

I added a Sow and Reap so we can find the number of ratings. Looking at the number of terms that have been collected.

L1 = Length(r1((2, 1)))

(* 6280 *)

If we look at the first 100 values, they all seem to be the same. However, they could be almost similar, so I eliminate the identical terms using Union

Union(r1((2, 1, 1 ;; 100))) // InputForm

(* {{1., 1., 1.}, {1., 1., 1.0000000149011612}, 
 {1., 1.0000000149011612, 1.}, {1.0000000149011612, 1., 1.}} *)

This may require further investigation as we are examining small differences, but it appears that only 4 assessments were different. If there is a repeated assessment, memorization seems to be a good idea. I implement this as follows:

model(a_?NumberQ, b_?NumberQ, c_?NumberQ) := 
 model(a, b, c) =  Module({y, x},
   Sow({a, b, c}); 
   First(y /. 
     NDSolve({y''(x) + a y(x) == 0, y(0) == b, y'(0) == c}, 
      y, {x, 0, 10})))

t2 = Timing(
  r2 = Reap(
     nlm2 = NonlinearModelFit(data, model(a, b, c)(x), {a, b, c}, x, 
       Method -> "Gradient"));)

(* {0.1875, Null} *)

The number of job evaluations is now

L2 = Length(r2((2, 1)))

(* 227 *)

Thus, a much lower number of function evaluations and the calculation is performed much faster. The time and function evaluation report is

{t1((1))/t2((1)), L1/L2 // N}

(* {23.3333, 27.6652} *)

It’s an acceleration of 20 times. So it seems that NonlinearModelFit makes unnecessary function assessments and that memorization makes a huge difference.

My questions are:

  1. Did I miss something?

  2. Why NonlinearModelFit do unnecessary job evaluations?

Thank you

Difficulty finding a plug assessments / average numbers

Many thanks for the answer.

The value is not predefined. It is essentially a numeric box with no defined value, but it covers the range 00001 to 99999.

The user sees the image and enters his personal evaluation … For example, "I think it's worth $ 100", he enters 100. This value of $ 100 is then displayed next to the 39; image in the form of "evaluation".

The next user arrives, repeats the process and assigns a value of $ 90 to enter "90". Automatically, the value of updates from 100 USD to 95 USD (average of the number of evaluations, 100 + 90/2 = 95)

If this does not match the available Badge / Reward plugins, how much would php code cost? Just a rough estimate because I really hoped that a plugin already exists.

Thank you so much!


How can I run multiple different kernels for multiple assessments of multiple scripts means Linux terminal?

I have several scripts to run, with the command: math.9 <script_name.m, on a Linux server based on a Linux terminal. The version of Mathematica on the server is Mathematica 9. I know that I can not run more than 7 processes per kernel. Is there a way to start another kernel terminal command or should I use Parallelize in the script? (Even if I do it this way, I can not start Mathematica because it indicates that I have reached the maximum number of processes).

Thanks for the help

How to hire the best iOS developers

Several factors must be taken into account when hiring an iPhone application development company or an iOS developer. Below you will find most of them that can help businesses develop the best iOS app.

Check the profile / developer portfolio
Verifying the developer profile is the first step in finding iOS developers. A professional iOS developer will show his portfolio with his previous iOS application development projects. Companies can take many tips and information from this information provided in the developer's portfolio. Also check references from previous organizations to make sure developers have really worked on these projects.
Check the communication skills of developers and the channels they use
Make sure the iOS app developer has good social and communication skills. During project development, you often need to communicate with developers about some project changes / updates. Developers should be able to respond quickly to you within 24 hours.
Check the skills of developers
Companies must also determine programming knowledge and developer expertise. They must have sufficient development skills to produce error-free codes. If you want a quality application, developers must have provided a reliable quality code for all the projects they have done. You can also take a special interview of the developers to know their skills and expertise. In the end, to develop iOS applications, the developer must be able to use an Objective-C or Swift programming language and must be familiar with the iOS technique.
View customer testimonials, reviews, and ratings given by app users
When consulting the developer's portfolio, you should also consult testimonials and feedback from previous customers. Some developers may also provide manipulated testimonials. Therefore, you should check the reality by contacting customers. You should also check the comments and ratings given by users of the mobile application developed by the developers on App Store.
Check if developers meet the deadline
An experienced and professional developer will always work hard to meet deadlines. Check if they meet deadlines. Publishing the iOS application within a specified time can sometimes prove to be very important for businesses because they have already planned certain events accordingly. In addition, lost time is a lost opportunity for many companies.

Check if the developers are creative enough
The development of iOS applications requires a lot of creativity. In the design and development of the application, developers can face many obstacles, which can only be overcome by the creative and original thinking of developers. Therefore, make sure that iOS developers are creative and follow an innovative approach to developing apps.

Check if the developer has understood the requirements of the mobile application
You must verify that the developers have understood the requirements of the mobile application. If they can not understand them clearly, they will not be able to provide the quality of the application that you expect from them.