Re: [eclipse-clp-users] fd_sets sameset negation

From: Matthew Skala <mskala_at_...203...>
Date: Tue, 11 Jan 2011 08:34:33 -0600 (CST)
On Tue, 11 Jan 2011, Oliver Shycle wrote:
> "sameset(Set1,Set2)" that makes the two sets the same. But how does the
> syntax look like, when I want the two sets to be different? If I use "neg

The solver probably doesn't support such constraints.  Note that solving
the negated version of a constraint may in general be much harder than
solving the non-negated version; it's not a symmetrical situation by any
means, so you can't generally expect that a given solver will support the
negated version of each constraint it does support.  You should also be
aware that problems that use these constraints may take much longer to
solve than problems that don't.

When I ran into a similar situation, where I wanted a "neither of these
sets is a subset of the other" constraint in ic_sets, I ended up
adding a customized constraint like this:

set_nsub_cst(P,Q):-var(P),!,suspend(set_nsub_cst(P,Q),2,P->inst).
set_nsub_cst(P,Q):-var(Q),!,suspend(set_nsub_cst(P,Q),2,Q->inst).
set_nsub_cst(P,Q):-lists:subset(P,Q),!,fail.
set_nsub_cst(P,Q):-lists:subset(Q,P),!,fail.
set_nsub_cst(_,_).

It shouldn't be difficult to create something similar for "set not equal,"
depending on how much propagation you need.  The above code doesn't really
do any propagation; it waits until the sets are fully instantiated before
testing them.  On the other hand, with this kind of constraint there may
not be much propagation possible anyway, and it worked well in practice
in my application.
-- 
Matthew Skala
Postdoctoral Fellow, University of Manitoba
mskala@...287...
Received on Tue Jan 11 2011 - 14:50:59 CET

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST