如何用LINGO解01规划问题
来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/08/19 15:38:37
如何用LINGO解01规划问题
我是个编程的菜鸟,只希望大神能帮我把下面的01 规划问题编成lingo的语言,最好能附上代码,
x(i,j,k) y(j,k) c(j) z(i,j) (i,j=1,2,3,4,5,6)(k=1,2,3)
MAX=∑y(j,k)*c(j)
MIN=∑x(k,i,j)*z(i,j)
∑x(i,j,k)= ∑y(k,j)
x(i,j,k)=0 or 1
y(j,k)=0 or 1
data
c(j):50 80 30 55 35 20
z(I,j):1 8 12 14 10 16
8 1 6 18 16 16
12 18 1.5 12 6 4
16 14 4 1 16 12
18 16 10 4 2 2
16 18 4 12 2 2
我是个编程的菜鸟,只希望大神能帮我把下面的01 规划问题编成lingo的语言,最好能附上代码,
x(i,j,k) y(j,k) c(j) z(i,j) (i,j=1,2,3,4,5,6)(k=1,2,3)
MAX=∑y(j,k)*c(j)
MIN=∑x(k,i,j)*z(i,j)
∑x(i,j,k)= ∑y(k,j)
x(i,j,k)=0 or 1
y(j,k)=0 or 1
data
c(j):50 80 30 55 35 20
z(I,j):1 8 12 14 10 16
8 1 6 18 16 16
12 18 1.5 12 6 4
16 14 4 1 16 12
18 16 10 4 2 2
16 18 4 12 2 2
![如何用LINGO解01规划问题](/uploads/image/z/4577094-54-4.jpg?t=%E5%A6%82%E4%BD%95%E7%94%A8LINGO%E8%A7%A301%E8%A7%84%E5%88%92%E9%97%AE%E9%A2%98)
这样子就行了,你看看:sets:
t_c/1..6/: c;
t_k/1..3/: k;
t_z(t_c, t_c): z;
t_y(t_c, t_k): y;
t_x(t_c, t_c, t_k): x;
endsets
max = @sum(t_y(I, J): y(I, J)*c(I));
!min = @sum(t_x(I, J, M): x(I, J, M)*z(I, M));
@sum(t_x(I, J, M): x(I, J, M)) = @sum(t_y(I, J): y(I, J));
@for(t_x: @bin(x));
@for(t_y: @bin(y));
data:
c = 50 80 30 55 35 20;
z = 1 8 12 14 10 16
8 1 6 18 16 16
12 18 1.5 12 6 4
16 14 4 1 16 12
18 16 10 4 2 2
16 18 4 12 2 2;
enddata
t_c/1..6/: c;
t_k/1..3/: k;
t_z(t_c, t_c): z;
t_y(t_c, t_k): y;
t_x(t_c, t_c, t_k): x;
endsets
max = @sum(t_y(I, J): y(I, J)*c(I));
!min = @sum(t_x(I, J, M): x(I, J, M)*z(I, M));
@sum(t_x(I, J, M): x(I, J, M)) = @sum(t_y(I, J): y(I, J));
@for(t_x: @bin(x));
@for(t_y: @bin(y));
data:
c = 50 80 30 55 35 20;
z = 1 8 12 14 10 16
8 1 6 18 16 16
12 18 1.5 12 6 4
16 14 4 1 16 12
18 16 10 4 2 2
16 18 4 12 2 2;
enddata