Vacation constraints

2022-05-24
2 min read

This project is an answer project for StackOverflow per the following link.

https://stackoverflow.com/questions/67970464/nurse-scheduling-largest-sequence-of-no-shifts-in-n-days-must-be-x

This project is not for newbie.

Specifications

In a sliding 6 week window, each nurse must have at least 14 consecutive days with no shifts (i.e., be assigned to shift O).

Implementation

We have implemented it ,based on the following project.
Maximum-length-series-of-shifts slow down solving speed

Since 2 weeks vacation is really a big problem, so we modeled here just 1 week vacation in this month.
But we are sure you can try the 2 weeks in the same manner.

Vacation

We are adding a vacation shift to clearly distinguish shifts in the solution display.

Scheduling Horison

We change the finish date to span 6 weeks.

Row Constraints.

Here is a overall constraints about the vacation. You may be thinking, “Why do we need so many constraints?” or “Isn’t this redundant?”
But these are all necessary constraints.

Let’s look at them one by one. The next constraint is that there is only one vacation per week this month. This is a direct statement to the specification. You may think, “Isn’t this enough?

OK, we uncheck the remaining constraints as follows.

And, the solution becomes;

So, this is not the solution we want. Yes, we have one week vacation on every staff. However unnecessary vacation exists in many portions.

To remove all unnecessary vacations, we implement following constraints.

First, we removes vacations more than 7 days.

Second, we remove vacations less than 7 days.

Our intention is that complete length of 7 days vacation exists within this month. We do not include continuity from previous month and next month. So we need special care for Start Date and Finish Date.

Solve it!

Solution

Project File

File → Open Project File from Github