Alternative Capacities

Businesses in industries like e-commerce, retail deliveries, and logistics providers deal with a variety of goods & items. In such operations, the actual load capacity of the vehicle can accommodate multiple combinations of different types of goods. As an example, a vehicle can accommodate either 10 boxes along with 2 pallets or else it can accommodate 3 boxes but 5 pallets.

For such scenarios, NextBillion.ai’s Route Optimization Flexible API provides alternate capacity settings to help leverage the cargo space of a vehicle by choosing the most efficient load configurations among those provided in the input problem statement. Once the users provide all possible load configurations for relevant vehicles, the optimization engine works with a wider range of potential solutions to provide a streamlined solution.

Get Started

Readers would need a valid NextBillion API key to try this example out. If you don’t have one, please contact us to get your API key now!

Setup

We have a total of 6 pickup jobs with loads specified in two dimensions - weight and boxes. The pickups are to be fulfilled by two vans which start and end their trip on the same location (a depot). Each pickup has a combination of weighted goods and boxes to be collected. On the other hand, each van is also capable of storing multiple combinations of these two types of items. We configure the locations, pickup jobs, vans and their capacity constraints one by one in the following sections.

Locations

First, we define the locations object and add all the location coordinates used in the problem along with a valid id. The locations object used in this example:

1
"locations":"{..}"

Jobs

Next, we define the 6 pickup jobs in our problem statement. For each of these tasks, we add:

A unique identifier Location index Pickup quantities of both dimensions i.e. weighted goods in kgs and the number of boxes.

Following is the JSON we use in this example:

1
"jobs":"[...]"

Vehicles

Now we configure 2 pickup vans that will be responsible for fulfilling the tasks. For each of them, we specify:

  • A unique ID
  • start_index & end_index to indicate the starting and ending locations of the route
  • capacity indicating the usual storage capacity of the vehicles
  • alternative_capacities to specify combinations of alternate capacities which can be used depending on the load quantities of the tasks to be performed.

Once the vehicles and their properties are defined, the resulting vehicles JSON is:

1
"vehicles":"[...]"

The capacity configuration for each vehicle is explained below:

  • Each van under usual conditions can accommodate [5 kgs of weight + 5 boxes], as specified by capacity.
  • However, if needed, the vans can also accommodate alternate combinations of these load types. Each of them can either pick up [3 kgs of weight + 10 boxes] or they can pick up [15kgs of weight + 3 boxes], as specified by alternative_capacities.

Optimization POST Request

When all the above components are put together we get the final POST request that we will submit to the optimizer.

1
curl --location 'https://api.nextbillion.io/optimization/v2?key=<your_api_key>' --header 'Content-Type: application/json' --data '{..}'

Optimization POST Response

Once the request is made, we get a unique ID in the API response:

1
{
2
"id": "bc254dcbc7638a443badf2a8db2a0eb1",
3
"message": "Optimization job created",
4
"status": "Ok"
5
}

Optimization GET Request

We use the request ID and retrieve the result through the Optimization GET request. Following is the GET request:

1
curl --location 'https://api.nextbillion.io/optimization/v2/result?id=bc254dcbc7638a443badf2a8db2a0eb1
2
&key=<your_api_key>'

Optimization GET Response

Following is the optimized route plan:

1
{
2
"description": "Alternative Capacities Example",
3
"result": "{...}",
4
"status": "Ok",
5
"message": ""
6
}

Following image shows a visual representation of the above route plan.

documentation image

Analyzing the Solution

Looking at the result we can observe that:

  • All task were fulfilled and the total cost of the solution is 5829
  • Both vehicles were used. Vehicle 1 fulfills pickup 1 & 2 while Vehicle 2, fulfills pickup 3, 4, 5 & 6
  • We also see that alternative capacities were used for both vehicles as the usual capacities were not sufficient to fulfill all jobs.
  • For Vehicle 1, the [3,10] configuration was used and for Vehicle 2 the [15, 3] configuration was used.

The above example exhibits how NextBillion.ai’s Route Optimization Flexible API uses the alternative capacities to serve the tasks specified and suggest the best solution. We encourage you to go ahead and try out different configurations of capacities, delivery or pickup loads and explore how the solution changes under different scenarios presented to Route Optimization Flexible API.

Learn more about the other powerful features and the related use cases that Route Optimization Flexible API can solve for you.

© 2024 NextBillion.ai all rights reserved.