Docs
  • Solver
  • Models
    • Field Service Routing
    • Employee Shift Scheduling
    • Pick-up and Delivery Routing
  • Platform
Try models
  • Pick-up and Delivery Routing
  • Constraints

Pick-up and Delivery Routing

    • Introduction
    • Getting started: Hello world
    • User guide
      • Terms
      • Planning AI concepts
      • Demo datasets
      • Validation
      • Routing with Timefold’s maps service
      • Metrics and optimization goals
    • Driver resource constraints
      • Lunch breaks and personal appointments
      • Route optimization
      • Shift hours and overtime
    • Job service constraints
      • Time windows and opening hours
      • Skills
      • Movable stops and multi-day schedules
      • Dependencies between stops
      • Priority stops and optional stops
      • Job requirements and tags
        • Job required drivers
        • Job pooling
        • Prohibit job combinations
        • Maximum time burden
        • Driver capacity
        • Tags
    • Changelog
    • Upgrading to the latest versions
    • 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, do not assign drivers to work after their max shift end time.

Breaking hard constraints results in infeasible plans.

Medium constraints help manage plans when resources are limited, for instance, avoid leaving stops unassigned. Medium constraints incentivize Timefold Platform to assign as many jobs and stops as possible.

Soft constraints help optimize plans based on the business goals, for instance, minimizing the amount of time drivers spend driving.

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. Pick-up and delivery constraint groups and constraints

Constraints are grouped together with similar constraints into constraint groups. The following constraint groups and constraints are available in pick-up and delivery.

2.1. Dependencies between stops

The constraints in this group are designed to sequence stops in the correct order, and if delays are required, make sure the delay is included.

The following constraints are part of the Dependencies between stops constraint group.

  • No semi-assigned jobs

  • Require stop dependency prerequisite assigned

  • Require stop dependency sequence

  • Require the same driver shift for dependent stop

For more information about this constraint group see the Dependencies between stops guide.

2.2. Job requirements, area affinity and tags

The constraints in this group are designed to assign required or preferred drivers for particular jobs, keep drivers within their areas, and limit a driver’s time per job type.

The following constraints are part of the Job requirements, area affinity and tags constraint group.

  • Driver capacity exceeded weight

  • Prefer stop driver match preferred drivers

  • Require stop driver match required drivers

  • Require stop driver not match prohibited drivers

For more information about this constraint group see the Job requirements and tags guide.

2.3. Lunch breaks and personal appointments

The constraints in this group are designed to apply breaks (lunch, appointments, team meetings, etc) for the drivers.

The following constraints are part of the Lunch breaks and personal appointments constraint group.

  • No conflict with fixed break

  • No conflict with fixed location break

  • No fixed break during job

  • No floating break during job

  • Max floating break end time (hard)

For more information about this constraint group see the Lunch breaks and personal appointments guide.

2.4. Movable stops and multi-day schedules

The constraint in this group is designed to delay flexible stops until a driver is in the neighborhood.

The following constraint is part of the Movable stops and multi-day schedules constraint group.

  • Prefer stops scheduled to the earliest day

For more information about this constraint group see the Movable stops and multi-day schedules guide.

2.5. Route optimization

The constraint in this group is designed to reduce the travel time per driver to increase productivity and reduces CO2 emissions.

The following constraint is part of the Route optimization constraint group.

  • Minimize travel time

For more information about this constraint group see the Route optimization guide.

2.6. Shift hours and overtime

The constraint in this group is designed to honor drivers' working hours and avoid unnecessary overtime.

The following constraint is part of the Shift hours and overtime constraint group.

  • Max shift end time (hard)

For more information about this constraint group see the Shift hours and overtime guide.

2.7. Skills

The constraints in this group are designed to match skill requirements, seniority, and customer affinity to reduce the service duration per task.

The following constraints are part of the Skills constraint group.

  • Minimize scheduling drivers with unnecessary skill levels

  • Require skills

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

2.8. Time windows and opening hours

The constraints in this group are designed to schedule stops to start and end within their time windows.

The following constraint are part of the Time windows and opening hours constraint group.

  • Require service max end time

  • Require service max start time

For more information about this constraint group see the Time windows and opening hours guide.

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 Minimize travel time constraint adds a soft penalty of 1 for every second of travel. If the total travel is 1 hour, the match score is 3,600.

If the minimizeTravelTimeWeight (which sets the weight of the Minimize travel time constraint) is set to 1, the final soft score for this instance of the constraint matching will be -3,600. If the minimizeMakespanWeight is set to 2, the final soft score for this instance of the constraint matching will be -7,200.

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 pick-up and delivery 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

Minimize scheduling drivers with unnecessary skill levels

minimizeUnnecessarySkillsWeight

Minimize travel time

minimizeTravelTimeWeight

Prefer stop driver match preferred drivers

matchPreferredDriversWeight

Next

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

  • Learn about balancing different optimization goals.

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