row dimension of aeq is inconsistent with length of beq. Help me pls.
6 views (last 30 days)
Show older comments
Dear all,
Help me pls. I trying to resolve optimization task with code "fmincon". Below show the codes I did. But when I started solving, I met fault "row dimension of aeq is inconsistent with length of beq". Anyones explain me about this for me, pls.
function f = objecfun(x)
f = 1203*(x(1)*x(2)*x(3))^0.759;
end
function [c, ceq] = lim(x)
c=[1.01*1.025*x(8)*x(1)*x(2)*x(4)-0.176*x(1)*x(2)*x(3)-0.166*(x(1)*x(2)*x(3))^(2/3)-0.08*x(5)-127;
2*x(2)*sqrt(1.017*x(9)/((x(9)-x(8))*1.06*x(9)^2/(12*x(9))));
73-1.6*x(8)*x(6)*(x(2)-2*0.2)*(x(3)-x(7)-2*0.2)];
ceq = [];
end
clc; clear all;
A=[6.7 0 -1 1 0 0 0 0 0];
b=-0.24;
lb=[24 5 2.5 1.5 600 5 0.8 0.5 0.6];
ub=[40 9 4.5 2.8 2000 7 1.2 0.6 0.75];
x0=[25 6 3 2 800 6,1 0.5 0.6];
[x,fval,exitflag,output,lambda]=fmincon('objecfun',x0,A,b,lb,ub,[],[],'lim');
end
0 Comments
Accepted Answer
Steven Lord
on 18 Apr 2019
You passed the inputs into fmincon in the wrong order. From the documentation page, the syntax you're calling is:
x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)
fmincon interprets your lb and ub as the linear equality constraints, not the bounds. Move the two empty arrays [] to between b and lb since you don't have linear equality constraints.
More Answers (0)
See Also
Categories
Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!