首页 新闻 会员 周边 捐助

lingo9.0 for循环致命

0
悬赏园豆:80 [已关闭问题] 关闭于 2018-04-15 12:41

model: 

 
sets: 
  waiter/1..7/:num,cost;
  st/1..9/:f;
  SQ(st,waiter):A;
endsets
 
data :
  cost=@file("data\cost.txt");
  f=@file("data\f.txt");
  A=@file("data\A.txt");
  enddata
   min=@sum(waiter:num*cost);
 @sum(waiter(j): a(1,j)*num(j))>=4;
 @sum(waiter(j): a(2,j)*num(j))>=3;
 @sum(waiter(j): a(3,j)*num(j))>=4;
 @sum(waiter(j): a(4,j)*num(j))>=6;
 @sum(waiter(j): a(5,j)*num(j))>=5;
 @sum(waiter(j): a(6,j)*num(j))>=6;
 @sum(waiter(j): a(7,j)*num(j))>=8;
 @sum(waiter(j): a(8,j)*num(j))>=8;
      @sum(waiter(j): a(9,j)*num(j))<=3;

 @for(waiter(i):@gin(num(i)));

end

 

这是正解,可将上面的sum写成循环就完蛋了。

model: 

 
sets: 
  waiter/1..7/:num,cost;
  st/1..9/:f;
  SQ(st,waiter):A;
endsets
 
data :
  cost=@file("data\cost.txt");
  f=@file("data\f.txt");
  A=@file("data\A.txt");
  enddata
   min=@sum(waiter:num*cost);
 
     @for(st(i):
  @sum(waiter(j)|i#le#8  :num(j)*a(i,j))>=f(i));
 @sum(waiter(j): a(9,j)*num(j))<=3;
 @for(waiter(i):@gin(num(i)));

end
 

 

问题是出在哪,st(i)么?求大佬赐教。

cost=100 100 40 40 40 40 40;

f=4 3 4 6 5 6 8 8 3;

A=1 1 1 0 0 0 0
1 1 1 1 0 0 0
1 1 1 1 1 0 0
0 1 1 1 1 1 0
1 0 0 1 1 1 1
1 1 0 0 1 1 1
1 1 0 0 0 1 1
1 1 0 0 0 0 1
0 0 1 1 1 1 1;

会飞的雅蠛蝶的主页 会飞的雅蠛蝶 | 初学一级 | 园豆:153
提问于:2018-03-27 00:34
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册