@@ -5778,14 +5778,14 @@ cdef class Model:
5778
5778
5779
5779
return vars
5780
5780
5781
- def getNVarsAnd (self , Constraint constraint ):
5781
+ def getNVarsAnd (self , Constraint and_cons ):
5782
5782
"""
5783
5783
Gets number of variables in and constraint.
5784
5784
5785
5785
Parameters
5786
5786
----------
5787
- constraint : Constraint
5788
- Constraint to get the number of variables from.
5787
+ and_cons : Constraint
5788
+ AND constraint to get the number of variables from.
5789
5789
5790
5790
Returns
5791
5791
-------
@@ -5795,16 +5795,16 @@ cdef class Model:
5795
5795
cdef int nvars
5796
5796
cdef SCIP_Bool success
5797
5797
5798
- return SCIPgetConsNVarsAnd (self ._scip, constraint .scip_cons)
5798
+ return SCIPgetNVarsAnd (self ._scip, and_cons .scip_cons)
5799
5799
5800
- def getConsVarsAnd (self , Constraint constraint ):
5800
+ def getVarsAnd (self , Constraint and_cons ):
5801
5801
"""
5802
- Gets variables in and constraint.
5802
+ Gets variables in AND constraint.
5803
5803
5804
5804
Parameters
5805
5805
----------
5806
- constraint : Constraint
5807
- Constraint to get the variables from.
5806
+ and_cons : Constraint
5807
+ AND Constraint to get the variables from.
5808
5808
5809
5809
Returns
5810
5810
-------
@@ -5816,9 +5816,12 @@ cdef class Model:
5816
5816
cdef SCIP_Bool success
5817
5817
cdef int i
5818
5818
5819
- SCIPgetConsNVarsAnd(self ._scip, constraint.scip_cons, & nvars, & success)
5819
+ constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(and_cons.scip_cons))).decode(' UTF-8' )
5820
+ assert (constype == ' and' , " The constraint handler %s does not have this functionality." % constype)
5821
+
5822
+ nvars = SCIPgetNVarsAnd(self ._scip, and_cons.scip_cons)
5820
5823
_vars = < SCIP_VAR** > malloc(nvars * sizeof(SCIP_VAR* ))
5821
- _vars = SCIPgetConsVarsAnd (self ._scip, constraint .scip_cons)
5824
+ _vars = SCIPgetVarsAnd (self ._scip, and_cons .scip_cons)
5822
5825
5823
5826
vars = []
5824
5827
for i in range (nvars):
@@ -5835,13 +5838,13 @@ cdef class Model:
5835
5838
5836
5839
return vars
5837
5840
5838
- def getResultantAnd (self , Constraint constraint ):
5841
+ def getResultantAnd (self , Constraint and_cons ):
5839
5842
"""
5840
5843
Gets the resultant variable in And constraint.
5841
5844
5842
5845
Parameters
5843
5846
----------
5844
- constraint : Constraint
5847
+ and_cons : Constraint
5845
5848
Constraint to get the resultant variable from.
5846
5849
5847
5850
Returns
@@ -5852,25 +5855,27 @@ cdef class Model:
5852
5855
cdef SCIP_VAR* _resultant
5853
5856
cdef SCIP_Bool success
5854
5857
5855
- _resultant = SCIPgetResultantAnd(self ._scip, constraint .scip_cons)
5858
+ _resultant = SCIPgetResultantAnd(self ._scip, and_cons .scip_cons)
5856
5859
5857
5860
ptr = < size_t> (_resultant)
5858
5861
# check whether the corresponding variable exists already
5859
5862
if ptr not in self ._modelvars:
5860
5863
# create a new variable
5861
- var = Variable.create(_resultant)
5862
- assert var.ptr() == ptr
5863
- self ._modelvars[ptr] = var
5864
+ resultant = Variable.create(_resultant)
5865
+ assert resultant.ptr() == ptr
5866
+ self ._modelvars[ptr] = resultant
5867
+ else :
5868
+ resultant = self ._modelvars[ptr]
5864
5869
5865
5870
return resultant
5866
5871
5867
- def isAndConsSorted (self , Constraint constraint ):
5872
+ def isAndConsSorted (self , Constraint and_cons ):
5868
5873
"""
5869
5874
Returns if the variables of the AND-constraint are sorted with respect to their indices.
5870
5875
5871
5876
Parameters
5872
5877
----------
5873
- constraint : Constraint
5878
+ and_cons : Constraint
5874
5879
Constraint to check.
5875
5880
5876
5881
Returns
@@ -5880,21 +5885,21 @@ cdef class Model:
5880
5885
"""
5881
5886
cdef SCIP_Bool success
5882
5887
5883
- return SCIPisAndConsSorted(self ._scip, constraint .scip_cons)
5888
+ return SCIPisAndConsSorted(self ._scip, and_cons .scip_cons)
5884
5889
5885
- def sortAndCons (self , Constraint constraint ):
5890
+ def sortAndCons (self , Constraint and_cons ):
5886
5891
"""
5887
5892
Sorts the variables of the AND-constraint with respect to their indices.
5888
5893
5889
5894
Parameters
5890
5895
----------
5891
- constraint : Constraint
5896
+ and_cons : Constraint
5892
5897
Constraint to sort.
5893
5898
5894
5899
"""
5895
5900
cdef SCIP_Bool success
5896
5901
5897
- PY_SCIP_CALL(SCIPsortAndCons(self ._scip, constraint .scip_cons))
5902
+ PY_SCIP_CALL(SCIPsortAndCons(self ._scip, and_cons .scip_cons))
5898
5903
5899
5904
def printCons (self , Constraint constraint ):
5900
5905
"""
0 commit comments