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

From: Joachim Schimpf <joachim.schimpf_at_...269...>
Date: Thu, 13 Jan 2011 15:09:53 +1100
Oliver Shycle wrote:
> Thanks Matthew for your hint.
> 
> The solver really obviously doen's support negation like this. I helped
> myself out by describing what I want using intersection and cardinality
> constraints:
> If two sets with cardinality 2 shall not be equal, then simply the
> intersection must have a cardinality of lower or equal than 1. So I can
> write:
>             #(Pair1 /\ Pair2, I),
>             I #=< 1
> 
> This should do the trick I guess. Note, this only works for my case
> because I know that the sets have a cardinality of exact 2.

Good idea.  A more general formulation (works for any cardinality) is

different_sets(X, Y) :-
    symdiff(X, Y, D),
    #(D) #>= 1.

It seems to do the limited amount of propagation that is possible
with this constraint:

?- X in_set_range [1,2]..[1,2,3], Y = [1,2,3], different_sets(X, Y).
X = [1, 2]
Y = [1, 2, 3]
Yes (0.00s cpu)


-- Joachim
Received on Thu Jan 13 2011 - 04:10:06 CET

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST