# How do I create an optimal MULTI-day work schedule using mixed integer linear programming?

11 views (last 30 days)
Mee on 21 Sep 2017
Commented: Serien Ali on 14 Sep 2018
Hi,
In this blog by Loren Shure Generating an Optimal Employee Work Schedule Using Integer Linear Programming, she showed how to solve a complicated scheduling problem. I am trying to recreate this but I want to do a weekly optimization with the constraint that an employee can work maximum 40 hours a week and one can work only one shift a day. Sean de Wolski made a comment that I could just duplicate the constraints to look at a longer time period at once but I do not know how to formulate it. Can someone please help me?
Serien Ali on 5 Sep 2018
Thank you!
Serien Ali on 14 Sep 2018
Hi Mai, were you able to get a hold of your laptop? Thanks

David Ding on 27 Sep 2017
Hi,
As per the blog, the constraints are captured in A and b where: Ax <= b.
Now, you need to look at how to change the values of A and b to match your scenario. The call to the function "intlinprog" is likely still going to be the same:
[x, cost] = intlinprog(f,1:nVars,A,b,[],[],lb,ub);
The difference will be the values of the input arguments. For starters, just by quickly glancing your description and the blog, for the inequality matrix A:
"...There are two parts to the inequality constraint matrix A, which are clearly visible. The top portion has 24 rows (because there are 24 hours in a day) and each row represents the constraint that at a particular hour, you need a minimum number of staff..."
Now, perhaps, if you wish to extend this to a week and following the above example, you can make the top portion of A to be of 168 rows, since there are 168 hours in a week?
Best of luck,
David
Mee on 28 Sep 2017
Thanks a lot David. I will try this.
Serien Ali on 30 Aug 2018
Hi David,
I am having trouble setting up weekly constraints. I have turned the example into 168 hours instead of 24, and have min/max hours per shift for each employee. However I am having trouble setting up min hours per week for each employee. How can I go about doing this? How can i add this constraint into the existing matrix that I am setting up?