@@ -5990,6 +5990,160 @@ cdef class Model:
59905990
59915991 return vars
59925992
5993+ def getNVarsAnd (self , Constraint and_cons ):
5994+ """
5995+ Gets number of variables in and constraint.
5996+
5997+ Parameters
5998+ ----------
5999+ and_cons : Constraint
6000+ AND constraint to get the number of variables from.
6001+
6002+ Returns
6003+ -------
6004+ int
6005+
6006+ """
6007+ cdef int nvars
6008+ cdef SCIP_Bool success
6009+
6010+ return SCIPgetNVarsAnd(self ._scip, and_cons.scip_cons)
6011+
6012+ def getVarsAnd (self , Constraint and_cons ):
6013+ """
6014+ Gets variables in AND constraint.
6015+
6016+ Parameters
6017+ ----------
6018+ and_cons : Constraint
6019+ AND Constraint to get the variables from.
6020+
6021+ Returns
6022+ -------
6023+ list of Variable
6024+
6025+ """
6026+ cdef SCIP_VAR** _vars
6027+ cdef int nvars
6028+ cdef SCIP_Bool success
6029+ cdef int i
6030+
6031+ constype = bytes(SCIPconshdlrGetName(SCIPconsGetHdlr(and_cons.scip_cons))).decode(' UTF-8' )
6032+ assert (constype == ' and' , " The constraint handler %s does not have this functionality." % constype)
6033+
6034+ nvars = SCIPgetNVarsAnd(self ._scip, and_cons.scip_cons)
6035+ _vars = SCIPgetVarsAnd(self ._scip, and_cons.scip_cons)
6036+
6037+ vars = []
6038+ for i in range (nvars):
6039+ ptr = < size_t> (_vars[i])
6040+ # check whether the corresponding variable exists already
6041+ if ptr in self ._modelvars:
6042+ vars .append(self ._modelvars[ptr])
6043+ else :
6044+ # create a new variable
6045+ var = Variable.create(_vars[i])
6046+ assert var.ptr() == ptr
6047+ self ._modelvars[ptr] = var
6048+ vars .append(var)
6049+
6050+ return vars
6051+
6052+ def getResultantAnd (self , Constraint and_cons ):
6053+ """
6054+ Gets the resultant variable in And constraint.
6055+
6056+ Parameters
6057+ ----------
6058+ and_cons : Constraint
6059+ Constraint to get the resultant variable from.
6060+
6061+ Returns
6062+ -------
6063+ Variable
6064+
6065+ """
6066+ cdef SCIP_VAR* _resultant
6067+ cdef SCIP_Bool success
6068+
6069+ _resultant = SCIPgetResultantAnd(self ._scip, and_cons.scip_cons)
6070+
6071+ ptr = < size_t> (_resultant)
6072+ # check whether the corresponding variable exists already
6073+ if ptr not in self ._modelvars:
6074+ # create a new variable
6075+ resultant = Variable.create(_resultant)
6076+ assert resultant.ptr() == ptr
6077+ self ._modelvars[ptr] = resultant
6078+ else :
6079+ resultant = self ._modelvars[ptr]
6080+
6081+ return resultant
6082+
6083+ def isAndConsSorted (self , Constraint and_cons ):
6084+ """
6085+ Returns if the variables of the AND-constraint are sorted with respect to their indices.
6086+
6087+ Parameters
6088+ ----------
6089+ and_cons : Constraint
6090+ Constraint to check.
6091+
6092+ Returns
6093+ -------
6094+ bool
6095+
6096+ """
6097+ cdef SCIP_Bool success
6098+
6099+ return SCIPisAndConsSorted(self ._scip, and_cons.scip_cons)
6100+
6101+ def sortAndCons (self , Constraint and_cons ):
6102+ """
6103+ Sorts the variables of the AND-constraint with respect to their indices.
6104+
6105+ Parameters
6106+ ----------
6107+ and_cons : Constraint
6108+ Constraint to sort.
6109+
6110+ """
6111+ cdef SCIP_Bool success
6112+
6113+ PY_SCIP_CALL(SCIPsortAndCons(self ._scip, and_cons.scip_cons))
6114+
6115+ def chgAndConsCheckFlagWhenUpgr (self , Constraint cons , flag ):
6116+ """
6117+ when 'upgrading' the given AND-constraint, should the check flag for the upgraded
6118+ constraint be set to TRUE, even if the check flag of this AND-constraint is set to FALSE?
6119+
6120+ Parameters
6121+ ----------
6122+ cons : Constraint
6123+ The AND constraint to change.
6124+ flag : bool
6125+ The new value for the check flag.
6126+
6127+ """
6128+
6129+ PY_SCIP_CALL(SCIPchgAndConsCheckFlagWhenUpgr(self ._scip, cons.scip_cons, flag))
6130+
6131+ def chgAndConsRemovableFlagWhenUpgr (self , Constraint cons , flag ):
6132+ """
6133+ when 'upgrading' the given AND-constraint, should the removable flag for the upgraded
6134+ constraint be set to TRUE, even if the removable flag of this AND-constraint is set to FALSE?
6135+
6136+ Parameters
6137+ ----------
6138+ cons : Constraint
6139+ The AND constraint to change.
6140+ flag : bool
6141+ The new value for the removable flag.
6142+
6143+ """
6144+
6145+ PY_SCIP_CALL(SCIPchgAndConsRemovableFlagWhenUpgr(self ._scip, cons.scip_cons, flag))
6146+
59936147 def printCons (self , Constraint constraint ):
59946148 """
59956149 Print the constraint
0 commit comments