Issue retrieving PoolObjVal
AnsweredHi, I am trying to run the following code, and I am getting the error:
"AttributeError: No solution available," referring to the PoolObjVal attribute of price.
price.setParam(GRB.Param.PoolSearchMode, 2)
price.setParam(GRB.Param.PoolSolutions, sol_num)
price.optimize()
for sol in range(price.SolCount):
price.setParam(GRB.Param.SolutionNumber, sol)
price.update()
if price.PoolObjVal > 0:
new_points.append(np.array([var.Xn for var in price.getVars()]))
I would appreciate any help in figuring out why this is. Right now, sol_num is set to 2.
Thanks!
Sam

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,
Marika0 
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 availableLet me know if this is what you need.
Best,
Sam
0 
As I said I cannot reproduce the error from the code snippet you shared.
Please provide a minimal reproducible example.0 
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 availableThanks!
0 
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 
Thank you for your help, that makes sense!
Sam
0
Please sign in to leave a comment.
Comments
6 comments