Project Report
Project Report
BS(CS) – D
Batch 2018
Submitted By:
Submitted to:
Date of Submission:
05-05-21
ASSUMPTIONS
• There are 2 time slots in a day: Morning and Noon (Hard Const 4: Exam must be held between 9am - 5pm)
• Each exam will be of 3 hours
• Morning Slot = 9am - 12pm
• Evening Slot = 2pm - 5pm
• It is possible that not all classrooms are used in a single day
• The higher the fitness score, the better the solution (Our goal is to maximize fitness value)
• Any day with exams scheduled will have exam at both morning and noon
HYPERPARAMETERS
USER-DEFINED CLASSES
• Class StudentData for keeping track of a particular student and their assigned courses
• Class Schedule, which represents the chromosome in this algorithm and is a possible solution
STEPS
• The first step is to generate a random population, or set of chromosomes/solutions. Each solution is represented by an
object of the Schedule class. Every Schedule object is assigned days to hold exams on; for every day, a random number
of classrooms is chosen then each classroom is assigned a morning exam, noon exam and their respective invigilators.
• A fitness value is calculated for each chromosome in the population. Fitness score is based upon the hard and soft
constraints required, with their clashes/conflicts used to calculate the final value. Every constraint has an equal
weightage in the score.
• Once fitness is calculated and stored, the population is passed through for parent selection. This is done using roulette
wheel selection to get the fittest chromosomes in the population.
• Crossover is done using these parents. To generate a crossover-ed population, two parents are selected for every
crossover. One is the fittest parent and the other is selected randomly, to ensure diversity. Two offspring are generated
for every set of parents until there is a whole population of offspring. The actual crossover itself is done by splitting
both parents at a randomly selected point and concatenating their separate parts to produce two offspring.
• The crossover-ed population are then passed for mutation. Within a predefined mutation probability, each
chromosome is mutated at random positions. This is done by generating new values for a selected position e.g.,
replacing an exam, or an invigilator or a whole day and so on.
• This population, which has now been crossover-ed and mutated, has its fitness recalculated. The fittest chromosome is
extracted as the local maximum and compared with the overall best solution generated so far.
• If the chromosome has satisfied the constraints, the algorithm finishes. Otherwise, the mutated population is now the
population passed to step 2, and the whole process will repeat all over.
• Algorithm runs until a solution is found or max number of generations exceeded – in which case, it returns the best
solution it had.
• If the best fitness values for the new population and the previous population are same for 50 generations, it is decided
that this population is stagnant and cannot be improved. In this case, a new population is generated and the previous
best solution stored. This process can go up to a fixed number of times (set as 3 for our purposes) and if it has not found
a solution by then, the fittest solution is selected from all the previous best solutions and returned.
• At each iteration, the current generation, fitness of overall best solution, and the fitness of the local best solution (for
that iteration) are displayed, along with how long the population has been stagnant.
• After every 25 iterations, the best solution so far is displayed, along with its fitness and the values of its constraints.
LOGIC
• We firstly created a collection of named tuples. The tuple contained following things:
1. Room Name
2. Morning Exam
3. Morning Invigilator
4. Noon Exam
5. Noon Invigilator
• Each tuple consists of 10 classes (i.e., C301 – C310). Each room will have the forementioned data.
• Next, every schedule object has 2 attributes:
1. Fitness (float)
2. Days (dictionary where every key is a day and the value is a named tuple of classrooms as mentioned
above.
• We are considering each schedule to be a chromosome
• The usage of user-defined classes, dictionaries and named tuples allowed us to organize and access the data very
easily
• The output displayed is the perfect schedule (in most cases) in actual date sheet format.
CONSTRAINTS IMPLEMENTED
Hard Constraints:
EXECUTION TIMELAPSE
Following is the link for execution time-lapse of both the sample dataset and the provided dataset:
1. Sample Dataset:
https://drive.google.com/file/d/1y9aIaTJcvJKdK9TL2edszigX942ni4q4/view?usp=sharing
2. Provided Dataset:
https://drive.google.com/file/d/1r2QzlT6q7gIqEZEl4W99uRphV_yGuSFH/view?usp=sharing
ISSUES FACED
SAMPLE DATASET: