Re: [eclipse-clp-users] search tree node count

From: Joachim Schimpf <jschimpf_at_...153...>
Date: Thu, 08 Jan 2009 15:42:32 +1100
Lars Kotthoff wrote:
> Dear list,
> 
>  is there a general, preferably easy, way of getting the number of search tree
> nodes explored when searching for the solution to a problem?

A "node" is a place where a nondeterministic choice is made, e.g. in indomain/1
when you are using finite domains.  You need to add a nonlogical counter to
your code, e.g.

labeling(AllVars) :-
         setval(nodes, 0),
         ( foreach(Var, AllVars) do
             ( var(Var) ->
                  incval(nodes)   % count before making choice
             ;
                  true            % don't count trivial nodes
             ),
             indomain(Var)
         ),
         getval(nodes, NN),
         printf("Solution found with %d nodes%n", [NN]).


In constraint programming, it is more customary to count backtracks instead
of nodes, see http://eclipse-clp.org/doc/tutorial/tutorial088.html#toc82


-- Joachim
Received on Thu Jan 08 2009 - 04:42:42 CET

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