Skip to content

AI Technical Articles

Why the Closest Rider Can Be the Wrong Choice for Two Orders

By Miles Park·

The closest available rider can be a sensible choice for one order. With two orders, taking the shortest first trip may leave the second rider facing a much longer trip. This worked example shows how a cost matrix makes the tradeoff visible and how to check the best assignment with SciPy.

Korean delivery company Baemin has publicly described its AI dispatch recommendation as a way to optimize the route and the broader flow from cooking to pickup to delivery. JoCoding’s video prompted this exercise. The matrix uses fictional travel times and illustrates the general assignment problem. Baemin’s public description does not identify the production solver or disclose its scoring rules.

Two riders and two orders

Cost matrix and two assignments showing a 14-minute greedy total and a 7-minute minimum total
Our figure illustrates the travel times and assignments from the worked example. The values are fictional. SciPy’s assignment solver.

Rider A can reach Order 1 in two minutes or Order 2 in three. Rider B can reach Order 1 in four minutes or Order 2 in twelve. The lowest individual cost is A to Order 1. Assigning that pair first leaves B with Order 2 and gives a total of 14 rider-minutes. Assign A to Order 2 and B to Order 1 and the total is seven. This is the sum of two trips. Both riders can travel at once.

Run the matrix in Python

import numpy as np
from scipy.optimize import linear_sum_assignment

minutes = np.array([[2, 3], [4, 12]])
riders = ["A", "B"]
orders = ["1", "2"]
selected_riders, selected_orders = linear_sum_assignment(minutes)
for rider, order in zip(selected_riders, selected_orders):
    print(f"Rider {riders[rider]} → Order {orders[order]}: "
          f"{minutes[rider, order]} min")
print("Total rider-minutes:", minutes[selected_riders, selected_orders].sum())

Output from our run

Rider A → Order 2: 3 min
Rider B → Order 1: 4 min
Total rider-minutes: 7

The solver returns the row and column indices for the chosen pairs. Indexing the matrix with both arrays extracts the two selected costs. In this square example, each rider takes one order and each order gets one rider. The SciPy function uses a modified Jonker–Volgenant algorithm to solve this assignment problem.

What the matrix leaves out

Travel time is only one possible cost. If Order 1 takes six more minutes to prepare, arrival and pickup become separate events. A dispatcher may also need to account for orders that have yet to enter the system, multiple orders on one route, forbidden pairs, rider availability or fairness. Changing the objective can change the assignment. Choose the cost you want to minimize and verify the resulting pairings against those operational constraints.

Baemin’s description of recommended dispatch · SciPy documentation · JoCoding’s assignment short

Join the discussion

Your email address will not be published. Required fields are marked *