diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6bae5f8..8db42be 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,8 @@ Next Release ----- * fix the objective offset test for compatibility with Debian sid * enable compatibility with Gurobi 12.0 +* fix an issue where the removal of more than 350 constraints + would lead to dangling references 1.8.2 ----- diff --git a/src/optlang/interface.py b/src/optlang/interface.py index 7cafe54..a51d168 100644 --- a/src/optlang/interface.py +++ b/src/optlang/interface.py @@ -1577,6 +1577,8 @@ def _remove_constraints(self, constraints): keys = [constraint.name for constraint in constraints] if len(constraints) > 350: # Need to figure out a good threshold here self._constraints = self._constraints.fromkeys(set(self._constraints.keys()).difference(set(keys))) + for co in constraints: + co.problem = None else: for constraint in constraints: try: