|
|
Re: Plotting objective function in FindMinimum
Posted:
Jan 11, 2013 10:22 PM
|
|
f[x_] = x Cos[x];
pts = Reap[fm = FindMinimum[f[x], {x, 2}, EvaluationMonitor :> Sow[{x, f[x]}]]][[-1, 1]]
{{2., -0.832294}, {3., -2.96998}, {4.72069, 0.0391653}, {3.37006, -3.28249}, {3.43491, -3.28821}, {3.42548, \ -3.28837}, {3.42562, -3.28837}, {3.42562, -3.28837}}
fm
{-3.28837, {x -> 3.42562}}
markers = Style[ToString[#], 18] & /@ Range[Length[pts]];
Show[ Plot[f[x], {x, 0, 4.8}, PlotStyle -> Lighter[Blue, .7]], ListPlot[List /@ pts, PlotMarkers -> markers], Graphics[{ Purple, Line[pts], Red, AbsolutePointSize[4], Point[pts[[-1]]]}], Frame -> True, Axes -> False, PlotRange -> All]
Bob Hanlon
On Thu, Jan 10, 2013 at 9:40 PM, <pguerron@gmail.com> wrote: > Hi, > > I want to track the progress of the minimizer FinMinimum. Is there a way to plot the objective function for each iteration of the minimization routine? > > Thanks, > > Pablo >
|
|