Initializing help system before first use

xpress.Or

xpress.Or


Purpose

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


Synopsis
xpress.Or(variables)
Argument
variables 
A list/array of binary variables or binary expressions
Example
The following example shows how to use or to model various logical constraints:
N = 10

x = xp.vars(N, vartype=xp.binary)  # Creates N binary variables

c = [1, 4, 7, 3, 5, 7, 8, 4, 4, 9]

p = xp.problem(x)  # Creates a problem with x, y

# 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.Or(x[1:]))

# Forces the logical OR between some logical expressions to
# be one, i.e., at least one of them must be one

p.addConstraint (xp.Or([x[1] & x[4], x[2] & x[1], x[3] & x[6]]) == 1)
Further information
1. For OR functions, all variables and expressions must be binary; an error will be generated otherwise.
2. A function call xpress.Or(x1,x2,...,xk) is equivalent to x1 or (x2 or (x3 or ... xk))...).
3. Note that since x1, x2, ..., xk, are binary variables, xpress.Or(x1,x2,...,xk) is equivalent to xpress.max(x1,x2,...,xk).
Related topics

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