错在哪里???????????急...........急,。。。。。。。。。。。。
MIN = 17*x11 + 33*x12 + 12*x13 + 14*x14 + 9*x21 + 18*x22 + 16*x23 + 13*x24 + 12*x31 + 11*x32 + 27*x33 + 14*x34 + 10*x42 + 21*x43 + 32*x44;
0 < x11+x12+x13+x14 <= 1;
0 < x21+x22+x23+x24 <= 1;
0 < x31+x32+x33+x34 <= 1;
0 < x42+x43+x44 <=1;
0 < x11+x21+x31 <= 1;
0 < x12+x22+x32+x42 <= 1;
0 < x13+x23+x33+x43 <= 1;
0 < x14+x24+x34+x44 <= 1;
@gin(x11);@gin(x12);@gin(x13);@gin(x14);
@gin(x21);@gin(x22);@gin(x23);@gin(x24);
@gin(x31);@gin(x32);@gin(x33);@gin(x34);
@gin(x42);@gin(x43);@gin(x44);
javascript?
model:
sets:
i_/1..4/:a;
j_/1..4/:b;
ij(i_,j_):x;
endsets
!可以在notpad++中使用正则表达式直接替换下面的x11到x44,查找目标x(\d)(\d)替换为x(\1,\2)即可;
MIN = 17*x(1,1) + 33*x(1,2) + 12*x(1,3) + 14*x(1,4) + 9*x(2,1) + 18*x(2,2) + 16*x(2,3) + 13*x(2,4) + 12*x(3,1) + 11*x(3,2) + 27*x(3,3) + 14*x(3,4) + 10*x(4,2) + 21*x(4,3) + 32*x(4,4);
!0 < x11+x12+x13+x14 <= 1;
x(1,1)+x(1,2)+x(1,3)+x(1,4)<=1;
x(1,1)+x(1,2)+x(1,3)+x(1,4)>=0;
!0 < x21+x22+x23+x24 <= 1;
x(2,1)+x(2,2)+x(2,3)+x(2,4)<=1;
x(2,1)+x(2,2)+x(2,3)+x(2,4)>=0;
!0 < x31+x32+x33+x34 <= 1;
x(3,1)+x(3,2)+x(3,3)+x(3,4)<=1;
x(3,1)+x(3,2)+x(3,3)+x(3,4)>=0;
!0 < x42+x43+x44 <=1;
x(4,2)+x(4,3)+x(4,4)<=1;
x(4,2)+x(4,3)+x(4,4)>=0;
!0 < x11+x21+x31 <= 1;
x(1,1)+x(2,1)+x(3,1)<=1;
x(1,1)+x(2,1)+x(3,1)>=0;
!0 < x12+x22+x32+x42 <= 1;
x(1,2)+x(2,2)+x(3,2)+x(4,2)<=1;
x(1,2)+x(2,2)+x(3,2)+x(4,2)>=0;
!0 < x13+x23+x33+x43 <= 1;
x(1,3)+x(2,3)+x(3,3)+x(4,3)<=1;
x(1,3)+x(2,3)+x(3,3)+x(4,3)>=0;
!0 < x14+x24+x34+x44 <= 1;
x(1,4)+x(2,4)+x(3,4)+x(4,4)<=1;
x(1,4)+x(2,4)+x(3,4)+x(4,4)>=0;
@for(ij(i,j):@gin(x(i,j)));
!有个问题你自己应该看一下,那个约束都是大于0小于1的,最小值只能全部是0啊,这还用解吗?
!如果你想的是每个约束都是大于0的话,那要更改了,因为Lingo认为>=与>是相同的,<=与<是相同的.
!所以可以直接把约束更改为是=1就可以了.
更改后的为:
model:
sets:
i_/1..4/:a;
j_/1..4/:b;
ij(i_,j_):x;
endsets
!可以在notpad++中使用正则表达式直接替换下面的x11到x44,查找目标x(\d)(\d)替换为x(\1,\2)即可;
MIN = 17*x(1,1) + 33*x(1,2) + 12*x(1,3) + 14*x(1,4) + 9*x(2,1) + 18*x(2,2) + 16*x(2,3) + 13*x(2,4) + 12*x(3,1) + 11*x(3,2) + 27*x(3,3) + 14*x(3,4) + 10*x(4,2) + 21*x(4,3) + 32*x(4,4);
!0 < x11+x12+x13+x14 <= 1;
x(1,1)+x(1,2)+x(1,3)+x(1,4)=1;
!0 < x21+x22+x23+x24 <= 1;
x(2,1)+x(2,2)+x(2,3)+x(2,4)=1;
!0 < x31+x32+x33+x34 <= 1;
x(3,1)+x(3,2)+x(3,3)+x(3,4)=1;
!0 < x42+x43+x44 <=1;
x(4,2)+x(4,3)+x(4,4)=1;
!0 < x11+x21+x31 <= 1;
x(1,1)+x(2,1)+x(3,1)=1;
!0 < x12+x22+x32+x42 <= 1;
x(1,2)+x(2,2)+x(3,2)+x(4,2)=1;
!0 < x13+x23+x33+x43 <= 1;
x(1,3)+x(2,3)+x(3,3)+x(4,3)=1;
!0 < x14+x24+x34+x44 <= 1;
x(1,4)+x(2,4)+x(3,4)+x(4,4)=1;
@for(ij(i,j):@gin(x(i,j)));
!没法插入图片