[ library(gfd) | Reference Manual | Alphabetic Index ]

atleast(?N, +Vars, +V)

Atleast N elements of Vars have the value V.
N
An integer or domain variable
Vars
A collection (a la collection_to_list/2) of domain variables or integers
V
An integer

Description

This constraint ensures that at least N elements of Vars have the value V.

This constraint is a specialisation of the more general count/4 constraint, with the (#>=) relation, i.e. the occurrences of V is greater than or equal to N. Note that the order in which N and V occur in the constraint are swapped with respect to occurrences/3 and count/4; this is for compatibility with the argument order in IC (for atmost/3).

ConsistencyModule is the optional module specification to give the consistency level for the propagation for this constraint: gfd_gac for domain (generalised arc) consistency. Note that if V is a domain variable, then the propagation is weak, achieving neither domain or bound consistency until V becomes ground.

This constraint is also known as atleast in the global constraint catalog, where N is restricted to an integer; the more general count/4 constraint is also known as count in the global constraint catalog, and the constraint is implemented using Gecode's count() constraint.

The constraint is also known as atleast in the global constraint catalog, and is implemented using Gecode's count() constraint.

Fail Conditions

Fails if less than N elements of Vars can be instantiated to V.

Examples

[eclipse 2]: N :: [3,6], atleast(N, [3,A,3,5,3,3], 3).

N = 3
A = A{[-1000000 .. 1000000]}

See Also

count / 4, atmost / 3, element / 3, occurrences / 3, lists : collection_to_list / 2