Skip to content

Commit 30aba21

Browse files
committed
Add option for get Rhs, Lhs of nonlinear cons. Remove some mentions of quadratic cons
1 parent 05df966 commit 30aba21

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44
### Added
5+
- Added option to get Lhs, Rhs of nonlinear constraints
56
- Added transformed option to getVarDict, updated test
67
- Added categorical data example
78
- Added printProblem to print problem to stdout

src/pyscipopt/scip.pxi

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4265,7 +4265,7 @@ cdef class Model:
42654265
if len(v) == 1: # linear
42664266
var = <Variable>v[0]
42674267
PY_SCIP_CALL(SCIPaddLinearVarNonlinear(self._scip, scip_cons, var.scip_var, c))
4268-
else: # quadratic
4268+
else: # nonlinear
42694269
assert len(v) == 2, 'term length must be 1 or 2 but it is %s' % len(v)
42704270

42714271
varexprs = <SCIP_EXPR**> malloc(2 * sizeof(SCIP_EXPR*))
@@ -4624,7 +4624,7 @@ cdef class Model:
46244624
enforce=True, check=True, propagate=True, local=False,
46254625
modifiable=False, dynamic=False, removable=False,
46264626
stickingatnode=False):
4627-
"""Adds multiple linear or quadratic constraints.
4627+
"""Adds multiple constraints.
46284628
46294629
Each of the constraints is added to the model using Model.addCons().
46304630
@@ -5578,7 +5578,7 @@ cdef class Model:
55785578
Parameters
55795579
----------
55805580
cons : Constraint
5581-
linear or quadratic constraint
5581+
constraint to change the right-hand side from
55825582
rhs : float or None
55835583
new right-hand side (set to None for +infinity)
55845584
@@ -5602,7 +5602,7 @@ cdef class Model:
56025602
Parameters
56035603
----------
56045604
cons : Constraint
5605-
linear or quadratic constraint
5605+
constraint to change the left-hand side from
56065606
lhs : float or None
56075607
new left-hand side (set to None for -infinity)
56085608
@@ -5626,7 +5626,7 @@ cdef class Model:
56265626
Parameters
56275627
----------
56285628
cons : Constraint
5629-
linear or quadratic constraint
5629+
constraint to get the right-hand side from
56305630
56315631
Returns
56325632
-------
@@ -5636,7 +5636,7 @@ cdef class Model:
56365636
constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
56375637
if constype == 'linear':
56385638
return SCIPgetRhsLinear(self._scip, cons.scip_cons)
5639-
elif constype == 'quadratic':
5639+
elif constype == 'nonlinear':
56405640
return SCIPgetRhsNonlinear(cons.scip_cons)
56415641
else:
56425642
raise Warning("method cannot be called for constraints of type " + constype)
@@ -5648,7 +5648,7 @@ cdef class Model:
56485648
Parameters
56495649
----------
56505650
cons : Constraint
5651-
linear or quadratic constraint
5651+
linear or nonlinear constraint
56525652
56535653
Returns
56545654
-------
@@ -5658,7 +5658,7 @@ cdef class Model:
56585658
constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
56595659
if constype == 'linear':
56605660
return SCIPgetLhsLinear(self._scip, cons.scip_cons)
5661-
elif constype == 'quadratic':
5661+
elif constype == 'nonlinear':
56625662
return SCIPgetLhsNonlinear(cons.scip_cons)
56635663
else:
56645664
raise Warning("method cannot be called for constraints of type " + constype)
@@ -5724,7 +5724,7 @@ cdef class Model:
57245724
Parameters
57255725
----------
57265726
cons : Constraint
5727-
linear or quadratic constraint
5727+
linear constraint
57285728
sol : Solution or None, optional
57295729
solution to compute activity of, None to use current node's solution (Default value = None)
57305730
@@ -5761,7 +5761,7 @@ cdef class Model:
57615761
Parameters
57625762
----------
57635763
cons : Constraint
5764-
linear or quadratic constraint
5764+
linear constraint
57655765
sol : Solution or None, optional
57665766
solution to compute slack of, None to use current node's solution (Default value = None)
57675767
side : str or None, optional

tests/test_nonlinear.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,14 @@ def test_addExprNonLinear():
305305
assert m.getNSols() > 0
306306
assert m.isEQ(m.getVal(y), 2)
307307
assert m.isEQ(m.getVal(z), 27)
308+
309+
def test_nonlinear_lhs_rhs():
310+
from helpers.utils import random_nlp_1
311+
312+
m = random_nlp_1()
313+
c = m.getConss()
314+
315+
m.hideOutput()
316+
m.optimize()
317+
assert m.isInfinity(-m.getLhs(c[0]))
318+
assert m.isEQ(m.getRhs(c[0]), 5)

0 commit comments

Comments
 (0)