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

<ConsistencyModule:> ordered(+Relation,+Vars)

Constrains Vars to be ordered according to Relation
Relation
One of the atoms #<, #=<, #>, #>=, #=, #\=
Vars
Collection of integers or (domain) variables

Description

Constrains the elements in Vars to be ordered according to Relation, which is one of #>, #>=, #<, #=<, #=, #\= (or equivalently, >, >=, <, =<, =, \=). Except for #\=, the relation must hold between any two adjacent two elements in Vars, for #\=, the #\= must hold for at least one adjacent pair of elements in Vars, i.e. not all elements in Vars are equal.

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), gfd_bc for bounds consistency, and gfd_vc for value consistency

This constraint is known as strictly_increasing (#>), increasing (#=>), . strictly_decreasing (#<), decreasing (#<=), all_equal (#=), not_all_equal (#\=) in the Global Constraint Catalog, and is implemented using Gecode's rel() constraint (variant with an IntVarArgs and an IntRelType).

Examples

[eclipse 9]: ordered((#<), [1,2,3,4]).

Yes (0.00s cpu)
[eclipse 10]: ordered((#<), [1,2,2,3,4]).

No (0.00s cpu)
[eclipse 11]: ordered((#=<), [1,2,3,4]).

Yes (0.00s cpu)
[eclipse 12]: ordered((#=<),  [1,2,2,3,4]).

Yes (0.00s cpu)
[eclipse 13]: ordered((#>), [4,3,2,1]).

Yes (0.00s cpu)
[eclipse 14]: ordered((#>), [4,3,3,2,1]).

No (0.00s cpu)
[eclipse 15]: ordered((#>=), [4,3,2,1]).

Yes (0.00s cpu)

[eclipse 16]:  ordered((#>=), [4,3,3,2,1]).

Yes (0.00s cpu)
[eclipse 17]: ordered((#=), [2,2,3,3]).

No (0.00s cpu)
[eclipse 18]: ordered((#=), [2,2,2,2]).

Yes (0.00s cpu)
[eclipse 19]: ordered((#\=), [2,2,3,3]).

Yes (0.00s cpu)
[eclipse 20]: ordered((#\=), [2,2,2,2]).

No (0.00s cpu)
[eclipse 21]: ordered((#>), [2]).

Yes (0.00s cpu)
[eclipse 22]: ordered((#\=), [X]).

No (0.00s cpu)
[eclipse 23]: [A,B] :: 3..7, [C,D] :: 4..10, ordered((#=), [A,B,C,D]).

A = A{[4 .. 7]}
B = B{[4 .. 7]}
C = C{[4 .. 7]}
D = D{[4 .. 7]}

Yes (0.00s cpu)
[eclipse 24]:  [A,B] :: 3..7, [C,D] :: 4..10, ordered((#>), [A,B,C,D]).

A = 7
B = 6
C = 5
D = 4

See Also

lex_le / 2, lex_lt / 2, lex_ge / 2, lex_gt / 2, sorted / 2, fd_global : ordered / 2, ic_global : ordered / 2, order : ordered / 2, eclipse_6 : collection_to_list / 2, lists : collection_to_list / 2