Skip to content

Commit

Permalink
Don't leave dangling refs when removing more than 350 constraints (#272)
Browse files Browse the repository at this point in the history
* set problem to none

* add RNs

* Update CHANGELOG.rst

Co-authored-by: Moritz E. Beber <[email protected]>

* implement review comments

---------

Co-authored-by: Moritz E. Beber <[email protected]>
  • Loading branch information
cdiener and Midnighter authored Nov 26, 2024
1 parent 5cbc2c1 commit 8e49484
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----
Expand Down
2 changes: 2 additions & 0 deletions src/optlang/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8e49484

Please sign in to comment.