Skip to content

Commit

Permalink
refactor(core): Simplify shift request implementation with lookup table
Browse files Browse the repository at this point in the history
  • Loading branch information
j3soon committed Aug 3, 2024
1 parent 2959ed0 commit dc92937
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions core/nurse_scheduling/preference_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ def shift_request(ctx: Context, preference, preference_idx):
# Note that a shift is represented as (d, r)
# i.e., max(weight * shifts[(d, r, p)]), for all satisfying (d, r)
p = preference.person
for (d, r) in ctx.map_p_dr[p]:
for _d in preference.day:
# TODO: parse dates
if (d + 1) not in preference.day:
continue
if ctx.requirements[r].id != preference.shift:
continue
d = _d - 1
r = ctx.map_rid_r[preference.shift]
# Add the objective
weight = 1
ctx.objective += weight * ctx.shifts[(d, r, p)]
Expand Down

0 comments on commit dc92937

Please sign in to comment.