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