How to see the current value of the variable in "fminsearch" optimization?
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ahmed Rehan
el 23 de Jul. de 2020
Comentada: Ahmed Rehan
el 24 de Jul. de 2020
Hi,
I am running fminsearch command to find a minimum of a function. It is taking very long. However, I want to see the current value of the variable being serached. For example,"X=fminsearch(@fcn,init0,options)" showld display X in each interation. I looked into documentaiton of "optimset" but I couldn't find something helpful.
Advance, Thanks,
Ahmed.
0 comentarios
Respuesta aceptada
Alan Weiss
el 23 de Jul. de 2020
You can do this using an Output Function. That example shows how to return the history of points, which is I think what you want.
Alan Weiss
MATLAB mathematical toolbox documentation
Más respuestas (1)
Vladimir Sovkov
el 23 de Jul. de 2020
optimset('Display','iter');
From Matlab documentation:
'Display' — Level of display
'notify' (default) | 'final' | 'off' | 'none' | 'iter'
Level of display, specified as the comma-separated pair consisting of 'Display' and one of these values:
- 'notify' — Display output only if the function does not converge.
- 'final' — Display just the final output.
- 'off' or 'none' — Display no output.
- 'iter' — Display output at each iteration (not available for lsqnonneg).
Display is available for all optimization solvers.
Example: options = optimset('Display','iter')
Data Types: char | string
2 comentarios
Vladimir Sovkov
el 23 de Jul. de 2020
I do not think it is possible with fminsearch due to a (generally) multidimensional nature of the variable, which is hard to display in a compact form.
The things are easier with the 1D variable: this case you can use an alternative function such as fminbnd, which is able to output the X values at every next itereation via the same approach; besides, it must be faster in the 1D case.
Ver también
Categorías
Más información sobre Optimization en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!