optymus.routing.VRPSolver

class optymus.routing.VRPSolver(distance_matrix=None, coordinates=None, demands=None, vehicle_capacity=None, num_vehicles=None, depot=0, verbose=True)[source]

Capacitated Vehicle Routing Problem solver.

Parameters:
  • distance_matrix (array-like, shape (n, n), optional) – Pairwise distance/cost matrix. Provide this OR coordinates.

  • coordinates (array-like, shape (n, 2), optional) – Node coordinates (Euclidean distances computed automatically).

  • demands (array-like, shape (n,)) – Demand at each node. demands[depot] should be 0.

  • vehicle_capacity (float) – Maximum load per vehicle.

  • num_vehicles (int, optional) – Number of vehicles. If None, uses the minimum feasible.

  • depot (int) – Index of the depot node (default 0).

  • verbose (bool) – Show progress information (default True).

__init__(distance_matrix=None, coordinates=None, demands=None, vehicle_capacity=None, num_vehicles=None, depot=0, verbose=True)[source]

Methods

__init__([distance_matrix, coordinates, ...])

solve([method, max_iter])

Solve the CVRP.

solve(method='savings', max_iter=100)[source]

Solve the CVRP.

Parameters:
  • method (str) – Algorithm to use. Currently "savings" (Clarke-Wright + 2-opt).

  • max_iter (int) – Maximum local-search improvement rounds.

Return type:

OptimizeResult