Re: [eclipse-clp-users] amount of shallow backtracking.

From: Joachim Schimpf <joachim.schimpf_at_...44...>
Date: Tue, 12 May 2009 14:18:56 +1000
Kish Shen wrote:
> mauricio montecinos wrote:
> 
>> Actually, I wanted to calculate the number of times that the algorithm
>> attempts assigns a value to a variable and the constraint propagation fails,
>> because the domains of non-instantiated variables are filtered and some
>> domain becomes empty then a next value is tried.
> 

It sounds like you want something like this:

my_indomain(Var, [V|Vs]) :-
     (
         Var = V, % try assigning the value
         true     % this is where the constraints wake up and may fail
      ->
         true     % no failure happened
     ;
         % assignment+propagation failed!
         % count only if there are still other values in the domain
         ( Vs == [] -> true ; incval(count) ),
         fail
     ).
my_indomain(Var, [_|Vs]) :-
     my_indomain(Var, Vs).



-- Joachim
Received on Tue May 12 2009 - 04:19:15 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 16 2024 - 09:13:20 CEST