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.
0 个评论
采纳的回答
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 个)
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
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!