Skip to content

Tasks

Tasks represent a delivery, pickup, or service activity at a location in your routing problem. The main goal of route optimisation is to service all tasks as efficiently as possible.

A task can involve any combination of the following three activities:

  • Delivery: Transport items from the depot to the task location. Goods are loaded at the depot and unloaded at the destination.
  • Pickup: Collect items from the task location and bring them back to the depot. Goods are loaded at the task site and unloaded at the depot.
  • Service: Carry out a service operation at a customer location for a specific duration.

Location

Each task is associated with a location defined by its latitude and longitude coordinates. The location determines the travel distances and durations to and from other locations.

Delivery and pickup load

The loads of a task specify its dimensions, such as weight, volume, or number of items for pickup and/or delivery. A task can specify both a delivery load (goods transported from the depot to the task location) and a pickup load (goods collected at the task location and returned to the depot). Multiple load dimensions can be used simultaneously, for example to model weight and volume constraints together. The number of load dimensions must be consistent across tasks and vehicle types. The total load on a vehicle should not exceed its capacity for each dimension. The Load and capacities tutorial covers this in detail.

Time windows and service duration

A task can have one or more time windows, each defined by a start and end time. Service must begin within exactly one of these time windows. A vehicle may arrive before the start of a time window and wait for the time window to open, but it cannot arrive after the end of a time window. When no time windows are specified, the task can be serviced at any time.

The service duration defines how long a vehicle must spend at the task location. This includes the time needed to load or unload goods, or to perform the requested service. Service should start (but not necessarily end) within the selected time window. For worked examples, see the Time windows and service duration tutorial.

Release time

The release time specifies the earliest time at which this task is ready at the depot. This models tasks that only become ready at a certain time, such as orders that first need to be picked in the warehouse before they can be dispatched on a route. A task is considered immediately available if a release time is not specified.

Allowed and disallowed vehicle types

Certain tasks can only be served by specific vehicle types. For example, a task requiring refrigerated transport should not be assigned to a standard vehicle. The allowed_vehicle_types field restricts a task to only be served by the listed vehicle types, while disallowed_vehicle_types prevents specific vehicle types from serving the task. When neither is specified, the task can be served by any vehicle type. Learn more in the Vehicle restrictions tutorial.

Priority

If not all tasks can be planned, the task priority parameter helps the solver decide which tasks to plan first. The priority value ranges from 0 to 100, with a default of 50. Tasks with a higher priority value (closer to 100) are more likely to be planned when not all tasks fit. For example, a task with priority 90 will be preferred over a task with priority 30. When all tasks can be planned, the priority has no effect. See the Task priorities tutorial for a worked example.