mamut_routing_lib.td.igp¶
IGP (Ichoua-Gendreau-Potvin 2003) engine for the igp-profile td model.
Three responsibilities:
- The exact IGP -> arrival-time NDCPWLF consolidation (
ichoua_travel_time -
build_arc_atf) -- the robust-marching construction previously maintained in the tdvrptw-workspace migration scripts (igp_atf.py), promoted here as the single source of truth. Breakpoints sit exactly where the departure or the arrival crosses a speed-zone boundary, each re-evaluated with the exact forward Ichoua loop so there is no drift; a degenerate-boundary skip and an ulp-scale monotone clamp harden the marching (byte-identical to the strict construction wherever that one validates, e.g. all of Dabia2013). -
The arc-category sidecar (
<Base>.igp.json[.gz], formatmamut-td-igp-categories): an explicit symmetric category matrix stored as digit strings, hashed over its uncompressed canonical JSON bytes like every other TD sidecar. -
The deterministic materialization of the canonical
InstanceATFsfrom anigp-profileinstance: Euclidean distancessqrt(dx*dx + dy*dy)from the instance coordinates, onebuild_arc_atfper arc of the complete graph, and a fixed materializergeneratorconstant so the resultingatf_sha256is reproducible from the published data alone.
IGP_MATERIALIZER_GENERATOR
module-attribute
¶
IGPFormatError
¶
Bases: ValueError
Raised when an IGP categories sidecar violates the canonical format.
InstanceCategories
dataclass
¶
InstanceCategories(
base_name: str,
benchmark_name: str,
num_customers: int,
num_categories: int,
categories: list[str],
generator: dict[str, Any] = dict(),
format_version: int = IGP_CATEGORIES_FORMAT_VERSION,
)
In-memory content of an IGP categories sidecar.
categories holds num_customers + 1 digit strings of the same
length; categories[i][j] is the category of arc (i, j). The matrix
is symmetric with a fixed '0' diagonal (self-arcs do not exist; the
value is never read).
ichoua_travel_time
¶
Exact forward IGP loop; last-zone speed extended beyond the horizon.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/td/igp.py
build_arc_atf
¶
Exact PWL arrival function: breakpoints at every zone-boundary crossing.
Zone bounds are coerced to floats: canonical ATF breakpoints must be
serialized as JSON floats (1080.0), and integer zone bounds would
otherwise leak python ints into xs and break the write/reload sha256
round-trip (1080 vs 1080.0).
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/td/igp.py
categories_to_canonical_json_bytes
¶
Serialize to the canonical JSON bytes (the input of categories_sha256).
Fixed key order, one category row per line, gzip-independent.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/td/igp.py
compute_categories_sha256
¶
save_instance_categories
¶
Write the sidecar; gzip iff the path ends with .igp.json.gz (mtime=0).
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/td/igp.py
load_instance_categories
¶
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/td/igp.py
euclidean_distance
¶
Canonical distance of the igp-profile model: sqrt(dx*dx + dy*dy).
IEEE-754 binary64 with correctly rounded sqrt -- fully deterministic,
and bit-identical to the stored Sintef2008 arc_costs on integer G&H
coordinates.
Source code in MAMUT-routing-tools/MAMUT-routing-lib/src/mamut_routing_lib/td/igp.py
materialize_instance_atfs
¶
materialize_instance_atfs(
instance: AnyTDBenchmarkInstance,
categories: InstanceCategories,
) -> "InstanceATFs"
Build the canonical complete-graph InstanceATFs of an igp-profile instance.