Skip to main content
Use the employees and locked fields on a shift to set an initial schedule or lock specific employee-shift pairings that the solver cannot change. These are parallel arrays: locked[i] controls whether employees[i] can be reassigned.

Use Cases

  • Warm start - Provide an initial solution for faster optimization
  • Fixed assignments - Lock confirmed shifts that cannot change
  • Partial planning - Keep some assignments fixed while optimizing others
  • Incremental scheduling - Add new shifts while preserving existing schedule

Warm Start

Provide an initial schedule without locking to help the solver find better solutions faster:
With locked: [false], the solver uses these employees as a starting point but may reassign them if a better solution exists.

Locked Assignments

Lock assignments that must not change:
Locked assignments are treated as hard constraints. If they conflict with other hard constraints (e.g., skills, availability), the solution becomes infeasible.

Shift Properties

employees
array
Names of employees pre-assigned to this shift
locked
array
Parallel array to employees. locked[i] controls whether employees[i] can be reassigned by the solver
employees and locked are indexed positionally: the first entry in locked applies to the first entry in employees, and so on. Omit locked (or set an entry to false) to leave an employee assignable.

Mixed Locking

Combine locked and unlocked assignments for partial replanning:
Alice stays on shift-1. Bob and Carol’s assignments serve as suggestions that the solver may improve.

Best Practices

  • Large problems where finding any solution is slow
  • Incremental changes to existing schedules
  • Testing “what-if” scenarios from a known state
  • Employee has confirmed the shift
  • Contractual obligations require specific assignments
  • External constraints not modeled in the API
  • Don’t lock assignments that violate skills or availability
  • Leave flexibility for the solver to optimize
  • Use locked: false for preferences, locked: true only for requirements