MCPcopy Create free account
hub / github.com/PyVRP/PyVRP / _solve

Function _solve

pyvrp/cli.py:72–152  ·  view source on GitHub ↗

Solves a single VRPLIB instance. Parameters ---------- data_loc Filesystem location of the VRPLIB instance. round_func Rounding function to use for rounding non-integral data. Argument is passed to ``read()``. seed Seed to use for the RNG.

(
    data_loc: Path,
    round_func: str,
    seed: int,
    max_runtime: float,
    max_iterations: int,
    no_improvement: int,
    per_client: bool,
    stats_dir: Path | None,
    sol_dir: Path | None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

70
71
72def _solve(
73 data_loc: Path,
74 round_func: str,
75 seed: int,
76 max_runtime: float,
77 max_iterations: int,
78 no_improvement: int,
79 per_client: bool,
80 stats_dir: Path | None,
81 sol_dir: Path | None,
82 **kwargs,
83) -> tuple[str, str, float, int, float]:
84 """
85 Solves a single VRPLIB instance.
86
87 Parameters
88 ----------
89 data_loc
90 Filesystem location of the VRPLIB instance.
91 round_func
92 Rounding function to use for rounding non-integral data. Argument is
93 passed to ``read()``.
94 seed
95 Seed to use for the RNG.
96 max_runtime
97 Maximum runtime (in seconds) for solving.
98 max_iterations
99 Maximum number of iterations for solving.
100 no_improvement
101 Maximum number of iterations without improvement.
102 per_client
103 Whether to scale stopping criteria values by the number of clients.
104 stats_dir
105 The directory to write runtime statistics to.
106 sol_dir
107 The directory to write the best found solutions to.
108
109 Returns
110 -------
111 tuple[str, str, float, int, float]
112 A tuple containing the instance name, whether the solution is feasible,
113 the solution cost, the number of iterations, and the runtime.
114 """
115 if kwargs.get("config_loc"):
116 params = SolveParams.from_file(kwargs["config_loc"])
117 else:
118 params = SolveParams()
119
120 data = read(data_loc, round_func)
121
122 if per_client:
123 max_runtime *= data.num_clients
124 max_iterations *= data.num_clients
125 no_improvement *= data.num_clients
126
127 stop = MultipleCriteria(
128 [
129 MaxRuntime(max_runtime),

Callers

nothing calls this directly

Calls 13

SolveParamsClass · 0.90
readFunction · 0.90
MultipleCriteriaClass · 0.90
MaxRuntimeClass · 0.90
MaxIterationsClass · 0.90
NoImprovementClass · 0.90
solveFunction · 0.90
write_solutionFunction · 0.85
getMethod · 0.80
from_fileMethod · 0.80
to_csvMethod · 0.80
is_feasibleMethod · 0.80

Tested by

no test coverage detected