Docs
  • Solver
  • Models
    • Field Service Routing
    • Employee Shift Scheduling
  • Platform
Try models
  • Employee Shift Scheduling
  • User guide
  • Constraints

Employee Shift Scheduling

    • Introduction
    • Getting started with employee shift scheduling
    • User guide
      • Terms
      • Planning AI concepts
      • Constraints
      • Understanding the API
      • Planning window
      • Time zones and Daylight Saving Time (DST)
      • Tags and tag types
      • Validation
      • Metrics and optimization goals
      • Score analysis
    • Employee resource constraints
      • Employee availability
      • Employee contracts
      • Pairing employees
      • Shift travel and locations
      • Work limits
        • Minutes worked per period
        • Minutes worked in a rolling window
        • Minutes logged per period
        • Days worked per period
        • Days worked in a rolling window
        • Consecutive days worked
        • Shifts worked per period
        • Shifts worked in a rolling window
        • Weekend minutes worked per period
        • Weekends worked per period
        • Weekends worked in a rolling window
        • Consecutive weekends worked
      • Time off
        • Days off per period
        • Consecutive days off per period
        • Consecutive days off in a rolling window
        • Consecutive minutes off in a rolling window
        • Shifts to avoid close to day off requests
      • Shift rotations and patterns
        • Shift rotations
        • Single day shift sequence patterns
        • Minimize gaps between shifts
        • Multi-day shift sequence patterns
        • Daily shift pairings
        • Overlapping shifts
        • Shift start times differences
        • Minutes between shifts
      • Shift type diversity
        • Shift types worked per period
        • Unique tags per period
      • Fairness
        • Balance time worked
        • Balance shift count
    • Shift service constraints
      • Alternative shifts
      • Cost management
      • Demand-based scheduling
      • Mandatory and optional shifts
      • Shift assignments
      • Skills and risk factors
    • Recommendations
    • Real-time planning
    • Real-time planning (preview)
    • Changelog
    • Upgrade to the latest version
    • Feature requests

Constraints

1. Overview

Constraints can be considered hard, medium, or soft.

Hard constraints represent rules and limitations of the real world that any planning solution has to respect. For instance, there are only 24 hours in a day and people can only be in one place at a time. Hard constraints also include rules that must be adhered to, for instance, employees must have certain skills to be assigned to specific shifts.

Breaking hard constraints results in infeasible plans.

Medium constraints help manage plans when resources are limited, for instance, assign as many mandatory shifts as possible. Medium constraints incentivize Timefold Platform to assign as many shifts as possible.

Soft constraints help optimize plans based on the business goals, for instance, keeping costs per period in a preferred range.

To help determine the quality of solutions, plans are assigned a score with values for hard, medium, and soft constraints.

0hard/-257medium/-6119520soft

Timefold examines many solutions during solving and is incentivized to use the solution with the highest score.

From the example score above, you can see zero hard constraints were broken, while both the medium and soft scores have negative values (the scores do not show how many constraints were broken, but values associated with those constraints).

Because breaking hard constraints would result in an infeasible solution, a solution that breaks zero hard constraints and has a soft constraint score of -1,000,000 is better than a solution that breaks 1 hard constraint but has a soft constraint score of 0.

It’s important to note that constraints have competing goals, for instance, a constraint that is concerned with fairness or load balancing may result in a solution that takes longer to execute, whereas constraints concerned with shortening the overall solution time may result in a solution that isn’t fairly disrupted among the available resources.

Timefold balances the competing priorities of constraints to arrive at solutions with the best overall score.

2. Employee shift scheduling constraint groups and constraints

Constraints are grouped together with similar constraints into constraint groups. The following constraint groups and constraints are available in employee shift scheduling.

2.1. Alternative shifts

The constraint in this group is designed to create multiple variants of a shift and make sure a specific number of the variants are assigned.

The following constraint is part of the Alternative shifts constraint group.

  • Required shift group assignment mode not met

For more information about this constraint group see the Alternative shifts guide.

2.2. Cost management

