GuidesAPI Reference
Guides

Define mixed load restrictions

Mixed load restrictions in the HERE Tour Planning API impose constraints that prohibit certain types of goods from sharing space on the same trip.

For example, in last-mile delivery scenarios, couriers often deliver a variety of goods to multiple locations, such as private addresses, businesses, or pickup points. Such goods may have specific requirements, such as size, weight, or fragility, which often prevent them from traveling in the same shipment. For example, transporting perishable items with temperature-sensitive requirements together with fragile electronics might be challenging because of the different handling and storage conditions each type needs.

Including mixing load restrictions in a routing problem

Configuring the HERE Tour Planning API to include mixing load restrictions in a routing problem involves defining the categories of goods that have specific restrictions, and then assigning each job to a category based on the type of goods it involves, as described in the following sections.

Identify categories of goods not to be mixed

First, in the problem specification, state which goods categories cannot be transported together by creating a mixingRestrictions object as part of a shift configuration, as shown in the following example:

"shifts": [
  {
      "start": { ... },
      "end": { ... }
      },
      "mixingRestrictions": {
        "level": "tour",
        "restrictions": [{
          "conflictingCategories":
          [
            "a",
            "b"
          ]
        }
      ]
    }
  }
]
📘

Note

The category names are user-defined. You have the flexibility to create and name your own categories based on your specific needs.

The mixingRestrictions object has the level and restrictions properties whose purpose is to define the categories of goods that a vehicle cannot transport together as well as the level at which the restrictions apply:

  • restrictions: This property defines the categories of goods that must not be transported together, based on factors such as type or characteristics. Under the restrictions property, the conflictingCategories lists comprises sets of conflicting categories. For example:
  "mixingRestrictions": {
    "level": "tour",
    "restrictions": [
      {
        "conflictingCategories": [ 
          "perishable",
          "electronics"
        ]
      },
      {
        "conflictingCategories": [
          "flammable",
          "oxidizing-agents"
        ]
      }
    ]
  }
  • level: The following levels of mixing restrictions are available:
    • "tour": This value defines the types of goods that a vehicle can transport during a tour. For example, if a vehicle is transporting refrigerated goods during a tour, a tour-level restriction would prohibit the addition of non-refrigerated goods to the same tour. In simple terms, a vehicle can only carry goods belonging to a single restricted category throughout the entire tour.
    • "subTour": This value specifies that mixing restrictions apply to a subset of the tour. These restrictions may govern the sequence of loading or unloading, or specify that certain goods must not be delivered or picked up together. For example, with subTour, a vehicle can deliver perishable goods on the way out and then pick up electronics on the way back. This level of flexibility isn't possible with the tour setting.
    As an additional example, consider a scenario where the vehicle needs cleaning or reconfiguration between transporting different categories of goods. In such cases, the tour setting is more suitable. However, more intricate scenarios requiring greater flexibility, especially when delivering and picking up different categories during a single tour, subTour provides a more versatile solution.

Categorize jobs

Next, for the optimizing algorithm to consider the mixing restrictions for a job, assign that job with a category name that you specified as part of the restrictions array, for example:

{
  "jobs": [
    {
      "id": "job_1",
      "category": "perishable",
      "tasks": {...}
    }
  ]
}
📘

Note

The category parameter is optional. If a job doesn't have a category assigned to it, no mixing restrictions apply to this job.

Examples

The following sections provide sample scenarios that demonstrate how mixed load restrictions affect tour optimization at the level of the entire tour as well as the order and priority of individual jobs.

Scenario 1: Tour-level mixing restrictions

In the following sample problem specification, the fleet consists of a single vehicle. This vehicle is subject to a mixed load restriction that prohibits the simultaneous transportation of goods belonging to both the perishable and electronics categories during the entire tour, as indicated by the level parameter. Notably, the restriction allows the vehicle to pick up or deliver items exclusively from a single restricted category throughout the entire tour.

The tour plan involves the following jobs:

  • A delivery job of the perishable category
  • A pickup job of the electronics category

The following JSON snippet provides the full problem specification:

