lemon-project-template-glpk

view 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
line source
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.
11 set I;
12 /* canning plants */
14 set J;
15 /* markets */
17 set K dimen 2;
18 /* transportation lane */
20 set L;
21 /* parameters */
23 param a{i in I};
24 /* capacity of plant i in cases */
26 param b{j in J};
27 /* demand at market j in cases */
29 param d{i in I, j in J};
30 /* distance in thousands of miles */
32 param e{l in L};
33 /* parameters */
35 param f;
36 /* freight in dollars per case per thousand miles */
38 table tab_plant IN "CSV" "plants.csv" :
39 I <- [plant], a ~ capacity;
41 table tab_market IN "CSV" "markets.csv" :
42 J <- [market], b ~ demand;
44 table tab_distance IN "CSV" "distances.csv" :
45 K <- [plant, market], d ~ distance;
47 table tab_parameter IN "CSV" "parameters.csv" :
48 L <- [parameter], e ~ value ;
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 */
53 var x{(i,j) in K} >= 0;
54 /* shipment quantities in cases */
56 minimize cost: sum{(i,j) in K} c[i,j] * x[i,j];
57 /* total transportation costs in thousands of dollars */
59 s.t. supply{i in I}: sum{(i,j) in K} x[i,j] <= a[i];
60 /* observe supply limit at plant i */
62 s.t. demand{j in J}: sum{(i,j) in K} x[i,j] >= b[j];
63 /* satisfy demand at market j */
65 solve;
67 table tab_result{(i,j) in K} OUT "CSV" "result.csv" :
68 i ~ plant, j ~ market, x[i,j] ~ shipment;
70 end;