- Mail actions: [ respond to this message ] [ mail a new topic ]
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]

From: Andreas Berger <aberger_at_...228...>

Date: Sun, 28 Feb 2010 14:51:57 +0100

Date: Sun, 28 Feb 2010 14:51:57 +0100

Ok, it was the easiest way to use the third solution, because i have C Integers as values. But I see it's not the most efficient way. With the domain {0 .. 10^7) it takes a second to calculate the value. An yes,. i have only a few constraints of this type and so it's ok. Maybe I will try to use the "bool_bitand" suggestion of yours, would that be much faster? But then i have to split the Integers into bits first... Thank's Andreas Joachim Schimpf schrieb: > Andreas Berger wrote: > >> Thank you! The constraint prototype for integer is exactly what I was >> looking for. >> > > I was afraid you would say that. The reason I offered this as the > last of 3 alternatives is that this is not a constraint that is > very suited to the way the ic solver represents integer variables. > > If you have just a few of these constraints, and the majority of > constraints are the usual arithmetic or global constraints over > integer variables, this is probably ok. > > But if your problem consists mostly of this kind of constraint, > you should seriously consider the other possibilities. > > > -- Joachim > > > >> Andreas >> >> >> Am 11.02.2010 02:44, schrieb Joachim Schimpf: >> >>> Andreas Berger wrote: >>> ... >>> >>> >>>> I want to express a Constraint of the Form: >>>> >>>> "Give me a Number X, which is bitwise connected (C++ '&' ) with a second >>>> Number A is 0. >>>> >>>> Something like: A /\ X = 0, give me a possible X when A = 9. >>>> >>>> I can't find an appropiate predicate for such kind of problem. I tried >>>> the following construct: >>>> 9 /\ X #= 0, but of course it does not work. >>>> >>>> Can someone give me a hint to solve this problem please. >>>> >>>> >>> First, you should consider whether it is not better to use boolean (0/1) >>> variables for the individual bits. Your constraints may then be easier >>> to express. For example, if you represent your numbers as lists of >>> boolean digits, you can define >>> >>> bool_bitand(X, Y, Z) :- >>> ( foreach(Xi,X), foreach(Yi,Y), foreach(Zi,Z) do >>> [Xi,Yi,Zi]::0..1, >>> Zi #= (Xi and Yi) >>> ). >>> >>> and express your example as >>> >>> ?- bool_bitand(X, [1, 0, 0, 1], [0, 0, 0, 0]). >>> X = [0, _368{[0, 1]}, _457{[0, 1]}, 0] >>> Yes (0.00s cpu) >>> >>> >>> Second, if your bit vectors represent sets, you could also consider >>> using the ic_set solver's set-variables to represent them. >>> >>> >>> Third, with your original representation, you could prototype such >>> a constraint as follows: >>> >>> :- lib(propia). >>> >>> int_bitand(X, Y, Z) :- ( labeling([X,Y,Z]), X/\Y =:= Z ) infers ic. >>> >>> which solves your example in this way: >>> >>> ?- X :: 0 .. 9, int_bitand(X, 9, 0). >>> X = X{[0, 2, 4, 6]} >>> Yes (0.00s cpu) >>> >>> >>> -- Joachim >>> >>> > > > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > ECLiPSe-CLP-Users mailing list > ECLiPSe-CLP-Users_at_lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users > > >Received on Sun Feb 28 2010 - 14:31:31 CET

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