I am making a solver to choose the best assignment to a set of people for an event, given their availability (chosen in a set $T$ of time slots), jobs preferences (among $J$ possible jobs) and some of other predefined constraints. We refer to a particular pair of (job, time slot) as a "shift".
I'm not optimizing the entire workforce at once but instead I assign one person at a time.* Here's an overview of how I modeled the sub-problem:
- Enumerate the set $S$ of all possible shifts ($|S| = |J|\times|T| = 90$ in my case)
- Use an objective function related to the number of people already assigned to each shift (and the need for that shift)
- Find solution $x \in \{0,1\}^{|S|}$ that associates to each element of $S$ a value in $\{0, 1\}$
The constraints are the following:
- Each person can be assigned up to N shifts (depending on their preference)
- Up to 2 shifts during the same day
- No consecutive shifts except when the job remains the same
- Each person can do only up to two different jobs during the entire event
I managed to encode all the constraints as a linear program except the last one. Any idea on how that could be done ? If that is not possible at all (which I suspect), what tool can I use to solve this problem ?
* I know that is sub-optimal, but finding a better algorithm will probably be the subject of another question ;)