0% found this document useful (0 votes)
102 views6 pages

A Genetic Algorithm For The Job-Shop Scheduling Problem: Joan Puigcerver I Pérez

This document describes a genetic algorithm for solving the job shop scheduling problem (JSP). The JSP involves scheduling a set of jobs, each consisting of tasks that must be completed sequentially, on a set of machines subject to resource constraints. The genetic algorithm uses a chromosome representation of solutions, a fitness function based on schedule makespan (completion time), and crossover and mutation operators. Experiments on small and large JSP instances evaluate the algorithm's performance for different parameter values.

Uploaded by

Arpit Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views6 pages

A Genetic Algorithm For The Job-Shop Scheduling Problem: Joan Puigcerver I Pérez

This document describes a genetic algorithm for solving the job shop scheduling problem (JSP). The JSP involves scheduling a set of jobs, each consisting of tasks that must be completed sequentially, on a set of machines subject to resource constraints. The genetic algorithm uses a chromosome representation of solutions, a fitness function based on schedule makespan (completion time), and crossover and mutation operators. Experiments on small and large JSP instances evaluate the algorithm's performance for different parameter values.

Uploaded by

Arpit Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

A Genetic Algorithm for the Job-Shop

Scheduling Problem
Joan Puigcerver i Pérez
[email protected]

June 22, 2013

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.

Sj,k ≥ Sj,k−1 + Dj,k−1 : 1 ≤ j ≤ n, 2 ≤ k ≤ t (1)


0 0
rj,k 6= rj,k0 ∨ Sj,k ∈
/ [Sj,k0 , Sj,k0 + Dj,k0 ] : 1 ≤ j ≤ n, 1 ≤ k, k ≤ t, k 6= k (2)

These two restrictions, as stated in the previous equations, imply an addi-


tional restriction: once a task starts, it cannot be preempted by any other task.

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.

2.1 Solution encoding


A solution for a JSP instance can be represented as a direct acyclic graph (DAG)
where each node represents a task and edges represent dependencies among tasks
(the within-job task ordering and the resources dependencies). Then, the times-
pan is given by the longest path from the start node to the end node. The start
node is defined as a dummy task called θI which takes 0 time steps and has an
outgoing edge to the first task of each job θj,1 , 1 ≤ j ≤ n. The target node θF
has incoming edges from the final task of each job θj,t , 1 ≤ j ≤ n and takes also
0 time steps to complete.

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.

θ1,1 θ1,2 θ2,1 θ2,2


ri,j 1 2 2 1
Di,j 3 2 5 1

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

Topological ordering Individual


θI θ1,1 θ2,1 θ1,2 θ2,2 θF 1 2 1 2
θI θ2,1 θ1,1 θ2,2 θ1,2 θF 2 1 2 1
θI θ1,1 θ2,1 θ2,2 θ1,2 θF 1 2 2 1
θI θ2,1 θ1,1 θ1,2 θ2,2 θF 2 1 1 2

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.

2.2 Fitness function


Since our objective is to minimize the timespan of the job-shop scheduling, we
use this function as the fitness function to minimize by the genetic algorithm.
Once the DAG representing the solution is obtained, the computation of the
fitness function can be done by computing the longest path from θI to θF in
the DAG. This is done in O(|E|) using a dynamic programming scheme, where
E is the set of edges in the solution DAG. In our implementation, the number
of edges in the solution DAG is O(n2 · t).

2.3 Crossover and mutation operations


The used crossover algorithm is a generalization of the order crossover operator
(OX) and was presented in [1]. A random pair of individuals of the population
at some iteration are merged with probability Pc to form a new individual. The
crossover operation uses a random segment of the first parent as an implant that
will be inserted in a random position in the chromosome of the second parent.
Once the new elements have been implanted into the vector, the old-duplicated
elements are removed. In order to create two individuals from the two parents,
first one of the parents is used to extract the implant and then, the other parent
is used.

When a new individual is created from a crossover, two random elements of


the chromosome are swapped with probability Pm . The parents are not mutated
to avoid the loss of the best solution found so far.

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.

In order to explore the effect of the parameters of the GA (population size,


number of iterations, crossover probability and mutation probability), the small
instances were used to measure the percentage of solutions proposed by the GA
with a timespan greater than the reference solution (the lower this percentage
is, the better). Additionally, the difference between the reference timespan for
each instance (obtained with a commercial product) and the timespan of the
solution found by the proposed genetic algorithm: Tref − TGA . The bigger the
difference is, the better the proposed genetic algorithm is in comparison to the
reference. If the reference is the exact solution to the JSP instance, the differ-
ence can be, at most 0.

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).

Figure 2: Performance of the GA for different parameters values.

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

Table 4: Final results for the small and large instances.

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.

The algorithm can be improved in several ways. As we explained before,


the way we encode the solutions as individuals of the population (a topological
ordering of the DAG) makes that multiple individuals of the population could
represent the same solution (different topological orderings are possible for a
given DAG). Also, we did not look too much at the speed factor. We used
Python to program our solution, which is not the best option if one is focused
on the speed.

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.

You might also like