Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -6,6 +6,7 @@
- Added isPositive(), isNegative(), isFeasLE(), isFeasLT(), isFeasGE(), isFeasGT(), isHugeValue(), and tests
- Added SCIP_LOCKTYPE, addVarLocksType(), getNLocksDown(), getNLocksUp(), getNLocksDownType(), getNLocksUpType(), and tests
### Fixed
- Fixed segmentation fault when logical constraints were used with expressions rather than variables.
Comment thread
Joao-Dionisio marked this conversation as resolved.
Outdated
### Changed
### Removed

Expand Down
11 changes: 10 additions & 1 deletion src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
if rc == SCIP_OKAY:
pass
elif rc == SCIP_ERROR:
raise Exception('SCIP: unspecified error!')

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

View workflow job for this annotation

GitHub Actions / test-coverage (3.11)

SCIP: unspecified error!
elif rc == SCIP_NOMEMORY:
raise MemoryError('SCIP: insufficient memory error!')
elif rc == SCIP_READERROR:
Expand Down Expand Up @@ -6308,6 +6308,9 @@

_resvar = (<Variable>resvar).scip_var
for i, var in enumerate(vars):
if not isinstance(var, Variable):
Comment thread
DominikKamp marked this conversation as resolved.
Outdated
raise TypeError("Expected Variable, got %s." % type(var))
Comment thread
DominikKamp marked this conversation as resolved.
Outdated

_vars[i] = (<Variable>var).scip_var

if name == '':
Expand Down Expand Up @@ -6373,6 +6376,9 @@

_resvar = (<Variable>resvar).scip_var
for i, var in enumerate(vars):
if not isinstance(var, Variable):
raise TypeError("Expected Variable, got %s." % type(var))

_vars[i] = (<Variable>var).scip_var

if name == '':
Expand Down Expand Up @@ -6437,6 +6443,9 @@

assert type(rhsvar) is type(bool()), "Provide BOOLEAN value as rhsvar, you gave %s." % type(rhsvar)
for i, var in enumerate(vars):
if not isinstance(var, Variable):
raise TypeError("Expected Variable, got %s." % type(var))

_vars[i] = (<Variable>var).scip_var

if name == '':
Expand Down Expand Up @@ -8763,7 +8772,7 @@
return Node.create(downchild), Node.create(eqchild), Node.create(upchild)


def branchVarVal(self, variable, value):
def branchVarVal(self, Variable variable, value):
"""
Branches on variable using a value which separates the domain of the variable.

Expand Down
19 changes: 19 additions & 0 deletions tests/test_cons.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ def test_cons_logical():
assert m.isEQ(m.getVal(result1), 1)
assert m.isEQ(m.getVal(result2), 0)

@pytest.mark.xfail(
reason="Logical constraints expect lists of binary variables"
)
def test_cons_logical_fail():
m = Model()
x1 = m.addVar(vtype="B")
x2 = m.addVar(vtype="B")
x3 = m.addVar(vtype="B")
x4 = m.addVar(vtype="B")
result1 = m.addVar(vtype="B")

m.addCons(x3 == 1 - x1)
m.addCons(x4 == 1 - x2)

# result1 true
Comment thread
Joao-Dionisio marked this conversation as resolved.
Outdated
m.addConsOr([x1*x3, x2*x4], result1)

m.optimize()

def test_SOScons():
m = Model()
x = {}
Expand Down