Download presentation
Presentation is loading. Please wait.
1
Jack Meyers & Daniel Morrison
Automated Scheduling Jack Meyers & Daniel Morrison
2
Scheduling Problem
3
Problem Description Math department currently schedules classes by hand, months of work Decided to create an algorithm to do this Assign classes an instructor and a time Restrictions are placed on how we can assign classes Algorithm adapts to changes in data to create new schedules
4
Hard Constraints An instructor can’t teach more than two classes in a row An instructor can teach at most one upper level class An instructor cannot teach two classes at the same time Cannot teach different classes in the same room at the same time A professor can teach up to three courses A lecturer can teach up to four courses Classes must be taught by a qualified instructor
5
Soft Constraints Instructors prefer teaching back to back classes
Instructors should teach at their preferred times Minimize the number of rooms Classes should be taught by instructors that prefer to teach the class
6
Instructor Preference Data
Math 151 Math 208 Math 309 Instructor 1 2 1 Instructor 2 7:45 am 8:50 am 9:55 am Instructor 1 2 Instructor 2 1
7
Difficulties Large number of possible schedules
NP problem - brute force will not work Making sure all hard constraints are met Maximizing all soft constraints
8
Two Algorithms Two main algorithms used in scheduling
Genetic Algorithm Integer Linear Programming Split up and each takes an algorithm Compare results
9
Genetic Algorithm
10
Algorithm Process Current population Only best adapted survive
Breed the stronger survivors New population Repeat until population is strong
11
Chromosome List of 0’s and 1’s that represent a schedule
We define the structure Create a population (many schedules) and iterate the schedules in it
12
Heuristic Function A measure of how good a chromosome is
Math 151 Math 208 Math 309 Instructor 1 2 1 Instructor 2 A measure of how good a chromosome is Used to compare possible schedules Heuristic Score: 5 Heuristic Score: 4 Heuristic Score: 0
13
Mutating Math 151 Math 208 Math 309 Instructor 1 2 1 Instructor 2 Randomly delete and reassign random bits in the chromosome, here 2 of the 6 bits Heuristic Score: 0 Heuristic Score: 5
14
Breeding Math 151 Math 208 Math 309 Instructor 1 2 1 Instructor 2 Merge two chromosomes into a single new one by combining the values Heuristic Score: 4 Heuristic Score: 0
15
Algorithm Process
16
Instructor-Class Assignment Method 1
Each bit in the chromosome represents a specific instructor-class pair 1 represents that instructor teaches that class, 0 means they don’t With 38 instructors and 116 sections, the chromosome is 4408 bits long 8.71 x schedules
17
Instructor-Class Assignment Method 2
Math 151 Math 208 Instructor 1 1 2 Instructor 2 Instructor 3 Instructor 4 Instructor 5 Chromosome picks an instructor that is able to teach each class Reduces chromosome to 555 bits 1.18 x schedules {1,5} {1,2,3}
18
Class-Time Assignment
Places all of an instructor’s classes into “blocks” Repeated sections are placed together Chromosome represents a combination of the blocks to determine the instructor’s schedule
19
Integer Linear Programming
Going to talk about Integer Linear Programming, also known as integer programming. The premise of IP is that you model your problem with a system of equations and then by maximizing that system of equations with integer values, you have optimized the model.
20
Target Function for Scheduling Classes
In order to demonstrate how this model worked, I am going to be using a modified example of how we schedules classes for instructors. In this case we are looking to solve for the instructor solutions matrix. The potential solutions for each of the x values in this matrix are 0 or 1, with 0 corresponding to the instructor not teaching at that time and 1 corresponding to the instructor teaching at that time. Clearly 0 and 1 are integer values which are needed for this type of solution since there are only two possible outcomes. The instructor’s time preference matrix, directly next to the solution matrix, corresponded to whether or not the instructor preferred to teach at that time, with 0 being it was impossible to teach at that time, 1 meaning it was possible and 2 meaning it was preferable. In order to create the target function, f(x), each of the corresponding values of these two matrices were multiplied together.
21
Hard Constraints Soft Constraints
Ensured by changing 0 to -9999 Created a strong bias against choosing impossible values for each x. Soft Constraints Maximized by changing 2 to 100 Gave a larger bias towards choosing the preferred values for each x. Next because the model tried to maximize this function by picking the values 0 or 1, we noticed that if the model ended up assigning a 1 to variable corresponding to a time that an instructor was unavailable to teach, there was very little penalty when maximizing the target function. This would result in an invalid schedule however and so there needed to be a strong penalty to the target function if one of these values were assigned wrong. To prevent this, we decided to convert all of the 0 values corresponding to an impossible teaching assignment to so that if a class was improperly scheduled, the target function would be hurt a disproportionate amount. Using this technique, we were able to make sure that none of the hard constraints were violated, thus ensuring a valid schedule. Next we also converted the 2’s corresponding to the preferred values from the time preference data to 100 in order to bias the model towards picking the preferred times. This worked on a similar intuition and helped maximize over the soft constraints. *mention and 100?
22
Constraint to limit maximum number of classes:
Next we are going to look at creating a constraint to limit each instructor to teaching at most one class in a three hour window. Constraints for integer programming are constructed as a series of inequalities utilizing the variables from the target function. Here h(x) is a list of three constraints, with each one corresponding to constraining one instructor to teaching at most one class in a three hour window.
23
Constraint to limit maximum number of classes:
For Instructor 1, the constraints would look like: Choose x1 = 0, x4 = 1 and x7 = 0. Then the hard constraint wasn’t invalidated and the soft constraint is maximized. Now to explain how the target function and constraints interact, we are going to look at the constraint corresponding to instructor 1 and the variables in the target function that also correspond to instructor 1. We want to maximize the following equation by choosing 0 or 1 for each x value meanwhile not invalidating the constraint below it. To do that, we’ll choose x_1 = 0, x_4 = 1 and x_7 = 0 which works because then we have found the highest value for the target function and the sum of the x values is 1 so the constraint was still satisfied. Solving this model with integer programming takes this same approach except it maximizes the entire target function over all of the constraints at once.
24
Simplex Method
25
2 - Dimensional Feasible Region
{ Bob ≤ orange line Jim ≤ green line Amy ≤ red line h(x) = We created a model of our problem with the R programming language and used a package from R called Lp_solve in order to optimize our model. Lp_solve finds the optimal solution via the simplex method which was created in 1946 by George Dantzig. The simplex method works by creating a feasible region where the potential solutions lie and then searching through a specific set of values in the feasible region in order to find the maximum value. To demonstrate how the simplex method works, we are going to look at this example where the feasible region is in two dimensions. Each of the constraints are represented on the graph as lines and the potential solutions lie in the region enclosed by the positive x_1 and x_2 values that are below all three of the lines. The points in the feasible region where any of the constraints or axes intersect are called extreme points and the maximum value for the equation lies in the the set of extreme points. Now we are going to extend this intuition to a problem with more variables. Feasible region formed by inequalities Theorem that max lies on vertices
26
Comparing Results Now we are going to compare the results of our two approaches with the schedule generated by the math department.
27
Strengths Weaknesses Genetic Algorithm
Simplicity makes it fast to implement, Heuristic function gives it flexibility. Randomness can give the model speed boost in large solution spaces. Difficult to find solutions since it can only randomly change Many invalid solutions (heuristic score 0) makes this problem worse. Integer Programming Easy to ensure hard constraints aren’t violated. Easy to ensure that soft constraints are maximized. Model always finds the same solution, so it is less flexible. Designing equations to model the constraints is hard. Now I’m going to explain some of the strengths and weaknesses of Integer Programming. The strengths were that it was easy to ensure that the hard constraints weren’t violated and that the soft constraints were optimized by choosing large negative or positive coeffiecients for the target function. The weaknesses however, included: the model always produced the same result so we only had one potential schedule as opposed to the genetic algorithm approach, and that the constraints are hard to model as linear inequalities, for example, I had to use four different integer programming models combined in order to create a single solution because some constraints needed to be satisfied before others could be considered.
28
Comparison Chart Here is a chart comparing a few of the key measures between all of the schedules. Most of these measures were based on how well the schedules satisfied the soft constraints and whether or not the schedules violated the hard constraints. One of our main goals was to create a program that is able to generate a schedule quickly and so both our our programs created schedules much faster than the math department, with the integer programming model running in about 10 seconds. The integer programming schedule was also able to ensure that every instructor taught only classes they preferred to teach compared to three with the actual schedule, while the genetic algorithm schedule had 34 classes being taught by instructors who didn’t prefer to teach the class. Finally, it was preferable if instructors taught two sections of the same class back to back in order to minimize their course preparation load and need to change rooms. The actual schedule had 36 such pairs of sections, the genetic algorithm schedule had 22 such pairs and the integer programming schedule had 46. Overall, based on the results we found that the genetic algorithm schedule performed at least as well as the actual schedule in most measures and the integer programming schedule outperformed the actual schedule in every measure.
29
Future Work So we have just shown that we can create these schedules that are better than what the math department is currently using but the code was relatively hard to use without direct knowledge of it. Daniel and I have decided to take the integer programming model and work to create a graphic interface so that in the future we can have a program where you can create a schedule and interact with aspects of the schedule to tune it to your liking. Our goal is to be able to train a member of the math department on this program so that they will be able to create these optimal schedules after we’re gone.
30
Questions? Thank you for coming out and listening to our presentation, do you have any questions? Murty, Katta G. (1983). Linear programming. New York: John Wiley & Sons, Inc. pp. xix+482. ISBN X. for images
32
n - Dimensional Feasible Region
The Simplex Method maps all extreme points to a vertex. The Simplex Method then “walks” down edges, choosing the edges that move to vertices with the highest values. In a model with n variables the feasible region created by the constraints is a multidimensional shape composed of edges and vertices like the example above in 3 dimensions. Like the 2 - dimensional model, the potential maximum values in the feasible region lie at the intersection of multiple constraints, that is the vertices on this model. A key feature of this feasible region is that for any of the vertices, if they are not a maximum point of the target function then there is an edge containing that vertex, such that moving away from that vertex on the edge increases the target function. The simplex method works on this intuition by creating this feasible region and then “walking” down the edges to vertices, choosing the edges that increase the target function. The method halts when it reaches a vertex corresponding to a maximum value for the target function. Then that maximum value for the target function can be converted into a schedule by reading the values of the variables in the target function and translating them into teaching or classroom assignments.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.