vrpy icon indicating copy to clipboard operation
vrpy copied to clipboard

Need help on adding Maximum Distance as a constraint.

Open rohitsingh30 opened this issue 2 years ago • 6 comments

Hi, We are trying to build a network design where we have heterogeneous vehicle combinations with different capacities and costs ($ per km). Issue 1: However, there is an additional constraint where we want to add maximum distance that a vehicle can travel (similar to duration (int, optional) – Maximum duration of the route. Defaults to None.). We were unable to find any parameter in the API documentation - (https://vrpy.readthedocs.io/en/latest/api.html#api) Issue 2: Further, can you please help or suggest how to add different maximum distances as a constraint for different vehicle types in the above problem statement Do let us know if you have any questions about this?

rohitsingh30 avatar Mar 22 '22 12:03 rohitsingh30

Hi, For issue 1, I suggest you use the maximum duration parameter. You can either convert the distance limit to a time limit, or set the time matrix to the distance matrix, so that the maximum duration refers to the distance matrix. For issue 2, this is not possible (yet). It would, however, be quite easy to add in a future version.

Kuifje02 avatar Mar 22 '22 12:03 Kuifje02

Cool! For #2, can you give me some high-level guidance on how it can be done? If I succeed, I'll be happy to send a PR!

rohitsingh30 avatar Mar 28 '22 13:03 rohitsingh30

Nice ! The general idea would be to have this paramater as a list, as explained in the docs here.

Kuifje02 avatar Mar 28 '22 13:03 Kuifje02

Sorry, I am not able to figure out exactly where I should be looking. While the first function call while building a solution is to the solve() method, the sequence of steps the library follows for building the solution is not clear to me. Can you please provide a high-level overview of the flow/logic?

rohitsingh30 avatar Mar 30 '22 11:03 rohitsingh30

@Kuifje02 I'm stuck with something similar as well. The idea of changing the core sounds daunting (😨) but it might be possible if I have some guidance/direction. 😅

ankush981 avatar Apr 20 '22 08:04 ankush981

The main idea is to replace the parameter by a list (instead of an integer), just like it is done for the load_capacity parameter : prob = VehicleRoutingProblem(G, mixed_fleet=True, load_capacity=[10, 15]) So the goal is to have the following: prob = VehicleRoutingProblem(G, mixed_fleet=True, load_capacity=[10, 15], duration = [50,60]) We need to make sure that the code remains consistent, everywhere where the parameter duration is called. Looking at how it is done for load_ capacity is the best option to get started.

Kuifje02 avatar Apr 20 '22 09:04 Kuifje02