{
  "fleet": {
    "types": [
      {
        "id": "my_delivery_truck",
        "profile": "car_96348d48d98f",
        "costs": {
          "fixed": 1,
          "distance": 0.5,
          "time": 0.2
        },
        "shifts": [
          {
            "start": {
              "time": "2022-10-15T00:01:00Z",
              "location": {
                "lat": 52.55066573174976,
                "lng": 13.388972561428876
              }
            },
            "end": {
              "time": "2022-10-15T23:51:00Z",
              "location": {
                "lat": 52.55066573174976,
                "lng": 13.388972561428876
              }
            },
            "mixingRestrictions": {
              "level": "tour",
              "restrictions": [{
                "conflictingCategories":
                  [
                    "perishable",
                    "electronics"
                  ]
                }
              ]
            }
          }
        ],
        "capacity": [
          10
        ],
        "amount": 1
      }
    ],
    "profiles": [
      {
        "type": "truck",
        "name": "car_96348d48d98f"
      }
    ]
  },
  "plan": {
    "jobs": [
      {
        "id": "job_1",
        "category": "perishable",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "location": {
                    "lat": 52.494682192176725,
                    "lng": 13.36425332402917
                  },
                  "duration": 90
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_2",
        "category": "electronics",
        "tasks": {
          "pickups": [
            {
              "places": [
                {
                  "location": {
                    "lat": 52.501370545070884,
                    "lng": 13.486476220061036
                  },
                  "duration": 90
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      }
    ]
  }
}

The following figure illustrates the solution the HERE Tour Planning API returned:

Tour-level restrictions for load mixing

As illustrated in the previous figure, the API returned a solution assigning only a single job while leaving the other one unassigned with the following explanation:

"reasons": [
    {
        "code": "MIXING_RESTRICTION_CONSTRAINT",
        "description": "cannot be assigned due to job mixing restriction",
        "details": [
            {
                "vehicleId": "my_delivery_truck_1",
                "shiftIndex": 0
            }
        ]
    }
]

In this scenario, the API applied the mixing restrictions (as specified in the problem) at the tour level, assigning only the jobs belonging to one restricted category to a single vehicle during the entire tour. In this case, the API selected the job belonging to the perishable category because that job was more efficient for the vehicle.

📘

Note

The previous example was simplified for demonstration purposes. In a more realistic scenario, you could avoid unassigned jobs in a tour by:

  • Increasing the number of shifts for the vehicle
  • Increasing the number of vehicles in the fleet

For more information, see Problem.

Scenario 2: Sub-tour-level restrictions

The problem specification in this scenario is the same as before, except for one change:

  • The value of the level parameter for the mixing restrictions is now subTour, as the following snippet demonstrates:
"mixingRestrictions": {
  "level": "subTour",
  "restrictions": [{
    "conflictingCategories": 
      [
        "perishable",
        "electronics"
      ]
    }
  ]
}

The following figure illustrates how the returned solution changed after updating the mixing restrictions level:

Sub-tour-level restrictions for load mixing

Here, the optimization algorithm ensures that a vehicle doesn't mix restricted goods, but only at the subTour level. In this scenario, the vehicle begins by delivering perishable goods. Upon completing that task, the vehicle, now empty, can pick up goods from the electronics category. This implies that both perishable and electronics categories are part of the same tour for the vehicle, but they are not present simultaneously. This contrasts with the tour restriction level, where such mixing would be restricted throughout the entire tour.

📘

Note

In the context of this scenario, if job_2 involved a delivery rather than a pickup, that particular job would end up unassigned. This is because carrying incompatible items during a single job (in this case, job_1) would violate the mixing restrictions at the subTour level, and the optimization algorithm prevents that.

Conclusions

  • The tour and subTour mixing restrictions levels contribute significantly to the efficient and compliant management of goods during transportation, allowing for customization based on the specific constraints and priorities of the transport scenario at hand.
  • The choice between the levels at which mixing restrictions apply depends on the specific requirements of the transportation scenario. The subTour level offers more granular control for scenarios where the vehicle's load can vary between jobs within a tour. Meanwhile, the tour level provides a stricter constraint, suitable for scenarios where maintaining separation of incompatible goods throughout the entire journey is critical.

Next steps

  • For more information about formulating problems in the HERE Tour Planning API, see Problem.
  • For an in-depth exploration of the HERE Tour Planning API methods, endpoints, and parameters, see the API Reference.