added vroom support
This PR adds support for Vroom's optimization by
- adding a new
Vroomrouter class with anoptimizationmethod - porting objects from Vroom's API to Python classes (in
routingpy.optimization.py)
~~Tests are still missing at this point.~~
looks good @chrstnbwnkl . it's fine for now to stay as close to vroom api as you did for the object model.
just a couple of things regarding type hinting need to be fixed. I generally prefer the way to put type hints directly into the def signature when you're defining the arguments. here is the old way, also fine and maybe even better for very long type hints:
https://github.com/gis-ops/routing-py/blob/185bf65acffca7f16c179291388065245c2f791f/routingpy/routers/valhalla.py#L173
Good point re type hinting, I thought it might be best to leave it in the rst type docstrings, since that's the way this has previously been dealt with in routingpy, but I completely agree that we should use proper type hinting instead!
you can run vroom binary locally, without relying on crappy vroom-express api
class VroomException(Exception):
pass
def solve(problem: vroom_problem.Definition, search_time_limit_ms: int = None) -> vroom_solution.Solution:
cmd = ['vroom']
if search_time_limit_ms is not None:
cmd.append('-l')
cmd.append(str(int(search_time_limit_ms / 1000)))
solving_result = subprocess.run(cmd,
input=problem.json(exclude_none=True).encode(),
capture_output=True)
if solving_result.returncode == 0:
return vroom_solution.Solution.parse_raw(solving_result.stdout)
else:
raise VroomException(solving_result.stderr.decode().strip())
And you also can add your own time/distance matrix like here, otherwise you'll have to bother with proper router configuration
https://github.com/VROOM-Project/vroom-scripts/blob/2bd8337dacd18c9773c458559a381ce300d4fb13/src/utils/matrix.py#L33
you can run vroom binary locally
you can only do that bcs you have vroom locally installed. the vast majority doesn't. then we'd have to package vroom for every platform which is out-of-scope here. routing-py is all about HTTP. if you want local you should use a package that's designed for that, e.g. pyvroom or our pyvalhalla for local valhalla