# Simulated Annealing, SearchPoints and InitialPoints options set at the same time

I have a function that needs to be minimized. Since the function depends on real-time data (which is fetched every few hours, and the function is redefined according to the new data), I have to run the minimization several times a day.

NMinimize[{CoolFunction[g,v], 0 <= v <= 4, -20 <= g <= 20},
{{g, -20, 20}, {v, 0, 4}},
Method -> {"SimulatedAnnealing", "SearchPoints" -> 100,
"RandomSeed" -> ru, "PostProcess" -> False,
"InitialPoints" -> {{gbest, vbest}}}];


gbest and vbest are the best result found in the previous minimization; ru is a value that increases by one each time the minimization algorithm is run. Since the optimal values don't change very much each time the minimization algorithm is run, one of the initial points is the previous solution (this avoids the possibility that the solution found is worse than just using the previous solution).

(As a side note: I set "PostProcess" to False, since it seems like that setting that option to True causes the Mathematica kernel to crash randomly)

Ideally, Mathematica should select 99 points randomly with the algorithm it usually uses, and add the given initial point to the list of initial points. Since the documentation is not very specific in this regard, I am not sure if this what it is doing (for example, it could be ignoring the "SearchPoints" option, and just running the Simulated Annealing with the single point I gave; giving potentially sub-optimal solutions).

• You can try using EvaluationMonitor to "debug" your settings. Dec 23, 2015 at 15:53

I believe the following shows you the starting points used:

tt = Trace[NMinimize[{x - y, -3 x^2 + 2 x y - y^2 >= -1}, {x, y},
Method -> {"SimulatedAnnealing", "SearchPoints" -> 3,
"InitialPoints" -> {{4.4, 5.5}}}],
TraceInternal -> True];

Cases[tt, OptimizationNMinimizeDumpnfPenalty[{x_?NumericQ, y_?NumericQ}] :>
{x, y}, Infinity]

(* {{4.4, 5.5}, {-0.535769, -0.13703}, {0.307368, -0.462162}} *)


Of course, as with any undocumented thingy, YMMV.

• Yes, this indicates the settings are working as I expected. Also, I found out that setting assigning the variable OptimizationNMinimizeDumpdbPrint = Print before running NMinimize makes NMinimize give (very lengthy) debug info, which also indicates the same behavior. Dec 24, 2015 at 0:39