Genetic algorithm - timetable: Difference between revisions
Mr. MacKenty (talk | contribs) |
Mr. MacKenty (talk | contribs) |
||
(One intermediate revision by the same user not shown) | |||
Line 9: | Line 9: | ||
== Learning objective == | == Learning objective == | ||
The learning objective for this problem set is to apply your understanding of genetic algorithms. | The learning objective for this problem set is to apply your understanding of genetic algorithms to satisfy course requests. | ||
== The Problem == | == The Problem == | ||
Line 28: | Line 28: | ||
import random | import random | ||
COURSE_SIZE = | COURSE_SIZE = 40 | ||
CLASS_SIZE = 50 | CLASS_SIZE = 50 | ||
CAPACITY_MIN = | CAPACITY_MIN = 30 | ||
CAPACITY_MAX = | CAPACITY_MAX = 60 | ||
REQUEST_COURSE_SIZE = 6 | REQUEST_COURSE_SIZE = 6 | ||
Latest revision as of 14:58, 13 December 2021
This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are:
- to build your skill applying computational thinking to a problem
- to assess your knowledge and skills of different programming practices
Learning objective[edit]
The learning objective for this problem set is to apply your understanding of genetic algorithms to satisfy course requests.
The Problem[edit]
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.
- Please construct a genetic algorithm which ideally meets the maximum number of requests.
- Your algorithm should meet the maximum number of requests.
- Your algorithm should have a fitness function
- 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[edit]
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)]
def generate_request_dict(grade):
request_dict = {}
for i in grade:
request_dict[i] = random.sample(courses, REQUEST_COURSE_SIZE)
return request_dict
requests_dict_9, requests_dict_10, requests_dict_11, requests_dict_12 = generate_request_dict(grade_9_students), generate_request_dict(grade_10_students), generate_request_dict(grade_11_students), generate_request_dict(grade_12_students)
# 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[edit]
Your solution will be graded using the following axis:
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
- To what extent is your code readable?
- To what extent is your code commented?
- To what extent are your variables well named?
- To what extent do you adhere to style guide?
References[edit]
A possible solution[edit]
Click the expand link to see one possible solution, but NOT before you have tried and failed!
not yet!