Skip to content

use_all_vehicles = True results in 'problem Infeasible' #147

@prasanik

Description

@prasanik

The below code is set up to have 4 nodes with 10 each as demand. It also has 4 vehicles with 10 capacity each. vrpy returns 4 routes as expected.. 1 node per route. But if you uncomment the line prob.use_all_vehicles, it results in error of problem infeasible. But as we have seen, when we run the code without this line, it does actually end up using all vehicles.

from networkx import DiGraph
from vrpy import VehicleRoutingProblem
import networkx as nx

def run():
    G = DiGraph()
    for v in [1, 2,3,4]:
           G.add_edge("Source", v, cost=[10, 11, 10, 10])
           G.add_edge(v, "Sink", cost=[10, 11, 10, 10])
           G.nodes[v]["demand"] = 10
    G.add_edge(1, 2, cost=[10, 11, 10, 10])
    G.add_edge(2, 3, cost=[10, 11, 10, 10])
    G.add_edge(3, 4, cost=[15, 16, 10, 10])
    
    nx.draw_networkx(G)

    prob=VehicleRoutingProblem(G, mixed_fleet=True, load_capacity=[10, 10, 10, 10])
    prob.num_vehicles = [1,1,1,1]
    #prob.use_all_vehicles=True
    prob.solve(time_limit=60)
    a = prob.best_value
    a = prob.best_routes
    a = prob.best_routes_type
    print(a)

run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions