diff --git a/CHANGELOG.md b/CHANGELOG.md index f58c50b43..a98f296fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased ### Added +- Added option to get Lhs, Rhs of nonlinear constraints - Added cutoffNode and test - Added getMajorVersion, getMinorVersion, and getTechVersion ### Fixed diff --git a/src/pyscipopt/scip.pxi b/src/pyscipopt/scip.pxi index 9828a80cc..0d1ae3faa 100644 --- a/src/pyscipopt/scip.pxi +++ b/src/pyscipopt/scip.pxi @@ -4362,7 +4362,7 @@ cdef class Model: if len(v) == 1: # linear var = v[0] PY_SCIP_CALL(SCIPaddLinearVarNonlinear(self._scip, scip_cons, var.scip_var, c)) - else: # quadratic + else: # nonlinear assert len(v) == 2, 'term length must be 1 or 2 but it is %s' % len(v) varexprs = malloc(2 * sizeof(SCIP_EXPR*)) @@ -4726,7 +4726,7 @@ cdef class Model: enforce=True, check=True, propagate=True, local=False, modifiable=False, dynamic=False, removable=False, stickingatnode=False): - """Adds multiple linear or quadratic constraints. + """Adds multiple constraints. Each of the constraints is added to the model using Model.addCons(). @@ -5696,7 +5696,7 @@ cdef class Model: Parameters ---------- cons : Constraint - linear or quadratic constraint + constraint to change the right-hand side from rhs : float or None new right-hand side (set to None for +infinity) @@ -5720,7 +5720,7 @@ cdef class Model: Parameters ---------- cons : Constraint - linear or quadratic constraint + constraint to change the left-hand side from lhs : float or None new left-hand side (set to None for -infinity) @@ -5744,7 +5744,7 @@ cdef class Model: Parameters ---------- cons : Constraint - linear or quadratic constraint + constraint to get the right-hand side from Returns ------- @@ -5754,7 +5754,7 @@ cdef class Model: constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8') if constype == 'linear': return SCIPgetRhsLinear(self._scip, cons.scip_cons) - elif constype == 'quadratic': + elif constype == 'nonlinear': return SCIPgetRhsNonlinear(cons.scip_cons) else: raise Warning("method cannot be called for constraints of type " + constype) @@ -5766,7 +5766,7 @@ cdef class Model: Parameters ---------- cons : Constraint - linear or quadratic constraint + linear or nonlinear constraint Returns ------- @@ -5776,7 +5776,7 @@ cdef class Model: constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8') if constype == 'linear': return SCIPgetLhsLinear(self._scip, cons.scip_cons) - elif constype == 'quadratic': + elif constype == 'nonlinear': return SCIPgetLhsNonlinear(cons.scip_cons) else: raise Warning("method cannot be called for constraints of type " + constype) @@ -5842,7 +5842,7 @@ cdef class Model: Parameters ---------- cons : Constraint - linear or quadratic constraint + linear constraint sol : Solution or None, optional solution to compute activity of, None to use current node's solution (Default value = None) @@ -5879,7 +5879,7 @@ cdef class Model: Parameters ---------- cons : Constraint - linear or quadratic constraint + linear constraint sol : Solution or None, optional solution to compute slack of, None to use current node's solution (Default value = None) side : str or None, optional diff --git a/tests/test_nonlinear.py b/tests/test_nonlinear.py index 0cec99940..383532f2e 100644 --- a/tests/test_nonlinear.py +++ b/tests/test_nonlinear.py @@ -305,3 +305,14 @@ def test_addExprNonLinear(): assert m.getNSols() > 0 assert m.isEQ(m.getVal(y), 2) assert m.isEQ(m.getVal(z), 27) + +def test_nonlinear_lhs_rhs(): + from helpers.utils import random_nlp_1 + + m = random_nlp_1() + c = m.getConss() + + m.hideOutput() + m.optimize() + assert m.isInfinity(-m.getLhs(c[0])) + assert m.isEQ(m.getRhs(c[0]), 5) \ No newline at end of file