# Genetic algorithm - timetable

This a problem set for you to work through [1]

This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are:

1. to build your skill applying computational thinking to a problem
2. to assess your knowledge and skills of different programming practices

## Learning objective

The learning objective for this problem set is to apply your understanding of genetic algorithms to satisfy course requests.

## The Problem

Please find below a python file which creates 4 dictionaries of requests, one for grade 9, 10, 11 and 12. Please execute this program and review the dictionaries and lists.

1. Please construct a genetic algorithm which ideally meets the maximum number of requests.
2. Your algorithm should meet the maximum number of requests.
3. Your algorithm should have a fitness function
4. Your algorithm should have selection strategy

Please understand we are only dealing with requests. Creating the timetable (when each class meets) is a different problem set.

## timetable generator

I am very grateful to a 12th grade student who wrote this timetable generator for me in 2021. :-)

import random

COURSE_SIZE = 40
CLASS_SIZE = 50
CAPACITY_MIN = 30
CAPACITY_MAX = 60
REQUEST_COURSE_SIZE = 6

courses = [i for i in range(COURSE_SIZE)]

grade_9_students = [i for i in range(CLASS_SIZE)]
grade_10_students = [i for i in range(CLASS_SIZE, CLASS_SIZE*2)]
grade_11_students = [i for i in range(CLASS_SIZE*2, CLASS_SIZE*3)]
grade_12_students = [i for i in range(CLASS_SIZE*3, CLASS_SIZE*4)]

# Capacity is the course id and then capacity of course:
capacity = [[i, random.randint(CAPACITY_MIN, CAPACITY_MAX)] for i in range(COURSE_SIZE)]

request_dict = {}
request_dict[i] = random.sample(courses, REQUEST_COURSE_SIZE)
return request_dict

# to see the dictionaries for each part of our schedule, uncomment the lines below
# and execute this program
# print(requests_dict_9)
# print(requests_dict_10)
# print(requests_dict_11)
# print(requests_dict_12)

## How you will be assessed

Scope

• To what extent does your code implement the features required by our specification?
• To what extent is there evidence of effort?

Correctness

• To what extent did your code meet specifications?
• To what extent did your code meet unit tests?
• To what extent is your code free of bugs?

Design

• To what extent is your code written well (i.e. clearly, efficiently, elegantly, and/or logically)?
• To what extent is your code eliminating repetition?
• To what extent is your code using functions appropriately?

Style