by Jake O Grady & Chukwuma George Anayo-Ezikeoha
This project implements Genetic Algorithm (GA) to solve a simplified exam timetabling problem. The objective is to assign exams to timeslots while minimizing student conflicts and improving schedule quality.
The algorithm evolves a population of candidate timetables over multiple generations using selection, crossover, mutation, and elitism.
The project is structured around a single main GA pipeline, supported by helper utility functions.
- Reads the problem instance file.
- Extracts:
- No. of exams
- No. of timeslots
- Size of population
- Generates the initial population.
- Creates a random timetable.
- Each exams is assigned a random timeslot.
Each individual is represented as: [timeslot_exam0, timeslot_exam1, ..., timeslot_examN]
- Checks:
- Hard constraint violations (same timeslot exams for a student)
- Soft constraint violations (consecutive exams)
- Computes fitness with hard and soft constraint violation penalty weights.
- Propagates best individuals to next generation.
- Combines tournament selection with elitism to create next generation
- Uniform crossover implementation
- Mutates chromosomes in such a way as to improve diversity while reducing number of conflicts.
- Mutation rate decreases over generations.
- Allows for proper exploration of search space and refinement of later generations.
- Reinitializes the bottom portion of the population.
- Triggered when fitness stagnates.
The main pipeline:
- Read instance data
- Initialize population
- Evaluate fitness
- Repeat for
NUM_GENERATIONS:- Selection
- Crossover
- Mutation
- Fitness evaluation
- Track best and average fitness
- Detect stagnation
- Output best solution
- Plot fitness progression
The following helper functions are imported:
plot_fitness_generationprint_best_solutionprint_alternative_solutionsprint_student_timetables
These handle visualization and formatted output.
HARD_PENALTYSOFT_PENALTYCROSSOVER_RATEELITE_COUNTNUM_GENERATIONSTOURNAMENT_SIZE
These are adjusted to study algorithmic variation in performance.
Look run_ga_params.sh to test performance of crossover rate and tournament size.