Error with Solving Pick-Delivery Problem - source Source or target Sink is not in G
See original GitHub issueI am having trouble solving the following pickup-delivery problem. I keep getting an error saying ‘Source’ or ‘Sink’ node missing, even though I added those in the graph. Does this problem require the use of only one vehicle at a time? As you will see the source for all three deliveries is the same. Thanks.
G = DiGraph()
G.add_edge(1, 2, cost=77.67)
G.add_edge(1, 3, cost=0.0)
G.add_edge(1, 4, cost=96.61)
G.add_edge(1, 5, cost=0.0)
G.add_edge(1, 6, cost=59.03)
G.add_edge(2, 1, cost=77.67)
G.add_edge(2, 3, cost=77.67)
G.add_edge(2, 4, cost=64.85)
G.add_edge(2, 5, cost=77.67)
G.add_edge(2, 6, cost=62.2)
G.add_edge(3, 1, cost=0.0)
G.add_edge(3, 2, cost=77.67)
G.add_edge(3, 4, cost=96.61)
G.add_edge(3, 5, cost=0.0)
G.add_edge(3, 6, cost=59.03)
G.add_edge(4, 1, cost=96.61)
G.add_edge(4, 2, cost=64.85)
G.add_edge(4, 3, cost=96.61)
G.add_edge(4, 5, cost=96.61)
G.add_edge(4, 6, cost=39.82)
G.add_edge(5, 1, cost=0.0)
G.add_edge(5, 2, cost=77.67)
G.add_edge(5, 3, cost=0.0)
G.add_edge(5, 4, cost=96.61)
G.add_edge(5, 6, cost=59.03)
G.add_edge(6, 1, cost=59.03)
G.add_edge(6, 2, cost=62.2)
G.add_edge(6, 3, cost=59.03)
G.add_edge(6, 4, cost=39.82)
G.add_edge(6,5, cost=59.03)
G.add_edge("Source", 1, cost=18.03)
G.add_edge(1, "Sink", cost=18.93)
G.add_edge("Source", 2, cost=61.29)
G.add_edge(2, "Sink", cost=61.29)
G.add_edge("Source",3, cost=18.03)
G.add_edge(3,"Sink", cost=18.03)
G.add_edge("Source", 4, cost=79.92)
G.add_edge(4, "Sink", cost=79.92)
G.add_edge("Source", 5, cost=18.03)
G.add_edge(5, "Sink", cost=18.03)
G.add_edge("Source", 6, cost=44.38)
G.add_edge(6,"Sink", cost=44.38)
G.nodes[1]["request"] = 2
G.nodes[1]["demand"] = 25000
G.nodes[2]["demand"] = -25000
G.nodes[3]["request"] = 4
G.nodes[3]["demand"] = 25000
G.nodes[4]["demand"] = -25000
G.nodes[5]["request"] = 6
G.nodes[5]["demand"] = 10000
G.nodes[6]["demand"] = -10000
v_prob = VehicleRoutingProblem(G, load_capacity = 25000)
v_prob.pickup_delivery = True
v_prob.solve(cspy=False)
The following error is raised:
Traceback (most recent call last):
File "pdp.py", line 96, in <module>
v_prob.solve(cspy=False)
File "C:\Users\romain.montagne\AppData\Local\Programs\Python\Python38\lib\site-packages\vrpy\vrp.py", line 238, in solve
self._solve(dive, solver)
File "C:\Users\romain.montagne\AppData\Local\Programs\Python\Python38\lib\site-packages\vrpy\vrp.py", line 454, in _solve
self._column_generation()
File "C:\Users\romain.montagne\AppData\Local\Programs\Python\Python38\lib\site-packages\vrpy\vrp.py", line 476, in _column_generation
self._find_columns()
File "C:\Users\romain.montagne\AppData\Local\Programs\Python\Python38\lib\site-packages\vrpy\vrp.py", line 518, in _find_columns
self._more_routes = self._solve_subproblem_with_heuristic(
File "C:\Users\romain.montagne\AppData\Local\Programs\Python\Python38\lib\site-packages\vrpy\vrp.py", line 583, in _solve_subproblem_with_heuristic
more_columns = self._attempt_solve_best_edges1(vehicle=vehicle,
File "C:\Users\romain.montagne\AppData\Local\Programs\Python\Python38\lib\site-packages\vrpy\vrp.py", line 625, in _attempt_solve_best_edges1
self.routes, self._more_routes = subproblem.solve(
File "C:\Users\romain.montagne\AppData\Local\Programs\Python\Python38\lib\site-packages\vrpy\subproblem_lp.py", line 47, in solve
self._add_new_route()
File "C:\Users\romain.montagne\AppData\Local\Programs\Python\Python38\lib\site-packages\vrpy\subproblem_lp.py", line 70, in _add_new_route
"new route %s %s" % (route_id, shortest_path(new_route, "Source", "Sink"))
File "C:\Users\romain.montagne\AppData\Local\Programs\Python\Python38\lib\site-packages\networkx\algorithms\shortest_paths\generic.py", line 160, in shortest_path
paths = nx.bidirectional_shortest_path(G, source, target)
File "C:\Users\romain.montagne\AppData\Local\Programs\Python\Python38\lib\site-packages\networkx\algorithms\shortest_paths\unweighted.py", line 221, in bidirectional_shortest_path
raise nx.NodeNotFound(msg)
networkx.exception.NodeNotFound: Either source Source or target Sink is not in G
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Issue regarding CMake Error: No source given to target
The error says what it means: there are no sources for libraries. #adding entries for lib_third_party_ti_mmcsdlib ...
Read more >NPM Install fails for studio · Issue #34 - GitHub
NPM install fails for the /studio/ directory with this error: npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree
Read more >pgRouting Manual (3.0) - Crunchy Data
If your problem is unreported, create a new issue for it. ... When negative: edge (source, target) does not exist, therefore it's not...
Read more >Do Not Soak : Under-Sink Storage - Target
Shop Target for Under Sink Storage you will love at great low prices. Choose from Same Day Delivery, Drive Up or Order Pickup....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@torressa I understand why the error is raised. One of the subproblems is infeasible, and solvers don’t all handle infeasibilities the same way. CBC (the default solver) outputs a value (which is meaningless) while CPLEX (and GUROBI ?) outputs
None
.Therefore the following conditions are not strict enough, I will update them:
https://github.com/Kuifje02/vrpy/blob/88d9ea477c2a8d357d7d5a4950536a55d399595d/vrpy/subproblem_lp.py#L42-L45
Ok, thank you both! I will try with CPLEX.