フィルターのクリア

Can I impose a time limit on fmincon without editing the m-file?

14 ビュー (過去 30 日間)
Michael
Michael 2012 年 11 月 23 日
I'm trying to compare different algorithms by imposing a time limit, however one of my algorithms calls fmincon and it seems impossible to terminate this based on a timer. For everything else I've been using
t = tic
while toc(t) < time_limit
[put code loop here]
end
But for my fmincon algorithm, the required code loop seems to be buried deep inside a helper function and I'd rather not get into the business of editing matlab codes if there are any simpler approaches.
Any suggestions? Thanks Mike

採用された回答

Matt J
Matt J 2012 年 11 月 24 日
Supply an Output Function. The output argument of an Output Function is a boolean stop flag which can force the optimization to terminate. You can set this flag based on tic...toc info if you want the optimization to stop based on time.
  1 件のコメント
Michael
Michael 2012 年 11 月 26 日
編集済み: Michael 2012 年 11 月 27 日
Do you know how I can pass the tic value/time_limit into the output function? The documentation says that all the function can call is information about the current iteration.
For example I'm trying to test the minimisation for a varying number of times, so I don't want to have to manually edit this output function every single time.

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by