1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/egypt.mod Mon Dec 06 13:09:21 2010 +0100
1.3 @@ -0,0 +1,519 @@
1.4 +# EGYPT, a static model of fertilizer production
1.5 +#
1.6 +# References:
1.7 +# Robert Fourer, David M. Gay and Brian W. Kernighan, "A Modeling Language
1.8 +# for Mathematical Programming." Management Science 36 (1990) 519-554.
1.9 +
1.10 +### SETS ###
1.11 +
1.12 +set center; # Locations from which final product may be shipped
1.13 +set port within center; # Locations at which imports can be received
1.14 +set plant within center; # Locations of plants
1.15 +
1.16 +set region; # Demand regions
1.17 +
1.18 +set unit; # Productive units
1.19 +set proc; # Processes
1.20 +
1.21 +set nutr; # Nutrients
1.22 +
1.23 +set c_final; # Final products (fertilizers)
1.24 +set c_inter; # Intermediate products
1.25 +set c_ship within c_inter; # Intermediates for shipment
1.26 +set c_raw; # Domestic raw materials and miscellaneous inputs
1.27 +
1.28 +set commod := c_final union c_inter union c_raw;
1.29 +
1.30 + # All commodities
1.31 +
1.32 +### PARAMETERS ###
1.33 +
1.34 +param cf75 {region,c_final} >= 0;
1.35 +
1.36 + # Consumption of fertilizer 1974-75 (1000 tpy)
1.37 +
1.38 +param fn {c_final,nutr} >= 0;
1.39 +
1.40 + # Nutrient content of fertilizers
1.41 +
1.42 +param cn75 {r in region, n in nutr} := sum {c in c_final} cf75[r,c] * fn[c,n];
1.43 +
1.44 + # Consumption of nutrients 1974-75 (1000 tpy)
1.45 +
1.46 +param road {region,center} >= 0;
1.47 +
1.48 + # Road distances
1.49 +
1.50 +param rail_half {plant,plant} >= 0;
1.51 +param rail {p1 in plant, p2 in plant} :=
1.52 + if rail_half[p1,p2] > 0 then rail_half[p1,p2] else rail_half[p2,p1];
1.53 +
1.54 + # Interplant rail distances (kms)
1.55 +
1.56 +param impd_barg {plant} >= 0;
1.57 +param impd_road {plant} >= 0;
1.58 +
1.59 + # Import distances (kms) by barge and road
1.60 +
1.61 +param tran_final {pl in plant, r in region} :=
1.62 + if road[r,pl] > 0 then .5 + .0144 * road[r,pl] else 0;
1.63 +
1.64 +param tran_import {r in region, po in port} :=
1.65 + if road[r,po] > 0 then .5 + .0144 * road[r,po] else 0;
1.66 +
1.67 +param tran_inter {p1 in plant, p2 in plant} :=
1.68 + if rail[p1,p2] > 0 then 3.5 + .03 * rail[p1,p2] else 0;
1.69 +
1.70 +param tran_raw {pl in plant} :=
1.71 + (if impd_barg[pl] > 0 then 1.0 + .0030 * impd_barg[pl] else 0)
1.72 + + (if impd_road[pl] > 0 then 0.5 + .0144 * impd_road[pl] else 0);
1.73 +
1.74 + # Transport cost (le per ton) for:
1.75 + # final products, imported final products,
1.76 + # interplant shipment, imported raw materials
1.77 +
1.78 +param io {commod,proc}; # Input-output coefficients
1.79 +
1.80 +param util {unit,proc} >= 0;
1.81 +
1.82 + # Capacity utilization coefficients
1.83 +
1.84 +param p_imp {commod} >= 0; # Import Price (cif US$ per ton 1975)
1.85 +
1.86 +param p_r {c_raw} >= 0;
1.87 +param p_pr {plant,c_raw} >= 0;
1.88 +
1.89 +param p_dom {pl in plant, c in c_raw} :=
1.90 + if p_r[c] > 0 then p_r[c] else p_pr[pl,c];
1.91 +
1.92 + # Domestic raw material prices
1.93 +
1.94 +param dcap {plant,unit} >= 0;
1.95 +
1.96 + # Design capacity of plants (t/day)
1.97 +
1.98 +param icap {u in unit, pl in plant} := 0.33 * dcap[pl,u];
1.99 +
1.100 + # Initial capacity of plants (t/day)
1.101 +
1.102 +param exch := 0.4; # Exchange rate
1.103 +
1.104 +param util_pct := 0.85; # Utilization percent for initial capacity
1.105 +
1.106 +### DERIVED SETS OF "POSSIBILITIES" ###
1.107 +
1.108 +set m_pos {pl in plant} := {u in unit: icap[u,pl] > 0};
1.109 +
1.110 + # At each plant, set of units for which there is
1.111 + # initial capacity
1.112 +
1.113 +set p_cap {pl in plant} :=
1.114 + {pr in proc: forall {u in unit: util[u,pr] > 0} u in m_pos[pl] };
1.115 +
1.116 + # At each plant, set of processes for which
1.117 + # all necessary units have some initial capacity
1.118 +
1.119 +set p_except {plant} within proc;
1.120 +
1.121 + # At each plant, list of processes that are
1.122 + # arbitrarily ruled out
1.123 +
1.124 +set p_pos {pl in plant} := p_cap[pl] diff p_except[pl];
1.125 +
1.126 + # At each plant, set of possible processes
1.127 +
1.128 +set cp_pos {c in commod} := {pl in plant: sum {pr in p_pos[pl]} io[c,pr] > 0};
1.129 +
1.130 +set cc_pos {c in commod} := {pl in plant: sum {pr in p_pos[pl]} io[c,pr] < 0};
1.131 +
1.132 +set c_pos {c in commod} := cp_pos[c] union cc_pos[c];
1.133 +
1.134 + # For each commodity, set of plants that can
1.135 + # produce it (cp_pos) or consume it (cc_pos),
1.136 + # and their union (c_pos)
1.137 +
1.138 +### VARIABLES ###
1.139 +
1.140 +var Z {pl in plant, p_pos[pl]} >= 0;
1.141 +
1.142 + # Z[pl,pr] is level of process pr at plant pl
1.143 +
1.144 +var Xf {c in c_final, cp_pos[c], region} >= 0;
1.145 +
1.146 + # Xf[c,pl,r] is amount of final product c
1.147 + # shipped from plant pl to region r
1.148 +
1.149 +var Xi {c in c_ship, cp_pos[c], cc_pos[c]} >= 0;
1.150 +
1.151 + # Xi[c,p1,p2] is amount of intermediate c
1.152 + # shipped from plant p1 to plant p2
1.153 +
1.154 +var Vf {c_final,region,port} >= 0;
1.155 +
1.156 + # Vf[c,r,po] is amount of final product c
1.157 + # imported by region r from port po
1.158 +
1.159 +var Vr {c in c_raw, cc_pos[c]} >= 0;
1.160 +
1.161 + # Vr[c,pl] is amount of raw material c
1.162 + # imported for use at plant pl
1.163 +
1.164 +var U {c in c_raw, cc_pos[c]} >= 0;
1.165 +
1.166 + # U[c,pl] is amount of raw material c
1.167 + # purchased domestically for use at plant pl
1.168 +
1.169 +var Psip; # Domestic recurrent cost
1.170 +var Psil; # Transport cost
1.171 +var Psii; # Import cost
1.172 +
1.173 +### OBJECTIVE ###
1.174 +
1.175 +minimize Psi: Psip + Psil + Psii;
1.176 +
1.177 +### CONSTRAINTS ###
1.178 +
1.179 +subject to mbd {n in nutr, r in region}:
1.180 +
1.181 + sum {c in c_final} fn[c,n] *
1.182 + (sum {po in port} Vf[c,r,po] +
1.183 + sum {pl in cp_pos[c]} Xf[c,pl,r]) >= cn75[r,n];
1.184 +
1.185 + # Total nutrients supplied to a region by all
1.186 + # final products (sum of imports plus internal
1.187 + # shipments from plants) must meet requirements
1.188 +
1.189 +subject to mbdb {c in c_final, r in region: cf75[r,c] > 0}:
1.190 +
1.191 + sum {po in port} Vf[c,r,po] +
1.192 + sum {pl in cp_pos[c]} Xf[c,pl,r] >= cf75[r,c];
1.193 +
1.194 + # Total of each final product supplied to each
1.195 + # region (as in previous constraint) must meet
1.196 + # requirements
1.197 +
1.198 +subject to mb {c in commod, pl in plant}:
1.199 +
1.200 + sum {pr in p_pos[pl]} io[c,pr] * Z[pl,pr]
1.201 +
1.202 + + ( if c in c_ship then
1.203 + ( if pl in cp_pos[c] then sum {p2 in cc_pos[c]} Xi[c,pl,p2] )
1.204 + - ( if pl in cc_pos[c] then sum {p2 in cp_pos[c]} Xi[c,p2,pl] ))
1.205 +
1.206 + + ( if (c in c_raw and pl in cc_pos[c]) then
1.207 + (( if p_imp[c] > 0 then Vr[c,pl] )
1.208 + + ( if p_dom[pl,c] > 0 then U[c,pl] )))
1.209 +
1.210 + >= if (c in c_final and pl in cp_pos[c]) then sum {r in region} Xf[c,pl,r];
1.211 +
1.212 + # For each commodity at each plant: sum of
1.213 + # (1) production or consumption at plant,
1.214 + # (2) inter-plant shipments in or out,
1.215 + # (3) import and domestic purchases (raw only)
1.216 + # is >= 0 for raw materials and intermediates;
1.217 + # is >= the total shipped for final products
1.218 +
1.219 +subject to cc {pl in plant, u in m_pos[pl]}:
1.220 +
1.221 + sum {pr in p_pos[pl]} util[u,pr] * Z[pl,pr] <= util_pct * icap[u,pl];
1.222 +
1.223 + # For each productive unit at each plant,
1.224 + # total utilization by all processes
1.225 + # may not exceed the unit's capacity
1.226 +
1.227 +subject to ap:
1.228 +
1.229 + Psip = sum {c in c_raw, pl in cc_pos[c]} p_dom[pl,c] * U[c,pl];
1.230 +
1.231 + # Psip is the cost of domestic raw materials,
1.232 + # summed over all plants that consume them
1.233 +
1.234 +subject to al:
1.235 +
1.236 + Psil = sum {c in c_final} (
1.237 +
1.238 + sum {pl in cp_pos[c], r in region}
1.239 + tran_final[pl,r] * Xf[c,pl,r]
1.240 +
1.241 + + sum {po in port, r in region} tran_import[r,po] * Vf[c,r,po] )
1.242 +
1.243 + + sum {c in c_ship, p1 in cp_pos[c], p2 in cc_pos[c]}
1.244 + tran_inter[p1,p2] * Xi[c,p1,p2]
1.245 +
1.246 + + sum {c in c_raw, pl in cc_pos[c]: p_imp[c] > 0}
1.247 + tran_raw[pl] * Vr[c,pl];
1.248 +
1.249 + # Total transport cost is sum of shipping costs for
1.250 + # (1) all final products from all plants,
1.251 + # (2) all imports of final products,
1.252 + # (3) all intermediates shipped between plants,
1.253 + # (4) all imports of raw materials
1.254 +
1.255 +subject to ai:
1.256 +
1.257 + Psii / exch = sum {c in c_final, r in region, po in port}
1.258 + p_imp[c] * Vf[c,r,po]
1.259 +
1.260 + + sum {c in c_raw, pl in cc_pos[c]} p_imp[c] * Vr[c,pl];
1.261 +
1.262 + # Total import cost -- at exchange rate --
1.263 + # is sum of import costs for final products
1.264 + # in each region and raw materials at each plant
1.265 +
1.266 +### DATA ###
1.267 +
1.268 +data;
1.269 +
1.270 +set center := ASWAN HELWAN ASSIOUT KAFR_EL_ZT ABU_ZAABAL ABU_KIR TALKHA SUEZ ;
1.271 +
1.272 +set port := ABU_KIR ;
1.273 +
1.274 +set plant := ASWAN HELWAN ASSIOUT KAFR_EL_ZT ABU_ZAABAL ;
1.275 +
1.276 +set region := ALEXANDRIA BEHERA GHARBIA KAFR_EL_SH DAKAHLIA DAMIETTA
1.277 + SHARKIA ISMAILIA SUEZ MENOUFIA KALUBIA GIZA BENI_SUEF FAYOUM
1.278 + MINIA ASSIOUT NEW_VALLEY SOHAG QUENA ASWAN ;
1.279 +
1.280 +set unit := SULF_A_S SULF_A_P NITR_ACID AMM_ELEC AMM_C_GAS C_AMM_NITR
1.281 + AMM_SULF SSP ;
1.282 +
1.283 +set proc := SULF_A_S SULF_A_P NITR_ACID AMM_ELEC AMM_C_GAS CAN_310 CAN_335
1.284 + AMM_SULF SSP_155 ;
1.285 +
1.286 +set nutr := N P205 ;
1.287 +
1.288 +set c_final := UREA CAN_260 CAN_310 CAN_335 AMM_SULF DAP SSP_155 C_250_55
1.289 + C_300_100 ;
1.290 +
1.291 +set c_inter := AMMONIA NITR_ACID SULF_ACID ;
1.292 +
1.293 +set c_ship := AMMONIA SULF_ACID ;
1.294 +
1.295 +set c_raw := EL_ASWAN COKE_GAS PHOS_ROCK LIMESTONE EL_SULFUR PYRITES
1.296 + ELECTRIC BF_GAS WATER STEAM BAGS ;
1.297 +
1.298 +set p_except[ASWAN] := CAN_335 ;
1.299 +set p_except[HELWAN] := CAN_310 ;
1.300 +set p_except[ASSIOUT] := ;
1.301 +set p_except[KAFR_EL_ZT] := ;
1.302 +set p_except[ABU_ZAABAL] := ;
1.303 +
1.304 +param cf75 default 0.0 :
1.305 +
1.306 + CAN_260 CAN_310 CAN_335 AMM_SULF UREA :=
1.307 +
1.308 +ALEXANDRIA . . 5.0 3.0 1.0
1.309 +ASSIOUT 1.0 20.0 26.0 1.0 27.0
1.310 +ASWAN . 40.0 . . .
1.311 +BEHERA 1.0 . 25.0 90.0 35.0
1.312 +BENI_SUEF 1.0 . 15.0 1.0 20.0
1.313 +DAKAHLIA 1.0 . 26.0 60.0 20.0
1.314 +DAMIETTA . . 2.0 15.0 8.0
1.315 +FAYOUM 1.0 . 20.0 6.0 20.0
1.316 +GHARBIA . . 17.0 60.0 28.0
1.317 +GIZA . . 40.0 6.0 2.0
1.318 +ISMAILIA . . 4.0 6.0 2.0
1.319 +KAFR_EL_SH 1.0 . 10.0 45.0 22.0
1.320 +KALUBIA . . 25.0 16.0 7.0
1.321 +MENOUFIA 1.0 . 24.0 21.0 30.0
1.322 +MINIA 2.0 15.0 35.0 1.0 41.0
1.323 +NEW_VALLEY . . . . 1.0
1.324 +QUENA . 95.0 2.0 . 3.0
1.325 +SHARKIA 1.0 . 31.0 50.0 28.0
1.326 +SOHAG . 65.0 3.0 . 7.0
1.327 +SUEZ . . 1.0 . .
1.328 +
1.329 + : SSP_155 C_250_55 C_300_100 DAP :=
1.330 +
1.331 +ALEXANDRIA 8.0 . . .
1.332 +ASSIOUT 35.0 5.0 .1 .
1.333 +ASWAN 8.0 . . .
1.334 +BEHERA 64.0 1.0 .1 .1
1.335 +BENI_SUEF 13.0 3.0 . .
1.336 +DAKAHLIA 52.0 1.0 . .
1.337 +DAMIETTA 5.0 . . .
1.338 +FAYOUM 17.0 1.0 . .
1.339 +GHARBIA 57.0 1.0 .2 .1
1.340 +GIZA 14.0 1.0 .1 .
1.341 +ISMAILIA 4.0 . . .
1.342 +KAFR_EL_SH 25.0 2.0 .1 .
1.343 +KALUBIA 22.0 1.0 . .1
1.344 +MENOUFIA 33.0 2.0 .1 .1
1.345 +MINIA 50.0 3.0 .2 .1
1.346 +NEW_VALLEY 1.0 . . .
1.347 +QUENA 8.0 . . .
1.348 +SHARKIA 43.0 1.0 .1 .
1.349 +SOHAG 20.0 1.0 . .
1.350 +SUEZ 1.0 . . . ;
1.351 +
1.352 +param fn default 0.0 : N P205 :=
1.353 +
1.354 + AMM_SULF .206 .
1.355 + CAN_260 .26 .
1.356 + CAN_310 .31 .
1.357 + CAN_335 .335 .
1.358 + C_250_55 .25 .055
1.359 + C_300_100 .30 .10
1.360 + DAP .18 .46
1.361 + SSP_155 . .15
1.362 + UREA .46 . ;
1.363 +
1.364 +param road default 0.0 :
1.365 +
1.366 + ABU_KIR ABU_ZAABAL ASSIOUT ASWAN HELWAN KAFR_EL_ZT SUEZ TALKHA :=
1.367 +
1.368 +ALEXANDRIA 16 210 607 1135 244 119 362 187
1.369 +ASSIOUT 616 420 . 518 362 504 527 518
1.370 +ASWAN 1134 938 518 . 880 1022 1045 1036
1.371 +BEHERA 76 50 547 1065 184 42 288 120
1.372 +BENI_SUEF 359 163 257 775 105 248 270 261
1.373 +DAKAHLIA 208 138 515 1033 152 58 219 3
1.374 +DAMIETTA 267 216 596 1114 233 131 286 66
1.375 +FAYOUM 341 145 308 826 88 230 252 243
1.376 +GHARBIA 150 65 485 1003 122 20 226 55
1.377 +GIZA 287 48 372 890 .9 133 169 146
1.378 +ISMAILIA 365 142 536 1054 173 241 89 146
1.379 +KAFR_EL_SH 145 105 525 1043 162 20 266 35
1.380 +KALUBIA 190 97 439 957 76 66 180 81
1.381 +MENOUFIA 157 154 472 990 109 33 213 90
1.382 +MINIA 384 288 132 650 230 372 394 386
1.383 +NEW_VALLEY 815 619 199 519 561 703 726 717
1.384 +QUENA 858 662 242 276 604 746 769 760
1.385 +SHARKIA 240 60 473 991 110 78 214 58
1.386 +SOHAG 715 519 99 419 461 603 626 617
1.387 +SUEZ 370 224 541 1059 178 246 . 298 ;
1.388 +
1.389 +param rail_half default 0 :
1.390 +
1.391 + KAFR_EL_ZT ABU_ZAABAL HELWAN ASSIOUT :=
1.392 +
1.393 +ABU_ZAABAL 85 . . .
1.394 +HELWAN 142 57 . .
1.395 +ASSIOUT 504 420 362 .
1.396 +ASWAN 1022 938 880 518 ;
1.397 +
1.398 +param : impd_barg impd_road :=
1.399 +
1.400 +ABU_ZAABAL 210 .1
1.401 +ASSIOUT 583 0
1.402 +ASWAN 1087 10
1.403 +HELWAN 183 0
1.404 +KAFR_EL_ZT 104 6 ;
1.405 +
1.406 +param io default 0.0 :=
1.407 +
1.408 + [*,AMM_C_GAS] AMMONIA 1.0
1.409 + BF_GAS -609.
1.410 + COKE_GAS -2.0
1.411 + ELECTRIC -1960.
1.412 + STEAM -4.
1.413 + WATER -700.
1.414 +
1.415 + [*,AMM_ELEC] AMMONIA 1.0
1.416 + EL_ASWAN -12.0
1.417 +
1.418 + [*,AMM_SULF] AMMONIA -.26
1.419 + AMM_SULF 1.0
1.420 + BAGS -22.
1.421 + ELECTRIC -19.
1.422 + SULF_ACID -.76
1.423 + WATER -17.
1.424 +
1.425 + [*,CAN_310] AMMONIA -.20
1.426 + BAGS -23.
1.427 + CAN_310 1.0
1.428 + LIMESTONE -.12
1.429 + NITR_ACID -.71
1.430 + STEAM -.4
1.431 + WATER -49.
1.432 +
1.433 + [*,CAN_335] AMMONIA -.21
1.434 + BAGS -23.
1.435 + CAN_335 1.0
1.436 + LIMESTONE -.04
1.437 + NITR_ACID -.76
1.438 + STEAM -.4
1.439 + WATER -49.
1.440 +
1.441 + [*,NITR_ACID] AMMONIA -.292
1.442 + ELECTRIC -231.
1.443 + NITR_ACID 1.0
1.444 + WATER -.6
1.445 +
1.446 + [*,SSP_155] BAGS -22.
1.447 + ELECTRIC -14.
1.448 + PHOS_ROCK -.62
1.449 + SSP_155 1.0
1.450 + SULF_ACID -.41
1.451 + WATER -6.
1.452 +
1.453 + [*,SULF_A_P] ELECTRIC -75.
1.454 + PYRITES -.826
1.455 + SULF_ACID 1.0
1.456 + WATER -60.
1.457 +
1.458 + [*,SULF_A_S] ELECTRIC -50.
1.459 + EL_SULFUR -.334
1.460 + SULF_ACID 1.0
1.461 + WATER -20. ;
1.462 +
1.463 +param util default 0 :=
1.464 +
1.465 + [*,*] SULF_A_S SULF_A_S 1 SULF_A_P SULF_A_P 1
1.466 + NITR_ACID NITR_ACID 1 AMM_ELEC AMM_ELEC 1
1.467 + AMM_C_GAS AMM_C_GAS 1 SSP SSP_155 1
1.468 + C_AMM_NITR CAN_310 1 C_AMM_NITR CAN_335 1
1.469 + AMM_SULF AMM_SULF 1 ;
1.470 +
1.471 +param p_imp default 0.0 :=
1.472 +
1.473 + PYRITES 17.5 AMM_SULF 75.
1.474 + EL_SULFUR 55. DAP 175.
1.475 + UREA 150. SSP_155 80.
1.476 + CAN_260 75. C_250_55 100.
1.477 + CAN_310 90. C_300_100 130.
1.478 + CAN_335 100. ;
1.479 +
1.480 +param p_r default 0.0 :=
1.481 +
1.482 + ELECTRIC .007
1.483 + BF_GAS .007
1.484 + WATER .031
1.485 + STEAM 1.25
1.486 + BAGS .28 ;
1.487 +
1.488 +param p_pr default 0.0 :=
1.489 +
1.490 + [HELWAN,COKE_GAS] 16.0
1.491 + [ASWAN,EL_ASWAN] 1.0
1.492 +
1.493 + [*,LIMESTONE] ASWAN 1.2
1.494 + HELWAN 1.2
1.495 +
1.496 + [*,PHOS_ROCK] ABU_ZAABAL 4.0
1.497 + ASSIOUT 3.5
1.498 + KAFR_EL_ZT 5.0 ;
1.499 +
1.500 +param dcap default 0.0 :=
1.501 +
1.502 + [ABU_ZAABAL,*] SSP 600
1.503 + SULF_A_P 227
1.504 + SULF_A_S 242
1.505 +
1.506 + [ASSIOUT,*] SSP 600
1.507 + SULF_A_S 250
1.508 +
1.509 + [ASWAN,*] AMM_ELEC 450
1.510 + C_AMM_NITR 1100
1.511 + NITR_ACID 800
1.512 +
1.513 + [HELWAN,*] AMM_C_GAS 172
1.514 + AMM_SULF 24
1.515 + C_AMM_NITR 364
1.516 + NITR_ACID 282
1.517 +
1.518 + [KAFR_EL_ZT,*] SSP 600
1.519 + SULF_A_P 50
1.520 + SULF_A_S 200 ;
1.521 +
1.522 +end;