Kuifje02/vrpy

best_routes_type returns invalid type ?

Kuifje02 opened this issue · 1 comments

I am having trouble with determining vehicle type by route.

I solved the problem below:


from networkx import DiGraph

G = DiGraph()

G.add_edge("Source", 1, cost=[1, 2])

G.add_edge("Source", 2, cost=[2, 4])

G.add_edge(1, "Sink", cost=[0, 0])

G.add_edge(2, "Sink", cost=[2, 4])

G.add_edge(1, 2, cost=[1, 2])

G.nodes[1]["demand"] = 13

G.nodes[2]["demand"] = 13

prob = VehicleRoutingProblem(G, mixed_fleet=True, load_capacity=[10, 15])

when I print out ‘prob.best_route’ and ‘prob.best_routes_type’, I get:

Best routes:  {1: ['Source', 1, 'Sink'], 2: ['Source', 2, 'Sink']}

Route type:  {1: 0, 2: 0}

As you can see, all the routes type have value ‘0’, which would mean that the routes used vehicle 1 with capacity 10. But this would not be possible since vehicles of type ‘0’ cannot handle a demand of 13 for node 1 and 2. Should I be seeing ‘Route type: {1: 1, 2: 1}’?

The way initial routes are created is too permissive with respect to load capacity:

vrpy/vrpy/vrp.py

Lines 897 to 901 in 96cc550

def _convert_initial_routes_to_digraphs(self):
"""
Converts list of initial routes to list of Digraphs.
By default, initial routes are computed with vehicle type 0 (the first one in the list).
"""

Initial route should be created only if feasible.