Re: [eclipse-clp-users] Propagators with a state

From: Wit Jakuczun <>
Date: Mon, 16 Feb 2009 15:40:34 +0100
2009/2/16 Kish Shen <>:
> Wit Jakuczun wrote:
>> But I would love to have other features:
>> - initial call of a propagator (could result in suspending). This would be
>>  especially useful for propagators based on demons.
> As propagators are normal ECLiPSe goals, you can simply write your
> propagator such that it is executed once before suspension, something like:
> propagator(...) :-
>        do_propagation(....),
>        suspend(do_propagation(....)...).

The code looks like that:

propagator(Vars, state(State0)) :-
    update_state(Vars, State0, State1),
    ( ground(Vars) -> check_solution(Vars)
    ; do_propagate(Vars, State1),
      suspend(propagator(Vars, state(State1), Susp), 3, Vars->inst, Susp)).

propagator(Vars, State,  Susp) :-
    State = state(State0),
    update_state(Vars, State0, State1),
    ( ground(Vars) -> kill_suspension(Susp), check_solution(Vars)
    ; do_propagate(Vars, State1), setarg(1, State, State1)).

update_state/3 must be called as there can be more that
one variable instantiated comparing to previous call of a propagator.
This is due to priorities!
Now, propagator/2 is called and if there is a need for suspension
a propagator/3 (demon) is suspended. If there were guarantee
that propagators are called for each variable change separately
then I could do as you proposed.
I hope I clarified the issue.

Best regards
[ Wit Jakuczun ]
[ WLOG Solutions   ]
Received on Mon Feb 16 2009 - 14:40:40 CET

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET