Problem with fmincon: nonlcon

fmincon runs fine without the non-linear constraint given by the function:
function [c,ceq] = DiagCAW11_constraints(theta,RC,r,bsum)
A=diag(theta(11:14),0);
B=diag(theta(15:18),0);
ceq = [];
c = diag(A.^2 + B.^2 - 1);
end
However when running with the constraint, I get the error
"Error using DiagCAW11_constraints
Too many input arguments."
Here is the entire minimization problem:
fmincon('DiagCAW11_likelihood',theta0,[],[],[],[],[],lb,ub,'DiagCAW11_constraints',options,RC,r,bsum);

2 件のコメント

Thorbjørn Kristiansen
Thorbjørn Kristiansen 2016 年 8 月 13 日
As I understand it, the constraint is supposed to have the same amount of input arguments as the function being minimized. Is this a misconception?
Thorbjørn Kristiansen
Thorbjørn Kristiansen 2016 年 8 月 14 日
If I add another input variable (x) to the constraint, fmincon runs, but gives the same results as without the constraint.

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

回答 (1 件)

Are Mjaavatten
Are Mjaavatten 2016 年 8 月 14 日

0 投票

To transfer the extra inputs to DiagCAW11_constraints you should use an anonymous function:
Make sure that RC, r, bsum are defined. Then define an anonymous function nonlcon as:
nonlcon = @(theta) DiagCAW11_constraints(theta,RC,r,bsum);
You may transfer parameters to DiagCAW11_likelihood in the same manner:
likelihood = @(theta) DiagCAW11_likelihood(theta,par1,par2)
Now you may call fmincon:
theta = fmincon(likelihood,theta0,[],[],[],[],lb,ub,nonlcon,options);
Good luck!

カテゴリ

ヘルプ センター および File ExchangeSystems of Nonlinear Equations についてさらに検索

質問済み:

2016 年 8 月 13 日

編集済み:

2016 年 8 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by