1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/cpp.mod Mon Dec 06 13:09:21 2010 +0100
1.3 @@ -0,0 +1,67 @@
1.4 +/* CPP, Critical Path Problem */
1.5 +
1.6 +/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
1.7 +
1.8 +/* Note: Reduced costs of auxiliary variables phi[j,k] (see below)
1.9 + can be only zero or one. The critical path is defined by the
1.10 + constraints, whose reduced cost is one. */
1.11 +
1.12 +set J;
1.13 +/* set of jobs (activities) */
1.14 +
1.15 +set P{j in J}, in J, default {};
1.16 +/* P[j] is a subset of jobs that immediately precede job j */
1.17 +
1.18 +param t{j in J}, >= 0;
1.19 +/* duration required to perform job j */
1.20 +
1.21 +var x{j in J}, >= 0;
1.22 +/* starting time of job j */
1.23 +
1.24 +s.t. phi{j in J, k in P[j]}: x[j] >= x[k] + t[k];
1.25 +/* job j can start only after all immediately preceding jobs have been
1.26 + completely performed */
1.27 +
1.28 +var z;
1.29 +/* project makespan */
1.30 +
1.31 +s.t. fin{j in J}: z >= x[j] + t[j];
1.32 +/* which is the maximum of the completion times of all the jobs */
1.33 +
1.34 +minimize obj: z;
1.35 +/* the objective is make z as small as possible */
1.36 +
1.37 +data;
1.38 +
1.39 +/* The optimal solution is 46 */
1.40 +
1.41 +param : J : t :=
1.42 + A 3 /* Excavate */
1.43 + B 4 /* Lay foundation */
1.44 + C 3 /* Rough plumbing */
1.45 + D 10 /* Frame */
1.46 + E 8 /* Finish exterior */
1.47 + F 4 /* Install HVAC */
1.48 + G 6 /* Rough electric */
1.49 + H 8 /* Sheet rock */
1.50 + I 5 /* Install cabinets */
1.51 + J 5 /* Paint */
1.52 + K 4 /* Final plumbing */
1.53 + L 2 /* Final electric */
1.54 + M 4 /* Install flooring */
1.55 +;
1.56 +
1.57 +set P[B] := A;
1.58 +set P[C] := B;
1.59 +set P[D] := B;
1.60 +set P[E] := D;
1.61 +set P[F] := D;
1.62 +set P[G] := D;
1.63 +set P[H] := C E F G;
1.64 +set P[I] := H;
1.65 +set P[J] := H;
1.66 +set P[K] := I;
1.67 +set P[L] := J;
1.68 +set P[M] := K L;
1.69 +
1.70 +end;