mamut_routing_lib.models¶
Pydantic models of the static benchmark contract (CVRP, VRPTW).
Every artifact is validated on load with extra="forbid": an instance file
(BenchmarkInstance for VRPTW, BenchmarkInstanceCVRP for CVRP, both
with an embedded (n+1) x (n+1) arc_costs matrix), a slim collection
instance (BenchmarkInstanceCVRPCollection / BenchmarkInstanceVRPTWCollection,
whose matrix comes from an arc_costs_source: a sha-pinned distances
sidecar or the euclidean rule), a solution (BenchmarkSolution), a
best-known solution (BenchmarkBKS, a solution plus its objective) and
an optimality claim (OptimalityMetadata, validated inside
metadata["optimality"]). Node index 0 is the depot unless depot says
otherwise; customers are 1..num_customers. Time-dependent instances live
in mamut_routing_lib.td.models.
AnyArcCostsSource
module-attribute
¶
AnyArcCostsSource = Annotated[
ArcCostsDistancesRef | ArcCostsEuclidean,
Field(discriminator="model"),
]
AnyCollectionStaticInstance
module-attribute
¶
AnyCollectionStaticInstance = (
BenchmarkInstanceCVRPCollection
| BenchmarkInstanceVRPTWCollection
)
ArtifactPaths
¶
Bases: BaseModel
Repository-relative paths of the four artifacts of a generated instance (.vrp.json, .vrp, meta, manifest).
validate_relative_paths
classmethod
¶
InstanceMetadata
¶
Bases: BaseModel
Structured metadata of a generated (OSM-derived) instance.
Historic families carry a free-form dict instead; artifacts.has_structured_metadata
tells the two apart. num_vehicles_lb is the bin-packing lower bound on the
route count that the -k<K> name suffix advertises.
sibling_variant_paths
class-attribute
instance-attribute
¶
derived_problem_paths
class-attribute
instance-attribute
¶
source_problem_paths
class-attribute
instance-attribute
¶
validate_path_map
classmethod
¶
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/models.py
validate_num_vehicles_lb
classmethod
¶
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/models.py
ReferenceLLA
¶
BenchmarkInstance
¶
Bases: _InstanceValidationMixin
A VRPTW instance with an embedded arc-cost matrix.
Adds per-node service_times and time_windows ([ready, due],
depot included) to the CVRP core. Historic families (Sintef2008, Dimacs2021,
Ortec2022) and hydrated collection instances use this model; the checker
prices waiting at ready and rejects arrival after due.
metadata
class-attribute
instance-attribute
¶
metadata: InstanceMetadata | dict[str, Any] = Field(
default_factory=dict, union_mode="left_to_right"
)
validate_vrptw_node_vector_lengths
classmethod
¶
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/models.py
from_legacy_dict
classmethod
¶
Build a BKS from the pre-contract dict shape (routes + cost) under objective_function.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/models.py
BenchmarkInstanceCVRP
¶
Bases: _InstanceValidationMixin
A CVRP instance with an embedded arc-cost matrix (no service times, no time windows).
metadata
class-attribute
instance-attribute
¶
metadata: InstanceMetadata | dict[str, Any] = Field(
default_factory=dict, union_mode="left_to_right"
)
ArcCostsDistancesRef
¶
ArcCostsEuclidean
¶
Bases: BaseModel
Arc costs materialized from the instance coordinates on load.
The canonical definition is round(hypot(dx, dy), decimals) on the
stored ENU coordinates (IEEE-754 doubles, Python round-half-to-even), so
no sidecar is needed for the euclidean metric variant.
validate_decimals
classmethod
¶
BenchmarkInstanceCVRPCollection
¶
Bases: _SlimInstanceValidationMixin
Slim CVRP instance of a family-first collection: arc costs by arc_costs_source, see artifacts.hydrate_collection_instance.
BenchmarkInstanceVRPTWCollection
¶
Bases: _SlimInstanceValidationMixin
Slim VRPTW instance of a family-first collection (service times and windows may be floats; hydration requires integers).
validate_vrptw_node_vector_lengths
classmethod
¶
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/models.py
validate_time_windows
classmethod
¶
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/models.py
OptimalityMetadata
¶
Bases: BaseModel
Structured record of an optimality proof, stored under metadata["optimality"].
The stamp asserts that the stored solution's cost is a proven optimum. The required fields identify the claim (who proved it, under which caveats, when); the optional fields carry the proof numerics and provenance. All free-text fields must be self-contained — meaningful to an external reader of the benchmark repository without access to any private context.
BenchmarkSolution
¶
Bases: _SolutionValidationMixin
A candidate solution: elementary routes of positive customer ids, optional cost.
cost may be None (the checker prices the routes) or the exact expected
value (the checker then reports objective_value_mismatch on any deviation).
BenchmarkBKS
¶
Bases: _SolutionValidationMixin
A best-known solution: a solution plus the objective_function it is best under.
Stored as <base>.bks.<ObjectiveFunction>.json next to the instance and
written only through mamut_routing_lib.bks (checker cost, mandatory
metadata.authors, replace-only-if-strictly-better).
from_legacy_dict
classmethod
¶
from_legacy_dict(
legacy_bks: dict[str, Any],
objective_function: ObjectiveFunction,
) -> "BenchmarkBKS"