VROOM-Project / vroom

Vehicle Routing Open-source Optimization Machine
http://vroom-project.org/
BSD 2-Clause "Simplified" License
1.31k stars 327 forks source link

Ensure request interpretation as TSP #1085

Closed cstenico closed 3 months ago

cstenico commented 4 months ago

Hello,

I've been testing VROOM with VROOM Express for the past couple of weeks. Right now, I'm looking into how requests are interpreted. I'm particularly interested in what happens when the request body doesn't include the 'amount' parameter for shipment and the 'capacity' parameter for the vehicle. Specifically, I want to confirm whether, in these cases, VROOM interprets the problem as a Traveling Salesman Problem (TSP), or if by any chance, it interprets it as a Capacitated Vehicle Routing Problem (CVRP) where the amount is zeroed and some random capacity is used.

My motivation is linked to understanding the difference between the algorithms used for each case. Having confirmation that the TSP is indeed applied will clarify which algorithm is being used for the problem.

Any insights you can offer on this matter would be greatly appreciated. Also, if this question is better suited for the VROOM repository, please let me know.

Thank you

jcoupey commented 4 months ago

TL;DR: if you only provide jobs with locations and a single vehicle without any other constraint, then the TSP code is used.

Longer version: first thing is that if you have any time window in the problem, the solve will reach for VRPTW::solve. Now if no timing is involved, we have a check inside CVRP::solve that will bypass the usual solving approach to reach for the TSP code:

https://github.com/VROOM-Project/vroom/blob/176f57a969fd2150915bdb3cdfba1607ee19e10e/src/problems/cvrp/cvrp.cpp#L150-L155

So if your input meet this check, it is guaranteed that the TSP code will be used.

jcoupey commented 4 months ago

If you're doing some benchmarking you should notice when the TSP code is used because the solutions will be usually better and faster to get than if you add, say, a non-binding capacity constraint that forces out of the TSP code.

jcoupey commented 3 months ago

Closing as answered.