Skip to main content

Issue retrieving PoolObjVal

Answered

Comments

6 comments

  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    Hi Sam,

    Could you try to remove the line \(\texttt{price.update()}\)? A model update should not be done in this situation.
    However, I can only reproduce an error \(\texttt{"AttributeError: Unable to retrieve attribute 'PoolObjVal'"}\) and not \(\texttt{"AttributeError: No solution available"}\). Do you have additional lines that you did not share in the code snippet?
    Could you share the log output as well? Which Gurobi version do you use?

    Best regards,
    Marika

    0
  • Sam Garvin
    Conversationalist
    First Question

    Hi, thanks for the quick reply. I removed the update line and still have the same issue. That's the code as it appears on my screen. Sorry, I'm not sure how to get the log output or what that is. This was the full error message I got:

    Traceback (most recent call last):
      File "C:\Users\Euler\PycharmProjects\CMOR442HW4\helpers.py", line 238, in <module>
        print(column_generation("C:\\Users\\Euler\\OneDrive\\Documents\\hw_prog.mps", "C:\\Users\\Euler\\Documents\\hwindices1.txt", 2))
      File "C:\Users\Euler\PycharmProjects\CMOR442HW4\helpers.py", line 218, in column_generation
        if price.PoolObjVal > 0:
      File "src\\gurobipy\\model.pxi", line 368, in gurobipy.Model.__getattr__
      File "src\\gurobipy\\model.pxi", line 1896, in gurobipy.Model.getAttr
      File "src\\gurobipy\\attrutil.pxi", line 103, in gurobipy._getattr
    AttributeError: No solution available

    Let me know if this is what you need. 

    Best, 

    Sam

    0
  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    As I said I cannot reproduce the error from the code snippet you shared. 
    Please provide a minimal reproducible example.

    0
  • Sam Garvin
    Conversationalist
    First Question

    My apologies. Here is the smallest program I could think to reproduce it on:

    import gurobipy as gp
    from gurobipy import GRB
    import numpy as np

    mod = gp.Model("model")

    x = mod.addVar(name = 'x')
    y = mod.addVar(name = 'y')

    obj = mod.setObjective(x+2*y, GRB.MAXIMIZE)
    mod.addConstr(2*x + y <= 10)

    mod.setParam(GRB.Param.PoolSearchMode, 2)
    mod.setParam(GRB.Param.PoolSolutions, 1)
    mod.optimize()
    mod.setParam(GRB.Param.SolutionNumber, 0)
    new_points = []
    if mod.PoolObjVal > 0:
    new_points.append(np.array([var.Xn for var in mod.getVars()]))

    The output is:

    Traceback (most recent call last):
      File "C:\Users\Euler\PycharmProjects\pythonProject1\main.py", line 18, in <module>
        if mod.PoolObjVal > 0:
      File "src\\gurobipy\\model.pxi", line 368, in gurobipy.Model.__getattr__
      File "src\\gurobipy\\model.pxi", line 1896, in gurobipy.Model.getAttr
      File "src\\gurobipy\\attrutil.pxi", line 103, in gurobipy._getattr
    AttributeError: No solution available

    Thanks!

    0
  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    Thanks!  In this case, you are solving a pure LP. The solution pool is only for MIPs. 
    The article How do I find additional solutions to a model? might be helpful.

    0
  • Sam Garvin
    Conversationalist
    First Question

    Thank you for your help, that makes sense!

    -Sam

    0

Please sign in to leave a comment.