Search for content

Constraints

Constraints play a crucial role in establishing relationships between various entities like vehicles, orders, tasks, and depots within the optimization process. They define specific rules or limitations that need to be followed when scheduling routes and assigning tasks.

There are three types of constraints that can be used.

  • Combination constraints restrict whether two entities can be used together, such as whether or not a depot is allowed to be visited by a vehicle.
  • Order constraints restrict how orders can be structurally planned on a route.
  • Task constraints restrict how tasks can be structurally planned on a route.

Each constraint places restrictions on the scheduling of tasks along routes. During the optimization process, all constraints, including the default ones associated with route structure, are taken into account. Each new constraint serves as an additional requirement, meaning that for a route to be valid, it must satisfy all the imposed constraints simultaneously.

Categories

Constraints are usually not only specific to one entity, like a vehicle or order, but entail different classes of entities. Therefore constraints are expressed based on categories, which are often functional properties of the entity itself. Examples of categories might be whether or not a vehicle can be cooled, the region a depot is located or whether a task requires certification of the driver.

Constraints are expressed between categories of orders, tasks, vehicles and depots. Each of these entities can define the categories it belongs to. If a constraint is expressed towards a category that does not contain any entities, the constraint is ignored.

Combination constraints

Combination constraints define relationships between various entities like vehicles, orders, and depots. They can both restrict as well as enforce certain combinations to guide optimization, aiding in efficient route planning.

Order-vehicle combination constraints

Order-vehicle combination constraints restrict which orders can or should be transported by which vehicles. There are three types of order-vehicle constraints available.

Order requires vehicle

When an order requires a vehicle, orders with the specified order category must be transported by a vehicle with the required vehicle category.

Example

Your fresh orders might require a vehicle to have a cooling compartment.

"constraints": {
  "combinations": {
    "orderVehicle": [
      {
        "type": "ORDER_REQUIRES_VEHICLE",
        "orderCategory": "FRESH",
        "vehicleCategory": "COOLING_COMPARTMENT"
      }
    ]
  }
}

 

Vehicle requires order

When a vehicle requires an order, vehicles with the specified vehicle category can only transport orders with the required order category.

Example

Your low-emission vehicles might be reserved to handle orders within a city center.

"constraints": {
  "combinations": {
    "orderVehicle": [
      {
        "type": "VEHICLE_REQUIRES_ORDER",
        "orderCategory": "CITY_CENTER",
        "vehicleCategory": "LOW_EMISSION"
      }
    ]
  }
}

 

Forbidden combination

When an order-vehicle combination is forbidden, an order with the specified order category is not allowed to be transported by a vehicle with the specified vehicle category.

Example

If you have vehicles with advertisements for company A, displayed on their side but company B is also a customer. Those vehicles are not allowed to visit company B.

"constraints": {
  "combinations": {
    "orderVehicle": [
      {
        "type": "FORBIDDEN_COMBINATION",
        "orderCategory": "COMPANY_B",
        "vehicleCategory": "ADVERTISES_COMPANY_A"
      }
    ]
  }
}

 

Depot-vehicle combination constraints

Depot-vehicle combination constraints restrict which depots can or should be visited by which vehicles. There are three types of depot-vehicle constraints available.

Depot requires vehicle

When a depot requires a vehicle, depots with the specified depot category can only be visited by vehicles with the required vehicle category.

Example

Depots within a low-emission zone can only be accessed by low-emission vehicles.

"constraints": {
  "combinations": {
    "depotVehicle": [
      {
        "type": "DEPOT_REQUIRES_VEHICLE",
        "depotCategory": "LOW-EMISSION",
        "vehicleCategory": "LOW-EMISSION"
      }
    ]
  }
}

 

Vehicle requires depot

When a vehicle requires a depot, vehicles with the specified vehicle category can only visit depots with the required depot category.

Example

Depots located in Berlin might be reserved for vehicles based in Germany.

"constraints": {
  "combinations": {
    "depotVehicle": [
      {
        "type": "VEHICLE_REQUIRES_DEPOT",
        "depotCategory": "BERLIN",
        "vehicleCategory": "GERMANY"
      }
    ]
  }
}

 

Forbidden combination

When a depot-vehicle combination is forbidden, a depot with the specified depot category is not allowed to be visited by a vehicle with the specified vehicle category.

Example

If you have a relatively small depot, it might not be accessible by large vehicles.

"constraints": {
  "combinations": {
    "depotVehicle": [
      {
        "type": "FORBIDDEN_COMBINATION",
        "depotCategory": "SMALL_DEPOT",
        "vehicleCategory": "LARGE_VEHICLE"
      }
    ]
  }
}

 

