Kuifje02 / vrpy

A python framework for solving the VRP and its variants with column generation.
MIT License
173 stars 42 forks source link

best_routes_type returns invalid type ? #110

Closed Kuifje02 closed 3 years ago

Kuifje02 commented 3 years ago

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}’?

Kuifje02 commented 3 years ago

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

https://github.com/Kuifje02/vrpy/blob/96cc5501d05c341cc50f4377d15f27fbf422584a/vrpy/vrp.py#L897-L901

Initial route should be created only if feasible.