mamut_routing_lib.solvers.run¶
Run any registered solver on one instance and check its routes.
run_solver is the one entry point the CLIs, the tools GUI and campaign
runners share:
- load the instance (static or time-dependent) unless it is given;
- pick the objective (
objectives.default_objectivewhen none is given); - refuse an unavailable solver (
SolverUnavailableError) or an instance the solver cannot take (InstanceNotSupportedError), before any work; - solve, with the monitor's clock restarted and its budget set;
- price the routes with the reference checker (
solutions.check_routes).
The checker's verdict and cost are authoritative; the solver's own cost is kept
in the result for information. Storing a BKS is the caller's decision
(solutions.submit_bks / bks.save_solution_as_bks_if_improved), so that a
campaign can keep a single writer per instance.
BKS_PROVENANCE_KEYS
module-attribute
¶
BKS_PROVENANCE_KEYS = (
"method",
"solver",
"solver_version",
"seed",
"time_limit_s",
"wall_time",
"solver_cost",
"solver_report",
"machine",
"vehicle_penalty",
"executable_sha256",
"input_sha256",
)
CheckedSolve
dataclass
¶
CheckedSolve(
result: SolveResult,
check: Any | None,
objective: ObjectiveFunction,
instance_path: Path,
instance_name: str,
support_warnings: tuple[str, ...] = (),
extra: dict[str, Any] = dict(),
checkable: Any = None,
)
A solver result plus the reference checker's verdict on its routes.
checkable
class-attribute
instance-attribute
¶
to_solution
¶
The routes as a BenchmarkSolution (cost left to the checker).
Source code in MAMUT-routing-lib/src/mamut_routing_lib/solvers/run.py
bks_metadata
¶
Provenance for a BKS built from this solve (no hostname: BKS files are published).
The keys are :data:BKS_PROVENANCE_KEYS. extra adds keys of the caller (a campaign
name, a run key); it cannot replace a provenance key or set a key of the BKS store.
Source code in MAMUT-routing-lib/src/mamut_routing_lib/solvers/run.py
to_json
¶
A JSON-ready summary: the checker's verdict next to the solver result.
Source code in MAMUT-routing-lib/src/mamut_routing_lib/solvers/run.py
prepare_solve
¶
prepare_solve(
solver: str | Solver,
instance_path: str | Path,
*,
objective_function: ObjectiveFunction | None = None,
instance: Any = None,
config: Any = None,
) -> tuple[Solver, Any, ObjectiveFunction, tuple[str, ...]]
Resolve and vet a solve without running it: (solver, instance, objective, support warnings).
Raises SolverUnavailableError or InstanceNotSupportedError with the reasons.
Source code in MAMUT-routing-lib/src/mamut_routing_lib/solvers/run.py
run_solver
¶
run_solver(
solver: str | Solver,
instance_path: str | Path,
*,
time_limit_s: float,
seed: int = 42,
objective_function: ObjectiveFunction | None = None,
instance: Any = None,
monitor: SolveMonitor | None = None,
initial_routes: list[list[int]] | None = None,
workdir: str | Path | None = None,
keep_artifacts: bool = False,
display: bool = False,
options: Mapping[str, Any] | None = None,
config: Any = None,
) -> CheckedSolve
Solve the instance at instance_path with solver (a name or a Solver) and check it.