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

Method from_file

pyvrp/solve.py:113–136  ·  view source on GitHub ↗

Loads the solver parameters from a TOML file.

(cls, loc: str | pathlib.Path)

Source from the content-addressed store, hash-verified

111
112 @classmethod
113 def from_file(cls, loc: str | pathlib.Path):
114 """
115 Loads the solver parameters from a TOML file.
116 """
117 with open(loc, "rb") as fh:
118 data = tomllib.load(fh)
119
120 node_ops = NODE_OPERATORS
121 if "node_ops" in data:
122 node_ops = [getattr(pyvrp.search, op) for op in data["node_ops"]]
123
124 route_ops = ROUTE_OPERATORS
125 if "route_ops" in data:
126 route_ops = [getattr(pyvrp.search, op) for op in data["route_ops"]]
127
128 return cls(
129 IteratedLocalSearchParams(**data.get("ils", {})),
130 PenaltyParams(**data.get("penalty", {})),
131 NeighbourhoodParams(**data.get("neighbourhood", {})),
132 node_ops,
133 route_ops,
134 data.get("display_interval", 5.0),
135 PerturbationParams(**data.get("perturbation", {})),
136 )
137
138
139def solve(

Callers 3

_solveFunction · 0.80

Calls 6

PenaltyParamsClass · 0.90
NeighbourhoodParamsClass · 0.90
PerturbationParamsClass · 0.90
getMethod · 0.80
loadMethod · 0.45

Tested by 2