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.

114 lines
3.2 KiB

2 months ago
  1. /* JSSP, Job-Shop Scheduling Problem */
  2. /* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
  3. /* The Job-Shop Scheduling Problem (JSSP) is to schedule a set of jobs
  4. on a set of machines, subject to the constraint that each machine can
  5. handle at most one job at a time and the fact that each job has a
  6. specified processing order through the machines. The objective is to
  7. schedule the jobs so as to minimize the maximum of their completion
  8. times.
  9. Reference:
  10. D. Applegate and W. Cook, "A Computational Study of the Job-Shop
  11. Scheduling Problem", ORSA J. On Comput., Vol. 3, No. 2, Spring 1991,
  12. pp. 149-156. */
  13. param n, integer, > 0;
  14. /* number of jobs */
  15. param m, integer, > 0;
  16. /* number of machines */
  17. set J := 1..n;
  18. /* set of jobs */
  19. set M := 1..m;
  20. /* set of machines */
  21. param sigma{j in J, t in 1..m}, in M;
  22. /* permutation of the machines, which represents the processing order
  23. of j through the machines: j must be processed first on sigma[j,1],
  24. then on sigma[j,2], etc. */
  25. check{j in J, t1 in 1..m, t2 in 1..m: t1 <> t2}:
  26. sigma[j,t1] != sigma[j,t2];
  27. /* sigma must be permutation */
  28. param p{j in J, a in M}, >= 0;
  29. /* processing time of j on a */
  30. var x{j in J, a in M}, >= 0;
  31. /* starting time of j on a */
  32. s.t. ord{j in J, t in 2..m}:
  33. x[j, sigma[j,t]] >= x[j, sigma[j,t-1]] + p[j, sigma[j,t-1]];
  34. /* j can be processed on sigma[j,t] only after it has been completely
  35. processed on sigma[j,t-1] */
  36. /* The disjunctive condition that each machine can handle at most one
  37. job at a time is the following:
  38. x[i,a] >= x[j,a] + p[j,a] or x[j,a] >= x[i,a] + p[i,a]
  39. for all i, j in J, a in M. This condition is modeled through binary
  40. variables Y as shown below. */
  41. var Y{i in J, j in J, a in M}, binary;
  42. /* Y[i,j,a] is 1 if i scheduled before j on machine a, and 0 if j is
  43. scheduled before i */
  44. param K := sum{j in J, a in M} p[j,a];
  45. /* some large constant */
  46. display K;
  47. s.t. phi{i in J, j in J, a in M: i <> j}:
  48. x[i,a] >= x[j,a] + p[j,a] - K * Y[i,j,a];
  49. /* x[i,a] >= x[j,a] + p[j,a] iff Y[i,j,a] is 0 */
  50. s.t. psi{i in J, j in J, a in M: i <> j}:
  51. x[j,a] >= x[i,a] + p[i,a] - K * (1 - Y[i,j,a]);
  52. /* x[j,a] >= x[i,a] + p[i,a] iff Y[i,j,a] is 1 */
  53. var z;
  54. /* so-called makespan */
  55. s.t. fin{j in J}: z >= x[j, sigma[j,m]] + p[j, sigma[j,m]];
  56. /* which is the maximum of the completion times of all the jobs */
  57. minimize obj: z;
  58. /* the objective is to make z as small as possible */
  59. data;
  60. /* These data correspond to the instance ft06 (mt06) from:
  61. H. Fisher, G.L. Thompson (1963), Probabilistic learning combinations
  62. of local job-shop scheduling rules, J.F. Muth, G.L. Thompson (eds.),
  63. Industrial Scheduling, Prentice Hall, Englewood Cliffs, New Jersey,
  64. 225-251 */
  65. /* The optimal solution is 55 */
  66. param n := 6;
  67. param m := 6;
  68. param sigma : 1 2 3 4 5 6 :=
  69. 1 3 1 2 4 6 5
  70. 2 2 3 5 6 1 4
  71. 3 3 4 6 1 2 5
  72. 4 2 1 3 4 5 6
  73. 5 3 2 5 6 1 4
  74. 6 2 4 6 1 5 3 ;
  75. param p : 1 2 3 4 5 6 :=
  76. 1 3 6 1 7 6 3
  77. 2 10 8 5 4 10 10
  78. 3 9 1 5 4 7 8
  79. 4 5 5 5 3 8 9
  80. 5 3 3 9 1 5 4
  81. 6 10 3 1 3 4 9 ;
  82. end;