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

Christian Schulte schulte at imit.kth.se
Thu Mar 16 13:59:12 CET 2006


Hi,

please let me take things in turn.

As it comes to the fact that each propagator is executed when created
(actually this is not strictly true, see below) we need to extend the
functionality for subscription. I don't know yet how to do it best (by an
optional parameter to subscribe or by a different method) but I am going to
look at it right after this email.

Currently, a propagator is processed for propagation (and hence will
eventually be propagated) when subscribing to a view according to the
following rules: if the propagators subscribes with respect to a PC_INT_VAL
or PC_SET_VAL propagation condition, the propagator is executed only if the
variable is assigned to a single value. Otherwise, a propagator is always
executed under the assumption that the propagator does not even know yet
that the bounds of the variables have changed (so quite strong).

As it comes to IntVar and subscription: don't! Propagators only talk about
IntViews! If you hav an IntVar x and you want to create a corresponding
IntView y, just do this: y = x (or longish: IntView y(x)). Please check how
we do it for our propagators: typically there is a post function (such as
linear, distinct, etc) which talks about IntVar and arrays. This then calls
a static post member function of the propagator class after it has created
views for the vars. This static post member function then uses new to create
a propagator. Look to the code for examples.

As it comes to new: all news are placament news and require a space
argument, so something like "new (home) ...". Again look for examples.

All the best
Christian

--
Christian Schulte, http://www.imit.kth.se/~schulte/ 

-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Jérémie Vautard
Sent: Tuesday, March 14, 2006 10:11 PM
To: users at gecode.org
Subject: [gecode-users] Propagator called too soon...


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




_______________________________________________
Gecode users mailing list
users at gecode.org https://www.gecode.org/mailman/listinfo/gecode-users





More information about the gecode-users mailing list