The constraints in this group are designed to keep the cost of staffing all shifts within budget.

The following constraints are part of the Cost management constraint group.

  • Costs per period not in preferred range

  • Costs per period not in required range

For more information about this constraint group see the Cost management guide.

2.3. Demand-based scheduling

The constraints in this group are designed to manage the number of assigned shifts and evenly spread the assigned shifts across periods of demand.

The following constraints are part of the Demand-based scheduling constraint group.

  • Balance shifts worked for minimum hourly demand

  • Shifts worked not in preferred hourly demand range

  • Shifts worked not in required hourly demand range

For more information about this constraint group see the Demand-based scheduling guide.

2.4. Employee availability

The constraints in this group are designed to only assign employees to shifts when they are available, and take employee preferences into consideration when making assignments.

The following constraints are part of the Employee availability constraint group.

  • Employee does not work during available time

  • Employee works during preferred time

  • Employee works during unavailable time

  • Employee works during unpreferred time

  • Employee works shift with non-matching required shift tags

  • Employee works shift with preferred shift tags

For more information about this constraint group see the Employee availability guide.

2.5. Fairness

The constraints in this group are designed to distribute work fairly across all employees.

The following constraints are part of the Fairness constraint group.

  • Balance shift count

  • Balance time worked

For more information about this constraint group see the Fairness guides.

2.6. Pairing employees

The constraints in this group are designed to manage how employees are paired (or not) on shifts.

The following constraints are part of the Pairing employees constraint group.

  • Employee is not paired with required employee

  • Employee is paired with preferred employee

  • Employee is paired with prohibited employee

  • Employee is paired with unpreferred employee

For more information about this constraint group see the Pairing employees guide.

2.7. Replanning

The constraint in this group is designed to reduce disruptions to the original plan when replanning.

The following constraint is part of the Replanning constraint group.

  • Employee assignment disrupted on replanning

For more information about this constraint group see the Real-time planning guide.

2.8. Resource-limited planning

The constraints in this group are designed to schedule as much priority work as possible when there aren’t enough people to cover all the shifts.

The following constraints are part of the Resource-limited planning constraint group.

  • Unassigned mandatory shift

  • Unassigned optional shift

For more information about this constraint group see the Mandatory and optional shifts guide.

2.9. Shift assignments

The constraints in this group are designed to manage which employees should (preferably) be assigned and not assigned to certain shifts.

The following constraints are part of the Shift assignments constraint group.

  • Concurrent shifts worked not in required range

  • Preferred employee assigned

  • Prohibited employee assigned

  • Shifts worked per period not in preferred range

  • Shifts worked per period not in required range

  • Unpreferred employee assigned

For more information about this constraint group see the Shift assignments guide.

2.10. Shift rotations and patterns

The constraints in this group are designed to create schedules that respect employees' work-life balance.

The following constraints are part of the Shift rotations and patterns constraint group.

  • Custom rotation duration in days not in preferred range for employee

  • Custom rotation duration in days exceeds required maximum for employee

  • Do not assign employees to shifts if the difference between start times is greater than the limit specified

  • Employee does not have preferred daily shift pairing

  • Employee does not have required daily shift pairing

  • Employee does not work required multi day shift sequence pattern

  • Employee does not work required single day shift sequence pattern

  • Employee has prohibited daily shift pairing

  • Employee has unpreferred daily shift pairing

  • Employee works preferred multi day shift sequence pattern

  • Employee works preferred single day shift sequence pattern

  • Employee works prohibited multi day shift sequence pattern

  • Employee works prohibited single day shift sequence pattern

  • Employee works unpreferred multi day shift sequence pattern

  • Employee works unpreferred single day shift sequence pattern

  • Minimize gaps between shifts for employee

  • Minutes between shifts not in preferred range for employee

  • Minutes between shifts not in required range for employee

  • Overlapping shift

  • Preferred shift rotation not met for employee

  • Required shift rotation not met for employee

  • Shift start time difference in minutes per period not in preferred range for employee

