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;