1 x表示某门课是否要选
model:
sets:
course/1..9/:x;
type/1..3/:a;
link(course,type):c;
endsets
data:c=1 0 01 0 01 1 01 0 11 1 00 1 10 0 10 1 00 1 1;
a=2 3 2;
enddata
min=@sum(course:x);@for(type(j):@sum(course(i):x(i)*c(i,j))>=a(j));
x(1)>=x(3);
x(1)>=x(5);
x(1)>=x(9);
x(2)>=x(3);
x(2)>=x(5);
x(2)>=x(9);
x(7)>=x(4);
x(7)>=x(6);
x(5)>=x(8);
@for(course:@bin(x));
end
2 x(i,j)表示第j个货舱装第i种货物重量
model:
sets
goods/1..4/:space,weight,profit;
carbin/1..3/:tspace,tweight;
link(goods,carbin):x;
endsets
data:
weight=18 15 23 12;
space=480 650 580 390;
profit=3100 3800 3500 2850;
tspace=6800 8700 5300;
tweight=10 16 8;
enddata
max=@sum(link(i,j):profit(i)*x(i,j));
@for(carbin(j):@sum(goods(i):x(i,j))<=tweight(j));
@for(carbin(j):@sum(goods(i):space(i)*x(i,j))<=tspace(j));
@for(goods(i):@sum(carbin(j):x(i,j))<=weight(i));
end
30分,以为是30人民币啊
呵呵,我先看看再说。