Genetic Algorithm For Scheduling Courses
Genetic Algorithm For Scheduling Courses
Genetic Algorithm For Scheduling Courses
Abstract. In the university, college students must be register for their classes,
and there still many college student that was confused on how to make a good
classes schedule for themselves. Mainly because of many variables and consid-
erations to be made, for examples, they have to consider how hard the classes
they are going to take, and also, they still have to consider their exam schedules
and also their availability time as well. Genetic Algorithm is one of many meth-
ods that can be used to create a schedule. This method determines the best sched-
ule using fitness cost calculation which can compare the quality of one schedule
against the other. Then, using crossover, mutation, and elitism selections, we can
determine better schedules. Based on the result of the survey held before, 70% of
the respondents gave point 4 and 30% of the respondents gave point 5 out of 5
for the quality of the schedule made using this applications.
1 Introduction
Schedule is very important to manage an activity, especially when the activity was car-
ried out in a large organization and held for long-term time or routine.
Within the scope of the university, the course schedule also is critical There are still
students who are confused when creating their own class schedules, because a lot of
consideration, for example: what subjects can be taken without clashing with another
schedule, a student who wants to the day - certain the day No lectures, due to personal
reasons or other student affairs, student who wants to take courses that would like to
correspond with their fields of specialization, and so forth. These things make them
have trouble making a personal course schedule. Through these problems, we conduct
research on a system that can help perform automatic scheduling lectures for students
by the day and the course desired by the student. The method used for the manufacture
of automatic schedule is Genetic Algorithm (GA). The reason is because GA is a
method that can find a solution that is both complex problems.
adfa, p. 1, 2011.
© Springer-Verlag Berlin Heidelberg 2011
2 Genetic Algorithm
Genetic Algorithm is a method to search an optimal solution for a problem. The method
will find a good solution by crossovers a possible solution with another solution to
create new solutions. After that method will mutate the new solutions so that they are
have parts of solution from the parents but not really same with the parent. The process
begin with the creation of random population of valid solutions / chromosomes, then
GA will count the fitness costs of each chromosomes in the population. After that two
chromosomes will be chose to crossover and produce offspring. Then the offspring will
be mutated. This process will be repeated till the stop condition was reached [1].
Given a clearly defined problem to be solved and a binary string representation for
candidate solutions, a basic GA can be represented as following major steps [2]:
1. Represent the problem variable domain as a chromosome of a fixed length, choose
the size of a chromosome population N, the crossover probability pc and the mutation
probability pm.
2. Step 2: Define a fitness function to measure the performance, or fitness, of an indi-
vidual chromosome in the problem domain. The fitness function establishes the basis
for selecting chromosomes that will be mated during reproduction.
3. Randomly generate an initial population of chromosomes of size N:
5. Select a pair of chromosomes for mating from the current population. Parent chro-
mosomes are selected with a probability related to their fitness. Highly fit chromo-
somes have a higher probability of being selected for mating than less fit chromo-
somes.
6. Create a pair of offspring chromosomes by applying the genetic operators – crosso-
ver and mutation.
7. Place the created offspring chromosomes in the new population.
8. Repeat Step 5 until the size of the new chromosome population becomes equal to
the size of the initial population, N.
9. Replace the initial (parent) chromosome population with the new (offspring) popu-
lation.
10. Go to Step 4, and repeat the process until the termination criterion is satisfied.
Fig. 1. Example of the slices in roulette wheel selection (Source: Negnevitsky, 2005)
2.2 Reproduction
There are several methods used in the GA Reproduction one of them is crossover.
Crossover is the crosses of at least 2 solutions, where through parts crossed, will gen-
erate new solutions. Through this crosses GA will add solutions and variations that are
useful later in the scoring stage when searching for a better solution [5]. The example
of the crossover could be seen in Figure 2.
Fig. 2. Crossover in binary chromosome (Source: Haupt, R.L., Haupt, S.E., 2004)
Besides the crossover, there is another way to complete reproduction, namely mutation.
Mutation is a method that converts a portion of the solution. Although altered a little
bit, it can create different variations resulting in different solutions and even new solu-
tion. One method used in this mutation is shuffle. [5]. Mutation role is to provide a
guarantee that the search algorithm is not trapped on a local optimum [6]. The example
of the mutation could be seen in Figure 3.
Fig. 3. Mutation in a binary chromosome (Source: Haupt, R.L., Haupt, S.E., 2004)
Students will enroll subjects which wants to be taken at the beginning of the semester,
during the study plan registration (SPR/PRS). PRS periods are divided into three times,
namely the PRS-1, PRS-2 and PRS-3. During the PRS-1, after receiving Study Results
Card (SRC/KHS), and get permission to register from faculty trustee, students can en-
roll subjects that have been opened by the department. For example, the list of courses
that are opened by PCU Informatics department could be seen in Figure 4.
Fig. 4. The list of courses that are opened for one semester
Then in Figure 5 you could see the example of courses that have been taken by students
that called the transcript.
Based on the example of courses offered (Figure 4) and student transcript (Figure 5),
the list of courses that can be taken by the student in the next semester could be seen in
Table 2.
Table 2. The example of courses which could be taken by student base on Figure 4 and 5
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Day 0 [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
Day 1 [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
Day 2 [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
Day 3 [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
Day 4 [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
Day 5 [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
Fig. 6. Chromosome Design
The chromosome has day index starting from zero to the fifth indexes. Where in each
day they have hour index starting from zero to the fourteen indexes.
Day index only have six days, because on the day of Sunday is certainly no lectures.
As for the hour index in each day, containing fourteen ranging from 07.30 to 22.30 with
a time range of 1 hour. For example of chromosomes that have been filled could be
seen in Figure 7.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Day 0 [2 ] [2 ] [2 ] [0] [0] [6 ] [6 ] [0] [0] [0] [0] [0] [0] [0] [0]
Day 1 [0] [0] [49] [49] [0] [0] [0] [0] [10] [10] [0] [0] [0] [0] [0]
Day 2 [0] [0] [0] [0] [0] [0] [0] [0] [0] [0] [0] [0] [0] [0] [0]
Day 3 [0] [0] [0] [0] [0] [0] [19] [19] [19] [0] [0] [0] [0] [0] [0]
Day 4 [0] [33] [33] [33] [0] [0] [0] [0] [0] [0] [0] [0] [0] [0] [0]
Day 5 [0] [0] [0] [0] [44] [44] [44] [0] [0] [0] [0] [0] [0] [0] [0]
The values present in a chromosome are the id of courses that opened in a semester.
Complete data from the ids are stored in a database table with the design as shown in
Table 3.
ID class 49
Course name Struktur Data
Class A
SKSk 2
SKSp 1
SKSs 0
SKSr 0
SKS prerequisites 0
Course prerequisites Pass PBO, Pass AP
Course Start 08.30
Course Finish 10.30
Exam Schedule Day 3, 10.30
Specialization Course No
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Day 0 [0] [0] [0] [7] [7] [7 ] [22] [22] [22] [0] [0] [0] [0] [0] [0]
Chromosome B
Whilst the mutation is done by randomly selecting two courses that have the same
length of time in the one of crossover result chromosome, the offspring, and then swap
their positions.
𝐹𝐶𝑆𝑀 = ∑𝑚
𝑖=1 𝑐𝑜𝑢𝑟𝑠𝑒𝑆𝑒𝑚𝑒𝑠𝑡𝑒𝑟[𝑖] (4)
Where:
If the course is mandatory for next semester:
courseSemester = (courseSemester [i] - semesters) * (-5)
If the course is mandatory for the last semester:
courseSemester = (semesters - courseSemester [i]) * (200)
If the course is mandatory for the current:
courseSemester = 100
m = number of existing courses
Where:
If the elective courses taken curriculum matches the user specialization:
courseCurriculum = 175
If the elective courses taken curriculum does not match the user specialization:
courseCurriculum = -75
m = number of courses in the chromosome
Where:
dayInterval = 300 - (interval between courses * 90)
n = number of day
Where:
n = number of existing courses on chromosome
If the user wishes 'Want to Take':
ValueDesireCourse = 100
If the user wishes 'Extremely Want to Take':
ValueDesireCourse = 1000
If the user wishes 'Less Want to Take':
ValueDesireCourse = -200
Where:
n = number of day
k = 3, on the morning: k = 1, on the afternoon: k = 2, on the night: k = 3
If in accordance with the expected time:
timeValue = number of hours filled * 200
If not in accordance with the expected time:
timeValue = number of hours filled * -200
Fitness Cost based on the maximum number of courses per day that is desired by the
user (FCMMK)
─ If user desirability ≥ number of courses,
𝑛𝑢𝑚𝑏𝑒𝑟𝑂𝑓𝐶𝑜𝑢𝑟𝑠𝑒𝑠 [𝑖]
𝐹𝐶𝑀𝑀𝐾 = ∑𝑛𝑖=1 ∗ 300 (10)
𝑢𝑠𝑒𝑟𝐷𝑒𝑠𝑖𝑟𝑎𝑏𝑖𝑙𝑖𝑡𝑦[𝑖]
Where:
n = number of day
Where:
w1 to w7 = weight of each fitness cost, value: 0...1.
Insert Transcript,
Day and Time
Is The PRS-1 No Preference, and
Schedule Exist?
desirability of the
courses.
Yes
View or Print 5
End top Schedules to
user
System starts with a login form to identify the user of the application. Furthermore, the
user can enter semester to be processed and areas of specialization are taken, as shown
in Figure 10.
Fig. 10. Form Login and form setting semester and specialization
Later the user can choose to process the PRS-1 or PRS-2. Next will be displayed to the
user some forms in sequence, as shown in Figure 11 to 12. Here the user can enter the
latest transcript, day and time he desire and the desirability settings for all courses that
could be taken for the next semester.
Fig. 13. Form to determine the desirability of all the courses that can be taken
Hereinafter the user can press a button to generate schedules using Genetic Algorithm.
Once the process is complete then to the user would be presented 5 best schedules.
These 5 best schedules are taken from 5 chromosomes with the highest fitness costs on
the last population. The scheduling results form and also the look to be printed (HTML
files) could be seen in Figure 14 and Figure 15. In addition, before starting the process
of scheduling, user can change the settings of variables required by the GA. Form to
change the settings can be seen in Figure 16.
Fig. 14. Form to view 5 best the results of automatic courses scheduling
To test the results of the system, especially the results of the courses schedule that is
generated automatically, we use several kinds of tests. The first test is testing the effect
of the maximum population against the processing time, and the best fitness cost value.
For this test, setting the mutation probability is 0.3. The test results could be seen in
Table 4.
From the test results it can be seen that the greater the maximum limit of the popu-
lation, the longer the process takes time, yet the average value of the best fitness costs
also increased. This is because more and more of the population there, will be the more
diverse opportunities to generate chromosomes, so that eventually the fitness cost val-
ues of the chromosomes will increase.
The second test is the test of the effects of increased mutation probability values
allowed on offspring chromosomes. For this test, the maximum population size be set
at 150 chromosome. The test results can be seen in Table 5.
Table 5. Tests on the mutation probability values
From the test results it can be seen that the greater the probability of mutation, the
longer the time required for the process, but the average fitness value of a chromosome
best cost also increased. This is because the higher the chance of mutation, the more
diverse the resulting chromosome will be are greater, so that eventually the fitness cost
value of the best chromosome will increase.
In addition we also did some other tests, such as testing the maximum number of
chromosomes are copied by elitism method from the old population to the new popu-
lation. We also tested the maximum number of 'elitism counter', this counter to count
how many the sequences of populations will produce the same best fitness cost values,
before the program stop the process. Of all the tests performed at last we obtained the
best values of each setting. These values are used as the default values setting of the
system. The amount of the default settings and the testing results using default settings
can be seen in Table 6 and Table 7.
Of testing by using the default settings could be seen that the GA produces the best
fitness cost value greater compared to other settings that have been tested. Moreover, it
can be seen that in general the system will be convergence on a particular chromosome.
The final testing is testing in the form of questionnaires to potential users, in example
students majoring in Informatics department of Petra Christian University. The results
summary of these questionnaires are as follows: As many as 60% of respondents gave
scores of 4 and 40% gave scores of 5, of the scale from 1 (worst) to 5 (best), for ease
of use of this application. From these results it can be concluded that the user interface
of the application is easy to use. Meanwhile, for the question about the quality of the
generated schedules, 70% of respondents gave scores of 4 and 30% gave scores of 5,
of scale from 1 (worst) to 5 (best). Therefore, it can be concluded that in general the
respondents felt be helped by the application that could generate courses schedule au-
tomatically.
6 Conclusion
From the tests it can be concluded that the automatic scheduling system is well made.
Processing speed is also good, averaging less than 1 minute. From the test results on
the potential users can be concluded that the interface has a good design and user
friendly. In addition, the automatically generated class schedules are also correct and
in accordance with the expectations of users.
References
1. Mitchell, M.: An Introduction to Genetic Algorithms. United States of America: Massachu-
setts Institute of Technology. (1996).
2. Negnevitsky, M.: Artificial Intelligence: A Guide to Intelligent Systems 2nd Ed. Pearson
Education Limited. (2005)
3. Goldberg, D.E.: Genetic Algorithms in Search, Optimization and Machine Learning. Addi-
son-Wesley, Reading, MA. (1989).
4. Davis, L.: Handbook on Genetic Algorithms. Van Nostrand Reinhold, New York. (1991).
5. Haupt, R.L., Haupt, S.E.: Practical Genetic Algorithms 2nd Ed. United States of America:
John Wiley & Sons, Inc. (2004).
6. Holland, J.H.: Adaptation in Natural and Artificial Systems. University of Michigan Press,
Ann Arbor. (1975).
7. Budhi, G.S., Handojo, A., Soloment, B.: The Use of compact-Genetic Algorithm (cGA) for
Petra Christian University Classroom Scheduling Optimization. In: Proc. National Seminar
on Information Technology. (2009).