急求用MATLAB解下列问题

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 02:25:11
急求用MATLAB解下列问题
xTn@Q%T~I\)% (BW2vbU يW[PEDuAIg; IV˲{Hg\wMwwut\iǻNaro^4oF^P!WzԢՈ_"/ L&gzuFXNgsΨ!6th*VmSHDȎ3Q4,Cm$I& a!$*!˜S)?iTKnETMEdIm*&L!+lsſBER%"vEAG } ܦ^ X9fkح.iW=0%f c\q ~DIGeٛ9HE:h }TNo{^>O%S2E:!cm>cS2duz'di~X.&ϖwW;ß/2.ĈLѐ8E]`08 M5bT4*F2ه62'Yjog3/Cg6ۼ}aQ+ 8R" V4 TS1Wh:US7T85I"=F6#p2?8+r&kEpˑ1+ƁR) Ϣ`$`AfCv+t{fV'!Fv*=ә# ͆XvQ&f!BGޏO':c#

急求用MATLAB解下列问题
急求用MATLAB解下列问题

急求用MATLAB解下列问题
f=[2;-1;2];
A=[-1 1 -1];
B=6;
Aeq=[-1 1 1];
Beq=4;
lb=[-inf 0 -inf];
lu=[0 inf inf];
[x,fval]=linprog(f,A,B,Aeq,Beq,lb,lu)
Optimization terminated.
x =
-5.0000
0.0000
-1.0000
fval =
-12.0000

根据第一个等式和第二个不等式可得易得x3<=-1;
同理x2可得其上限x2<=5;
故重写方程:
min f=2x1-x2+2x3
s.t. -x1+x2+x3=4
-x1+x2-x3<=6
x1<=0
x2<=5
x3<=-1
x2>=0<...

全部展开

根据第一个等式和第二个不等式可得易得x3<=-1;
同理x2可得其上限x2<=5;
故重写方程:
min f=2x1-x2+2x3
s.t. -x1+x2+x3=4
-x1+x2-x3<=6
x1<=0
x2<=5
x3<=-1
x2>=0

附上代码。
f=[2;-1;2];
A=[-1 1 -1;0 -1 0];
b=[6 0];
lb=[];ub=[0 5 -1];
[x,fval,exitflag,output]=linprog(f,A,b,[],[],lb,ub)

结果如下:
x =
-2.5041
0.0000
-3.4959
fval =
-12.0000
exitflag =
1
output =
iterations: 5
algorithm: 'large-scale: interior point'
cgiterations: 0
message: 'Optimization terminated.'
constrviolation: 0
firstorderopt: 8.9531e-011

收起