Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bind/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ void init_input(py::module_ &m) {
"Solve routing problem",
py::arg("nb_searches"), py::arg("depth"), py::arg("nb_threads"), py::arg("timeout")
)
.def("check", &vroom::Input::check, "Check solution feasibility", py::arg("nb_thread") = 1);
.def("_check", &vroom::Input::check, "Check solution feasibility", py::arg("nb_thread") = 1);
}
27 changes: 27 additions & 0 deletions src/vroom/input/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,33 @@ def set_costs_matrix(
matrix_input = _vroom.Matrix(numpy.asarray(matrix_input, dtype="uint32"))
self._set_costs_matrix(profile, matrix_input)

def check(
self,
nb_threads: int = 1,
) -> Solution:
"""Check predefined vehicle routes and compute ETAs.

Validates the feasibility of predefined vehicle steps
(plan mode) and sets estimated times of arrival for each
step. Returns a full Solution with routes, arrivals, and
any violations.

Vehicles must have predefined steps (``VehicleStep``)
assigned before calling this method.

Args:
nb_threads:
The number of threads to use.

Returns:
A Solution containing per-step ETAs and any
violations.
"""
solution = Solution(self._check(nb_thread=int(nb_threads)))
solution._geometry = self._geometry
solution._distances = self._distances
return solution

def solve(
self,
exploration_level: int,
Expand Down
8 changes: 7 additions & 1 deletion test/test_libvroom_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,10 @@ def test_plan_mode_check():
],
),
])
assert problem_instance.check(), "no feasible route possible."
solution = problem_instance.check()
assert solution, "no feasible route possible."
routes = solution.routes
assert not routes.empty, "check() should return routes with ETAs"
assert "arrival" in routes.columns
assert "duration" in routes.columns
assert set(routes["vehicle_id"].unique()) == {7, 8}
Loading