Skip to content

mamut_routing_tools.generation.writers

Instance artifact writers and parsers (CVRPLIB .vrp, workbench _meta.json, _manifest.json, and the lib-contract .vrp.json payloads).

instance_path_plan

instance_path_plan(
    city: str,
    method: str,
    n_customers: int,
    route_count: int,
    output_root: str | Path,
    name_suffix: str = "",
) -> tuple[Path, str]

Folder and base name of an instance.

name_suffix disambiguates instances that would otherwise share a name -- bulk rows differing only by seed, for example. It is empty in the common case, so the established <city>_<abbr>-n<N>-k<K> naming is unchanged.

Source code in MAMUT-routing-tools/src/mamut_routing_tools/generation/writers.py
def instance_path_plan(
    city: str,
    method: str,
    n_customers: int,
    route_count: int,
    output_root: str | Path,
    name_suffix: str = "",
) -> tuple[Path, str]:
    """Folder and base name of an instance.

    ``name_suffix`` disambiguates instances that would otherwise share a name --
    bulk rows differing only by seed, for example. It is empty in the common
    case, so the established ``<city>_<abbr>-n<N>-k<K>`` naming is unchanged.
    """
    city_slug = slugify(city)
    n_nodes = n_customers + 1
    folder = Path(output_root) / "osm" / city_slug / f"n{n_nodes}"
    base = f"{city_slug}_{method_abbrev(method)}-n{n_nodes}-k{route_count}{name_suffix}"
    return folder, base