8
$\begingroup$

Supplying initial guesses works for two parameters:

In[238]:= Table[{i, j}, {i, 1/10, 1, 1/10}, {j, 1/10, 1, 1/10}];
testtab = Flatten[%, 1];

In[240]:= NMinimize[(x + y - 2/10)^2, {x, y}, 
 Method -> {"Automatic", "InitialPoints" -> testtab}]

Out[240]= {0., {x -> 0.1, y -> 0.1}}

But not a single parameter:

In[236]:= footab = Table[i, {i, 1/10, 1, 1/10}];

In[237]:= NMinimize[(x - 2/10)^2, {x}, 
 Method -> {"Automatic", "InitialPoints" -> footab}]

NMinimize::parchange: Inappropriate parameter: 
InitialPoints -> {1/10,1/5,3/10,2/5,1/2,3/5,7/10,4/5,9/10,1}, changed to Automatic. >>

Out[237]= {0., {x -> 0.2}}

The latter seems like a straight-forward simplification of the first case, but yet it clearly doesn't like the initial points a supplied, even though they seem to be viable (one of the guesses is even the correct answer). Now, I do get the right answer in the second case, but I have more complicated code minimizing over a single parameter where it doesn't give me the right answer because Mathematica isn't accepting my initial guesses.

Any thoughts? Thanks for your time as always.

$\endgroup$
9
$\begingroup$

Feed "InitialPoints" a list of 1D vectors:

bartab = Table[{i}, {i, 1/10, 1, 1/10}];

NMinimize[(x - 2/10)^2, {x}, 
 Method -> {"Automatic", "InitialPoints" -> bartab}]
(*  {0., {x -> 0.2}}  *)
|improve this answer|||||
$\endgroup$
1
$\begingroup$

Because NMinimize needs initial "regions", not values.

According to the manual, the initial "guess" region (not value) is given as a constrain. (bold mine)

NMinimize[{x^2, 3 <= x <= 4}, {x}]

In order for NMinimize to work, it needs a rectangular initial region in which to start. This is similar to giving other numerical methods a starting point or starting points. The initial region is specified by giving each variable a finite upper and lower bound. This is done by including in the constraints, or {x,a,b} in the variables. If both are given, the bounds in the variables are used for the initial region, and the constraints are just used as constraints. If no initial region is specified for a variable x, the default initial region of is used. Different variables can have initial regions defined in different ways.

https://reference.wolfram.com/language/tutorial/ConstrainedOptimizationGlobalNumerical.html

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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