[gecode-users] Posting propagator : IntView lifetime ?

Grégoire Dooms dooms at info.ucl.ac.be
Wed Apr 12 11:40:48 CEST 2006


jeremie.vautard wrote:
> Hi ! 
>
> I have been checking how some of  the public static post
> members of propagator classes works for posting constraints
> passing IntVar arguments, however I get lost in the code. Can
> anyone tell me exactly how this works ? If I understand well,
> for the subscription part, it is only necessary to create the
> Intview, subscribe the new propagator to this view, and then,
> the view can be destroyed, as the subscription called the
> InVarImp subscribe method. 
The IntView and IntVar are just shells which encapsulate a pointer to an 
IntVarImp
They are just references to the real variable.
> But, concerning the domain
> shrinking of the variables, I have to keep a trace of the
> views of the variables I possibly modify.
The propagator keeps the references to the variables it needs to modify.
If your prop. works on two integer variables, just keep an IntView for 
each of them.
>  During space
> cloning, how is the update of these views managed ?
On cloning of the propagator, call v.update(home,p.v) which will update 
the reference such that it points to the new cloned variable and not to 
the old one.
>  Must I
> create new views from the IntVars each time the propagate()
> method is called ? 
>   
No. just keep two IntViews as data members in you propagator.
> My point is to create a propagator which concerns two integer
> variables and post it using only the intVars of the concerned
> two variables. What is the best way to do this ?
Use IntView's in the propagator and just build an IntView from the 
IntVar when posting.
Apart from their API, they can be considered the same object .

One way to not have to bother with update etc...  is to simply inherit 
from BinaryPropagator<IntView, PC_INT_DOM>
Have a look at a simple binary propagator such as Int::Nq :
http://www.gecode.org/gecode-doc-latest/int_2rel_2nq_8icc-source.html

Does this answer your questions ?
--
Grégoire Dooms





More information about the gecode-users mailing list