RE: Counting backtracks

From: Aminu, Farouk <f.aminu_at_lancaster.ac.uk>
Date: Fri 02 May 2003 03:10:47 PM GMT
Message-ID: <7F332A8009EE5D4CB62C87717A3498A1645510@exchange-be1.lancs.ac.uk>
This is how I put the code in the program.

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

	init_backtracks :-
        setval(backtracks,0).

	get_backtracks(B) :-
        	getval(backtracks,B).
        
	count_backtracks :-
        	setval(deep_fail,false).

	count_backtracks :-
        	getval(deep_fail,false),        
        	setval(deep_fail,true),
        	incval(backtracks),
        	fail.

	mylabeling(AllVars) :-
        	( foreach(Var, AllVars) do
            	count_backtracks,
            	indomain(Var)                      
        	).

'Pieces' are my search variables and 'Total' is the variable I am minimising.

regards,

Farouk



-----Original Message-----
From: Joachim Schimpf [mailto:j.schimpf@icparc.ic.ac.uk]
Sent: 02 May 2003 15:52
To: eclipse-users@icparc.ic.ac.uk
Cc: Aminu, Farouk
Subject: Re: [eclipse-users] Counting backtracks


"Aminu, Farouk" wrote:
> 
> 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])'

As you can see from the error message, B is not instantiated.
Probably because you haven't called init_backtracks.


-- 
 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 16:11:04 2003

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