a=[-2 -5 -1];
b=[-10];
a1=[1 1 1];
b1=[7];
x0=[0 0 0]';
f=[-2 -3 5]';
[x,fval,exitflag,output,lambda]=linprog(f,a,b,a1,b1,x0)
运行结果:(所求值为最小值,加个负号就是最大值了)
x =
0.0000
7.0000
0.0000
fval =
-21.0000
exitflag =
1
output =
iterations: 5
algorithm: 'interior-point'
cgiterations: 0
message: 'Optimization terminated.'
constrviolation: 8.8818e-16
firstorderopt: 5.0598e-12
lambda =
ineqlin: 4.8989e-15
eqlin: 3.0000
upper: [3x1 double]
lower: [3x1 double]
追问
求解