xpress.And
Returns a logical AND of two or more binary variables or expressions.
xpress.And(variables)
variables
|
A list/array of binary variables or binary expressions
|
N = 10 p = xp.problem() # Creates a problem x = p.addVariables(N, vartype=xp.binary) # Creates N binary variables c = [1, 4, 7, 3, 5, 7, 8, 4, 4, 9] # Sets a linear objective p.setObjective (xp.Sum(c[i] * x[i] for i in range(N))) # Linear constraint p.addConstraint (xp.Sum(x) <= 6) # Constrains the first x variable to be the conjunction of all other x's p.addConstraint (x[0] == xp.And(x[1:])) # Forces the logical AND between some logical expressions to # be zero, i.e., at least one of them must be zero p.addConstraint (xp.And([x[1] | x[4], x[2] | x[1], x[3] | x[6]]) == 0)
© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.