For more information about this constraint group see the Shift rotations and patterns guides.

2.11. Shift travel and locations

The constraints in this group are designed to respect employees' shift location preferences and reduce the amount of time employees spend traveling to their shifts.

The following constraints are part of the Shift travel and locations constraint group.

  • Locations worked per period not in preferred range for employee

  • Locations worked per period not in required range for employee

  • Maximum employee to shift travel distance exceeded

  • Minimize travel distance

  • Minimum time between shifts including travel not met

For more information about this constraint group see the Shift travel and locations guide.

2.12. Shift type diversity

The constraints in this group are designed to control the number of different types of shifts and tasks employees can be assigned.

The following constraints are part of the Shift type diversity constraint group.

  • Shift types worked per period not in preferred range for employee

  • Shift types worked per period not in required range for employee

  • Unique tags per period not in preferred limit

  • Unique tags per period not in required limit

For more information about this constraint group see the Shift type diversity guides.

2.13. Skill and risk factors

The constraints in this group are designed to define skills and risk factors to make sure shifts are assigned to employees with the right qualifications and no risk factors.

The following constraints are part of the Skill and risk factors constraint group.

  • Employee has prohibited risk factor associated with shift

  • Preferred skill missing

  • Required skill missing

For more information about this constraint group see the Skills and risk factors guide.

2.14. Time off

The constraints in this group are designed to manage employees' time off

The following constraints are part of the Time off constraint group.

  • Consecutive days off per period not in preferred range for employee

  • Consecutive days off per period not in required range for employee

  • Consecutive days off in rolling window not in preferred range for employee

  • Consecutive days off in rolling window not in required range for employee

  • Consecutive minutes off in rolling window not in preferred range for employee

  • Consecutive minutes off in rolling window not in required range for employee

  • Days off per period not in preferred range for employee

  • Days off per period not in required range for employee

  • Employee has prohibited shift near day off request

  • Employee has unpreferred shift near day off request

For more information about this constraint group see the Time off guides.

2.15. Work limits

The constraints in this group are designed to manage employees' contractual hours.

The following constraints are part of the Work limits constraint group.

  • Consecutive days worked not in preferred range for employee

  • Consecutive days worked not in required range for employee

  • Consecutive weekends worked per period not in preferred range for employee

  • Consecutive weekends worked per period not in required range for employee

  • Days worked in rolling window not in preferred range for employee

  • Days worked in rolling window not in required range for employee

  • Days worked per period not in preferred range for employee

  • Days worked per period not in required range for employee

  • Employee works compact sequence

  • Minutes logged per period not in preferred range for employee

  • Minutes logged per period not in required range for employee

  • Minutes worked in rolling window not in preferred range for employee

  • Minutes worked in rolling window not in required range for employee

  • Minutes worked per period not in preferred range for employee

  • Minutes worked per period not in required range for employee

  • Preferred minimum time between different sequences not met for employee

  • Preferred sequence start day met for employee

  • Shifts worked in rolling window not in preferred range for employee

  • Shifts worked in rolling window not in required range for employee

  • Shifts worked per period not in preferred range for employee

  • Shifts worked per period not in required range for employee

  • Weekend minutes worked per period not in preferred range for employee

  • Weekend minutes worked per period not in required range for employee

  • Weekends worked in rolling window not in preferred range for employee

  • Weekends worked in rolling window not in required range for employee

  • Weekends worked per period not in preferred range for employee

  • Weekends worked per period not in required range for employee

For more information about this constraint group see the Work limits guides.

3. Constraint weights

Every constraint has a weight and a match score that will be applied to the dataset score every time the constraint is matched.

The final score for an instance of a constraint being matched is calculated by multiplying the constraint weight by the match score.

Active soft constraints have a default weight of 1, meaning that all soft constraints are equally weighted. Constraint weights can be changed to make some constraints more important than others.

A constraint with a weight of 10, increases the impact of the score by a factor of 10 (10 * match score).

When a constraint has a weight of 0, the constraint score has no impact.

