[gecode-users] question about lexical ordering constraint and others

Christopher Jefferson caj at cs.st-andrews.ac.uk
Tue May 10 23:02:16 CEST 2011


On 10 May 2011, at 17:35, Kish Shen wrote:

> Hi,
> 
> I have a few (more) question about various Gecode constraints that I am interfacing to ECLiPSe:
> 
> 1) the constraint for lexical ordering
> 
> rel(Home, IntVarArgs, IntRelType, IntVarArgs)
> 
> requires the two arrays to be the same size. It seems the same restriction applies in the global constraint catalog for the lexical ordering constraints as well. However, the existing ECLiPSe lexical ordering constraints does not have this restriction -- i.e. the two sequences of numbers being compared can be different lengths. What is the reason for the same length restriction?
> 
> The lexical ordering for sequences of different length used in ECLiPSe seems to be the natural one, where missing numbers in the shorter sequence are replaced by 'bottom', i.e. a value smaller than any number.
> So (using . to separate numbers in a sequence)
> 
> 1.3 > 1.2.5
> 
> 1.2.5 > 1.2
> 
> etc.
> 
> Could such a definition of ordering be used in the Gecode version as well?

The easiest way to implement this is as follows:

If the second array is longer, just truncate it to the length of the first.
If the first array is longer, truncate it to the length of the first and change the lex<= constraint to a lex< (assuming gecode has a lex< constraint).

If you don't have a lex< constraint, you can make one by sticking 1 on the end of the first array and 0 on the end of the second (once the arrays are the same length).

Chris


More information about the users mailing list