I'm writing a script to help me schedule shifts for a team. I have the model and the script to solve it, but when I try to run it, it takes too long. I think it might be an issue with the size of the problem I'm trying to solve. Before getting into the details, here are some characteristics of the problem:
- Team has 13 members.
- Schedule shifts for a month: 18 operating hours/day, 7 days/week, for 4 weeks.
- I want to schedule non-fixed shifts: members can be on shift during any of the 18 operating hours. They can even be on for a couple hours, off for another hour, and then on again, etc. This is subject to some constraints.
Sets of the problem:
- m: each of the members
- h: operating hours (0 to 17)
- d: days of the week (0 to 6)
- w: week of the month (0 to 4)
Variables:
- X[h,h,d,w]: Binary. 1 if member m starts a shift on hour h,d,w. 0 otherwise.
- Y[h,h,d,w]: Binary. 1 if member m is on shift on hour h,d,w. 0 otherwise.
- W[m,d,w]: Binary. 1 if member m had any shift on day d,w. 0 otherwise.
- G[m,w]: Binary. 1 if member m had the weekend off during week w. 0 otherwise.
The problem has 20 constraints, 13 which are "real constraints" of the problem and 7 which are relations between the variables, for the model to work.
When I run it, I get this message:
At line 2 NAME MODEL
At line 3 ROWS
At line 54964 COLUMNS
At line 295123 RHS
At line 350083 BOUNDS
At line 369067 ENDATA
Problem MODEL has 54959 rows, 18983 columns and 201097 elements
Coin0008I MODEL read with 0 errors
I left it running overnight and didn't even get a solution. Then I tried changing all variables to continuous variables and it took ~25 seconds to find the optimal solution.
I don't know if I'm having issues because of the size of the problem, or if it's because I'm using only binary variables. Or a combination of that. Are there any general tips or best practices that could be used to improve performance on a model? Or is it always related to the specific model I'm trying to solve?