Depots

Depots are an important piece of any logistic operations and serve as a center for fulfilling customer orders. In the last mile or on-demand delivery line of businesses, depots are used to fulfill orders of multiple or single inventory types, or they can be used to serve orders within a specific area of a large city, or facilitating reverse logistics scenarios among many other functions.

NextBillion.ai’s Route Optimization Flexible API is capable of emulating real-world parameters of depot operations to solve route planning problems involving depots, efficiently. In this example we are going to solve scenarios of managing deliveries and reverse logistics using depots.

Setup

We have 4 depots which can serve orders for multiple regions and inventory types. Using these depots we want to fulfill a total of 8 orders 6 deliveries and 2 pick-ups. We use 4 delivery vans to fulfill these orders. Let’s configure each of these entities one by one below. 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{
2 "locations": "[...]"
3}

Jobs

Next, we define the 6 delivery and 2 pickup jobs in our problem statement. For these tasks we add:

  • A unique identifier for each task
  • Location indexes for each task
  • Specify depots which can fulfill each task
  • Delivery quantities for each of 6 delivery tasks and pickup quantities for each of the 2 pickup tasks

Following is the JSON we use in this example:

Depots

Next we specify the depots and their locations. These depots will be used to fulfill the tasks as per their configuration. The depot attribute used in the problem is:

1{
2 "depots": "[...]"
3}

Vehicles

Now we configure 4 delivery vans that will be responsible for fulfilling the tasks. We specify:

  • A unique ID for each vehicle
  • start_depot_ids to denote the vehicles which can fulfill the delivery tasks.
  • end_depot_ids to denote the vehicles which can fulfill the pickup tasks
  • If a vehicle can fulfill both delivery and pickup type of tasks then, we need to configure both start_depot_ids and end_depot_ids.

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

1{
2 "vehicles": "[...]"
3}

Optimization POST Request

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

1curl --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": "4ce63ea6eceee3eb70eb4d21437ddf94",
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:

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

Optimization GET Response

Following is the optimized route plan:

1{
2 "description": "Depots Example",
3 "result": '{...}'
4}

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

docs-image

Analyzing the Solution

Looking at the result we can observe that:

  • All task were fulfilled and the total cost of the solution is 2949
  • Vehicles starting from depot 1 and depot 2 fulfilled 2 delivery tasks each
  • Vehicles starting from depot 3 & 4 completed 1 delivery and 1 pickup each and returned to the specified depot with the picked-up goods.

The above example exhibits how NextBillion.ai’s Route Optimization Flexible API uses the depots to serve the tasks provided and suggests the best solution. We encourage you to go ahead and try out different configurations of depots, delivery and pickup tasks 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.