Complete Class Scheduling System (Timetable generator) using Genetic Algorithms in C# and MS SQL
Project: Complete Class Scheduling System (Timetable generator) using Genetic Algorithms in C# and MS SQL with Source Code
About the Project
Make Class Schedule is one of those NP-hard problems. The problem can be solved using a heuristic search algorithm to find the optimal solution, but it only works for simple cases. For more complex inputs and requirements, finding a considerably right answer can take a while, or it may be impossible. This is where genetic algorithms come into the game.
In this article, I assume that you are familiar with the basic concepts of genetic algorithms, and I won’t describe them in detail because it has been done so many times before. When you make a class schedule, you must consider many requirements (number of professors, students, classes and classrooms, size of the classroom, laboratory equipment in the school, and many others). These requirements can be divided into several groups by their importance. Hard conditions (if you break one of these, then the schedule is infeasible):
- A class can be placed only in a spare classroom.
- No professor or student group can have more than one class at a time.
- A classroom must have enough seats to accommodate all students.
- To place a class in a classroom, the classroom must have laboratory equipment (computers, in our case) if the class requires it.
Some soft requirements (can be broken, but the schedule is still feasible):
- Preferred time of class by professors.
- Favorite classroom by professors.
- Distribution (in time or space) of classes for student groups or professors.
Hard and soft requirements, of course, depend on the situation.
The genetic algorithm is relatively simple. For each generation, it performs two basic operations:
- Randomly selects N pairs of parents from the current population and produces N new chromosomes by performing a crossover operation on a couple of parents.
- Randomly selects N chromosomes from the current community and replaces them with new ones. The algorithm doesn’t select chromosomes for a replacement if it is among the best chromosomes in society.
These two operations are repeated until the best chromosome reaches a fitness value equal to 1 (meaning that all classes in the schedule meet the requirement). As mentioned before, the genetic algorithm keeps track of the M’s best chromosomes in the population and guarantees that they will not be replaced while they are among the best chromosomes.