error in fmincon code

2 ビュー (過去 30 日間)
bus14
bus14 2019 年 4 月 25 日
コメント済み: bus14 2019 年 4 月 25 日
Hi community,
I am busy optimizing a function in fmincon, I think I have all parameters set up correctly. However I get an error when I am running the code. I think the problem lies in my objective function.
%V=[V(1) V(2) V(3)]=[Y(1) Y(2) Z(1)]
l = 0.4;
q = 6;
s = [2;2.2];
A1 = [1,1];
x = [20; 25];
d = 80;
V0=[1,2,4];
objective = [-s.',(l-q).']; %(l-q).'*y-s.'*z; %[ Y, Z] tried both of these
% X(1)=V(1)+A1(1)*V(3) X(2)=V(2)+A11(2)*V(3)
Aeq = [eye(2), A1.']; %=[1 0 A1(1);0 1 A1(2)]
beq = x;
lb = [0, 0, 0]; %requires 3 bounds as there are 3 variables
ub = [Inf, Inf, d];
sol = fmincon(objective,V0,[],[],Aeq,beq,lb,ub);
y = [sol(1);sol(2)]
z = sol(3)
error that pops up is
Error in probeerfmin (line 14)
sol = fmincon(objective,V0,[],[],Aeq,beq,lb,ub);
Thankyou!

採用された回答

Torsten
Torsten 2019 年 4 月 25 日
編集済み: Torsten 2019 年 4 月 25 日
V0 = [1;2;4];
objective = @(V)[-s.',(l-q).']*V;
But why do you shoot with canons on sparrows (means: why do you use a nonlinear optimizer for a linear problem) ?
  1 件のコメント
bus14
bus14 2019 年 4 月 25 日
Thanks Torsten,
Wanted to try if it would also work using fmincon instead of linprog. Might need fmincon later on in making an expectation of this objective function.

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

その他の回答 (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