Re: Counting backtracks

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Fri 02 May 2003 11:40:23 AM GMT
Message-ID: <3EB25927.B19EE0E6@icparc.ic.ac.uk>
Karen Petrie (scomkep@zeus.hud.ac.uk) wrote
>...
> Then you need to redefine the event handler:
> 
> write_info(_Error, Predicate):-
>         arg(1, Predicate, Minimum),
>         printf("Found a solution with cost %d \n", [Minimum]),
>         get_backtracks(B),
>         printf("Backtracks to this point = %d \n \n", [B]).
> 
> %set event handler
> :- set_event_handler(280, write_info/2).
> 
> Then all you do is call minimize on your labelling:
> 
> minimize(mylabeling(SearchVars), OptimalNumber)


There is actually no need to use this obscure event handler.
You can simply write:

    minimize((
	    mylabeling(SearchVars),
            get_backtracks(B),
            printf("Backtracks to this point = %d \n \n", [B])
	), OptimalNumber)

Whenever mylabeling/1 succeeds, you have a better solution.


-- 
 Joachim Schimpf              /             phone: +44 20 7594 8187
 IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
 Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
Received on Fri May 02 12:40:30 2003

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:23 PM GMT GMT