Initializing help system before first use

xpress.And

Purpose

Returns a logical AND of two or more binary variables or expressions.


Synopsis
xpress.And(variables)
Argument
variables 
A list/array of binary variables or binary expressions
Example
The following example shows how to use and to model various logical constraints:
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)
Further information
1. For AND functions, all variables and expressions must be binary; an error will be generated otherwise.
2. A function call xpress.And(x1,x2,...,xk) is equivalent to x1 and (x2 and (x3 and ... xk))...).
3. Note that since x1, x2, ..., xk, are binary variables, xpress.And(x1,x2,...,xk) is equivalent to xpress.min(x1,x2,...,xk).
Related topics

© 2001-2024 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.