lemon-project-template-glpk

view deps/glpk/examples/transp.mod @ 11:4fc6ad2fb8a6

Test GLPK in src/main.cc
author Alpar Juttner <alpar@cs.elte.hu>
date Sun, 06 Nov 2011 21:43:29 +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 param a{i in I};
18 /* capacity of plant i in cases */
20 param b{j in J};
21 /* demand at market j in cases */
23 param d{i in I, j in J};
24 /* distance in thousands of miles */
26 param f;
27 /* freight in dollars per case per thousand miles */
29 param c{i in I, j in J} := f * d[i,j] / 1000;
30 /* transport cost in thousands of dollars per case */
32 var x{i in I, j in J} >= 0;
33 /* shipment quantities in cases */
35 minimize cost: sum{i in I, j in J} c[i,j] * x[i,j];
36 /* total transportation costs in thousands of dollars */
38 s.t. supply{i in I}: sum{j in J} x[i,j] <= a[i];
39 /* observe supply limit at plant i */
41 s.t. demand{j in J}: sum{i in I} x[i,j] >= b[j];
42 /* satisfy demand at market j */
44 data;
46 set I := Seattle San-Diego;
48 set J := New-York Chicago Topeka;
50 param a := Seattle 350
51 San-Diego 600;
53 param b := New-York 325
54 Chicago 300
55 Topeka 275;
57 param d : New-York Chicago Topeka :=
58 Seattle 2.5 1.7 1.8
59 San-Diego 2.5 1.8 1.4 ;
61 param f := 90;
63 end;