I am trying to track the evolution of NMinimize using the SimulatedAnnealing options. Simulated annealing has 3 parameters to track: 1) the latest trial point, 2) the latest accepted point, 3) the global minimum found so far.

It seems to me that using stepmonitor tracks quantity 3). Evaluationmonitor tracks either 1) or 2) but I can't figure out which.

My questions are: A) What do stepmonitor/evaluationmonitor actually track? B) How can I track both 1) and 2)?

Simple code to play around with (adapted from NMinimize help):

f[x_, y_] := 20 Sin[π/2 (x - 2 π)] + 20 Sin[π/2 (y - 2 π)] + (x - 2 π)^2 + (y - 2 π)^2;

fS = {f[0., 0]}; fE = {f[0., 0]};

NMinimize[f[x, y], {x, y}, Method -> {"SimulatedAnnealing", "SearchPoints" -> 10, "PerturbationScale" -> 5, "PostProcess" -> False, "InitialPoints" -> {{0, 0}}, "RandomSeed" -> Floor[AbsoluteTime[]]}, EvaluationMonitor :> AppendTo[fE, f[x, y]], StepMonitor :> AppendTo[fS, f[x, y]]]

Dynamic[Show[ListPlot[fS, Joined -> True, PlotStyle -> Blue], ListPlot[fE, Joined -> False, PlotStyle -> Red], PlotRange -> All]]
  • $\begingroup$ My understanding is, that EvaluationMonitor will be evaluated whenever the function is evaluated. StepMonitor will be evaluated whenever a point is accepted which here should not necessarily be the best point found so far. I would assume that the best point found so far must be accessed by different means. $\endgroup$
    – gwr
    Commented Apr 3, 2016 at 11:15

1 Answer 1


Trying out with MMA 11.0 strongly indicates that StepMonitor accesses the currently best guess, while EvaluationMonitor seems to access the trial guesses. Both can be accessed simultaneously by setting StepMonitor as well as EvalutationMonitor.

This is seen looking at a function we all know the minimum of ($x^2$), setting the acceptance probability to zero, and sowing the values in both ways. One finds with :






Here, we see that the first run (StepMonitor) always returns the best guess, while the second run (EvaluationMonitor) seems to return the random guesses.

In order to have two comparable runs, it is important to set "RandomSeed" as well. Also, "PostProcess" needs to be turned off, in order to stop at values that are really found by guessing randomly. Finally, "SearchPoints" is set to 1, which excludes deflecting different starting points.

Example how both can be tracked simulataneously:

Reap[NMinimize[x^2,x,StepMonitor:>Sow[x,"StepMonitor"], EvaluationMonitor:>Sow[x,"EvaluationMonitor"],MaxIterations->10,Method->{"SimulatedAnnealing","BoltzmannExponent"->Function[{a,b,c},-\[Infinity]],"SearchPoints"->1,"InitialPoints"->{{1}},"PostProcess"->False,"RandomSeed"->6417}]]


As stated initially, this is not a proof but merely strong indication.

(Edited 16:21 at day of post because my initial answer was wrong).

  • $\begingroup$ That is my experience as well, with version 10.1 $\endgroup$
    – user38196
    Commented Feb 14, 2017 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.