From: Thom Fruehwirth <fruehwir_at_informatik.uni-muenchen.de>

Date: Thu 25 Jan 2001 04:26:08 PM GMT

Message-ID: <3A7053A0.A9F5EFDD@informatik.uni-muenchen.de>

Date: Thu 25 Jan 2001 04:26:08 PM GMT

Message-ID: <3A7053A0.A9F5EFDD@informatik.uni-muenchen.de>

rui@omega.di.uminho.pt wrote: > > I was trying to express a constraint like C #= abs(A) in fd. After a few > attempts it seemed that none of the usual arithmetic constraints, appart > from the basic operations (+, -, * and /) can be easily represented. > > Is this true? Or am I just being a clueless newbie? > Is the way around to write those constraints from scratch as user defined > ones? > > --Rui Mendes >From the definition of abs(i)=a if (i < 0) a = -i else a = i; it follows that (sorry, latex) $(i<0 \land a= -i) \lor (\neg i<0 \land a= i)$ which leads to the invariant $a \geq 0 \land a \geq i \land i \geq -a$ that you can use as propagator for the abs-constraint. In finite domains, you can also write your own propagator in the constraint handling rules library of Eclipse, something like: I::ListDomain, A#=abs(I) ==> setof(V, (member(W,ListDomain), V is abs(W)), AL), A::AL. A::ListDomain, A#=abs(I) ==> setof(V, (member(W,ListDomain),(V is W;V is -W), IL), I::IL. Thom Fruehwirth -- http://www.pst.informatik.uni-muenchen.de/~fruehwir/Received on Thu Jan 25 16:39:33 2001

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