Skip to content

Commit dadff0e

Browse files
committed
Change name and better test
1 parent 600c67a commit dadff0e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/pyscipopt/scip.pxi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,7 @@ cdef class Constraint:
21962196
constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(self.scip_cons))).decode('UTF-8')
21972197
return constype == 'knapsack'
21982198

2199-
def isLinearRepresentable(self):
2199+
def isLinearType(self):
22002200
"""
22012201
Returns True if constraint can be represented as a linear constraint.
22022202
@@ -7308,7 +7308,7 @@ cdef class Model:
73087308
cdef SCIP_Bool success
73097309
constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
73107310

7311-
if cons.isLinearRepresentable():
7311+
if cons.isLinearType():
73127312
return SCIPconsGetRhs(self._scip, cons.scip_cons, &success)
73137313
elif constype == 'nonlinear':
73147314
return SCIPgetRhsNonlinear(cons.scip_cons)
@@ -7351,7 +7351,7 @@ cdef class Model:
73517351
cdef SCIP_Bool success
73527352
constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode('UTF-8')
73537353

7354-
if cons.isLinearRepresentable():
7354+
if cons.isLinearType():
73557355
return SCIPconsGetLhs(self._scip, cons.scip_cons, &success)
73567356
elif constype == 'nonlinear':
73577357
return SCIPgetLhsNonlinear(cons.scip_cons)

tests/test_cons.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ def test_getConsVals():
3535
x[i] = m.addVar("%i" % i, vtype="B")
3636

3737
c1 = m.addCons(quicksum(x[i] for i in x) <= 1)
38-
c2 = m.addConsKnapsack([x[i] for i in x], [1]*n_vars, 10)
38+
c2 = m.addConsKnapsack([x[i] for i in x], [i for i in range(1, n_vars+1)], 10)
3939
vals1 = m.getConsVals(c1)
4040
vals2 = m.getConsVals(c2)
4141

4242
assert len(vals1) == n_vars
4343
assert all(isinstance(v, float) for v in vals1)
4444
assert len(vals2) == n_vars
4545
assert all(isinstance(v, float) for v in vals2)
46+
assert m.getConsVals(c2) == [i for i in range(1, n_vars+1)]
4647

4748
def test_constraint_option_setting():
4849
m = Model()

0 commit comments

Comments
 (0)