VRP variants supported
Basic CVRP example
import nerox
import numpy as np
client = nerox.Client()
n_customers = 50
n_vehicles = 5
vehicle_capacity = 100
# Random demand and distance matrix
rng = np.random.default_rng(0)
demands = rng.integers(5, 25, size=n_customers + 1) # +1 for depot
demands[0] = 0 # depot has no demand
coords = rng.random((n_customers + 1, 2)) * 100
dist = np.linalg.norm(coords[:, None] - coords[None, :], axis=-1)
job = client.optimize.cvrp(
distance_matrix=dist,
demands=demands,
vehicle_capacity=vehicle_capacity,
n_vehicles=n_vehicles,
depot=0, # index of depot node
solver="gpu",
)
result = job.wait()
print(f"Total distance: {result.objective:.1f}")
for i, route in enumerate(result.routes):
print(f"Vehicle {i}: depot → {' → '.join(str(c) for c in route)} → depot")Time window constraints
# Each customer has an [earliest, latest] arrival window
time_windows = [
(0, 0), # depot: always open
(8, 12), # customer 1: must arrive between 8:00–12:00
(10, 14), # customer 2
# ...
]
job = client.optimize.cvrp(
distance_matrix=dist,
demands=demands,
vehicle_capacity=vehicle_capacity,
n_vehicles=n_vehicles,
depot=0,
time_windows=time_windows,
service_times=[0] + [15] * n_customers, # 15-min service per stop
solver="gpu",
)How NEROX encodes VRP as QUBO
Vehicle routing is internally reformulated as a QUBO by introducing binary variables x[v, c, t] = 1 if vehicle v visits customer c at position t in its route. Capacity, ordering, and depot-return constraints are encoded as quadratic penalty terms. The objective minimizes total edge cost weighted by the route assignment variables.
This formulation is handled automatically — you supply the problem parameters, and NEROX builds the QUBO, solves it on GPU, and decodes the result back into routes.
Real-world scale
NEROX handles fleet dispatch problems with up to 500 customers and 50 vehicles in a single API call. For larger instances, use the Hybrid Solver which decomposes the route assignment into geographic clusters before optimizing each cluster's tour independently.
