File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -2196,7 +2196,7 @@ cdef class Constraint:
2196
2196
constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(self .scip_cons))).decode(' UTF-8' )
2197
2197
return constype == ' knapsack'
2198
2198
2199
- def isLinearRepresentable (self ):
2199
+ def isLinearType (self ):
2200
2200
"""
2201
2201
Returns True if constraint can be represented as a linear constraint.
2202
2202
@@ -7308,7 +7308,7 @@ cdef class Model:
7308
7308
cdef SCIP_Bool success
7309
7309
constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode(' UTF-8' )
7310
7310
7311
- if cons.isLinearRepresentable ():
7311
+ if cons.isLinearType ():
7312
7312
return SCIPconsGetRhs(self ._scip, cons.scip_cons, & success)
7313
7313
elif constype == ' nonlinear' :
7314
7314
return SCIPgetRhsNonlinear(cons.scip_cons)
@@ -7351,7 +7351,7 @@ cdef class Model:
7351
7351
cdef SCIP_Bool success
7352
7352
constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(cons.scip_cons))).decode(' UTF-8' )
7353
7353
7354
- if cons.isLinearRepresentable ():
7354
+ if cons.isLinearType ():
7355
7355
return SCIPconsGetLhs(self ._scip, cons.scip_cons, & success)
7356
7356
elif constype == ' nonlinear' :
7357
7357
return SCIPgetLhsNonlinear(cons.scip_cons)
Original file line number Diff line number Diff line change @@ -35,14 +35,15 @@ def test_getConsVals():
35
35
x [i ] = m .addVar ("%i" % i , vtype = "B" )
36
36
37
37
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 )
39
39
vals1 = m .getConsVals (c1 )
40
40
vals2 = m .getConsVals (c2 )
41
41
42
42
assert len (vals1 ) == n_vars
43
43
assert all (isinstance (v , float ) for v in vals1 )
44
44
assert len (vals2 ) == n_vars
45
45
assert all (isinstance (v , float ) for v in vals2 )
46
+ assert m .getConsVals (c2 ) == [i for i in range (1 , n_vars + 1 )]
46
47
47
48
def test_constraint_option_setting ():
48
49
m = Model ()
You can’t perform that action at this time.
0 commit comments