scheduling/ matching/ preference algorithm - algorithm

I have this problem but not sure what algorithm it belongs to.
We are trying to make a scheduling system where the users can choose the time preferences and then they are grouped into classes with their most preferred time.
Let say I have 100 users. Those users have their time preferences. We want to divide them into 4 -> 6 class with about 20 -> 25 students in each class. My question is
How to schedule them into the class time that they most preferred with the least amount of classes used ?
(Another constraint factor we have is the amount of teachers we have and the maximum hours a week they can teach. Also we want to be able to have makeup class. For eg: students who miss class this week can be reschedule for next week. )

One way to go about a multi-objective optimization problem like this is to find a solution that satisfies one objective, and then use local search to attempt to satisfy the remaining constraints.
For example, if you ignore the constraint that you would like to minimize the number of classes used, then you can treat this as a variant on the Stable Marriage Problem (or weighted bipartite graph matching problem) - this has the nice property that it can be solved in polynomial time. Your variant on the problem is most similar to the "hospitals/residents" problem (assigning many residents to a few hospitals based on preference).
This will leave you with several classes with only a few students in them, so you next perform a local search to satisfy the "minimize the number of classes" constraint (if you formulated the Stable Marriage algorithm correctly then you should have already satisfied the "no class exceeds 25 students" constraint) - from there you have two options:
Sort the classes from fewest to most students and close the classes with the fewest students, reassigning the evicted students to the remaining classes
Continue to take the students' preferences into account and sort the classes from least-preferred to most-preferred (so if you have 5 students in a class who assigned it a weight of 10 then you would first close a class with 10 students who assigned it a weight of 2).
You would then perform another local search to satisfy the teachers' hours constraints - you would perform the "teachers can't teach more than X hours" search after you perform the "minimize the number of classes" search, since the latter optimization will make it easier to perform the former optimization.
If the resulting algorithm is fast enough then you can randomize it and run it a few dozen times, saving the best result. For example, rather than closing the class with the fewest students first, randomly select a class to close (weight the selection so that it usually selects the smallest class - a completely random search won't perform well)
It's possible that you'll find that one of your constraints is causing a lot of conflicts, e.g. when satisfying the teachers' hours constraint you discover that you're having to rearrange a large percentage of the students. If this occurs then change the constraint ordering, so that satisfying the teachers' hours is done on the second or even the first pass rather than on the third pass.
The makeup-class-constraint might actually belong at the top of the constraint list (even though it's got a low priority), depending on its specifications. For example, you may have the requirement that the makeup class occur before any other class (so that e.g. a student with class on Tuesday can have the makeup class on Monday and get caught up prior to his regular class); even though the makeup class constraint has a low priority, it has the tightest requirements, and so it needs to get ordered first.

Related

Maximise subset selection under constraints

I am working on a scheduling problem for a team of volunteers. I have boiled my problem down to the following algorithmic problem:
I have a matrix with ~60 rows representing volunteers and ~14 columns representing days. Each entry is an integer in the range 0 to 3 inclusive representing how free the volunteer is on that day. I want to choose exactly 4 entries from each column (4 volunteers a day) such that (in order of importance)
A 0-entry is never chosen.
The workload is as spread out as possible (first give everyone one shift, then start giving out second shifts, etc. We can expect that most volunteers will only have one shift per 2-week period, and some may even have none.)
The sum over selected entries is maximised (volunteers get days that they prefer).
I want to output a decision matrix that has a 1 whenever a volunteer is chosen for a day, and 0 otherwise. I believe this is an instance of the nurse-rostering problem, so I'm not expecting a fast solution, but I just want to make a brute force algorithm that will work in a reasonable time for my ~60 person team. I'm just really not sure how to start tackling this problem. Is it suited for backtracking, or is there some way to calculate the best placement of each volunteer based on the distribution of his/her day-scores?

How to design an algorithm to put elements into groups with constraints?

I was given a task of putting students into groups (to prepare a coding camp), but with several constraints. Though I've finished the task by hand, I'd like to know is there already exist some algorithms for tasks like this, or how can I design such an algorithm.
Background: 40 students in total, with these attributes:
gender: F/M
grade: Year 1/2
school: School 1/School 2/...
early assessment result: Rank from 1 to 40
Constraints: All of them needs to be satisfied.
Exactly 4 people per group
Each group needs to have at least a girl
Each group needs to have at least a Year 2 student
4 group members needs to come from 4 different schools
Each group needs to have at least a student who ranked top 10 in early assessment
What I'm expecting:
The Best: An existing algorithm/program for these kind of problems
Or, An algorithm for this specific problem
Or at least, Some ideas of creating an algorithm for this specific problem
My thoughts:
Since I've successed in making groups by hand, I know that such a solution indeed exists for my current dataset. But if I need an algorithm to find a solution for me, it should first try to check whether a solution even exists, by check if the number of girl / Year 2 students is greater than 10 (with pigeonhole principle), and some other conditions. And obviously, Constraint 5 is the easiest, and can provide a base solution for the rest. However, I still can not find a systematic way of doing it. Perhaps bruteforce and randomization can help? I'm not sure.
And sorry, since the data is confidential, I can not post it.
Update: After consulting a friend, here is a possible method:
First put the top 1 to 10 into 10 different groups.
Then iterate through groups. If the only person in the group is a boy/girl, try to add a girl/boy from a different school.
Then the problem size is reduced from 2^40 to 2^20, making bruthforce a viable solution.

Multiple depot vehicle scheduling

I have been playing around with algorithms and ILP for the single depot vehicle scheduling problem (SDVSP) and now want to extend my knowledge towards the multiple depot vehicle scheduling problem (MDVSP), as i would like to use this knowledge in a project of mine.
As for the question, I've found and implemented several algorithms for the MDSVP. However, one question i am very curious about is how to go about determining the amount of needed depots (and locations to an extend). Sadly enough i haven't been able to find any resources really which do not assume/require that the depots are set. Thus my question would be: How would i be able to approach a MDVSP in which i can determine the amount and locations of the depots?
(Edit) To clarify:
Assume we are given a set of trips T1, T2...Tn like usually in a SDVSP or MDVSP. Multiple trips can be driven in succession before returning to a depot. Leaving and returning to depots usually only happen at the start and end of a day. But as an extension to the normal problems, we can now determine the amount and locations of our depots, opposed to having set depots.
The objective is to find a solution in which all trips are driven with the minimal cost. The cost consists of the amount of deadhead (the distance which the car has to travel between trips, and from and to the depots), a fixed cost K per car, and a fixed cost C per depots.
I hope this clears up the question somewhat.
The standard approach involves adding |V| binary variables in ILP, one for each node where x_i = 1 if v_i is a depot and 0 otherwise.
However, the way the question is currently articulated, all x_i values will come out to be zero, since there is no "advantage" of making the node a depot and the total cost = (other cost factors) + sum_i (x_i) * FIXED_COST_PER_DEPOT.
Perhaps the question needs to be updated with some other constraint about the range of the car. For example, a car can only go so and so miles before returning to a depot.

Class Scheduling to Boolean satisfiability [Polynomial-time reduction] part 2

I asked few days ago, a question about how to transform a University Class Scheduling Problem into a Boolean Satisfiability Problem.
(Class Scheduling to Boolean satisfiability [Polynomial-time reduction])
I got an answer by #Amit who was very elegant and easy to code.
Basically, his answer was like this : instead of considering courses, he considered time-intervals.
So for the i-th course, he just indicted all the possible intervals for this course. And we obtain a solution when there is at least 1 true-interval for every course and when no interval overlap an other.
This methods works very well when we consider only courses and nothing else. I generalize it by encoding the room inside the interval.
for example, instead of [8-10] to say that a course can happen between 8am and 10am.
I used [0.00801 - 0.01001] to say that a course can happen between 8am and 10am in the room 1.
I'm sure that you are currently wandering "why use double ?" well, because here come my problem :
To continue to generalize this method, I encode also the n° of the teacher in this interval.
I used [1.00801 - 1.01001] to say that a course can happen between 8am and 10am in the room 1 and be taught by the teacher n°1.
Here is what I got for now :
like this [1.008XX - 1.010XX] can happen in the same time as [2.008YY - 2.010YY], which is true, if the teacher 1 is teaching in the room X between 8am and 10am, the teacher 2 can teach also in Y between 8am and 10am, if and only if the room is available.
The problem is : with this method I cannot assure that XX and YY will be different and that YY will be available, because [1.008XX - 1.010XX] don't overlap [2.008XX - 2.010XX], so for now, the solver consider this possible.
And I still don't have any clue on how to assure this, by using this interval-method...
I need a way to encode {Interval, room and teacher-id} in order that :
a teacher cannot be in 2 places in the same interval.
there cannot be 2 teachers in the same room for the same interval.
there is a least 1 interval true by course.
Thanks in advance for your help,
Best regards !
Follow up question: Class Scheduling to Boolean satisfiability [Polynomial-time reduction] Final Part
This answer is extension of Part 1's answer, and uses the same notations when possible.
Ok, assume each interval is assigned to one teacher (if more than one teacher can take the interval, just have multiple instances of it, with different teachers per instance), so to indicate teacher t teaches in a classroom p at time x to y, we can use the old variable that this class is given - V_{i,j} - for the class and interval.
For each teacher t , and for each pair of intervals c=(x1,y1), d=(x2,y2) in classes (a,b) the teacher might participate in, add the clause:
Q_{t,i,j} = Not(V_ac) OR Not(V_bd) OR Smaller(y1,x2) OR Smaller(y2,x1)
Intuitively, the above clause guarantees a teacher cannot be in the same time in two places - no intervals overlap that the same teacher is assigned to them.
By chaining each pair (i,j) for each teacher t with AND to the original formula, it satisfies your first constraint - a teacher cannot be in 2 places in the same interval. - since each teacher cannot be in two places at the same time.
Your second constraint there cannot be 2 teachers in the same room for the same interval. is also satisfied by the fact that there cannot be two classes that overlap the time and class.
The 3rd constraint there is a least 1 interval true by course. is satisfied by the F1 clause, since you have to choose at least one interval (with one teacher assigned) for each course.

Algorithm to Rate Objects with Numerous Comparisons

Lets say I have a list of 500 objects. I need to rate each one out of 10.
At random I select two and present them to a friend. I then ask the friend which they prefer. I then use this comparison (ie OBJECT1 is better than OBJECT2) to alter the two objects' rating out of ten.
I then repeat this random selection and comparison thousands of times with a group of friends until I have a list of 500 objects with a reliable rating out of ten.
I need to figure out an algorithm which takes the two objects current ratings, and alters them depending on which is thought to be better...
Each object's rating could be (number of victories)/(number of contests entered) * 10. So the rating of the winner goes up a bit and the rating of the loser goes down a bit, according to how many contests they've previously entered.
For something more complicated and less sensitive to the luck of the draw with smaller numbers of trials, I'd suggest http://en.wikipedia.org/wiki/Elo_rating_system, but it's not out of 10. You could rescale everyone's scores so that the top score becomes 10, but then a match could affect everyone's rating, not just the rating of the two involved.
It all sort of depends what "reliable" means. Different friends' judgements will not be consistent with respect to each other, and possibly not even consistent over time for the same person, so there's no "real" sorted order for you to sanity-check the rankings against.
On a more abstruse point, Arrow's Impossibility Theorem states some nice properties that you'd like to have in a system that takes individual preferences and combines them to form an aggregated group preference. It then proceeds to prove that they're mutually inconsistent - you can't have them all. Any intuitive idea of a "good" overall rating runs a real risk of being unachievable.

Resources