Optimized Driver Assignments with Travel Cost

What is a Travel Cost?

Travel cost refers to the effort or expense associated with moving a vehicle from one location to another, typically measured in terms of either distance or duration. In the context of on-demand rides and deliveries, minimizing this cost — especially when vehicles are traveling empty (e.g., en route to the next pickup) — can result in significant operational benefits.

The Driver Assignment API gives you the flexibility to specify whether distance or duration is more important when calculating travel cost. The chosen travel cost plays an important role in reducing fuel consumption, increasing the number of fulfilled orders, and ultimately delivering a better experience to customers.

How Travel Cost impacts Order Assignments?

When you submit a request to the Driver Assignment API, it evaluates all available vehicles and calculates the travel cost to each order’s pickup location using the selected cost metric — either distance or duration. The API then finalizes assignments such that the total travel cost for the fleet i.e. the combined cost for all assigned vehicles traveling to their respective pickups, is minimized. This ensures a more efficient dispatching strategy across the board.

It’s important to note that travel cost is not the only factor in the decision-making process. Assignments are also influenced by any attribute-based constraints, ongoing trip details (via remaining_waypoints), and any filter conditions (such as maximum acceptable ETA to pickup) defined in the input payload.

Following is a sample travel_cost configuration for setting driving distance as the metric for determining traveling cost.

1
{
2
"options": {
3
"travel_cost":"driving_distance"
4
}
5
}

Example: API Request with Travel Costs

To optimize assignments based on travel cost, you must explicitly configure the travel_cost field inside the options object. The example below sets it to “driving_eta”, which means that the API will prefer assignments that minimize the total time taken by vehicles to reach pickup locations.

Sample Request

1
curl --location 'https://api.nextbillion.io/optimization/driver-assignment/v1?key=<you_api_key>' --header 'Content-Type: application/json' --data '{
2
"filter": {...},
3
"orders": {...},
4
"vehicles": {...}
5
}

Sample Response

1
{
2
"status": 200,
3
"result": {
4
"trips": "[...]",
5
"unassigned_orders": "[...]",
6
"available_vehicles": null
7
}
8
}

We can see that the API response returns trip assignments for four of the five orders. Each trip includes a vehicle, the assigned order, and key travel metrics such as ETA and distance to pickup. In this case:

  • Four vehicles are assigned to four orders based on lowest driving ETA to the pickup.

  • Order 2 remains unassigned because no vehicle could reach it within the allowed ETA threshold (pickup_eta: 900 seconds).

Each trip shows the calculated ETA (in seconds) and distance (in meters) to the pickup. The assignments reflect how minimizing travel time improves efficiency by reducing empty miles and ensuring timely pickups.

Check out all the advanced features of Driver Assignment API and learn how to leverage them for fast, efficient on-demand order fulfillment.

© 2025 NextBillion.ai all rights reserved.