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

<ConsistencyModule:> table(+Vars, ++Table)

Constrain Vars' solutions to be those defined by the tuples in Table.
Vars
Collection of N (domain) variables or integers, or a collection of a collection of N (domain) variables or integers.
Table
Collection of tuples, each of which is a collection of N integer values

Description

table is an extensional constraint or user defined constraint, i.e. the solutions for the each posted constraint is explicitly defined within the constraint. Each table constraint specifies the solutions to N variables, with all the solutions for this constraint specified in Table, in the form of tuples, each of N values that is one solution to the constraint.

Vars represents the variables that are to be satisfied for this constraint. It can be one collection of N variables (or integers), or a collection of a collections of N variables (or integers), if the constraint is to be satisfied by more than one collection of variables. Posting the constraint with multiple collections of variables is logically equivalent to posting individual table constraint with the same Table for each collection, but should be more efficient as the same Table is shared by all the collections.

ConsistencyModule is the optional module specification to give the consistency level for the propagation for this constraint: gfd_gac for generalised arc consistency (domain consistency).

This constraint is known as in_relation in the global constraint catalog, with the allowance for multiple collections of variables taken from SICStus Prolog's table/2 constraint. This constraint is implemented in Gecode as the extensional() constraint with the variant that takes a TupleSet as an argument.

Examples

[eclipse 9]: table([5,3,3], [[](5,2,3),[](5,2,6),[](5,3,3)]).  % succeed
                                                               
[eclipse 10]:  table([[5,3,3],[5,2,3]],  
                     [[](5,2,3),[](5,2,6),[](5,3,3)]).         % succeed

[eclipse 11]: table([5,3,2], [[](5,2,3),[](5,2,6),[](5,3,3)]). % fail

[eclipse 12]: L = [A,B,C], table(L, [[](5,2,3),[](5,2,6),[](5,3,3)]), 
        labeling(L), writeln(L), fail.
[5, 2, 3]
[5, 2, 6]
[5, 3, 3]

No (0.00s cpu)