建筑工地的位置(用平面坐标a,b表示,单位:km)及水泥日用量d(单位:t)用下表给出。目前两个临时料厂位于P(5,1),Q(2,7),日储量各有20t。求从A,B两料厂分别向各工地运送多少水泥,使总的吨公里数最小。两个新的料场应建在何处,节省的吨公里数有多大?
工地编号
1 2 3 4 5 6
a 1.25 8.75 0.5 5.75 3 7.25
b 1.25 0.75 4.75 5 6.5 7.75
d 3 5 4 7 6 11
model:
sets:
demand/1..6/:a,b,d;
supply/1..2/:x,y,e;
link(demand,supply):c;
endsets
data:
a=1.25,8.75,0.5,5.75,3,7.25;
b=1.25,0.75,4.75,5,6.5,7.75;
d=3,5,4,7,6,11;
e=20,20;
enddata
init:
x,y=5,1,2,7;
endinit
min=@sum(link(i,j):c(i,j)*((x(j)-a(i))^2+(y(j)-b(i))^2)^(1/2));
@for(demand(i):@sum(supply(j):c(i,j))=d(i););
@for(supply(i):@sum(demand(j):c(j,i))<=e(i););
@for(supply:@free(x);@free(y););
End
中c的矩阵表示,@free函数意义init作用 以及
min=@sum(link(i,j):c(i,j)*((x(j)-a(i))^2+(y(j)-b(i))^2)^(1/2));
@for(demand(i):@sum(supply(j):c(i,j))=d(i););
@for(supply(i):@sum(demand(j):c(j,i))<=e(i););
@for(supply:@free(x);@free(y););
翻译 (希望详细一点,因为没学过这程序了)
|