1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/csv/transp_csv.mod Mon Dec 06 13:09:21 2010 +0100
1.3 @@ -0,0 +1,70 @@
1.4 +# A TRANSPORTATION PROBLEM
1.5 +#
1.6 +# This problem finds a least cost shipping schedule that meets
1.7 +# requirements at markets and supplies at factories.
1.8 +#
1.9 +# References:
1.10 +# Dantzig G B, "Linear Programming and Extensions."
1.11 +# Princeton University Press, Princeton, New Jersey, 1963,
1.12 +# Chapter 3-3.
1.13 +
1.14 +set I;
1.15 +/* canning plants */
1.16 +
1.17 +set J;
1.18 +/* markets */
1.19 +
1.20 +set K dimen 2;
1.21 +/* transportation lane */
1.22 +
1.23 +set L;
1.24 +/* parameters */
1.25 +
1.26 +param a{i in I};
1.27 +/* capacity of plant i in cases */
1.28 +
1.29 +param b{j in J};
1.30 +/* demand at market j in cases */
1.31 +
1.32 +param d{i in I, j in J};
1.33 +/* distance in thousands of miles */
1.34 +
1.35 +param e{l in L};
1.36 +/* parameters */
1.37 +
1.38 +param f;
1.39 +/* freight in dollars per case per thousand miles */
1.40 +
1.41 +table tab_plant IN "CSV" "plants.csv" :
1.42 + I <- [plant], a ~ capacity;
1.43 +
1.44 +table tab_market IN "CSV" "markets.csv" :
1.45 + J <- [market], b ~ demand;
1.46 +
1.47 +table tab_distance IN "CSV" "distances.csv" :
1.48 + K <- [plant, market], d ~ distance;
1.49 +
1.50 +table tab_parameter IN "CSV" "parameters.csv" :
1.51 + L <- [parameter], e ~ value ;
1.52 +
1.53 +param c{i in I, j in J} := e['transport cost'] * d[i,j] / 1000;
1.54 +/* transport cost in thousands of dollars per case */
1.55 +
1.56 +var x{(i,j) in K} >= 0;
1.57 +/* shipment quantities in cases */
1.58 +
1.59 +minimize cost: sum{(i,j) in K} c[i,j] * x[i,j];
1.60 +/* total transportation costs in thousands of dollars */
1.61 +
1.62 +s.t. supply{i in I}: sum{(i,j) in K} x[i,j] <= a[i];
1.63 +/* observe supply limit at plant i */
1.64 +
1.65 +s.t. demand{j in J}: sum{(i,j) in K} x[i,j] >= b[j];
1.66 +/* satisfy demand at market j */
1.67 +
1.68 +solve;
1.69 +
1.70 +table tab_result{(i,j) in K} OUT "CSV" "result.csv" :
1.71 + i ~ plant, j ~ market, x[i,j] ~ shipment;
1.72 +
1.73 +end;