Plot update on each function call when running fmincon in parallel

9 ビュー (過去 30 日間)
Etienne Coetzee
Etienne Coetzee 2020 年 5 月 5 日
コメント済み: Ameer Hamza 2020 年 5 月 5 日
Dear All
I am trying to run fmincon in parallel and would like to plot the function value after each objective function calll. I also want to save/log this value to a global variable or file. Global variables cannot be used and I am not sure what to do next. I have tried different suggestions from the FEX but just cannot get it to work. Any help or suggestions would be much appreciated.
Thanks in advance
Etienne

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 5 日
編集済み: Ameer Hamza 2020 年 5 月 5 日
To plot the objective function value, you can specify using optimoptions(). For example
opts = optimoptions('fmincon', 'PlotFcn', 'optimplotfval');
fmincon(@(x) sum(x.^2.*exp(x)), rand(4,1), [], [], [], [], [], [], [], opts)
You can find the list of available plot functions here: https://www.mathworks.com/help/releases/R2020a/optim/ug/fmincon.html#busog7r-options and you can also create your custom plot function.
To save the value, you will need to use outputFcn, as demonstrated in John's answer here: https://www.mathworks.com/matlabcentral/answers/510713-is-it-possible-to-store-the-intermediate-values-of-fmincon#answer_420002. You can use his FEX package (mentioned in his answer) to avoid the global variable.
  2 件のコメント
Etienne Coetzee
Etienne Coetzee 2020 年 5 月 5 日
Thanks Ameer. This looks like what I am looking for. I will try it tomorrow.
Ameer Hamza
Ameer Hamza 2020 年 5 月 5 日
Sure. You can comment if there is some issue.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver 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