mamut_routing_lib.checker¶
The static solution checker: the authority on what a CVRP/VRPTW solution costs.
check_solution validates a solution against an embedded-matrix instance
(customer indices, single service, capacity, time windows with waiting at
ready and hard due dates, fleet size) and prices it by summing the
instance's arc_costs along each route, depot to depot, in plain Python
arithmetic (ints stay ints, floats accumulate left to right). Every stored BKS
cost is this value. Slim collection instances must be hydrated first
(artifacts.hydrate_collection_instance); time-dependent instances use
mamut_routing_lib.td.checker.
is_better_solution defines the order of each objective: MonoCost,
Duration and FleetCostDuration compare the cost alone,
HierarchicalVehicleCost compares the route count first.
SolutionCheckStatus
¶
Bases: str, Enum
Outcome of a check: valid or the first violation met, in route order.
The checker stops at the first violation, so a solution with several defects
reports only one. route_timing_infeasible is reserved for the
time-dependent checker.
INVALID_CUSTOMER_INDEX
class-attribute
instance-attribute
¶
CUSTOMER_SERVED_MULTIPLE_TIMES
class-attribute
instance-attribute
¶
VEHICLE_CAPACITY_EXCEEDED
class-attribute
instance-attribute
¶
TIME_WINDOW_VIOLATED
class-attribute
instance-attribute
¶
NOT_ALL_CUSTOMERS_SERVED
class-attribute
instance-attribute
¶
TOO_MANY_VEHICLES_USED
class-attribute
instance-attribute
¶
OBJECTIVE_VALUE_MISMATCH
class-attribute
instance-attribute
¶
ROUTE_TIMING_INFEASIBLE
class-attribute
instance-attribute
¶
SolutionCheckResult
¶
Bases: BaseModel
Status plus, when valid, the priced routing_cost and num_routes; error_message explains a rejection.
is_valid
¶
make_invalid
classmethod
¶
A rejection with status and a human-readable error_message.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/checker.py
make_valid
classmethod
¶
A valid result carrying the priced cost and route count.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/checker.py
compute_route_cost
¶
Cost of one route: depot -> route[0] -> ... -> route[-1] -> depot over instance.arc_costs (no feasibility check).
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/checker.py
compute_solution_cost
¶
compute_solution_cost(instance: AnyBenchmarkInstance, solution_or_routes: BenchmarkSolution | BenchmarkBKS | list[list[int]]) -> int | float
Sum of compute_route_cost over the routes of a solution, BKS or plain route list.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/checker.py
check_cvrp_solution
¶
check_cvrp_solution(instance: BenchmarkInstanceCVRP, solution: BenchmarkSolution | BenchmarkBKS) -> SolutionCheckResult
Validate and price a solution on a CVRP instance (capacity, coverage, fleet; no timing).
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/checker.py
check_vrptw_solution
¶
check_vrptw_solution(instance: BenchmarkInstance, solution: BenchmarkSolution | BenchmarkBKS) -> SolutionCheckResult
Validate and price a solution on a VRPTW instance (capacity, coverage, fleet, time windows with waiting).
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/checker.py
check_solution
¶
check_solution(instance: AnyBenchmarkInstance, solution: BenchmarkSolution | BenchmarkBKS) -> SolutionCheckResult
Validate and price solution on a static instance; the single entry point.
Dispatches on the instance model. Raises TypeError for time-dependent
instances (use mamut_routing_lib.td.check_td_solution) and for slim
collection instances (hydrate them first).
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/checker.py
get_objective_tuple
¶
get_objective_tuple(routes: list[list[int]], cost: int | float, objective_function: ObjectiveFunction) -> tuple[int | float, ...]
The comparison key of a solution under objective_function: (cost,) or (num_routes, cost) for the hierarchical objective.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/checker.py
is_better_solution
¶
is_better_solution(candidate_routes: list[list[int]], candidate_cost: int | float, existing_routes: list[list[int]], existing_cost: int | float, objective_function: ObjectiveFunction) -> bool
True when the candidate strictly precedes the existing solution under objective_function (see get_objective_tuple).