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

1 次查看(过去 30 天)
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.

采纳的回答

John D'Errico
John D'Errico 2015-5-18
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 个评论
Laurence hutton-smith
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

请先登录,再进行评论。

更多回答(1 个)

Alan Weiss
Alan Weiss 2015-5-18
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

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by