RoutingInstance

class RoutingInstance(name='', comment='', problem_type='CVRP', dimension=0, capacity=0, n_vehicles=1, coords=<factory>, demands=<factory>, depot=0, cost_matrix=<factory>, optimal_cost=None)[source]

Bases: object

Parsed VRP/TSP instance data.

Variables:
  • name – Instance name from the file header.

  • comment – Instance comment (may contain optimal cost).

  • problem_type"CVRP" or "TSP".

  • dimension – Total number of nodes (including depot).

  • capacity – Vehicle capacity (CVRP only, 0 for TSP).

  • n_vehicles – Number of vehicles (extracted from name -kN pattern or from comment, 1 for TSP).

  • coords – Node coordinates, shape (dimension, 2).

  • demands – Node demands, shape (dimension,). Depot demand is 0.

  • depot – Depot node index (0-based).

  • cost_matrix – Euclidean distance matrix, shape (dimension, dimension).

  • optimal_cost – Optimal cost from comment, if available.

Attributes Summary

Attributes Documentation

capacity: int = 0
comment: str = ''
coords: ndarray[tuple[Any, ...], dtype[float64]] = <dataclasses._MISSING_TYPE object>
cost_matrix: ndarray[tuple[Any, ...], dtype[float64]] = <dataclasses._MISSING_TYPE object>
demands: ndarray[tuple[Any, ...], dtype[float64]] = <dataclasses._MISSING_TYPE object>
depot: int = 0
dimension: int = 0
n_customers

Number of customers (excluding depot).

n_vehicles: int = 1
name: str = ''
optimal_cost: float | None = None
problem_type: str = 'CVRP'