Is it possible to extract the Method
which is used in functions like NMinimize
, FindRoot
, FindMinimium
, and partners when one doesn't set this option explicitly? Basic example:
NMinimize[x^4 - 3 x^2 - x, x]
What is used as Method
here?
I expected to find some setting in SystemOptions[]
but was unable to. Obviously AbsoluteOptions[expr]
cannot be used in such a case since unlike a e.g. graphic, the minimization result does not contain this option information anymore.
Here is what is stated in the documentation of Method
:
With the default setting
Method -> Automatic
, Mathematica will automatically try to pick the best method for a particular computation.
This tells us the chosen Method
depends on the input problem. Therefore, a fixed setting in SystemOptions
wouldn't make sense.
Additionally, there exists a document describing some internal implementations. Basically, you can extract most information from there, but I was hoping for a way to extract the used Method
during a run.
NMinimize[]
(from here): "For linear cases,NMinimize
andNMaximize
use the same methods asLinearProgramming
. For nonlinear cases, they use Nelder-Mead methods, supplemented by differential evolution, especially when integer variables are present." $\endgroup$OptionValue
doesn't get evaluated when/where the option exist?f[x_, y_] := (x^2 + y^2 - 16)^2; first = True; {sol, {{ mthd}}} = Reap[ NMinimize[f[x, y], {{x, -5, 5}, {y, -5, 5}}, Method -> "DifferentialEvolution", EvaluationMonitor :> If[first, Sow[OptionValue[Method]]; first = False;]]]; mthd
$\endgroup$NMinimize
, yes, it is possible. I described how to get diagnostic output here. For your example it seems to be that differential evolution is used. $\endgroup$Cases[Trace[NMinimize[x^4 - 3 x^2 - x, x], Optimization`NMinimizeDump`method, TraceInternal -> True], {HoldForm[Optimization`NMinimizeDump`method], m_ /; FreeQ[m, Automatic]} :> m, Infinity]
$\endgroup$