ตะวัน บุญธนภัทร
unread,Mar 6, 2019, 12:38:11 PM3/6/19Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to or-tools-discuss
I’m working on the Nurse Scheduling Problem
I modified many constraint to suit my situation.
Until i currently stuck on how to Add constraint
That in every employee must have at least
once of 2-“consecutive” days of Day-OFF.
My situation
Number of days = 7
Number of employees = 7
Number of shifts per day = 4
Each employee has 3 days OFF in a week
But i want at least once that the day OFF is next to each other.
I didn’t include OFF as a shift
so for my code the sum of every shift in one day is 0 mean day OFF.
I tried to make a list of work of every employee
to be [d1,d2,d3...d7] -> [1,0,1,...0]
If 1 mean that employee work on day 1 and
0 mean they off on that day
By this code:
For employee in all_employee:
work_day = []
For d in all_days
work_day.append(sum(shift[(d,s,employee)] for s in all_shifts))
Then I make a new list of consecutive day
[(d1+d2),(d2+d3),(d3+d4)....(d6+d7)]
By
consecutive_day = []
for i in range(num_day - 1)
consecutive_day.append(work_day[i] + work_day[i+1], ... )
Then 0 should indicate the 2-days OFF in consecutive
So I add constraint
model.AddBoolOr([0 in consecutive_day])
But this doesn’t work
I don’t understand
I tried more than several approaches but none works
....
Could you please suggest on how to do this please.
Thank you.