Multiple trips to a depot

Depots or fulfillment centers are a key component in industries like e-commerce, retail deliveries. They are critical for order processing, and storage of goods while helping businesses manage the inventory efficiently and ensure quick and accurate delivery to customers. In such operations, it is quite common for vehicles to make repeat trips to the depots throughout the day to pick-up inventory for the next round of deliveries. The repeated trips can be due to multiple reasons like limited number of vehicles or their limited capacity, incompatible types of goods or bulk orders among others.

NextBillion.ai’s Route Optimization Flexible API can easily model such an operation using its shipments property and generate an optimized route plan to complete all the deliveries across by making multiple trips back to a designated depot.

Setup

In this example we will deliver 7 orders using a single 1 vehicle. Each shipment has to be picked from a given location (designated depot) and then delivered to its respective drop-off location. Also, the capacity of the available vehicle is such that it can’t accommodate more than 3 orders at a time.

Let’s configure the locations, shipments, and vehicles one by one in the following sections to model this business problem.

Locations

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

1
"locations": {
2
"id": 1,
3
"location": [
4
"34.04118314,-118.24377960",
5
"34.05248264,-118.25345384",
6
"34.04890945,-118.25881547",
7
"34.04456349,-118.26277841",
8
"34.03674018,-118.25811613",
9
"34.03374589,-118.25333728",
10
"34.02959234,-118.24611074",
11
"34.04736425,-118.23375569"
12
]
13
}
1
"locations": "{...}"

Shipments

Next, we define the 7 shipments in our problem statement. For each of these shipments, we add:

  • A unique identifier for both steps
  • Respective location index for both steps. Since we have all the pickups to be performed at the given depot, the location index for all pickup steps would be the same
  • Service time to perform the pickup and delivery steps
  • Quantities of the load to be delivered

Following is the JSON we use in this example:

1
"shipments": "[...]"

Vehicles

Now we configure the delivery vehicle that will complete these shipments. For the given vehicle, we specify:

  • A unique ID
  • start_index & end_index to indicate the starting and ending locations of the route. We will configure both locations to be the same as the depot location.
  • capacity of the vehicle

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

1
"vehicles": [
2
{
3
"id": 1,
4
"start_index": 0,
5
"end_index": 0,
6
"capacity": [
7
3
8
]
9
}
10
]
11

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
{
2
"description": "Multiple Trips to Depot",
3
"locations": "{...}",
4
"shipments": "[...]",
5
"vehicles": "[...]"
6
}

Optimization POST Response

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

1
{
2
"id": "9eb9904a8b5dbdfa7167dab60d00bbd9",
3
"message": "Optimization job created",
4
"status": "Ok",
5
"warning": [
6
"location_index[0] is used for both pickups/deliveries as well as vehicle start/end"
7
]
8
}

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=9eb9904a8b5dbdfa7167dab60d00bbd9&key=<your_api_key>'

Optimization GET Response

Following is the optimized route plan:

1
{
2
"description": "Multiple Trips to Depot",
3
"result": "{...}",
4
"status": "Ok",
5
"message": ""
6
}

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

Route plan for vehicle making multiple trips to depot

Analyzing the Solution

Looking at the result we can observe that:

  • All task were fulfilled and the total cost of the solution is 2779
  • Vehicle 1 makes multiple trips back to the depot location. After being loaded to full capacity at the start, the vehicle comes back to the depot to load goods another couple of times.

The above example exhibits how NextBillion.ai’s Route Optimization Flexible API models the conventional depot or a fulfillment center scenarios where the vehicles make multiple trips back to the center to complete all deliveries following an optimized route plan. We encourage you to go ahead and try out different configurations of vehicle 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.