Traceback error in gurobi.Model.optimize
AnsweredHello,
I have defined a function to solve an algorithm. This function has worked before with other instances, now I am testing the algorithm with another instance but I get the following traceback and I don't get why the code is working fine with other instances on the same data.
Traceback (most recent call last):
File "my file", line 85, in <module>
cb2 = CB2_sol_NOP(network=metnet,k=2,log=False)
File "my file where the function lives", line 838, in CB_sol_2_NOP m.optimze(lazycall)
File 'src\gurobipy\model.pxi,line 864, in gurobipy.Model.optimize gurobipy.GurobiError
The only difference with this experiment was that I set a different model.Params.Time_Limit. Could this be the cause of the error?
I'd appreciate your help
-
Hi Jose,
Could you please provide a minimal reproducible example?
Did you try executing your code without the callback?
Where exactly did you change something?
Best regards,
Jaromił0 -
Hello Jaromil,
I will try to provide a reproducible example or I can share my code and the data I am using.
I can't really execute the code without the callback. I am using the callbacks to introduce a series of lazy-cuts as part of the algorithm.
The only difference was when I changed the model.Params.TimeLimit from 1000 to 400
0 -
Hi Jose,
Note that uploading files in the Community Forum is not possible but we discuss an alternative in Posting to the Community Forum. Please try to reduce the size of your example as much as possible.
Best regards,
Jaromił0 -
Hello Jaromil,
I tried to reduce it as much as possible. The problem only presents when I run my experiment with the particular data and its size. It is easier to share a file. I am posting a link to a google drive and a link to the same folder in onedrive where a copy can be found. The problem results when running \(\texttt{run_experiment_k2.py}\). The gurobi model is in \(\texttt{Ob_Met_Net_solmethods.py}\). I'd appreciate some light on this problem.
- Google Drive
https://drive.google.com/drive/folders/17l192ooWY4qz7sAQeZ9LwmCP-z5co3iz?usp=sharing
- OneDrive
Best,
Jose
0 -
Hi Jose,
Google Drive works fine. However, I get
FileNotFoundError: [Errno 2] No such file or directory: '../B_Yeast/Data/Yeast/Yeast_LB.csv'
Best regards,
Jaromił0 -
Sorry about that.
The file's updated, now it should be able to read the files from the Data folder.
0 -
This seems to work now. I'll have a look. Could you let me know which Gurobi version you are using?
0 -
I am working with version 9.5.2
0 -
What exactly do I have to set to get the error you describe? And how long does it take to get to the issue? The code seems to work fine on my end.
0 -
You could try updating to Gurobi v10. Please note that in v10, the addMConstr method has been changed. It does not accept tupledicts any more. Thus, when you switch to v10, you have to adjust your code to provide a list of variables
# in support_functions.py
v_wt = wt.addVars(obj.M, lb=-GRB.INFINITY, ub=GRB.INFINITY, vtype=GRB.CONTINUOUS, name='v_wt')
v_wtl = []
for i in obj.M:
v_wtl.append(v_wt[i])
wt.setObjective(1*v_wt[obj.biomass],GRB.MAXIMIZE)
wt.addMConstr(obj.S,v_wt,'=',obj.b,name='Stoi')
#in Ob_Met_Net_solmethods.py
cbv = m.addVars(network.M,lb=-GRB.INFINITY,ub=GRB.INFINITY,vtype=GRB.CONTINUOUS,name='cbv')
cbvl = []
for i in network.M:
cbvl.append(cbv[i])
cby = m.addVars(network.M,vtype=GRB.BINARY,name='cby')
m.setObjective(1*cbv[network.chemical],GRB.MAXIMIZE)
m.addMConstr(network.S,cbvl,'=',network.b,name='Stoi')
#[...]
fv = imodel.addVars(network.M,lb=-GRB.INFINITY,ub=GRB.INFINITY,vtype=GRB.CONTINUOUS,name='fv')
fvl = []
for i in network.M:
fvl.append(fv[i])
imodel.params.LogToConsole = 0
imodel.setObjective(2000*fv[network.biomass] + fv[network.chemical], GRB.MAXIMIZE)
imodel.addMConstr(network.S,fvl,'=',network.b,name='Stoi')0 -
I really appreciate the time you've taken to look into my problem. I ran again my script from the same folder without any change and I still get an error. I updated the google drive folder with a copy of the log file with the error. I will update my gurobi version but still don't really understand why it's not working on my end.
Thanks,
Alex
0 -
Hi Alex,
Could you run the error log again but with all Gurobi output turned on?
0 -
Hi Jaromil,
The log is now available. Thanks so much!
Best,
Alex
0 -
Hi Alex,
Thank you for the log. There you can see
Solve interrupted (error code 10001)
which can be found in the error documentation. It is an out-of-memory error. There are a couple of ways how to avoid this error and they are described in How do I avoid an out-of-memory error?
Your model is not very big but it looks like you are solving many models and do quite some computing in the callback. Maybe the memory consumption in the callback can be reduced. I would recommend to switch to a machine with more memory.
Best regards,
Jaromił0 -
Hi Jaromil,
I really appreciate everything you did. Yes, I am solving the follower's problem from a bilevel problem iteratively in the callbacks which surely takes a lot of computing and memory consumption.
Thanks!
Alex
0
Please sign in to leave a comment.
Comments
15 comments