lemon-project-template-glpk
comparison deps/glpk/examples/csv/transp_csv.mod @ 9:33de93886c88
Import GLPK 4.47
author | Alpar Juttner <alpar@cs.elte.hu> |
---|---|
date | Sun, 06 Nov 2011 20:59:10 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b06f71675ef2 |
---|---|
1 # A TRANSPORTATION PROBLEM | |
2 # | |
3 # This problem finds a least cost shipping schedule that meets | |
4 # requirements at markets and supplies at factories. | |
5 # | |
6 # References: | |
7 # Dantzig G B, "Linear Programming and Extensions." | |
8 # Princeton University Press, Princeton, New Jersey, 1963, | |
9 # Chapter 3-3. | |
10 | |
11 set I; | |
12 /* canning plants */ | |
13 | |
14 set J; | |
15 /* markets */ | |
16 | |
17 set K dimen 2; | |
18 /* transportation lane */ | |
19 | |
20 set L; | |
21 /* parameters */ | |
22 | |
23 param a{i in I}; | |
24 /* capacity of plant i in cases */ | |
25 | |
26 param b{j in J}; | |
27 /* demand at market j in cases */ | |
28 | |
29 param d{i in I, j in J}; | |
30 /* distance in thousands of miles */ | |
31 | |
32 param e{l in L}; | |
33 /* parameters */ | |
34 | |
35 param f; | |
36 /* freight in dollars per case per thousand miles */ | |
37 | |
38 table tab_plant IN "CSV" "plants.csv" : | |
39 I <- [plant], a ~ capacity; | |
40 | |
41 table tab_market IN "CSV" "markets.csv" : | |
42 J <- [market], b ~ demand; | |
43 | |
44 table tab_distance IN "CSV" "distances.csv" : | |
45 K <- [plant, market], d ~ distance; | |
46 | |
47 table tab_parameter IN "CSV" "parameters.csv" : | |
48 L <- [parameter], e ~ value ; | |
49 | |
50 param c{i in I, j in J} := e['transport cost'] * d[i,j] / 1000; | |
51 /* transport cost in thousands of dollars per case */ | |
52 | |
53 var x{(i,j) in K} >= 0; | |
54 /* shipment quantities in cases */ | |
55 | |
56 minimize cost: sum{(i,j) in K} c[i,j] * x[i,j]; | |
57 /* total transportation costs in thousands of dollars */ | |
58 | |
59 s.t. supply{i in I}: sum{(i,j) in K} x[i,j] <= a[i]; | |
60 /* observe supply limit at plant i */ | |
61 | |
62 s.t. demand{j in J}: sum{(i,j) in K} x[i,j] >= b[j]; | |
63 /* satisfy demand at market j */ | |
64 | |
65 solve; | |
66 | |
67 table tab_result{(i,j) in K} OUT "CSV" "result.csv" : | |
68 i ~ plant, j ~ market, x[i,j] ~ shipment; | |
69 | |
70 end; |