Load demands and limits

The loadDemands property is defined under ShipmentModel.shipments.Shipment and the loadLimits property under ShipmentModel.vehicles.Vehicle.

Load demands and limits are a type of constraint you can use to manage capacity. They specify a shipment's required capacity and a vehicle's maximum capacity, which lets you optimize route assignments based on these constraints.

Load demands and limits can support objectives like:

  • Prevent vehicles from being overloaded.
  • Monitor how vehicle loads change as shipments are picked up and delivered.
  • Restrict the number of times a vehicle can visit a specific location.

Load demands and limits are specified in these properties:

  • loadDemands specifies the capacity amount a particular shipment needs.
  • loadLimits specifies the maximum capacity for a given vehicle.

Structure

As shown in the diagram, load demands and limits are structured as follows:

Properties

This section describes properties for load demands and limits, which are the following:

  • Load type: A shared property between load demands and limits.
  • Load and LoadLimit: Unique properties present in load demands and load limits respectively.

Load type

Load types are string keys that identify the type of load demands for a shipment and load limits for a vehicle. Load types have these important characteristics:

  • User-defined: Load types are ones you define. There are no predefined system variables for load types.
  • Shared: Load types are meant to be shared between shipments and vehicles. This means that a shipment will consume a vehicle's capacity up to its limit only when their load types match. If a vehicle doesn't specify any load limit for a particular type, it can carry an unlimited amount of that load type.

The string keys that represent the load types use the Protocol Buffers map type syntax. These string keys must not be null to avoid issues. When naming a load type, it's recommended to use identifiers describing the type of the load and its unit. For example: weightKg, volume_gallons, palletcount, or frequencyDaily.

Load and LoadLimit

The Load and LoadLimit objects contain specific properties to define capacity requirements for shipments and vehicles, the following table describes these properties:

Object Parent Property Property type Property description
Load loadDemands amount string (int64 format) Defines the shipment's capacity requirement in the specified type.
LoadLimit loadLimits maxLoad string (int64 format) Defines the vehicle's maximum load capacity in the specified type.

Examples

The following example shows the structure of a load demand where you can set the loadDemands type as a string and the amount property as a string in the int64 format:

"loadDemands": {
  "MATCHING_LOAD_TYPE": {
    "amount": "YOUR_LOAD_AMOUNT"
  }
}

The following example shows the most basic structure of a load limit, where you can set the loadLimits type as a string, and the maxLoad property as a string in the int64 format:

"loadLimits": {
  "MATCHING_LOAD_TYPE": {
    "maxLoad": "YOUR_MAX_LOAD"
  }
}

Try it out

Use the code examples above to create a fictional scenario. In this scenario, you have a shipment weighing 10 kilograms, and a vehicle that can carry 100 kilograms:

  1. In the loadDemands example, define the load type as weightKg.

    Once you do this, the load type in the loadLimits example will also populate, sharing the load type. Remember the types of the loadDemands and loadLimits must match for the shipment to consume the vehicle's limits.

  2. In the same loadDemands example, set the amount property to 10.

    This means the shipment weighs 10 kilograms.

  3. In the loadLimits example, set the maxLoad property to 100.

    This means the vehicle can carry a maximum of 100 kilograms.

Remember there's no set of predefined types. In this example, you could change kilograms to points, or change it to linear measurements instead of weight. This flexibility lets you tailor load demands and limits to your specific needs.

Request example

The following example shows the structure of a basic optimizeTours request with loadDemands in a shipment and loadLimits in a vehicle:

{
  "model": {
    "shipments": [
      {
        "pickups": [
          {
            "arrivalLocation": {
              "latitude": 00.000000,
              "longitude": 00.000000
            }
          }
        ],
        "deliveries": [
          {
            "arrivalLocation": {
              "latitude": 00.000000,
              "longitude": 00.000000
            }
          }
        ],
        "loadDemands": {
          "MATCHING_LOAD_TYPE": {
            "amount": "YOUR_LOAD_AMOUNT"
          }
        }
      }
    ],
    "vehicles": [
      {
        "startLocation": {
          "latitude": 00.000000,
          "longitude": 00.000000
        },
        "endLocation": {
          "latitude": 00.000000,
          "longitude": 00.000000
        },
        "costPerKilometer": 1.0,
        "loadLimits": {
          "MATCHING_LOAD_TYPE": {
            "maxLoad": "YOUR_MAX_LOAD"
          }
        }
      }
    ]
  }
}

Remember a shipment can have multiple load demands, and a vehicle can have multiple load limits, allowing you to provide complex constraints to take into consideration when optimizing your fleet's routes.