Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
### Added
- Added option to get Lhs, Rhs of nonlinear constraints
- Added transformed option to getVarDict, updated test
- Added categorical data example
- Added printProblem to print problem to stdout
Expand Down
20 changes: 10 additions & 10 deletions src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
if rc == SCIP_OKAY:
pass
elif rc == SCIP_ERROR:
raise Exception('SCIP: unspecified error!')

Check failure on line 275 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / test-coverage (3.11)

SCIP: unspecified error!

Check failure on line 275 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / Integration-test (3.8)

SCIP: unspecified error!

Check failure on line 275 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / Windows-test (3.8)

SCIP: unspecified error!

Check failure on line 275 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / Integration-test (3.9)

SCIP: unspecified error!

Check failure on line 275 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / Windows-test (3.9)

SCIP: unspecified error!

Check failure on line 275 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / Integration-test (3.10)

SCIP: unspecified error!

Check failure on line 275 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / Windows-test (3.10)

SCIP: unspecified error!

Check failure on line 275 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / Integration-test (3.11)

SCIP: unspecified error!

Check failure on line 275 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / Integration-test (3.12)

SCIP: unspecified error!

Check failure on line 275 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / Windows-test (3.11)

SCIP: unspecified error!

Check failure on line 275 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / Windows-test (3.12)

SCIP: unspecified error!
elif rc == SCIP_NOMEMORY:
raise MemoryError('SCIP: insufficient memory error!')
elif rc == SCIP_READERROR:
Expand Down Expand Up @@ -4265,7 +4265,7 @@
if len(v) == 1: # linear
var = <Variable>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 = <SCIP_EXPR**> malloc(2 * sizeof(SCIP_EXPR*))
Expand Down Expand Up @@ -4624,7 +4624,7 @@
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().

Expand Down Expand Up @@ -5578,7 +5578,7 @@
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)

Expand All @@ -5602,7 +5602,7 @@
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)

Expand All @@ -5626,7 +5626,7 @@
Parameters
----------
cons : Constraint
linear or quadratic constraint
constraint to get the right-hand side from

Returns
-------
Expand All @@ -5636,7 +5636,7 @@
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)
Expand All @@ -5648,7 +5648,7 @@
Parameters
----------
cons : Constraint
linear or quadratic constraint
linear or nonlinear constraint

Returns
-------
Expand All @@ -5658,7 +5658,7 @@
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)
Expand Down Expand Up @@ -5724,7 +5724,7 @@
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)

Expand Down Expand Up @@ -5761,7 +5761,7 @@
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
Expand Down
11 changes: 11 additions & 0 deletions tests/test_nonlinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading