Chuang Liu wrote: > hi there: > I am using library fd to implement a tree search > method. I like to control the value selection for > variables during the search process. I have a variable > whose domain is [1, 2, 3, 4, 5], and I associate a > weight to every value. I want the search process to > try value with higher weight first. > > I tried to sort the value domain based on the weight > of values like > V :: [2, 1, 3, 5, 4], > indomain(V) > > But indomain always pick the 1 first. If all your variable domains are subsets of one "superdomain" which you can order, then you can define a variable-independent value-selection predicate and use that instead of indomain. E.g. for your example: % enumerate values 1..9 in some heuristic order domain_value(7). domain_value(2). domain_value(6). domain_value(1). domain_value(3). domain_value(9). domain_value(5). domain_value(4). domain_value(8). ?- V :: 1..5, domain_value(V). V = 2 Yes (0.00s cpu, solution 1, maybe more) ? ; V = 1 Yes (0.00s cpu, solution 2, maybe more) ? ; V = 3 Yes (0.00s cpu, solution 3, maybe more) ? ; V = 5 Yes (0.00s cpu, solution 4, maybe more) ? ; V = 4 Yes (0.00s cpu, solution 5, maybe more) ? ; No (0.00s cpu) ?- V :: [4,6,7], domain_value(V). V = 7 Yes (0.00s cpu, solution 1, maybe more) ? ; V = 6 Yes (0.00s cpu, solution 2, maybe more) ? ; V = 4 Yes (0.00s cpu, solution 3, maybe more) ? ; No (0.00s cpu) -- Joachim Schimpf / phone: +44 20 7594 8187 IC-Parc / mailto:J.Schimpf@imperial.ac.uk Imperial College London / http://www.icparc.ic.ac.uk/eclipseReceived on Wed Dec 08 15:11:11 2004
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:32 PM GMT GMT