Using StepMonitor/EvaluationMonitor with DifferentialEvolution in NMinimize
EvaluationMonitor
is going to be called whenever the objective function is being evaluated, that is much more often than StepMonitor
.
The reason for not getting any points back is that the StepMonitor
specification is not propagated to the NMinimize
call. Try the following syntax instead
nlm = Reap @ NonlinearModelFit[data, Exp[a x/(b + c x)], {a, b, c}, x,
Method -> {NMinimize, StepMonitor :> Sow[{a, b, c}],
Method -> "DifferentialEvolution"}]
For the values of the objective function at these points, one could build the sum of squared residuals by hand, but there is also an internal function that can be used (the added factor of two is because in the default 2-norm case the objective function is $\frac12 \bf r \cdot \bf r$, where $\bf r$ is the residual vector).
obj = Optimization`FindFit`ObjectiveFunction[data, Exp[a x/(b + c x)], {a, b, c}, x];
nlm = Reap @ NonlinearModelFit[data, Exp[a x/(b + c x)], {a, b, c}, x,
Method -> {NMinimize, StepMonitor :> Sow[2 obj[{a, b, c}]],
Method -> "DifferentialEvolution"}]