1 /* CPP, Critical Path Problem */
3 /* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
5 /* Note: Reduced costs of auxiliary variables phi[j,k] (see below)
6 can be only zero or one. The critical path is defined by the
7 constraints, whose reduced cost is one. */
10 /* set of jobs (activities) */
12 set P{j in J}, in J, default {};
13 /* P[j] is a subset of jobs that immediately precede job j */
15 param t{j in J}, >= 0;
16 /* duration required to perform job j */
19 /* starting time of job j */
21 s.t. phi{j in J, k in P[j]}: x[j] >= x[k] + t[k];
22 /* job j can start only after all immediately preceding jobs have been
23 completely performed */
26 /* project makespan */
28 s.t. fin{j in J}: z >= x[j] + t[j];
29 /* which is the maximum of the completion times of all the jobs */
32 /* the objective is make z as small as possible */
36 /* The optimal solution is 46 */
40 B 4 /* Lay foundation */
41 C 3 /* Rough plumbing */
43 E 8 /* Finish exterior */
44 F 4 /* Install HVAC */
45 G 6 /* Rough electric */
47 I 5 /* Install cabinets */
49 K 4 /* Final plumbing */
50 L 2 /* Final electric */
51 M 4 /* Install flooring */