FMINCON - Failure in initial objective function evaluation. FMINCON cannot continue.

11 ビュー (過去 30 日間)
og
og 2016 年 10 月 30 日
コメント済み: og 2016 年 10 月 31 日
I am trying to minimise a self-written objective function, called S_min, subject to simple linear inequality constraints. Since S_max is a function of 5 arguments but I only want to optimise over the first 2, I use a function handle:
fun = @(x,y) S_min(x,y,2,MU1,P_max); % MU1, P_max defined above [not shown]
And then implement the optimisation through:
fmincon(fun, [0.5,6], A ,B); % A, B defined above [not shown]
I checked that fun(0.5,6), i.e. evaluated at the starting values, gives a correct, scalar, answer; and that the vector [0.5,6] satisfies inequality constraints, i.e. A.*[0.5,6]<=B.
However, when trying to minimise as above, I get the following error message:
"Error in fmincon (line 536) [...]
Failure in initial objective function evaluation. FMINCON cannot continue."
This is surprising as the function should evaluate correctly at this point.
Is there anything I can do to fix this?

採用された回答

Matt J
Matt J 2016 年 10 月 30 日
編集済み: Matt J 2016 年 10 月 30 日
FMINCON expects your function handle to look like this,
fun = @(p) S_min(p(1),p(2),2,MU1,P_max);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Least Squares についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by