Aggregative functions¶
Aggregative functions combine several values, or the elements of an array, into a single result, or impose a condition over the whole set of elements they are applied to.
The following functions are available:
See also
See Constraint Programming functions for a general explanation on how to read the signature tables below.
sum¶
Returns the sum of all its operands. The second argument is used to index a subset of the first argument to be considered. If the dimension of the first argument is 2, the sum is performed over the columns.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument 2 |
array of integers of dimension 1, interval, collection. |
Optional |
Signature (dimension of Argument 1: 2)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
prod¶
Returns the product of all its operands. The second argument is used to index a subset of the first argument to be considered. If the dimension of the first argument is 2, the product is performed over the columns.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument 2 |
array of integers of dimension 1, interval, collection. |
Optional |
Signature (dimension of Argument 1: 2)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
max¶
Returns the maximum value among all its operands. The second argument is used to index a subset of the first argument to be considered. If the dimension of the first argument is 2, the maximum is performed over the columns.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument 2 |
array of integers of dimension 1, interval, collection |
Optional |
Signature (dimension of Argument 1: 2)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
min¶
Returns the minimum value among all its operands. The second argument is used to index a subset of the first argument to be considered. If the dimension of the first argument is 2, the minimum is performed over the columns.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument 2 |
array of integers of dimension 1, interval, collection |
Optional |
Signature (dimension of Argument 1: 2)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
and¶
Returns 1 if all its operands are equal to 1, and 0 otherwise. When applied to an empty collection, it evaluates to 1. The second argument is used to index a subset of the first argument to be considered. If the dimension of the first argument is 2, the logical and is performed over the columns.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument 2 |
array of integers of dimension 1, interval, collection |
Optional |
Signature (dimension of Argument 1: 2)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
or¶
Returns 0 if all its operands are equal to 0, and 1 otherwise. When applied to an empty collection, it evaluates to 0. The second argument is used to index a subset of the first argument to be considered. If the dimension of the first argument is 2, the logical or is performed over the columns.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument 2 |
array of integers of dimension 1, interval, collection |
Optional |
Signature (dimension of Argument 1: 2)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
xor¶
Returns 1 if the number of operands equal to 1 is odd, and 0 if it is even. When applied to an empty collection, it evaluates to 0. The second argument is used to index a subset of the first argument to be considered. If the dimension of the first argument is 2, the logical xor is performed over the columns.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument 2 |
array of integers of dimension 1, interval, collection |
Optional |
Signature (dimension of Argument 1: 2)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
atLeastOne¶
Returns 1 if at least one of its operands is equal to 1, and 0 otherwise. When applied to an empty collection, it evaluates to 0. The second argument is used to index a subset of the first argument to be considered. If the dimension of the first argument is 2, the at least one operation is performed over the columns.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument 2 |
array of integers of dimension 1, interval, collection |
Optional |
Signature (dimension of Argument 1: 2)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
atMostOne¶
Returns 1 if at most one of its operands is equal to 1, and 0 otherwise. When applied to an empty collection, it evaluates to 0. The second argument is used to index a subset of the first argument to be considered. If the dimension of the first argument is 2, the at most one operation is performed over the columns.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument 2 |
array of integers of dimension 1, interval, collection |
Optional |
Signature (dimension of Argument 1: 2)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
exactlyOne¶
Returns 1 if exactly one of its operands is equal to 1, and 0 otherwise. When applied to an empty collection, it evaluates to 0. The second argument is used to index a subset of the first argument to be considered. If the dimension of the first argument is 2, the exactly one operation is performed over the columns.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument 2 |
array of integers of dimension 1, interval, collection |
Optional |
Signature (dimension of Argument 1: 2)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
allDifferent¶
Returns 1 if all of its operands are different, and 0 otherwise. When applied to an empty collection, it evaluates to 1. The second argument is used to index a subset of the first argument to be considered.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
numeric |
Mandatory |
Argument 2 |
array of integers of dimension 1, interval, collection |
Optional |
hull¶
Returns the smallest interval including all the intervals given as operands. Its start is the smallest start and its end is the largest end among the operands. The second argument is used to index a subset of the first argument to be considered.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
interval |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
interval |
Mandatory |
Argument 2 |
array of integers of dimension 1, interval, collection |
Optional |
intersection¶
Returns the largest interval fully contained in every operand. The second argument is used to index a subset of the first argument to be considered.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
interval |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
interval |
Mandatory |
cover¶
Returns 1 if the given collections form a cover of their common domain, i.e. if every element of the domain belongs to at least one of the collections, and 0 otherwise.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
collection |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
collection |
Mandatory |
disjoint¶
Returns 1 if the given collections are pairwise disjoint, i.e. if no element belongs to more than one of the collections, and 0 otherwise.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
collection |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
collection |
Mandatory |
partition¶
Returns 1 if the given collections form a partition of their common domain, i.e. if every element of the domain belongs to exactly one of the collections, and 0 otherwise.
Parameters
Signature (dimension of Argument 1: 0)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
collection |
Mandatory |
Argument >= 2 |
Additional operand(s). Any number of these arguments can be provided; together with the previous argument(s), they are treated as forming a single array of dimension 1. |
Optional |
Signature (dimension of Argument 1: 1)
Parameter |
Description |
Requirement |
|---|---|---|
Argument 1 |
collection |
Mandatory |