Compound Logic and Comparison Operators in Configuration Constraints
Both Compound Logic and Comparison operators test for the truth of their operands and are described in the following table. They return a true or false rather than a quantity.
Compound Logic operators, such as AND, NOT, OR, are used to link expressions together when creating a constraint. For example: (Condition A AND Condition B) requires Item C. Compound Logic operators are also called Boolean operators.
Operator | Example | Description |
---|---|---|
NOT |
|
Logical negation. True when A is false and false when A is true. A can be an item or sub-expression. |
AND |
|
Both A and B. True only when both A and B are true. When used as a top-level constraint, means that only solutions where both A and B are true are allowed. A and B can be items or sub-expressions. |
OR |
|
Either A or B or both. False only when both A and B are false. A and B can be items or sub-expressions. |
Exclusive OR |
|
A or B but not both. A and B must have opposite truth states. False when A and B are either both true or both false. A and B can be items or sub-expressions. |
NOT AND |
|
Converse of A AND B. False only when both A and B are true. When used as a top-level constraint, means that A and B cannot both be present. A and B can be items or sub-expressions. |
Comparison operators compare their operands and return a true or false and are described in the following table. In the following constraint, when the quantity of item A is less than item B (when the comparison is true), then item C is required.
(Item A < Item B) requires C
If you specify an item as an operand in a comparison, the quantity of the item in the solution is used to make the comparison. If you specify an expression as an operand, the expression must resolve to a number.
If you specify an expression that resolves to true or false, then true is assigned the value 1 and false is assigned the value 0.
Operator | Example | Description |
---|---|---|
Greater than |
|
A is greater than B |
Not less than |
|
A is greater than or equal to B |
Equals |
|
A equals B |
Equals (compound) |
|
True if A=B AND A=C And A=D |
Not equal to |
|
A does not equal B |
Not greater than |
|
A is less than or equal to B |
Less than |
|
A is less than B |
When you are building a constraint, you can compound the comparison operators. For example, you could build the following expression:
(A>B>C>D)
This expression is equivalent to the following expression:
A>B AND A>C AND A>D