[gecode-users] Posting propagator : IntView lifetime ?

Grégoire Dooms dooms at info.ucl.ac.be
Thu Apr 13 18:07:08 CEST 2006


jeremie.vautard wrote:
> Hi ! 
>
> first, thanks Grégoire and Christian. I now understand what to
> do exactely for creating my propagator. I just have one
> remaining question (in fact, more a check than a question) :
> is it OK to call, within the propagate method of a propagator,
> a method from a class which is totally external to the current
> space, but takes some IntViews in argument ? I am trying to
> make an extensively defined binary constraint (so the accepted
> couples are listed in a big table) : I have a class in which
> my table is stored, and this class has a method '' PropCost
> check(IntView x,y) '' which will actually remove values from
> the IntViews. So, in the propagate method of my propagator,
> may I just do return ctr->check(xa,xb) (where ctr is a pointer
> to an Extensive Binary Constraint object the propagator
> knows). I think this wouldn't create any problems, but I
> prefer to check...
>   
It's ok as long as
1) you pass the Space* to the check method (as it is needed to remove 
the values).
2) you return a ModEvent instead of a PropCost. This ModEvent must be 
built by combining the me of each tell to the IntViews.
You can combine by using IntVarImp::combine(me1,me2) (defined in 
Variable<VTI,PC>) . Also don't forget that each time you do
me=x.inter(i); // you also have to do
GECODE_ME_CHECK(me); // as you cannot do other tells if this one failed.
3) don't forget to return ES_SUBSUMED or ES_FAIL if the views are 
assigned and to not return ES_FIX (prefer ES_NOFIX) unless you are sure 
that you have a reached fixed point (eg. this might not be the case if 
shared(x,y) returns true.).

Best,
--
Gregoire Dooms






More information about the gecode-users mailing list