From 8cac3fb86abac97de33f1e2385bf937a6fb7028f Mon Sep 17 00:00:00 2001 From: Hugo Linsenmaier Date: Thu, 14 May 2026 06:20:17 +0000 Subject: [PATCH 1/2] Skip matrix validation check --- python/cuopt/cuopt/routing/vehicle_routing.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/cuopt/cuopt/routing/vehicle_routing.py b/python/cuopt/cuopt/routing/vehicle_routing.py index 71b276a704..6ece8eaf64 100644 --- a/python/cuopt/cuopt/routing/vehicle_routing.py +++ b/python/cuopt/cuopt/routing/vehicle_routing.py @@ -57,7 +57,7 @@ def __init__(self, n_locations, n_fleet, n_orders: int = -1): super().__init__(n_locations, n_fleet, n_orders=n_orders) @catch_cuopt_exception - def add_cost_matrix(self, cost_mat, vehicle_type=0): + def add_cost_matrix(self, cost_mat, vehicle_type=0, *, skip_validation=False): """ Add a matrix for all locations (vehicle/technician locations included) at once. @@ -84,6 +84,10 @@ def add_cost_matrix(self, cost_mat, vehicle_type=0): num_location rows and columns. vehicle_type : uint8 Identifier of the vehicle. + skip_validation : bool + If True, skips Python validation for matrix shape, NULL values, + and non-negative values. The caller is responsible for providing + a valid square matrix matching the number of locations. Examples -------- @@ -125,7 +129,8 @@ def add_cost_matrix(self, cost_mat, vehicle_type=0): if vehicle_type in self.costs: raise ValueError("Vehicle type matrix has already been added") - validate_matrix(cost_mat, "cost matrix", self.get_num_locations()) + if not skip_validation: + validate_matrix(cost_mat, "cost matrix", self.get_num_locations()) super().add_cost_matrix(cost_mat, vehicle_type) From 945ac73c5d5b96521ceea03895ddf4fe7754f364 Mon Sep 17 00:00:00 2001 From: Hugo Linsenmaier Date: Thu, 14 May 2026 15:46:07 -0700 Subject: [PATCH 2/2] Fix style --- python/cuopt/cuopt/routing/vehicle_routing.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/cuopt/cuopt/routing/vehicle_routing.py b/python/cuopt/cuopt/routing/vehicle_routing.py index 6ece8eaf64..e9d6e462d5 100644 --- a/python/cuopt/cuopt/routing/vehicle_routing.py +++ b/python/cuopt/cuopt/routing/vehicle_routing.py @@ -57,7 +57,9 @@ def __init__(self, n_locations, n_fleet, n_orders: int = -1): super().__init__(n_locations, n_fleet, n_orders=n_orders) @catch_cuopt_exception - def add_cost_matrix(self, cost_mat, vehicle_type=0, *, skip_validation=False): + def add_cost_matrix( + self, cost_mat, vehicle_type=0, *, skip_validation=False + ): """ Add a matrix for all locations (vehicle/technician locations included) at once.