0% found this document useful (0 votes)
11 views7 pages

Project Report

The document describes an exam schedule generator that uses a genetic algorithm. It outlines the assumptions, hyperparameters, user-defined classes, and steps used in the algorithm. The algorithm generates a random initial population of schedules, calculates their fitness, performs selection, crossover and mutation to produce new generations, and returns the best schedule once the constraints are satisfied or the maximum generations is reached. It implemented hard constraints like no student having multiple exams concurrently and soft constraints like exams being scheduled in fewer days.

Uploaded by

srinath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

Project Report

The document describes an exam schedule generator that uses a genetic algorithm. It outlines the assumptions, hyperparameters, user-defined classes, and steps used in the algorithm. The algorithm generates a random initial population of schedules, calculates their fitness, performs selection, crossover and mutation to produce new generations, and returns the best schedule once the constraints are satisfied or the maximum generations is reached. It implemented hard constraints like no student having multiple exams concurrently and soft constraints like exams being scheduled in fewer days.

Uploaded by

srinath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Exam Schedule Generator Using Genetic Algorithm

CS-461 Artificial Intelligence

BS(CS) – D

Batch 2018

Submitted By:

Hassan Shahzad 18i-0441

Sana Ali Khan 18i-0439

Submitted to:

Sir Saad Salman

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

• Population size: randomly chosen within a range of 50 – 200


• Maximum number of generations: randomly chosen within a range of 100-1000
• Crossover probability: kept as 1 to ensure crossover
• Mutation probability: 0.6 (for a high chance of mutation)

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.

• The final solution is displayed at the end in main.

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:

1. Exam is scheduled for each course = 


2. Student cannot give more than one exam at a time = 
3. Teacher invigilates one exam at a time = 
4. Teacher invigilates one exam in a row = 
5. Student is enrolled in at least 3 courses = 
6. Exam won’t be held on weekends = 
7. Exam must be invigilated by a teacher = 
8. Use at max 10 classrooms = 
Soft Constraints:

1. Break on Friday from 1-2pm = 


2. Student should not give more than 1 exam consecutively = 
3. MG Course scheduled before CS Course = 
4. Exam is scheduled in less days = 
5. Almost equal number of invigilation duties = 

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

• Data was being overwritten a lot


• We were initially scheduling in 5 days only due to which the algorithm kept running infinitely without ever
giving the perfect solution.
• Constraints weren’t specified clearly
• Requirements kept changing with each day forcing us to update the code
• Another issue we faced was that crossover was returning same schedules.
• Most of solutions were empty initially, as empty timetable satisfied most of the constraints.

SAMPLE DATASET:

temp_teachers.csv temp_courses.csv temp_studentcourses.csv

Bilal Khalid CS111 OOP Abeera CS111


Abeera CS115
Shehreyar Rashid CS112 DS Abeera CS116
Umair Arshad CS113 DB Adil CS111
Adil CS119
Subhan Ullah CS114 Algo Adil CS113
Ejaz Ahmed CS115 CNET Ali CS118
Ali CS119
Kifayat Ullah MG211 DLD Ali CS117
Waseem Shahzad CS116 PF Aysha CS112
Adnan Tariq CS117 OS Aysha CS114
Aysha CS117
Asif Naeem CS118 DF Azka CS115
Hasan Mujtaba CS119 SE Azka CS118
Azka MG211
Sidra Khalid Hassan CS112
Faisal Cheema Hassan CS114
Hassan CS117
Shoaib Mehboob Hurriya CS113
Tayyaba Zainab Hurriya CS114
Arshad Islam Hurriya MG211
Sana CS112
Noor ul Ain Sana CS113
Zeeshan Qaiser Sana MG211
Sundus CS111
Muhammad Asim Sundus CS112
Behjat Zuhaira Sundus CS117
Wajeeha CS119
Kashif Munir Wajeeha CS114
Hammad Majeed Wajeeha MG211
Noreen Jamil Zaynab CS111
Zaynab CS114
Hassan Mustafa Zaynab CS119
Farwa Batool Zeeshan CS111
Zeeshan CS112
Zeeshan CS115
SCREENSHOTS OF OUTPUT
PROVIDED DATASET:

teachers.csv courses.csv studentCourse.csv

Ayesha Bano CS217 Object Oriented Programming Sam D Edwards AI2011


Aqeel Shahzad Sheila Hughton DS3011
EE227 Digital Logic Design
Farah Naz Yasmin Ahmed SE110
Hamda Khan CS211 Discrete Structures Sarah N Md Sallehuddin Khan
Usman Rashid SE110 Intro to Software Engineering EE229
Farah Jabeen Awan CS118 Programming Fundamentals Sarah Nolasco AI2011
Sara Aziz CS219 Database Systems Jenna Riley EE229
Gul e Aisha Usman Rafiq CS307
Maimoona Rassol CS220 Operating Systems Reem N Hassan MG220
Sajid Khan CS302 Design & Analysis of Algorithms Sarah Hinett CS328
Tayyab Nadeem CY2012 Digital Forensics Kamal Anwar EE229
Mehboobullah CS307 Computer Networks Mika Tatsumoto CS219
Muhammad bin Muhammad Ijaz-Ul-Haq AI2011
CS328 Software Engineering
Qasim Abdul Gafur SS118
Zainab Moin EE229 Computer Organization and Assembly Language Ana Vukojevic CS307
Sumera Abbas AI2011 Programming for AI Arooba Zahoor CS302
Sadia Nauman DS3011 Big Data Analytics Ahmad F Yang Abd Talib MG223
Shahzad Mehmood Natasha Leeson CS328
CS328 Software Engineering
Sanaa Ilyas Ramesh R Singh MG220
Nagina Safdar CS218 Data Structures Sara Zamberlan CS211
Asma Nisa EE229 Computer Organization & Assembly Language Adam N Starling CS217
Sehrish Hassan CS211 Discrete Structures Maria M Ponce Carpio EE229
Waqas Munir MT224 Differential Equations Iram Matloob MT224
Usman Ashraf Sarah J Roberts SS152
SS113 Pakistan Studies
Muhammad Usman Maria Lytras CS307
Naveed Ahmad MG220 Marketing Management Mohammad Abir CS218
Zainab Abaid MG223 Fundamentals of Management Nabila Altaf CS211
Rohail Gulbaz SS111 Islamic and Religious Studies Yasmin Ahmed CS307
Hassan Raza Maria A Grenfell MT205
SS152 Communication & Presentation Skills
etc. Mohamed A Baalousha MG220
SS118 Psychology Ayan Lowe SE110
MT205 Probability and Statistics Mohammed I Al Arfaj SS152
etc.
SCREENSHOTS OF OUTPUT

You might also like