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[]):

        CostFunction[{tx, ty, tz, ox}],
        tx >= 0 && tx <= a, ty >= 0 && ty <= b, tz >= 0 && tz <=c, ox >=0 && ox <= d},
  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" ?

What is wrong, please?


1 Answer 1


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[[1]] + 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).

  • 1
    $\begingroup$ 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 ! $\endgroup$
    – phdstudent
    Oct 24, 2013 at 2:04
  • 1
    $\begingroup$ Have you looked at ImageAlign or ImageCorrespondingPoints. These are likely to do a better job than a direct optimization. $\endgroup$
    – bill s
    Oct 24, 2013 at 2:33
  • 1
    $\begingroup$ 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 $\endgroup$
    – phdstudent
    Oct 24, 2013 at 2:58
  • 1
    $\begingroup$ 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? $\endgroup$
    – phdstudent
    Oct 24, 2013 at 17:35
  • 1
    $\begingroup$ 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. $\endgroup$
    – bill s
    Oct 24, 2013 at 17:38

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.