In get_objective in gurobi.py you are trying to set the const property of LinExpr, which doesn't have a setter.
To reproduce:
>>> import mip
>>> model = mip.Model(solver_name="gurobi")
Set parameter Username
Academic license - for non-commercial use only - expires 2023-07-07
>>> x = model.add_var("x"I)
>>> model.objective = x
>>> model.objective
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/mkrimmel/.local/lib/python3.8/site-packages/mip/model.py", line 821, in objective
return self.solver.get_objective()
File "/home/mkrimmel/.local/lib/python3.8/site-packages/mip/gurobi.py", line 543, in get_objective
obj_expr.const = self.get_objective_const()
AttributeError: can't set attribute
Not sure why const cannot have a setter. Either way, you could just use the constructor of LinExpr directly. I may prepare a PR for this because I probably need to have this fixed.
In
get_objective
ingurobi.py
you are trying to set theconst
property ofLinExpr
, which doesn't have a setter. To reproduce:Not sure why
const
cannot have a setter. Either way, you could just use the constructor ofLinExpr
directly. I may prepare a PR for this because I probably need to have this fixed.