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

lex_le(+Collection1, +Collection2)

Collection1 is lexicographically less or equal to Collection2
Collection1
Collection of integers or (domain) variables
Collection2
Collection of integers or (domain) variables

Description

Imposes a lexicographic ordering between the two lists. I.e. either is the first element of Collection1 strictly smaller than the first element of Collection2, or the first elements are equal and the lexicographic order holds between the two list tails. A non-existing element (i.e. when the end of list is reached) is strictly smaller than any existing element.

This constraint is known as lex_lesseq in the global constraint catalog, but the catalog's definition requires Collection1 and Collection2 to be the same size. It is implemented using Gecode's rel() constraint (variant that takes two IntVarArgs arguments), with the IRT_LQ IntRelType.

Examples

[eclipse 31]: lex_le([5,2,3,1], [5,2,6,2]).
   ...
Yes (0.00s cpu)
[eclipse 32]: lex_le([5,2,3,9], [5,2,3,9]).
   ...
Yes (0.00s cpu)
[eclipse 33]: lex_le([5,2,4], [5,2,4,1]).
  ...
Yes (0.00s cpu)
[eclipse 34]: lex_le([5,2,4,1], [5,2,4,0]).

No (0.00s cpu)

See Also

lex_lt / 2, lex_gt / 2, lex_ge / 2, lex_eq / 2, lex_ne / 2, fd_global : lex_le / 2, ic_global : lex_le / 2, fd_global_gac : lex_le / 2, ic_global_gac : lex_le / 2