请哪位高手看看这个LINGO程序哪有错误

问题描述:

请哪位高手看看这个LINGO程序哪有错误
model:
sets:
people/1..7/:c,x;
endsets
data:
c=16 15 16 19 14 12 18;
enddata
min=@sum(people:x);
@sum(people(i)|i#le#5:x(i))>16;
@sum(people(i)|i#le#4#and#i#ge#7#and#i#le#7:x(i))>15;
@sum(people(i)|i#le#3#and#i#eq#6#and#i#eq#7:x(i))>16;
@sum(people(i)|i#le#2#and#i#eq#5#and#i#eq#7:x(i))>19;
@sum(people(i)|i#le#1#and#i#eq#4#and#i#eq#7:x(i))>14;
@sum(people(i)|i#ge#3#and#i#le#7:x(i))>12;
@sum(people(i)|i#eq#2#and#i#eq#6:x(i))>18;
end
为什么不能运行啊?能不能把正确的给写出来.
那为什么有的地方用and有的地方用的or?有什么区别吗?
1个回答 分类:综合 2014-10-18

问题解答:

我来补答
model:
sets:
people/1..7/:c,x;
endsets
data:
c=16 15 16 19 14 12 18;
enddata
min=@sum(people:x);
@sum(people(i)|i#le#5:x(i))>16;
@sum(people(i)|i#le#4#or#(i#ge#7#and#i#le#7):x(i))>15;
@sum(people(i)|i#le#3#or#i#eq#6#or#i#eq#7:x(i))>16;
@sum(people(i)|i#le#2#or#i#eq#5#or#i#eq#7:x(i))>19;
@sum(people(i)|i#le#1#or#i#eq#4#or#i#eq#7:x(i))>14;
@sum(people(i)|i#ge#3#and#i#le#7:x(i))>12;
@sum(people(i)|i#eq#2#or#i#eq#6:x(i))>18;
end
你模型转化时出的问题,运行结果:
Global optimal solution found.
Objective value:32.00000
Total solver iterations:0
Variable Value Reduced Cost
C( 1) 16.00000 0.000000
C( 2) 15.00000 0.000000
C( 3) 16.00000 0.000000
C( 4) 19.00000 0.000000
C( 5) 14.00000 0.000000
C( 6) 12.00000 0.000000
C( 7) 18.00000 0.000000
X( 1) 0.000000 0.000000
X( 2) 18.00000 0.000000
X( 3) 0.000000 1.000000
X( 4) 13.00000 0.000000
X( 5) 0.000000 1.000000
X( 6) 0.000000 0.000000
X( 7) 1.000000 0.000000
and是并且的意思,or是或者的意思,i#eq#2#and#i#eq#6的意思是i=2并且i=6,实际上这是不可能的事情;而i#eq#2#or#i#eq#6的意思是i=2或者i=6,我想这才是你想要表达的意思.
 
 
展开全文阅读
剩余:2000