More on withTuples
The withTuples operator lets you provide more than one set of operands to a constraint. It has the following syntax:
withTuples (((A, B, C),(D,E F),...), ruleA(%1,%2,%3,...),...)
For example, you have the following two constraints:
req(and([A],[B]),excl([C],[G]))
When both A and B are present, C and G exclude each other
req(and([D],[E]),excl([F],[G]))
When both D and E are present, F and G exclude each other.
The previous two constraints can be considered one required constraint that has two sets of operands. The withTuples operator lets you write the constraint in this fashion. This makes constraint maintenance easier. If the operands change, you can edit them in one location, rather than having to locate all the constraints in which they appear. Here is one way to combine the two constraints using withTuples:
withTuples((([A],[B],[C]),([D],[E],[F])),req(and(%1,%2),
excl(%3,[G]))
Notice that each group of operands is enclosed in parentheses. Also notice that the whole section where the operands are specified is itself enclosed in parentheses.
You can also use the withTuples operator to specify the operands for multiple constraints. For example, you have the following two constraints:
req(and([A],[B]),[C])
inc([C], [Resource1])
If both A and B are present, C is required, and contribute the value of C to Resource1.
These two constraints are different but they make use of the same operands. You could use the withTuples operator to show that these two constraints use the same operands as follows:
withTuples((([A],[B],[C])),req(and(%1,%2),%3),inc(%3,[Resource1]))