Skip to content

Commit

Permalink
Don't trigger update in _get_expression with gurobi (#121)
Browse files Browse the repository at this point in the history
Avoid an infinite recursion
  • Loading branch information
cdiener authored and KristianJensen committed Aug 7, 2017
1 parent 8c2c88b commit f74c447
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion optlang/gurobi_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ def _get_expression(self):
if self.problem is not None and self._expression_expired and len(self.problem._variables) > 0:
grb_obj = self.problem.problem.getObjective()
terms = []
variables = self.problem._variables
for i in range(grb_obj.size()):
terms.append(grb_obj.getCoeff(i) * self.problem.variables[grb_obj.getVar(i).getAttr('VarName')])
terms.append(grb_obj.getCoeff(i) * variables[grb_obj.getVar(i).getAttr('VarName')])
expression = symbolics.add(terms)
# TODO implement quadratic objectives
self._expression = expression + getattr(self.problem, "_objective_offset", 0)
Expand Down

0 comments on commit f74c447

Please sign in to comment.