关于matlab编程,最优化问题求解,即求最大值,哪位大师可以帮忙写下代码?谢谢了!满意追加财富值!
Max=x1+x2+x3+x4+x5X1+x2+x4<=95X3+x4+x5<=80X1+x4<=82X2+x4+x5<=90X3+x5<=71...
Max=x1+x2+x3+x4+x5
X1+x2+x4<=95
X3+x4+x5<=80
X1+x4<=82
X2+x4+x5<=90
X3+x5<=71 展开
X1+x2+x4<=95
X3+x4+x5<=80
X1+x4<=82
X2+x4+x5<=90
X3+x5<=71 展开
2012-06-22
展开全部
lingo解答:
Max=x1+x2+x3+x4+x5;
x1+x2+x4<=95;
x3+x4+x5<=80;
x1+x4<=82;
x2+x4+x5<=90;
x3+x5<=71;
Global optimal solution found.
Objective value: 166.0000
Infeasibilities: 0.000000
Total solver iterations: 6
Variable Value Reduced Cost
X1 5.000000 0.000000
X2 81.00000 0.000000
X3 71.00000 0.000000
X4 9.000000 0.000000
X5 0.000000 0.000000
Row Slack or Surplus Dual Price
1 166.0000 1.000000
2 0.000000 1.000000
clear all;close all;clc;
f=[-1;-1;-1;-1;-1]; %这个是你的目标函数是系数
A=[1,1,0,1,0;
0,0,1,1,1;
1,0,0,1,0;
0,1,0,1,1;
0,0,1,0,1]; %这里是约束的左边系数,注意这里是A*x<=b,所以你的条件中要化为小于等于,所以这里只选了第1和第2个条件
b=[95;80;82;90;71]; %约束的右边系数
xmin=[0;0]; %变量的最小值,就是上面的条件(4)
xmax=[inf;inf] %变量的最大值,此例中无,设为无穷大
x0=xmin; %计算的初值
[x,fmin]=linprog(f,A,-b,[],[],xmin,xmax,x0);
x,fmin
x =
31.0632
44.2715
-17.3126
-170.3348
-53.6874
fmin =
166.0000
Max=x1+x2+x3+x4+x5;
x1+x2+x4<=95;
x3+x4+x5<=80;
x1+x4<=82;
x2+x4+x5<=90;
x3+x5<=71;
Global optimal solution found.
Objective value: 166.0000
Infeasibilities: 0.000000
Total solver iterations: 6
Variable Value Reduced Cost
X1 5.000000 0.000000
X2 81.00000 0.000000
X3 71.00000 0.000000
X4 9.000000 0.000000
X5 0.000000 0.000000
Row Slack or Surplus Dual Price
1 166.0000 1.000000
2 0.000000 1.000000
clear all;close all;clc;
f=[-1;-1;-1;-1;-1]; %这个是你的目标函数是系数
A=[1,1,0,1,0;
0,0,1,1,1;
1,0,0,1,0;
0,1,0,1,1;
0,0,1,0,1]; %这里是约束的左边系数,注意这里是A*x<=b,所以你的条件中要化为小于等于,所以这里只选了第1和第2个条件
b=[95;80;82;90;71]; %约束的右边系数
xmin=[0;0]; %变量的最小值,就是上面的条件(4)
xmax=[inf;inf] %变量的最大值,此例中无,设为无穷大
x0=xmin; %计算的初值
[x,fmin]=linprog(f,A,-b,[],[],xmin,xmax,x0);
x,fmin
x =
31.0632
44.2715
-17.3126
-170.3348
-53.6874
fmin =
166.0000
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询