[gecode-users] Propagator called too soon...

Jérémie Vautard jeremie.vautard at laposte.net
Tue Mar 14 22:10:44 CET 2006


Hello !

(These questions come in the same context than the "Extending integer 
and set variables to quantified variables 
<http://www.gecode.org/gecode-users/2006-March/001000.html>" thread I 
started a while ago...)

I have made a propagator which fails the space immediately when invoked, 
in order to stop the propagation as soon as an universally quantified 
variable domain is reduced. The only problen I have is that this 
propagator is also called one first time at the very begining of the 
propagation loop. Is there a way to avoid this first call, and call the 
propagator only when the variable domain have been actually reduced ? I 
suppose that it can be done using propagation conditions, but I must 
admit I don't really understand how to create user-defined PropConds.

Another, maybe trivial, question : what is the best way to subscribe a 
propagator to a particular IntVar ? The way I use presentely is I think 
a little dirty : I have created a "QIntVar" class which extands the 
IntVar class by only adding it a   IntvarImp* GetVar()   method 
returning the protected "var"member of the IntVar class. Then, I use the 
subscribe() method of this IntVarImp in order to subscrime my "fail-now" 
propagator. Is there a cleaner way to achieve this ?

Yet another question : when I try to make a new "Fail-now" propagator 
using the 'new' operator, (  ForAllProp* pr = new ForAllProp(home,fd) by 
example. I have defined the  ForAllProp(Space* home, bool fd=false) 
constructor. ), I get an error at the compilation process. I have for 
the moment avoided the problem by declaring only one global "ForAllProp 
fa(myspace);" and using subscribe(myspace,&fa,condition), but I don't 
really like this. For the same reason, the copy() is for the moment 
defined by :
Actor* copy(Space* home, bool share) {return this;}
and I wonder if it will not be a source of problems later...

Here is my ForAllProp class, defining the "Fail now" propagator :

class ForAllProp : public Propagator {
public : 
  ForAllProp(Space * home, bool fd = false) : Propagator(home,fd) {};
  ForAllProp(Space * home, bool share, ForAllProp & p) : Propagator(home, share, p) {};
  PropCost cost(void) const {return PC_UNARY_LO;};
  ExecStatus propagate(Space * home) {cout<<"ForAll réduit";return ES_FAILED;};
  Actor* copy(Space* home, bool share) {return this;}
};


Best regards,

Jeremie







More information about the gecode-users mailing list