Multiple outputs from FMINSEARCH function

9 ビュー (過去 30 日間)
Kevin Moerman
Kevin Moerman 2012 年 2 月 8 日
編集済み: Cedric 2013 年 10 月 4 日
For FMINSEARCH in combination with a function MYFUN one could use:
[X,fval,exitflag,output]= fminsearch(@(X) myfun(X),X,options);
Normally the output of MYFUN is minimized through modification of the paramter(s) X. However if MYFUN is able to produce multiple outputs i.e.:
[ouput1,ouput2,ouput3,...,ouputN]=myfun(X)
It seems that FMINSEARCH aims to minimize ouput1 by default, which is fortunately what I need, and, following optimization FMINSEARCH outputs fval which is equivalent to the value of output1 for the best case of X. However I am also interested in the other outputs.
How can the other outputs be obtained? Function evaluations take a VERY long time so I'd like to avoid rerunning the problem.
Kevin

回答 (4 件)

Sean de Wolski
Sean de Wolski 2012 年 2 月 8 日
What you are describing is a multiobjective optimization problem. In the Optimization toolbox, fgoalattain will be your friend. If you have the Global Optimization Toolbox, gamultiobj may also be your friend.
  1 件のコメント
Kevin Moerman
Kevin Moerman 2012 年 2 月 8 日
Thanks for you rapid answer and for suggesting those functions I'll look into them in the future when I need to do multiobjective optimization. Currently though I'm not interested in that. I actually only want to optimize using output1. Its just that I want to view the other outputs (a set of quality metrics I've created) once optimizations is finished. Currently fminsearch does not provide me the other function outputs.
Kevin

サインインしてコメントする。


Seth DeLand
Seth DeLand 2012 年 2 月 8 日
As long as myfun doesn't take a long time to evaluate, the simplest thing to do would be to call myfun again after the optimization with the optimal X that FMINSEARCH found.
It isn't guaranteed that the last time FMINSEARCH called myfun during the optimization, that it did so with the optimal X. The best X could have come from a previous evaluation. So it's a good idea to evaluate the function one final time to call it with the exact X that was returned.
  1 件のコメント
Kevin Moerman
Kevin Moerman 2012 年 2 月 8 日
This is what I've been doing so far but function evaluations take a very long time (>4hours) so its not ideal.

サインインしてコメントする。


John D'Errico
John D'Errico 2012 年 2 月 8 日
By making one last call to MYFUN, with the converged values of your optimization.
If you really wanted to optimize some other output of MYFUN, this too is trivial to accomplish. Just put a wrapper function around MYFUN, selecting out only the output you want to optimize.
I think you are looking too hard for a solution to something obtainable by simple means.
  1 件のコメント
Kevin Moerman
Kevin Moerman 2012 年 2 月 8 日
IDEM Seth DeLand's answer. Function evaluations take >4hours so I'd like to know if there's an alternative. I can also save X and the other outputs which each run with a unique name (they dont take up too much space on disc) and then find the right data afterwards depending on the optimal X. However this seems a "ducktape" appraoch.

サインインしてコメントする。


Alan Weiss
Alan Weiss 2012 年 2 月 8 日
I believe that Loren Shure's "memoize" post could be adapted to your problem: http://blogs.mathworks.com/loren/2006/02/08/use-nested-functions-to-memoize-costly-functions/

カテゴリ

Help Center および File ExchangeProblem-Based Optimization Setup についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by