フィルターのクリア

FMINCON - Include constraints provided by the objective function

9 ビュー (過去 30 日間)
Lennart
Lennart 2023 年 3 月 22 日
コメント済み: Lennart 2023 年 3 月 22 日
Hi All,
I am currently working on an optimization problem with fmincon. The objective function takes quite a while to calculate, but in the end it is giving me a result in terms of resulting mass. This mass shall be optimized/minimized using fmincon which is working quite well on its own.
I am calling fmincon as follows:
[x,fval] = fmincon(@MASTER, x0,[], [], [],[],lb,ub,[], options);
Now, I would like to include constraints as well. Checking the help/support pages, I can simply add a constraint evaluation function at the end of the fmincon-call.
However, my objective function is also capable of giving me my constraint information as well. I am currently not returing it of course but it can be easily calculated. Sure I can double-call the function, once for objective and once for constraint, but I really dont want to call it twice due to the long calculation time. Is there any way I can use the constraint values I am already calculating in my objective function to be used by fmincon without calling it a second time?
Any advice would be fantastic!
kind regards,
Lennart

回答 (1 件)

Jon
Jon 2023 年 3 月 22 日
You can use nested functions to avoid recomputing your constraint values.
  1 件のコメント
Lennart
Lennart 2023 年 3 月 22 日
That fits scarily well to my problem, thank you very much!

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

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by