or-tools: Exception thrown while calling SetRange method.
I wanted to solve vehicle routing problem instance as a usage example I used cvrptw.py. Then I have created weekly model which has time_horizon=5x24x3600(the total number of seconds in a week). After that when I setting time constraints :
time_dimension.CumulVar(int(customer.index)).SetRange( customer.tw_open, customer.tw_close)
I am getting exception like this :
ortools-2.3393-py2.7-linux-x86_64.egg/ortools/constraint_solver/pywrapcp.py", line 1300, in SetRange return _pywrapcp.IntExpr_SetRange(self, l, u) Exception: CP Solver fail
In that case tw_open=28800 and tw_close=68400. I expected to get more informative exception message to be able to understand what I am doing wrong.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (5 by maintainers)
Hi Guys, I have the same problem and issues when I implemented my model. Please check If you set fix_start_cumul_to_zero == false, whether the problem will be solved. We need to set this value to FALSE, if we do not want to cumulate from zero, which is the lower bound.
Are you calling set range outside search? This is not supported.
You should add a constraint instead of calling a modifier. Laurent Perron | Operations Research | lperron@google.com | (33) 1 42 68 53 00
Le mar. 15 mai 2018 à 17:00, Yajun Ding notifications@github.com a écrit :
I had the same problem and I had solved it reight now. how to solve: I have a constraint: routing.AddDimensin( time_callback, 2, 30, →this is the problem …) I request the maximum travel time is 30h, but in my time windows, time > 30, so you can Adjust the the maximum travel time to avoid this problem
let’s say vehicle starts 9.00 AM (3600x9 = 32400) if you’re setting dimension with
fix_start_cumul_to_zero=False
your capacity argument while setting dimension should be greater than 32400
routing.AddDimension(... , capacity>32400)
As @lperron said, you might want to try adding constraints instead of setting the range, like this:
or, if you don’t want to use constraints for some reason, try setting the min and max values independently.
Sometimes I fix errors that mention
argument 2 of type 'int64'
by doing an explicit cast toint
, but I don’t know why this works.Hope it helps.
Hi Guys i am also facing the similar issue. i am running the below code but getting some issue. Please help me finding out the issue.
Code:
Error:
And I have the same mistake. I need to solve the problem with total time constraint. I know, that this is solving by time_horizon in AddDimension. But my nodes have over day time windows, for example it open at 23:00 and close at 01:00 next day. So I convert it to 82800 and 90000. But total time constraint is only 12 hours, 43200. So I want open depot from 0 to 259200 (not to 43200, thats how AddDimension works) and add 1 day to all customers, so that this customer will be 169200 and 176400. In this case i understand, that dimension of time_horizon have to be equal as max dimension of time windows. For example, if my max time windows dimension (on customers, not on depot) will be = 176400 (6 characters) time_horizon 43200 (5 characters) will raise an error
Traceback (most recent call last): File “D:/Work/VRPTW/VRPTW3/cvrptw.py”, line 342, in <module> main() File “D:/Work/VRPTW/VRPTW3/cvrptw.py”, line 235, in main time_dimension.CumulVar(locations).SetRange(start, end) File “C:\Users\MDesh.virtualenvs\VRPTW3-rmdLUytm\lib\site-packages\ortools\constraint_solver\pywrapcp.py”, line 1339, in SetRange return _pywrapcp.IntExpr_SetRange(self, l, u) Exception: CP Solver fail
But if time_horizon will be , for example, 143200 (6 characters) - everything will be ok. So that there are two ways - to open the depot for my task (i dont know, how i can do it, i ll ask about it in the new issue, #533) and, probably, repair this error. Will be grateful for any help. Thanks.