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:Shift Properties
Names of employees pre-assigned to this shift
Parallel array to
employees. locked[i] controls whether employees[i] can be reassigned by the solveremployees 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
When to use warm start
When to use warm start
- Large problems where finding any solution is slow
- Incremental changes to existing schedules
- Testing “what-if” scenarios from a known state
When to lock assignments
When to lock assignments
- Employee has confirmed the shift
- Contractual obligations require specific assignments
- External constraints not modeled in the API
Avoid locking pitfalls
Avoid locking pitfalls
- Don’t lock assignments that violate skills or availability
- Leave flexibility for the solver to optimize
- Use
locked: falsefor preferences,locked: trueonly for requirements