Ole Tranberg wrote: > > So "?Goal" is "(search(Strategy,...),labeling_ff(Vars))". > > What does this mean? I got the point of the search strategies (or at least most of it) and I can > see what is going on in labeling_ff/1. But how do these two work together? > Is the search strategy some kind of a "help" to the labeling_ff/1? Look at the following search with 3 variables: ?- [X,Y,Z]::1..3, labeling([X,Y,Z]), writeln([X,Y,Z]), fail. [1, 1, 1] [1, 1, 2] [1, 1, 3] [1, 2, 1] [1, 2, 2] [1, 2, 3] [1, 3, 1] [1, 3, 2] [1, 3, 3] [2, 1, 1] [2, 1, 2] [2, 1, 3] [2, 2, 1] [2, 2, 2] [2, 2, 3] [2, 3, 1] [2, 3, 2] [2, 3, 3] [3, 1, 1] [3, 1, 2] [3, 1, 3] [3, 2, 1] [3, 2, 2] [3, 2, 3] [3, 3, 1] [3, 3, 2] [3, 3, 3] No (0.05s cpu) You see that the possible combinations are tried in a particular order. Now imagine you know somehow that the value 2 is a good choice for Y. A good search heuristic would then be to first try all the combinations where Y is 2. You can program this as follows: ?- [X,Y,Z]::1..3, (Y#=2;Y#\=2), labeling([X,Y,Z]), writeln([X,Y,Z]), fail. [1, 2, 1] [1, 2, 2] [1, 2, 3] [2, 2, 1] [2, 2, 2] [2, 2, 3] [3, 2, 1] [3, 2, 2] [3, 2, 3] [1, 1, 1] [1, 1, 2] [1, 1, 3] [1, 3, 1] [1, 3, 2] [1, 3, 3] [2, 1, 1] [2, 1, 2] [2, 1, 3] [2, 3, 1] [2, 3, 2] [2, 3, 3] [3, 1, 1] [3, 1, 2] [3, 1, 3] [3, 3, 1] [3, 3, 2] [3, 3, 3] No (0.06s cpu) The roster program uses the same idea. It first makes some heuristic choices for some of the variables, then it uses the generic labeling(ff)/1 predicate for the remaining search. Note that labeling/1 will simply skip variables which are aready instantiated. -- Joachim Schimpf / phone: +44 20 7594 8187 IC-Parc, Imperial College / mailto:J.Schimpf@ic.ac.uk London SW7 2AZ, UK / http://www.icparc.ic.ac.uk/eclipseReceived on Wed Sep 11 16:47:54 2002
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:16 PM GMT GMT