GAC lexicographic less-than-or-equal constraint

From: Warwick Harvey <wh_at_icparc.ic.ac.uk>
Date: Thu 14 Feb 2002 01:52:56 PM GMT
Message-ID: <20020214135256.A2648@tempest.icparc.ic.ac.uk>
Hi,

In the past I've had a number of enquiries about the lexicographic
less-than-or-equal constraint (lexico_le/2 from fd_global), in particular
whether it maintained Generalised Arc Consistency.  The short answer to that
is no, it's not; there are some circumstances where it does not propagate as
much domain information as it could.

Anyway, since I've just had another request about this, I thought I'd post
the source code to a GAC implementation I developed last year, for anybody
who wants it.

If you're using the new IC library, try this:

:- lib(ic).

my_lexico_le(Xs, Ys) :-
	my_lexico_le(Xs, Ys, 1).

my_lexico_le([], [], 1).
my_lexico_le([X | Xs], [Y | Ys], B) :- 
	B #= (X #< Y + B1),
	my_lexico_le(Xs, Ys, B1).  


If you're using the old FD library, try this:

:- lib(fd).

my_lexico_le(Xs, Ys) :-
	my_lexico_le(Xs, Ys, 1).

my_lexico_le([], [], 1).
my_lexico_le([X | Xs], [Y | Ys], B) :- 
	B isd (X #< Y + B1),
	my_lexico_le(Xs, Ys, B1).  


These implementations may leave some delayed goals lying around longer than
necessary (they'll go away when everything is ground), but they ought to
maintain GAC, if that's what you want.

Cheers,
Warwick
Received on Thu Feb 14 13:54:48 2002

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:13 PM GMT GMT