PyVRP / VRPLIB

Python package to read and write vehicle routing problem instances.
https://github.com/PyVRP/VRPLIB
MIT License
84 stars 8 forks source link

Verification functions #27

Closed leonlan closed 1 year ago

leonlan commented 1 year ago

It would be nice to provide functions that can verify any VRP-type solution. Of course, we need to make a verification function for each type of VRP-type problem.

I have no idea yet how the interface will look like. But here's an idea:

from cvrplib import read_instance, read_solution, verify

instance = read_instance(instance_path)
solution = read_solution(solution_path)

# Pass the solution and all relevant instance attributes
verify.cvrp(solution, instance['capacity']) 
verify.vrptw(solution, instance['capacity'], instance['duration_matrix'], instance['time_windows'])
leonlan commented 1 year ago

I propose a more user-friendly interface:

verify(solution, instance, type=‘cvrp’) # verify CVRP solution
verify(solution, instance, type=‘vrptw’) # verify VRPTW solution

It’s not as explicit as the one I proposed before. But it’s way easier to use.

We should allow the first argument to be a file path or an actual solution object, and idem for the second argument.

leonlan commented 1 year ago

In the verify module, we can write modular verification functions for each constraint.

leonlan commented 1 year ago

I'm in doubt whether this library should support verification of solutions. It may be doable for classical VRP variants, such as CVRP and VRPTW, but I don't know if it's feasible for other variants.

leonlan commented 1 year ago

I have decided that this and #51 is not something we will support. Our library focuses on input/output of VRPLIB instances. Validating the instance content is outside the scope of this library.