boolAbstraction

Creates a constraint that abstracts the values of one array as Boolean values in another array.

Syntax


constraint boolAbstraction(intExprArray y, intExprArray x, intArray values)

Parameters

  • y: an array of abstracted integer expressions
  • x: an array of reference integer expressions
  • values: an array of integer values to abstract

Description

This function creates and returns a constraint that abstracts an array of integer expressions in a model. It differs from abstraction in that elements each y[i] is Boolean.

Like abstraction, for each element x[i] there is an expression y[i] corresponding to the abstraction of x[i] with respect to the values array. That is,

  • x[i] = v with v in values if and only if y[i] = true()
  • x[i] = v with v not in values if and only if y[i] = false()

This constraint maintains a many-to-one mapping that makes it possible to define constraints that impinge only on a particular set of values from the domains of constrained variables.

Example

Here is a simple example that demonstrates the behavior of this constraint by abstracting values of integer variables [i,j,k] as values of Boolean variables [a,b,c]. The example enforces the fact that each abstracted variable is true and ensures that each value in values is found in the reference variables [i,j,k]:


// declare abstracted variables 
a = intVar(0..1);
b = intVar(0..1);
c = intVar(0..1);
// declare reference variables
i = intVar(1..10);
j = intVar(1..10);
k = intVar(1..10);
// enforce abstraction
boolAbstraction([a,b,c],[i,j,k],[2,3,5]);
// checking part:
// force abstracted value to true
(a + b + c) == 3;
// enforce the fact reference values are all different
alldiff([i,j,k]);
// the number of occurrences of each abstraction value in the reference variable array must be one!
count([i,j,k], 2) == 1;
count([i,j,k], 3) == 1;
count([i,j,k], 5) == 1;

Requirements

Arrays 'x' and 'y' must be of the same size.