RE: Counting backtracks

From: Aminu, Farouk <f.aminu_at_lancaster.ac.uk>
Date: Fri 02 May 2003 02:32:31 PM GMT
Message-ID: <7F332A8009EE5D4CB62C87717A3498A164550F@exchange-be1.lancs.ac.uk>
Hello,

I used: 

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

but I am getting the following message:

'type error in printf("%d \n \n", [B])'

am I doing something wrong?

Farouk

Umaru Farouk Aminu
Department of Management Science,
Lancaster University,
Lancaster,
LA1 4YX,
UK.
Tel: +44 1524 383619 (Home)
      +44 1524 593865 (School)
      +44 1524 844885 (Fax)




-----Original Message-----
From: Joachim Schimpf [mailto:j.schimpf@icparc.ic.ac.uk]
Sent: 02 May 2003 12:40
To: eclipse-users@icparc.ic.ac.uk
Subject: Re: [eclipse-users] Counting backtracks


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 15:38:33 2003

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