On Fri, 2002-11-29 at 09:21, Warwick Harvey wrote: > Hi Sebastian, > > On Thu, Nov 28, 2002 at 11:46:32PM -0500, Sebastian Sardina wrote: > > I have fd and fd_search loaded: > > > > [eclipse 35]: X :: [red, blue, green], indomain(X, random). > > type error in indomain(_248{[blue, green, red]}, random) > > Abort > > Yes, this used to work. > > > [eclipse 36]: X :: [red, blue, green], indomain(X, split). > > type error in indomain(_248{[blue, green, red]}, split) > > This never worked. yes you are right here. My mistake. random worked but split never did. > The fd_search library was never intended to work for symbolic domains; the > fact that it did work for the random method was purely accidental (the > original author of the library was very surprised to hear that it did). > > Since the last release, the fd_search code has become common between it and > the ic_search library. In making it generic, some of the error checking and > reporting was cleaned up. Some months later we realised that this may have > inadvertently stopped fd_search from working with symbolic domains, but when > investigating the impact of this we discovered that only the random method > had worked previously and that that had been accidental. In the lead up to > the 5.5 release we considered trying to restore the functionality to > maintain complete compatibility, but it wasn't a high priority and it wasn't > clear how useful the functionality was anyway. (And if we were going to > address symbolic domains, it probably should have been done properly, which > we certainly didn't have time for.) ok I understand now. > In any event, it shouldn't be too hard to write your own indomain predicate > to do what you want. In particular, you can use ::/2 to retrieve a > representation of the current domain of a variable, which you can then pass > to the nth_value/3 predicate provided by fd_search, which returns the Nth > value in the given domain (though if your domains are symbolic, ::/2 will > always return a simple list, which you can do with as you like). Plug in a > random number (or whatever ordering you like) and "Bob's your uncle" as they > say... now I can write something like: my_random_choice(X) :- ........ < using nth_value/3 and random/1 > Now here is my big doubt: 2) how can I make my random-choice procedure to repetitively select different random values for X without repeating? should my_random_choice/1 be responsible of doing that or search/6 itself takes care of this? > > Once you have this predicate you can of course use it as the choice method > in a call to search/6; indeed, by providing your own selection and choice > methods, the variables don't even need to be FD variables: in the past I've > used fd_search's search/6 to solve problems involving sets. Yes right they don't even have to be FD variables. But should my my_random_choice/1 be as good and efficient as the indomain_random already provided for say integer finite domains? My program uses many types of variables, only some of them being symbolic. I want to apply search/6 randomly for every variable but I want a general and still efficient solution. > Cheers, > Warwick Thanks SebastianReceived on Mon Dec 02 04:57:43 2002
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:19 PM GMT GMT