mamut_routing_lib.solvers.external.adapter¶
ExternalSolver: run a described solver executable on a library instance.
One solve, in order:
- hydrate the instance (collection matrices from their sidecars) and refuse what the solver cannot take: depot not at index 0, asymmetric costs for a symmetric solver, demands or distances beyond its limits;
- pick the integer scale (
scaling) and write the input files with fixed names into the work directory (problem.vrp,problem.par); - run the executable (
process): own process group, budget + grace, cooperative stop through the monitor, progress lines as live incumbents; - read the solution file (
solutionsparsers), map its ids onto the library's, and check an integer cost report against the weights in the exported matrix.
The routes still go through the reference checker afterwards
(solvers.run.run_solver): a solver's own cost is never trusted.
PreparedInput
dataclass
¶
PreparedInput(
workdir: Path,
problem: Path,
params: Path | None,
solution: Path,
plan: ScalePlan,
vehicles: int | None,
fixed_fleet: int | None,
problem_type_line: str,
checkable: Any,
)
Input files written for one run, and how the data was scaled.
ExternalSolver
¶
A Solver backed by an executable described by an ExternalSolverDescriptor.
Source code in MAMUT-routing-lib/src/mamut_routing_lib/solvers/external/adapter.py
resolve_executable
¶
(absolute executable, jar or Python script, reason when missing).
A Python solver names its script in executable. Without one, its argv names a module or a
script by itself, and this is the interpreter that runs it.
Source code in MAMUT-routing-lib/src/mamut_routing_lib/solvers/external/adapter.py
solver_file
¶
The file that is the solver: the native executable, the jar, or the script of a Python solver.
None for a Python solver that names no script: the interpreter is not the solver, and its
hash would say nothing about the code that ran.
Source code in MAMUT-routing-lib/src/mamut_routing_lib/solvers/external/adapter.py
availability
¶
Source code in MAMUT-routing-lib/src/mamut_routing_lib/solvers/external/adapter.py
supports
¶
prepare
¶
Write the solver's input files into workdir; raises InstanceNotSupportedError.
Source code in MAMUT-routing-lib/src/mamut_routing_lib/solvers/external/adapter.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
build_argv
¶
solve
¶
Source code in MAMUT-routing-lib/src/mamut_routing_lib/solvers/external/adapter.py
find_on_path
¶
(the command name on PATH, or a hit that only a relative PATH entry gives).
Only the absolute entries of PATH are searched. A relative entry (., an empty one, bin)
is the working directory, which the solvers config never reads on purpose: a file called
filo2 in a benchmark tree would run, and be credited, as the solver. Such a hit is
returned apart, for the message that says why the solver is not available.