Can fmincon output all the considered 'x' values for minimisation of the function f(x)?

2 visualizaciones (últimos 30 días)
I am currently using fmincon to minimise a function f(x), I was hoping there would be a way I could, along with the value of x that minimises f(x), also output all the values of x that led to that final value?
I would like to be able to visualise the minimiser results through the iterations, as the function f(x) is of a quite high dimension.

Respuesta aceptada

John D'Errico
John D'Errico el 18 de Mayo de 2015
As Alan points out, the output function is perfect for your purpose. Of course, you could simply put a display into your objective function.
Or you could use a global variable in the objective function to accumulate all of the calls in one array. Since it is global, when done, you will have a big array that contains all of the calls.
One other approach is to accumulate the calls in one persistent variable in the objective function. Then make one last call to the function and have your objective return that variable as the SECOND returned argument to your objective.
Note that if fmincon is differentiating the function using finite differences, there will be multiple calls with nearly the exact same values repeated, but with tiny differences. You can drop them out.
Finally, you ask about visualizing the calls in some high number of dimensions. This will be a serious problem. I think you may not appreciate that it is difficult. Unless of course, you just happen to have one of the really new hyper-spatial monitors, that can display data in a vast number of dimensions. They are very expensive, and always seem to break down. Ok, sarcasm off, the point is, you cannot easily visualize data in a high number of dimensions. You can try to use tools like Chernoff faces, etc., but expect it to be difficult.
  1 comentario
Laurence hutton-smith
Laurence hutton-smith el 19 de Mayo de 2015
Dear John,
Many thanks for your helpful answer! Thanks for clarifying this, this should work perfectly.
Also regarding the high dimension of my output, it is then interpreted by another function that uses it to construct an object in 3 dimensions, so has a very natural visualisation method.
Best wishes,
Laurence

Iniciar sesión para comentar.

Más respuestas (1)

Alan Weiss
Alan Weiss el 18 de Mayo de 2015
You can use an output function for this purpose. In fact, the example in that link shows how to do exactly what you want.
Alan Weiss
MATLAB mathematical toolbox documentation

Categorías

Más información sobre Solver Outputs and Iterative Display 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!

Translated by