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

From: Joachim Schimpf <joachim.schimpf_at_...44...>
Date: Mon, 16 Feb 2009 11:17:05 +1100
Wit Jakuczun wrote:
> Hi Kish,
>    the propagator looks like that (this is an example only):
> propagate(Var, OldDom, Susp) :-
>     propagate(Var),
>     ic:get_domain_as_list(Var, NewDom),
>     kill_suspension(Susp),
>     suspend( propagate(Var, NewDom, Susp1),3, Var->ic:hole, Susp1).
> Here the state is a domain of a variable.
> What is the better way to deal with such propagators?

As Kish said, you add a State variable, and use setarg/3 on its arguments.
For your example above this would be

:- demon propagate/3.
propagate(Var, State, Susp) :-
     State = state(OldDom),
     ic:get_domain_as_list(Var, NewDom),
     setarg(1, State, NewDom).

You can find examples of this in the library files ic_constraints.ecl or

Btw, in 6.1 I intend to add set_suspension_arg/3 for this purpose.

Received on Mon Feb 16 2009 - 00:17:09 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 22 2019 - 12:14:57 CEST