Skip to main content

Traceback error in gurobi.Model.optimize

Answered

Comments

15 comments

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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
  • Jose Vindel
    Gurobi-versary
    Thought Leader
    Investigator

    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
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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
  • Jose Vindel
    Gurobi-versary
    Thought Leader
    Investigator

    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

    https://strath-my.sharepoint.com/:f:/r/personal/jose_vindel-garduno_strath_ac_uk/Documents/B_Yeast(G)?csf=1&web=1&e=D8HUk5

    Best,

    Jose

     

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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
  • Jose Vindel
    Gurobi-versary
    Thought Leader
    Investigator

    Sorry about that.

    The file's updated, now it should be able to read the files from the Data folder.

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    This seems to work now. I'll have a look. Could you let me know which Gurobi version you are using?

     

    0
  • Jose Vindel
    Gurobi-versary
    Thought Leader
    Investigator

    I am working with version 9.5.2

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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
  • Jose Vindel
    Gurobi-versary
    Thought Leader
    Investigator

    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
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Alex,

    Could you run the error log again but with all Gurobi output turned on?

    0
  • Jose Vindel
    Gurobi-versary
    Thought Leader
    Investigator

    Hi Jaromil,

    The log is now available. Thanks so much!

    Best,

    Alex

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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
  • Jose Vindel
    Gurobi-versary
    Thought Leader
    Investigator

    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.