# Simulated Annealing InitialPoints option

I have a cost function that depends on 4 parameters: CostFunction[{tx,ty,tz,ox}].

I used NMinimize[] function with SimulatedAnnealing method to determine its minimum. I looked for an example that uses the InitialPoints option but I did not find any. For this reason I am posting my question.

My code is like this (I cannot post the CostFunction[]):

  NMinimize[{
CostFunction[{tx, ty, tz, ox}],
tx >= 0 && tx <= a, ty >= 0 && ty <= b, tz >= 0 && tz <=c, ox >=0 && ox <= d},
{tx,ty,tz,ox},
Method -> {"SimulatedAnnealing", "PerturbationScale" -> 3, "SearchPoints" -> 10}]


The above code works correctly but when I add the "InitialPoints"->{0,0,0,0}, I receive the following error:

NMinimize::parchange: "Inappropriate parameter: \!$$\"InitialPoints\"$$ -> {0,0,0,0}, changed to Automatic"

Another option is not very clear "RandomSeed" ?

Borrowing the function from the documentation in the optimization tutorial

Clear[a, f];
a = Reverse /@ Distribute[{{-32, -16, 0, 16, 32}, {-32, -16, 0, 16, 32}},  List];
f = 1/(0.002 + Plus @@ MapIndexed[1/(#2[] + Plus @@ (({x, y} - #1)^6)) &, a]);

NMinimize[f, {{x, -50, 50}, {y, -50, 50}}, Method -> {"SimulatedAnnealing",
"InitialPoints" -> Flatten[Table[{i, j}, {i, -45, 45, 5}, {j, -45, 45, 5}], 1]}]
{0.998004, {x -> -31.9783, y -> -31.9783}}


I think the problem with your use of InitialPoints is that you have to give it a list of points, and not a single point! Randomseed is used in many functions to specify a starting point for the random number generator so that all runs of the algorithm use the same set of random numbers (this may be desired for repeatability).

• Ok! Thanks, in fact I am developping a program to align each frame from a video with a model. In ieration K, I minimize the costfunction[] to get the optimal rigid transformation between model and video frame, in the next iteration k+1, I want to inject the transformation given in the iteration k as initial point in order to get rapidly the convergence in the next iteration (k+1). Thanks ! Oct 24, 2013 at 2:04
• Have you looked at ImageAlign or ImageCorrespondingPoints. These are likely to do a better job than a direct optimization. Oct 24, 2013 at 2:33
• Thanks for your response, But I need precisily to do direct optimization, because in my case, I can not take a corresponding points. Thanks a lot Oct 24, 2013 at 2:58
• Please, What is the exactly role of the option InitialPoints. Going back to my exemple above, I pick InitialPoints like this Flatten[Table[{i, j, k, l}, {i, -500, 500, 50}, {j, -500, 500, 50}, {k, -90, 90, 20}, {l, -90, 90, 20}], 3]; The algorithm become very slow. I think that, it uses the InitialPoints as a starting points and from each points it look for an optimum, for this reason it is slow! And what is the relation between the option SearchPoints and InitialPoints? is the algorithm takes the SearchPoints from the IntialPoints? Oct 24, 2013 at 17:35
• Simulated annealing works by starting at a large number of initial guesses and then moving in (some kind of mostly) downhill direction until it converges. You want to start at a large variety of initial guesses in order not to miss any minima. Oct 24, 2013 at 17:38