diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d8fb8097..ada54121f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Added `getBase()` and `setBase()` methods to `LP` class for getting/setting basis status - Added `getMemUsed()`, `getMemTotal()`, and `getMemExternEstim()` methods - Added `isReoptEnabled()` and raising error if not enabled upon calling `reoptSolve()` +- SOS1/SOS2 constraints are now realease after addition similar to the other constraint types ### Fixed - Removed `Py_INCREF`/`Py_DECREF` on `Model` in `catchEvent`/`dropEvent` that caused memory leak for imbalanced usage - Used `getIndex()` instead of `ptr()` for sorting nonlinear expression terms to avoid nondeterministic behavior diff --git a/src/pyscipopt/scip.pxi b/src/pyscipopt/scip.pxi index cc872aa1b..1d3427142 100644 --- a/src/pyscipopt/scip.pxi +++ b/src/pyscipopt/scip.pxi @@ -7151,8 +7151,10 @@ cdef class Model: PY_SCIP_CALL(SCIPaddVarSOS1(self._scip, scip_cons, wrapper.ptr[i], weights[i])) PY_SCIP_CALL(SCIPaddCons(self._scip, scip_cons)) + pyCons = self._getOrCreateCons(scip_cons) + PY_SCIP_CALL(SCIPreleaseCons(self._scip, &scip_cons)) - return self._getOrCreateCons(scip_cons) + return pyCons def addConsSOS2(self, vars, weights=None, name="", initial=True, separate=True, enforce=True, check=True, @@ -7216,8 +7218,10 @@ cdef class Model: PY_SCIP_CALL(SCIPaddVarSOS2(self._scip, scip_cons, wrapper.ptr[i], weights[i])) PY_SCIP_CALL(SCIPaddCons(self._scip, scip_cons)) + pyCons = self._getOrCreateCons(scip_cons) + PY_SCIP_CALL(SCIPreleaseCons(self._scip, &scip_cons)) - return self._getOrCreateCons(scip_cons) + return pyCons def addConsAnd(self, vars, resvar, name="", initial=True, separate=True, enforce=True, check=True,