Skip to content

Encourage preferred block length

Similar to the objective that rewards forward rotating shifts, this objective is designed to create more employee friendly schedules. This is done by rewarding shift phases of the same shift that are close to the pre-defined optimal block length.

Implemented using Google's OR Tools

src/cp/objectives/rotate_shifts_forward.py
for length, var in [(len, cast(IntVar, var)) for (len, var) in block_length_vars]:
    k: int = abs(length - self._target_block_length)
    penalties.append(k * var)
penalties.append(
    abs((self._max_block_length + 1) - self._target_block_length) * unmatched_block,
)