A Genetic Algorithm For The Job-Shop Scheduling Problem: Joan Puigcerver I Pérez
A Genetic Algorithm For The Job-Shop Scheduling Problem: Joan Puigcerver I Pérez
Scheduling Problem
Joan Puigcerver i Pérez
[email protected]
1 Introduction
The job-shop scheduling problem (JSP) consists on a given set of n jobs to per-
form J = {J1 , . . . , Jn }. Each job j is composed by t tasks Tj =< θj,1 , . . . , θj,t >
(1 ≤ j ≤ n), each of them with an associated duration Dj,k (1 ≤ j ≤ n,
1 ≤ k ≤ t). Each task θj,k needs also an specific resource rj,k ∈ R from the
set of m resources R = {R1 , . . . , Rm }, (1 ≤ j ≤ n, 1 ≤ k ≤ t). The objective
is to schedule the start time Sj,k of each task θj,k to minimize the completion
time of the whole set of jobs (the timespan). This has to be done subject to the
following restrictions: all tasks within a job have to be completed sequentially
and no two tasks are assigned to the same machine at the same time. This two
restrictions can be formally specified using the bellow equations.
It has been proven that this problem is NP-Hard and can be reduced to
finding the minimum cost Hamiltonian path in a directed graph with weighted
edges (a disjunctive graph)[6, 5, 2]. Because of the complexity of the problem,
exact solutions for big instances cannot be computed in a reasonable amount of
time. Different approximate solutions based on branch and bound[3], simulated
annealing[7], genetic algorithms[4], and other techniques have been explored in
the literature. Here we present a genetic algorithm (GA) that is able to produce
reasonable solutions with a polynomial time complexity.
2 Genetic Algorithm
Genetic Algorithms are iterative algorithms that encode a solution for a given
problem as an individual of a fixed-size population. At any given iteration, two
or more individuals (solutions) are combined to create new individuals (this is
called a crossover). Individuals may also be modified with random modifications
1
of the encoded solution (mutations). The key process here is that individuals are
combined and modified randomly and all of them are evaluated using a fitness
function that has to be minimized (or maximized, depending on the problem).
Then, only the best individuals from each iteration will survive to the next it-
eration (additionally, some “bad” solutions may survive which sometimes helps
to avoid local optima).
Thus, in order to solve any optimization problem using GAs one must define
how the solutions are encoded as individuals of the population, which fitness
function has to be optimized, and how they are combined (crossover operation)
and mutated (mutation operation) to create new individuals.
We use a typical representation for the JSP which encodes the restriction
stated in equation 1 implicitly (tasks within a job must be completed sequen-
tially). The individuals encode a topological ordering of the DAG representing
the solution. The tasks are represented only by their job identifier, and the task
identifier is represented implicitly by the relative position of each task in the
chromosome (for example, the first task from job 1, will be task 1, the second
task from job 2 will be task 2, and so on). This allows us to represent the
previous restriction implicitly in the chromosome. For instance, suppose the
instance of the JSP represented in table 1 with two jobs, two tasks for each job
and two machines.
Table 1: A JSP instance example for two jobs, two tasks for each job and two
machines.
The previous instance can be represented using the directed graph shown in
figure 1a and a possible solution would be the one depicted in figure 1b. The
presented solution schedules θ1,1 before θ2,2 and θ2,1 before θ1,2 . Tasks θ1,1 and
θ2,1 can be done in parallel, same as tasks θ1,2 and θ2,2 .
Note that, in the general case, multiple topological orderings can be obtained
from a given DAG. Given 1b, table 2 shows four topological orderings of the
same DAG which lead to four different representations of the same solution.
2
θ1,1 θ1,2
θI θI θF
θF
θ1,2 θ2,1
θ2,2
θ2,1 θ2,2
θ1,1
(a) Directed graph representing the JSP (b) A possible solution for the instance
instance from table 1. presented from table 1.
Figure 1
Table 2: The four possible topological orderings from the solution represent by
figure 1b and their corresponding representation in the GA.
The DAG can be reconstructed from a topological ordering, given the defini-
tion of the instance. This is done in O(n2 · t), which is the upper bound number
of edges in the DAG.
3
3 Experiments
Different experiments were done using several instances of the JSP. Two types of
instances were used: small and large instances. All small instances have 3 jobs
that are characterized by the number of machines m (3, 5 or 7), the number
of tasks per job t (5, 7 or 10) and the maximum value of the duration time
Dmax (10, 50 or 100). A set of 10 instances are used for each combination of
the three variables. All of the large instances are characterized have 3 jobs and
3 machines and are characterized by the variables t (20, 25, 30) and Dmax (50,
100, 200). Also 10 instances are used for each combination of parameters.
Figure 2a shows the evolution of Tref − TGA for different values of the muta-
tion probability Pm . It is shown that there are no significant differences among
many of the Pm values. The better performance was achieved for Pm = 0.1.
The population size for this experiments was set to 50, the number of iterations
was also set to 50 and the crossover probability was set to 0.5. Intervals are
shown for a 95% confidence.
Figure 2b shows the evolution of Tref − TGA for different values of the
crossover probability Pm . The mutation probability was set to 0.1 and the
rest of parameters were set as before. Here it is shown that the impact of the
crossover probability is very significant, achieving the best performance when
Pc = 1.
Figures 2c and 2d show the evolution of the average Tref −TGA and P (TGA >
Tref ) for different values of the population size and number of iterations. This
two functions are plot together because at some value of the x coordinate,
the expected number of generated individuals is the same in both scenarios.
The expected number of generated individuals generated individuals grows with
O(Pc · N · I), where N is the population size and I is the number of iterations.
In the experiment where the number of iterations was explored, the population
size was set constant to 50, while when the explored variable was the population
size, the number of iterations was 50. In both cases, the crossover probability
was set to 0.5 and the mutation probability was set to 0.1. So, the cases where
P opulation = 500 and Iterations = 500, the expected number of generated
individuals is 0.5 · 500 · 50 = 12500. These plots show that given a fixed number
of expected individuals, it is usually slightly better to have a bigger population
instead of more iterations. It is also shown that as we increase the value of
these parameters, the quality of the obtained solution improves (and also the
4
computation time required to obtain it).
-1.9 0
-2 -1
-2.1
-2
-2.2
-3
Tref - Tga
Tref - Tga
-2.3
-4
-2.4
-5
-2.5
-6
-2.6
-7
-2.7
-2.8 -8
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Pm Pc
(a) Evolution of Tref −TGA for different (b) Evolution of Tref − TGA for differ-
Pm values. ent Pc values.
0 0.3
Population
Iterations
-1 0.25
-2 0.2
Tref - Tga
Tref - Tga
-3 0.15
-4 0.1
-5 0.05
Population
Iterations
-6 0
0 200 400 600 800 1000 0 200 400 600 800 1000
(c) Evolution of Tref −TGA for different (d) Evolution of P (TGA > Tref ) for dif-
polpulation sizes (red) and number of ferent polpulation sizes (red) and num-
iterations (green). ber of iterations (green).
A final evaluation of the small and large instances was done using the val-
ues for each parameter shown in table 3. Pm was set to 0.05 instead of 0.1,
because that 0.1 was obtained when Pc was set to 0.5, and as we explained, the
mutations are applied only on the children of the crossover operations, so, to
maintain the ratio of mutated individuals, the mutation probability Pm must
be set to 0.05.
Parameter Value
Population 1000 (Small), 6000 (Large)
Iterations 50
Pc 1.0
Pm 0.05
Table 3: Parameters used for the final evaluation of the small and large in-
stances.
Table 4 reports the results achieved using the previous configuration on the
small and large instances.
5
Instances Tref − TGA P (TGA > Tref )
Small −0.0004 ± 0.0004 0.0004
Large −68.8767 ± 2.4166 0.9244
4 Conclusions
We presented a simple and competitive genetic algorithm for the job-shop
scheduling problem. The presented algorithm have shown to be slightly worse
than the reference solutions that were provided for the small instances and usu-
ally worse for the large instances, but this comparison is not fair since we don’t
know which parameters the reference solution used to control the amount of
time invested in finding a solution (that is, population and iterations). Also,
despite of our solution is usually worse, the difference with the reference solution
is not very high, given that the average timespan of the reference solution for
the large instances is 1959.97.
References
[1] C. Bierwirth. A generalized permutation approach to job shop schedul-
ing with genetic algorithms. Operations-Research-Spektrum, 17(2-3):87–92,
1995.
[2] J. Blażewicz, E. Pesch, and M. Sterna. The disjunctive graph machine
representation of the job shop scheduling problem. European Journal of
Operational Research, 127(2):317–331, 2000.
[3] J. Carlier and E. Pinson. An algorithm for solving the job-shop problem.
Management science, 35(2):164–176, 1989.
[4] L. Davis. Job shop scheduling with genetic algorithms. In Proceedings of
the 1st international conference on genetic algorithms, pages 136–140. L.
Erlbaum Associates Inc., 1985.
[5] J. K. Lenstra and A. R. Kan. Computational complexity of discrete opti-
mization problems. Annals of Discrete Mathematics, 4:121–140, 1979.
[6] J. K. Lenstra, A. R. Kan, and P. Brucker. Complexity of machine scheduling
problems. 1977.
[7] P. J. Van Laarhoven, E. H. Aarts, and J. K. Lenstra. Job shop scheduling
by simulated annealing. Operations research, 40(1):113–125, 1992.