The match score is derived from the penalty or reward constraints apply when they are matched.

For instance, the Minutes worked per period not in preferred range for employee constraint adds a soft penalty that is derived from the additional minutes an employee works. If a rule specifies an employee can work a maximum of 240 minutes per day, but the employee is assigned 300 minutes, the Minutes worked per period not in preferred range for employee constraint will return a match score of -60.

If the minutesWorkedPerPeriodNotInPreferredRangeForEmployeeWeight (which sets the weight of the Minutes worked per period not in preferred range for employee constraint) is set to 1, the final soft score for this instance of the constraint matching will be -60. If the minutesWorkedPerPeriodNotInPreferredRangeForEmployeeWeight is set to 2, the final soft score for this instance of the constraint matching will be -120.

3.1. Constraint weight configuration

Constraint weights can be configured in individual input datasets or as part of a configuration profile that can be reused with future input datasets.

3.1.1. Configure a configuration profile

Constraint weights can be configured in Timefold Platform by creating a configuration profile and setting the weight in the configuration profile:

  1. Log in to Timefold Platform: app.timefold.ai

  2. Select the employee shift scheduling tile.

  3. Select Configuration profiles.

  4. Add a new configuration profile (or modify an existing profile) and configure the constraint weights.

The configuration profile can be specified when you submit a new dataset by appending a query parameter with the configuration profile name to the POST URL.

For instance, if the configuration profile is called test, the query parameter would be: ?configurationId=test

Learn more about configuration parameters and profiles.

3.1.2. Configure constraint weights in an input dataset

Constraint weights can be configured per JSON input dataset.

For instance, to set the exampleWeight to 10 add the following:

{
  "config": {
    "model": {
      "overrides": {
        "exampleWeight": 10
      }
    }
  }
}

3.2. Available constraint weights

Constraint Constraint weight

Balance shift count

balanceShiftCountWeight

Balance shifts worked for minimum hourly demand

balanceShiftsWorkedForMinimumHourlyDemandWeight

Balance time worked

balanceTimeWorkedWeight

Consecutive days off in rolling window not in preferred range for employee

consecutiveDaysOffInRollingWindowNotInPreferredRangeForEmployeeWeight

Consecutive days off per period not in preferred range for employee

consecutiveDaysOffPerPeriodNotInPreferredRangeForEmployeeWeight

Consecutive days worked not in preferred range for employee

consecutiveDaysWorkedNotInPreferredRangeForEmployeeWeight

Consecutive minutes off in rolling window not in preferred range for employee

consecutiveMinutesOffInRollingWindowNotInPreferredRangeForEmployeeWeight

Consecutive weekends worked per period not in preferred range for employee

consecutiveWeekendsWorkedPerPeriodNotInPreferredRangeForEmployeeWeight

Costs per period not in preferred range

costsPerPeriodNotInPreferredRangeWeight

Custom rotation duration in days exceeds preferred maximum for employee

customRotationDurationInDaysNotInPreferredRangeForEmployeeWeight

Days off per period not in preferred range for employee

daysOffPerPeriodNotInPreferredRangeForEmployeeWeight

Days worked in rolling window not in preferred range for employee

daysWorkedInRollingWindowNotInPreferredRangeForEmployeeWeight

Days worked per period not in preferred range for employee

daysWorkedPerPeriodNotInPreferredRangeForEmployeeWeight

Employee assignment disrupted on replanning

employeeAssignmentDisruptedOnReplanningWeight

Employee does not have preferred daily shift pairing

employeeDoesNotHavePreferredDailyShiftPairingWeight

Employee has unpreferred daily shift pairing

employeeHasUnpreferredDailyShiftPairingWeight

Employee has unpreferred shift near day off request

employeeHasUnpreferredShiftNearDayOffRequestWeight

Employee is paired with preferred employee

employeeIsPairedWithPreferredEmployeeWeight

Employee is paired with unpreferred employee

employeeIsPairedWithUnpreferredEmployeeWeight

Employee works compact sequence