Order constraints

Order constraints are rules that govern how orders can be arranged or scheduled within a route, ensuring specific conditions are met before certain orders are picked up or delivered. They regulate the sequence and arrangement of orders to ensure efficient and compliant route planning. If a vehicle category is specified, the constraint can be aimed to apply only to particular vehicles.

Respected order sequences

Respected order sequences require that one order be completed before another begins. When referring to executing an order, this involves both the pickup and the delivery task. This constraint ensures a specific sequence in which orders are handled, establishing that certain orders must follow the completion of another order.

Example

Say you transport both food and garbage. Since food can be contaminated by garbage, food should be delivered before any garbage may be handled. This constraint should only be applied to vehicles with a single compartment.

"constraints": {
  "orders": {
    "respectedSequences": [
      {
        "orderCategories": [
          "FOOD",
          "GARBAGE"
        ],
        "vehicleCategory": "SINGLE_COMPARTMENT"
      }
    ]
  }
}

 

Loading incompatibilities

Loading incompatibility constraints dictate when certain orders can be picked up or delivered, considering whether another order of a specific category is already in the vehicle. These rules prevent handling certain tasks if the vehicle already contains orders that fit a particular category, ensuring that such orders are not picked up or delivered together.

Example

If you transport both small and big boxes, it's efficient to stack and arrange small boxes once big boxes are present, optimizing the remaining space. Loading the small boxes initially might lead to difficulties in organizing the vehicle and should therefore be avoided. In this example, we apply this constraint to all vehicles.

"constraints": {
  "orders": {
    "loadingIncompatibilities": [
      {
        "loadedOrderCategory": "SMALL_BOX",
        "forbiddenOrderCategory": "BIG_BOX"
      }
    ]
  }
}

 

Note the asymmetric nature of the constraint above. While it is not allowed the pickup or deliver big boxes while your vehicle contains small boxes, the reverse is permissible – you can pick up or deliver small boxes even if your vehicle already contains big boxes. If you don’t want certain order types to be mixed, this can be enforced with two loading incompatibilities.

Example

If you don’t want to transport explosive materials in combination with inflammables.

"constraints": {
  "orders": {
    "loadingIncompatibilities": [
      {
        "loadedOrderCategory": "EXPLOSIVE",
        "forbiddenOrderCategory": "INFLAMMABLE"
      },
      {
        "loadedOrderCategory": "INFLAMMABLE",
        "forbiddenOrderCategory": "EXPLOSIVE"
      }
    ]
  }
}

Task constraints

Task constraints define limitations on how tasks can be scheduled within a route, dictating specific rules that tasks must follow. For instance, these constraints might prevent the scheduling of a particular task before another task, or they might require tasks of certain categories to be scheduled in a predetermined order. Essentially, task constraints regulate the sequencing and arrangement of tasks within a route, ensuring that specific rules or conditions are adhered to during the scheduling process. If a vehicle category is specified, the constraint can be aimed to apply only to particular vehicles.

Respected task sequences

Respected task sequences require tasks belonging to specific categories to follow a predefined order when scheduled. This constraint ensures that tasks of certain categories are arranged in a particular sequence, dictating the order in which they are planned within a route.

Example

If you have delivery orders in Germany and France and desire not to cross the border too often. You might want to enforce that all deliveries in Germany are handled before the deliveries in France. This constraint should be applied to all vehicles, and therefore the vehicle category is not filled in.

"constraints": {
  "tasks": {
    "respectedSequences": [
      {
        "taskCategories": [
          "GERMANY",
          "FRANCE"
        ]
      }
    ]
  }
}

 

Forbidden task sequences

Forbidden task sequences impose restrictions on the scheduling of tasks by dictating that tasks of a particular category cannot be scheduled before tasks of another category, either directly before or anywhere before in the route. This ensures a specific order or arrangement of tasks, preventing certain combinations from occurring within the route.

Example

When you transport both parcels and letters, for example, and certain customers have a premium delivery agreement for parcels, their parcels should be delivered first. This is an example where a forbidden task sequence can be used.

"constraints": {
  "tasks": {
    "forbiddenSequences": [
      {
        "firstTaskCategory": "STANDARD_DELIVERY",
        "type": "NOT_BEFORE",
        "secondTaskCategory": "PREMIUM_DELIVERY",
        "vehicleCategory": "PARCEL_DELIVERY_VAN"
      }
    ]
  }
}