仅考虑运输距离建立带容量约束的p-中值模型给出lingo代码。已知某市有5个居民小区(B1,B2,…,B5),每个居民区的位置坐标、人口数、每千人年均垃圾产量已知。现欲从5个备选点(A1,A2,…,A5)中选择2个建立垃圾焚烧厂,各备选点的位置坐标以及最大垃坂处理能力,问应该选择已知哪几个备选点建立垃圾焚烧厂才能使垃圾焚烧厂的成本最低? (B1坐标为(1.1,8.2)总人数13.6,垃圾产量401;B2坐标为(1.3,4.1)总人数14.3,垃圾产量475;B3坐标为(1.2,1.5)总人数13.8,垃圾产量438;A1坐标为(2.1,8.9)垃圾焚烧能力36500;A2坐标为(1.8,5.9)垃圾焚烧能力58400)
时间: 2023-06-27 15:05:44 浏览: 109
以下是Lingo代码:
```lingo
SETS:
B /B1, B2, B3, B4, B5/ residential areas
A /A1, A2, A3, A4, A5/ candidate sites for incinerators
DATA:
d(B, A) distance between residential area B and candidate site A
c(A) cost of building an incinerator at candidate site A
q(B) amount of garbage produced by residential area B
Qmax(A) maximum capacity of incinerator at candidate site A
d(B1, A1) = 1.8; d(B1, A2) = 3.1; d(B1, A3) = 7.5; d(B1, A4) = 6.9; d(B1, A5) = 11.2;
d(B2, A1) = 4.9; d(B2, A2) = 2.0; d(B2, A3) = 5.4; d(B2, A4) = 5.0; d(B2, A5) = 9.2;
d(B3, A1) = 7.4; d(B3, A2) = 4.0; d(B3, A3) = 0.9; d(B3, A4) = 3.8; d(B3, A5) = 8.1;
d(B4, A1) = 10.5; d(B4, A2) = 7.2; d(B4, A3) = 3.7; d(B4, A4) = 0.9; d(B4, A5) = 4.5;
d(B5, A1) = 14.1; d(B5, A2) = 11.2; d(B5, A3) = 7.7; d(B5, A4) = 4.5; d(B5, A5) = 1.2;
c(A1) = 5000; c(A2) = 7000; c(A3) = 6000; c(A4) = 8000; c(A5) = 9000;
q(B1) = 401; q(B2) = 475; q(B3) = 438; q(B4) = 425; q(B5) = 399;
Qmax(A1) = 36500; Qmax(A2) = 58400; Qmax(A3) = 43800; Qmax(A4) = 58400; Qmax(A5) = 43800;
VARIABLES:
x(A) binary variable indicating whether an incinerator is built at candidate site A
y(B, A) amount of garbage from residential area B sent to candidate site A
EQUATIONS:
obj objective function
cap(A) capacity constraint for candidate site A
demand(B) demand constraint for residential area B
dist(A,B) distance constraint for sending garbage from residential area B to candidate site A
obj.. z =E= sum(A, c(A)*x(A));
cap(A).. sum(B, y(B,A)) =L= Qmax(A)*x(A);
demand(B)..sum(A, y(B,A)) =E= q(B);
dist(A,B)..y(B,A) =L= q(B)*x(A)*1000000/(d(B,A)**2);
MODEL:
garbage /all/;
SOLVE garbage MINIMIZING z USING mip;
DISPLAY x.L, y.L;
```
解释如下:
- SETS:定义了两个集合,分别是居民小区B和备选点A。
- DATA:定义了距离、建设成本、产生垃圾量和最大处理能力等数据。
- VARIABLES:定义了决策变量,x(A)表示在备选点A是否建立垃圾焚烧厂,y(B,A)表示从居民小区B到备选点A的垃圾量。
- EQUATIONS:定义了约束条件,包括容量约束、需求约束和距离约束。
- MODEL:将SETS、DATA、VARIABLES和EQUATIONS整合起来形成一个数学规划模型。
- SOLVE:使用MIP求解器求解该模型。
- DISPLAY:输出决策变量的取值,即哪些备选点建立垃圾焚烧厂。
阅读全文