The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

67 lines
1.6 KiB

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