2.某公司有6个建筑工地要开工,每个工地的位置(用平面坐标系a,b表示,距离单位:千米)及水泥日用量d(吨)由下表给出. 目前有两个临时料场位于A(5,1),B(2,7),日储量各有30吨.
(1)试制定每天的供应计划,即从A,B两料场分别向各工地运送多少吨水泥,使总的吨千米数最小?
(2)为了进一步减少吨千米数,打算舍弃两个临时料场,改建两个新的,日储量各为30吨,问应建在何处,节省的吨千米数会多大?
1
2
3
4
5
6
a
1
8
0
5
3
8
b
1
0
4
6
6
7
d
4
6
6
7
8
11
解:(1)代码:model:
sets:
production/pr1..pr2/:d,e,f;
position/po1..po6/:a,b,c;
links(production,position):x;
endsets
data:
a b=1 1
8 0
0 4
5 6
3 6
8 7;
c=4 6 6 7 8 11;
f=30 30;
d e=5 1
2 7;
enddata
min=@sum(links(i,j):@sqrt(((a(j)-d(i))^2+(b(j)-e(i))^2))*x(i,j));
@for(production(i):@sum(position(j):x(i,j))<f(i));
@for(position(j):@sum(production(i):x(i,j))=c(j));
@for(production:@free(d);@free(e););
end
(2)代码:
model:
sets:
production/pr1..pr2/:d,e,f;
position/po1..po6/:a,b,c;
links(production,position):x;
endsets
data:
a b=1 1
8 0
0 4
5 6
3 6
8 7;
c=4 6 6 7 8 11;
f=30 30;
d=,; e=,;
enddata
min=@sum(links(i,j):@sqrt(((a(j)-d(i))^2+(b(j)-e(i))^2))*x(i,j));
@for(production(i):@sum(position(j):x(i,j))<f(i));
@for(position(j):@sum(production(i):x(i,j))=c(j));
@for(production:@free(d);@free(e););
end
运行结果:
Local optimal solution found.
Objective value: 106.8555
Infeasibilities: 0.000000
Total solver iterations: 63
Variable Value Reduced Cost
D( PR1) 0.000000 -2.929012
D( PR2) 5.210653 0.000000
E( PR1) 4.000000 8.685333
E( PR2) 5.955272 0.000000
F( PR1) 30.00000 0.000000
F( PR2) 30.00000 0.000000
A( PO1) 1.000000 0.000000
A( PO2) 8.000000 0.000000
A( PO3) 0.000000 0.000000
A( PO4) 5.000000 0.000000
A( PO5) 3.000000 0.000000
A( PO6) 8.000000 0.000000
B( PO1) 1.000000 0.000000
B( PO2) 0.000000 0.000000
B( PO3) 4.000000 0.000000
B( PO4) 6.000000 0.000000
B( PO5) 6.000000 0.000000
B( PO6) 7.000000 0.000000
C( PO1) 4.000000 0.000000
C( PO2) 6.000000 0.000000
C( PO3) 6.000000 0.000000
C( PO4) 7.000000 0.000000
C( PO5) 8.000000 0.000000
C( PO6) 11.00000 0.000000
X( PR1, PO1) 4.000000 0.000000
X( PR1, PO2) 0.000000 0.000000
X( PR1, PO3) 6.000000 0.000000
X( PR1, PO4) 0.000000 0.000000
X( PR1, PO5) 2.000000 0.000000
X( PR1, PO6) 0.000000 0.000000
X( PR2, PO1) 0.000000 0.000000
X( PR2, PO2) 6.000000 0.000000
X( PR2, PO3) 0.000000 0.000000
X( PR2, PO4) 7.000000 0.000000
X( PR2, PO5) 6.000000 0.000000
X( PR2, PO6) 11.00000 0.000000
Row Slack or Surplus Dual Price
1 106.8555 -1.000000
2 18.00000 0.000000
3 0.000000 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000000 0.000000
7 0.000000 0.000000
8 0.000000 0.000000
9 0.000000 -4.373022