or-tools: The Routing Solver "returned a result with an error set" when changing first solution algorithm
Hello. I use Python 3.7 and the or-tools I have installed is v. 7.5.7466
I am executing the Routing Solver on my data and when the First Solution algorithm is set to PATH_CHEAPEST_ARC it works like a charm. However, I am not very satisfied with the result and I tried to experiment a bit with the metaheuristics (it does not perform any better) and concluded that the problem might be with the algorithm that has been selected to find the first solution.
I tried using a number of different algorithms, for example:
- GLOBAL_CHEAPEST_ARC
- LOCAL_CHEAPEST_ARC
but it always results in the following exception:
Traceback (most recent call last):
File "/home/ross/code/python/cvrptw/cvrptw/cvrptw_model.py", line 297, in time_callback
from_node = self.manager.IndexToNode(from_index)
File "/home/ross/.local/lib/python3.7/site-packages/ortools/constraint_solver/pywrapcp.py", line 3558, in IndexToNode
return _pywrapcp.RoutingIndexManager_IndexToNode(self, index)
OverflowError: in method 'RoutingIndexManager_IndexToNode', argument 2 of type 'int64'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/ross/code/python/cvrptw/cvrptw/cvrptw.py", line 444, in <module>
manager, routing, assignment = vrp.solve()
File "/home/ross/code/python/cvrptw/cvrptw/cvrptw_model.py", line 259, in solve
self.search_parameters)
File "/home/ross/.local/lib/python3.7/site-packages/ortools/constraint_solver/pywrapcp.py", line 3928, in SolveWithParameters
return _pywrapcp.RoutingModel_SolveWithParameters(self, search_parameters, solutions)
SystemError: <built-in function RoutingModel_SolveWithParameters> returned a result with an error set
I do not think there is an error with my data as it works for a different algorithm, but I am not very sure what should I check or test. Any advise is welcome and please let me know whether you need more information. Thank you in advance.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22
I had the exact same exception, and after reading @ecotner’s comment I figured it out. I had code in my callback function that threw an exception (undefined variable).
For some reason the stack traces point to the right callback, but to the
IndexToNode
function rather than the crashing code.Hi, I was having a similar problem (getting the exact same error in RoutingIndexManager_IndexToNode), and was able to resolve it, maybe my experience will help you…
I found that the problem was that my callback was referencing a variable that didn’t exist in the scope (it was an attribute of my wrapper class). Relevant snippet here:
where I made the replacement
data
->self.data
. I don’t know why the error was pointing to the IndexToNode method, since clearly it was a problem with an undefined variable. My guess is that any error within the callback is handled similarly.Some other things that may be contributing:
return data['service_time_matrix'][from_node] + data['time_matrix'][from_node][to_node]
; is it possible that you’re incorrectly indexingdata['service_time_matrix'][from_node]
? (If it’s a matrix, it should have both from/to indexes.)I’m also on linux, using 64bit Python 3.7.4. I can verify it works with AUTOMATIC, (PATH|LOCAL|GLOBAL)_CHEAPEST_ARC (I wasn’t able to find feasible solutions for all of them within 30 seconds, but they don’t error out like I was getting before).