Application of Genetic Algorithm and Simulated Annealing Algorithm For Course Scheduling Problem
Application of Genetic Algorithm and Simulated Annealing Algorithm For Course Scheduling Problem
International Conference on Modeling, Analysis, Simulation Technologies and Applications (MASTA 2019)
Deng-yu-hui LI*, Jia-ji SHEN, Hui-zhu DONG, Yi-ran SU and Zhi-gang ZHANG
University of Science and Technology Beijing, China
*Corresponding author
Abstract. In this paper, we propose a special course scheduling problem with class combination. By
dismantling the restrictions of given classes, students with similar foundations are reorganized into
new classes. It helps to improve the efficiency of the class and the acceptance of students. However, it
is difficult to arrange new classes and time artificially, considering class capacity and the conflict
with other courses. And as the number of class increases, the calculation time shows an exponential
growth, which is an NP-hard problem. In order to solve this problem, we use genetic algorithm and
simulated annealing algorithm to get the optimal solution.
Introduction
As one of the core contents of teaching management, class scheduling is an important indicator to
measure the level of teaching management.[1] The intelligent automatic course arrangement is a
NP-hard problem.[2] Nowadays, many universities face the problem of class recombination. That is,
due to the different original capabilities of students, it is necessary to reorganize classes just for a
certain course, to help the new class become more efficient and more active. In this paper, we use
genetic algorithm and simulated annealing algorithm to discuss the course scheduling problem with
class recombination, and analyze their results respectively. Our experiments come from real situation
in the University of Science and Technology Beijing, taking the subject of English as an example.
Problem Description
We need to arrange English classes for 120 given classes. There are seven feasible periods, which are
Tuesday's 1st, 2nd and 3rd lessons and Wednesday's 1st, 2nd, 3rd and 4th lessons. Before the English
class, the Mathematics class time has been arranged, which is available for the 1st, 2nd and 3rd
lessons on Monday, Wednesday, and Friday. According to the existing schedule, the time of the
English class and the Mathematics class cannot be conflicted, and the course arrangement of the
English class also has the following requirements:
1. The students are divided into five levels, each of which accounts for 10%, 10%, 20%, 40%, 20%.
So there are five levels in each class. But the proportion of five levels in these classes is different, and
it should be ensured that the sum of students of each level is equal to the pre-set proportion.
2. There are seven optional periods. Because the number of students in classes varies, we should
pay attention to combine large and small classes, so that the number of new classes in each period is
similar.
3. All students are divided into 7 periods. The number of students in each period should be equal to
1/7 of total students. At the same time, the number of students in each period is divided into 2-5
according to English level. and the ratio should be 1:2:4:2.
As we can see, this problem belongs to integer programming, the equality of the above
requirements can not be fully satisfied, so in the actual solution, we weaken it to the minimum error,
that is, the difference between the final results and the above requirements is the smallest.
7
class is selected, so there is i 1
X cmti 1 . Soft constraints includes three parts. Since they are all
related to the number of students in each English level, a matrix A1206 is needed, whose rows store the
information of different class. And the number of students with different English level respectively.
min y j 1 i 1 X cit j 17
7 120
(3)
(4)
j 1 i 1 A(i,5) X cit j 195 j 1 i 1 A(i,1) X ci t j 97
7 120 7 120
Precise Method
Based on Lingo
Firstly, we prepare a data file to store the number information of each class, that is matrix A . And
matrix Y stores the information of Mathematics class. It takes 37 seconds as shown in the second
picture, without soft constraints.
Traversal Method
Traverse method is to list all the situations, and then choose the ones that satisfy the conditions. In
this problem, there are 120 classes and 7 feasible periods, so we need to generate a matrix of 120 7 ,
in which each row only have one 1, and the rest are 0. After the initial matrix A is generated, it is
added to the matrix B which stores the information of Mathematics class. The size of matrix B is
120 7 . If a class has a Math class during a certain period, the corresponding element is -1, and 0,
409
Advances in Intelligent Systems Research, volume 168
otherwise. If the number of non-zero elements in the summation matrix is 240, it means there is no
conflict between English class and Math class. Then, the preliminary screening is performed so that
the number of classes in each period is roughly equal. The initial screening method is to sum the
matrix A by column, and then to find the variance between these numbers, and take the A with
minimum variance. Since the method takes too much time, following results just consider 7 classes.
Coding
In this problem, we take the real number coding method, and each gene represents a selected period of
one class. There are seven optional periods correspond to the real numbers 1-7 as follows:
Table 1. The coding of GA
Tuesday Wednesday
period
1st class 2nd class 3rd class 1st lesson 2nd class 3rd class 4th class
coding 1 2 3 4 5 6 7
Each class corresponds to a number, and the problem is transformed into finding out the optimal
sequence. The sequence consists of numbers from 1 to 7, and the number of people in each period is
as average as possible, in order to optimize the use of resources. After that, we define the global
population pop. pop(i,j) represents the time of English class selected by j-th class of the i-th
individual.
Table 2. The structure of chromosomes
2 3 4 3 4 5 6 … 7 5 4 1 2
Initialization
First, a reasonable set of solutions is obtained by observation, while the other sets of solutions are
randomly generated by the random number method, forming the first generation together.
Fitness Function
The fitness function is the key to evaluate the pros and cons of individuals. It is divided into two parts,
the difference between the number of people and the predicted one for each period, and the variance
of the number of students in each period according to each level.
Selection
We take the roulette method, that is, according to the ratio of the local fitness function to the global
fitness function, assign choose probability to each individual. Elite selection can be used, that is, the
two parents with the greatest fitness function are always retained to the next generation.
410
Advances in Intelligent Systems Research, volume 168
Crossover
First, randomly pair for individuals in the group. Secondly, randomly set the intersection position,
including two-point intersection and three-point intersection. Finally, the genes between the positions
of the paired chromosome intersections are exchanged, and the other positions remain unchanged.
Take the intersection of twelve classes as an example: (arrows indicate the locations of crossover)
Results Analysis
After Selection, Crossover, and Mutation, we get a new generation of populations, and continue the
above operations. Until the maximum genetic algebra is reached, it stops. Table 3 shows the optimal
descendant sequence, which is the English class time selected. Compared with the previous methods,
it runs faster. After many experiments, the optimal fitness is stable at around 0.0882.
411
Advances in Intelligent Systems Research, volume 168
Initialization
We take the initial temperature as 500, the termination temperature as 1, and the temperature change
rate as 0.95. Temperature is an important parameter, which decreases gradually with the iteration of
the algorithm to simulate the cooling process during solid annealing.
Objective Function
Simulated annealing algorithm optimizes the minimum of objective function.[4] In this model, the
objective function is the variance of the number of students in each period and the deviation of the
number of students in each period according to different levels. The two factors work together.
Metropolis Criterion
It refers to the probability that it accepts a new solution. For the minimizing problem, for the current
solution x and the new solution x', there are 3 states. If f (x')< f (x) the new solution will be accepted as
f ( x' ) f ( x)
the current solution. If exp - is greater than a random number in (0,1) interval, the
T
new solution will still be accepted as the current solution. Otherwise, the new solution will be rejected,
and the current solution will be retained. It can be seen that the temperature is high at the beginning,
which gives the algorithm a greater chance to jump out of the local optimal solution. As it proceeds,
the temperature gradually decreases and the probability of accepting the worse solution decreases.
Results Analysis
It is a randomly selected of one-time running result as shown in Table 4. When the temperature is
higher than the termination temperature, it stops. This is the outermost cycle, which has 123 times,
and the inner cycle has 1000 times. In general, the number of cycles is at least 123 x 1000 = 123 000,
except for some cycles which have certain requirements for random solutions and initial solutions.
Table 4. Results of simulated annealing algorithms
Result
Number of examinations in each period (17 17 21 13 12 21 19)
Number of persons in each period (472 501 596 365 346 605 527)
The variance 8.9414e+03
The sum of the deviations 575.7400
Summary
We propose a special problem of courses arrangement, with class recombination. Therefore, students
with similar foundations can form a new class. We consider about the required number of students in
different period and the conflict of other courses, it is very difficult to arrange them manually. We use
specific methods to solve small-scale cases first, to verify the model. And then, we give the solutions
based on genetic algorithm and simulated annealing algorithm.
Acknowledgement
This paper was funded by the Beijing Education Union.
References
[1] GONG Cheng, CHEN Gaoyun, LIU Yintian, LI Daiwei, Solution to Course Scheduling in
Colleges and Universities Based on Improved Genetic Algorithm, J. Software Engineering. 2018,
21(3):1-4.
412
Advances in Intelligent Systems Research, volume 168
[2] ZONG Wei, Research and Realization of University Timetable System Algorithm, J. Computer
Simulation, 2011, 28(12): 389-392.
[3] CHEN Lu, WANG Xiu, Solution to Course-Timetabling Problem of Mobile Learning System
Based on Improved Genetic Algorithm, J. Computer Engineering and Applications, 2019,
55(6):218-223.
[4] Zhu H. D. and Zhong Y., An improved simulated annealing algorithm, J. Computer Technology
and Development, 2009, 6(19): 32-35.
413