employeeWorksCompactSequenceWeight

Employee works during preferred time

employeeWorksDuringPreferredTimeWeight

Employee works during unpreferred time

employeeWorksDuringUnpreferredTimeWeight

Employee works preferred multi day shift sequence pattern

employeeWorksPreferredMultiDayShiftSequencePatternWeight

Employee works preferred single day shift sequence pattern

employeeWorksPreferredSingleDayShiftSequencePatternWeight

Employee works shift with preferred shift tags

employeeWorksShiftWithPreferredShiftTagsWeight

Employee works unpreferred multi day shift sequence pattern

employeeWorksUnpreferredMultiDayShiftSequencePatternWeight

Employee works unpreferred single day shift sequence pattern

employeeWorksUnpreferredSingleDayShiftSequencePatternWeight

Locations worked per period not in preferred range for employee

locationsWorkedPerPeriodNotInPreferredRangeForEmployeeWeight

Minimize gaps between shifts for employee

minimizeGapsBetweenShiftsForEmployeeWeight

Minimize travel distance

minimizeTravelDistanceWeight

Minutes between shifts not in preferred range for employee

minutesBetweenShiftsNotInPreferredRangeForEmployeeWeight

Minutes logged per period not in preferred range for employee

minutesLoggedPerPeriodNotInPreferredRangeForEmployeeWeight

Minutes worked in rolling window not in preferred range for employee

minutesWorkedInRollingWindowNotInPreferredRangeForEmployeeWeight

Minutes worked per period not in preferred range for employee

minutesWorkedPerPeriodNotInPreferredRangeForEmployeeWeight

Preferred employee assigned

preferredEmployeeAssignedWeight

Preferred minimum time between different sequences not met for employee

preferredMinimumTimeBetweenDifferentSequencesNotMetForEmployeeWeight

Preferred sequence start day met for employee

preferredSequenceStartDayMetForEmployeeWeight

Preferred shift rotation not met for employee

preferredShiftRotationNotMetForEmployeeWeight

Preferred skill missing

preferredSkillMissingWeight

Sequence ends on allowed sequence start day for employee

sequenceEndsOnAllowedSequenceStartDayForEmployeeWeight

Shift start time difference in minutes per period not in preferred range for employee

shiftStartTimeDifferenceInMinutesPerPeriodNotInPreferredRangeForEmployeeWeight

Shift types worked per period not in preferred range for employee

shiftTypesWorkedPerPeriodNotInPreferredRangeForEmployeeWeight

Shifts worked in rolling window not in preferred range for employee

shiftsWorkedInRollingWindowNotInPreferredRangeForEmployeeWeight

Shifts worked not in preferred hourly demand range

shiftsWorkedNotInPreferredHourlyDemandRangeWeight

Shifts worked per period not in preferred range

shiftsWorkedPerPeriodNotInPreferredRangeWeight

Shifts worked per period not in preferred range for employee

shiftsWorkedPerPeriodNotInPreferredRangeForEmployeeWeight

Unassigned optional shift

unassignedOptionalShiftWeight

Unique tags per period not in preferred limit

uniqueTagsPerPeriodNotInPreferredRangeForEmployeeWeight

Unpreferred employee assigned

unpreferredEmployeeAssignedWeight

Weekend minutes worked per period not in preferred range for employee

weekendMinutesWorkedPerPeriodNotInPreferredRangeForEmployeeWeight

Weekends worked in rolling window not in preferred range for employee

weekendsWorkedInRollingWindowNotInPreferredRangeForEmployeeWeight

Weekends worked per period not in preferred range for employee

weekendsWorkedPerPeriodNotInPreferredRangeForEmployeeWeight

Next

  • See the full API spec or try the online API.

  • Learn more about employee shift scheduling from our YouTube playlist.

  • Learn about balancing different optimization goals.

  • © 2025 Timefold BV
  • Timefold.ai
  • Documentation
  • Changelog
  • Send feedback
  • Privacy
  • Legal
    • Light mode
    • Dark mode
    • System default