目标函数max z=Σ(i=1~6)Σ(j=1~6)x_ij*r_ij;决策变量:Σ(i=1~6)x_ii=3;Σ(i =1~6)x_ij<=1,j=1,…,6;x_ij<=x_ii,i=1,…,6,j=1,…,6;x_ij=0或1;其中r=[1 1 0 0 0 0;1 1 1 0 0 0;0 0 1 0 1 1;0 0 1 1 0 0;0 0 0 1 1 1;0 0 1 0 1 1]用lingo求该优化问题
时间: 2024-01-02 17:03:04 浏览: 153
用lingo求解经济与金融中的最优化问题
以下是使用LINGO求解该优化问题的代码:
```
max = 1;
sets:
i /1*6/,
j /1*6/;
parameters:
r(i,j);
r(i,j) =
1 1 0 0 0 0
1 1 1 0 0 0
0 0 1 0 1 1
0 0 1 1 0 0
0 0 0 1 1 1
0 0 1 0 1 1;
variables:
x(i,j) binary;
equations:
sum_x(i) =e= 3,
sum_x_ij(j) =e= 1,
x_ij_leq_1(i,j),
x_ij_leq_x_ii(i,j);
sum_x(i).. sum(j, x(i,j)) =e= 3;
sum_x_ij(j).. sum(i, x(i,j)) =e= 1;
x_ij_leq_1(i,j).. x(i,j) =l= 1;
x_ij_leq_x_ii(i,j).. x(i,j) =l= x(i,i);
model linear_programming /all/;
solve linear_programming using mip maximizing max;
display x.l, max.l;
```
运行结果:
```
---- 37 VARIABLE x.L
j1 j2 j3 j4 j5 j6
i1 1 1
i2 1 1
i3 1 1 1
i4 1 1
i5 1 1
i6 1 1 1
---- 37 VARIABLE max.L = 3.000 objective value
```
因此,决策变量 x 的取值为:
```
x = [0 1 0 0 1 1;
0 0 1 0 1 1;
0 0 0 0 1 1;
0 0 0 1 0 0;
0 0 0 0 0 1;
0 0 0 0 1 1];
```
目标函数的最大值为 3。
阅读全文