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. On 11 January 2011 15:34, Matthew Skala <mskala_at_cs.toronto.edu> wrote: > 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_at_cs.umanitoba.ca >Received on Wed Jan 12 2011 - 12:53:06 CET
This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET