I'm new to ORTools and trying to implement an algo for employee scheduling problem involving multiple shifts and work centers over month using ORTools,
https://notebook.community/google/or-tools/examples/notebook/sat/schedule_requests_sat,
https://github.com/google/or-tools/blob/master/examples/python/shift_scheduling_sat.py,
etc.... For a given work center, the demand for employees during a given shift is required (for ex.: 3 employees on am shift, 2 employees on pm shift and 1 employee on evening shift. The objective is to assign the selected employees to shifts and work centers. i did something like this below for 40 employees, 10 work centers and month but the solution ends with some employees with 42 hours and others with like 7 hours....
shift = {}
for n in all_nurses:
for s in all_shifts: # range(num_shifts):
for d in all_days:
for l in all_sites:
shift[(n, s, d, l)] = model.NewBoolVar(
'shift_n%is%id%il%i' % (n, s, d, l))
Each nurse works at most one shift per day.
for n in all_nurses:
for d in all_days:
model.Add(sum(shift[(n, s, d, l)]
for s in range(num_shifts) for l in all_sites) <= 1)
Each nurse works 5 days week
for n in all_nurses:
week = []
for l in all_sites:
for s in all_shifts:
for d in all_days:
week.append(shift[(n, s, d, l)])
# week.append(sum(shifts[(n,d,s)] for s in all_shifts))
# print(week)
model.Add(sum(week) == 5)
the numbers of nurses on day d in shift s at site l should be less or equal to weekly_cover_demands[l][d][s]
for l in all_sites:
for d in all_days:
for s in range(num_shifts):
model.Add(sum(shift[(n, s, d, l)]
for n in all_nurses) <= weekly_cover_demands[l][d][s])
model.Maximize(
sum(shift[(n, s, d, l)]
for l in all_sites for d in all_days for n in all_nurses for s in range(num_shifts)))