COIN-OR::LEMON - Graph Library

source: glpk-cmake/examples/csv/transp_csv.mod

Last change on this file was 1:c445c931472f, checked in by Alpar Juttner <alpar@…>, 14 years ago

Import glpk-4.45

  • Generated files and doc/notes are removed
File size: 1.6 KB
Line 
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
11set I;
12/* canning plants */
13
14set J;
15/* markets */
16
17set K dimen 2;
18/* transportation lane */
19
20set L;
21/* parameters */
22
23param a{i in I};
24/* capacity of plant i in cases */
25
26param b{j in J};
27/* demand at market j in cases */
28
29param d{i in I, j in J};
30/* distance in thousands of miles */
31
32param e{l in L};
33/* parameters */
34
35param f;
36/* freight in dollars per case per thousand miles */
37
38table tab_plant IN "CSV" "plants.csv" :
39  I <- [plant], a ~ capacity;
40
41table tab_market IN "CSV" "markets.csv" :
42  J <- [market], b ~ demand;
43
44table tab_distance IN "CSV" "distances.csv" :
45  K <- [plant, market], d ~ distance;
46
47table tab_parameter IN "CSV" "parameters.csv" :
48  L <- [parameter], e ~ value ;
49
50param c{i in I, j in J} := e['transport cost'] * d[i,j] / 1000;
51/* transport cost in thousands of dollars per case */
52
53var x{(i,j) in K} >= 0;
54/* shipment quantities in cases */
55
56minimize cost: sum{(i,j) in K} c[i,j] * x[i,j];
57/* total transportation costs in thousands of dollars */
58
59s.t. supply{i in I}: sum{(i,j) in K} x[i,j] <= a[i];
60/* observe supply limit at plant i */
61
62s.t. demand{j in J}: sum{(i,j) in K} x[i,j] >= b[j];
63/* satisfy demand at market j */
64
65solve;
66
67table tab_result{(i,j) in K} OUT "CSV" "result.csv" :
68  i ~ plant, j ~ market, x[i,j] ~ shipment;
69
70end;
Note: See TracBrowser for help on using the repository browser.