[gecode-users] CCP ask for Gecode

Guido Tack tack at ps.uni-sb.de
Wed Apr 23 07:50:25 CEST 2008


Mauricio Toro wrote:
> The ask propagator worked fine in Gecode.
> I tried it with an example to find concurrently
> if there is path in directed graph.
> Running around 30000 "ask"s in a 10000 arcs
> graph it took around 0,112 seconds.
>
> To manage the AskBody I defined a class
> "AskBody" with a virtual Execute method,
> that way different bodies can be defined
> for the ask propagator inhereting from that class.
>
> I don't know how to define the "spec" method.

You can ignore it and just return NULL.  This will only mean that  
reflection is not available for your propagator.  The alternative  
would be to delegate reflection to the AskBody class (so that would  
have to have a spec method as well).

> Additionally, I had problems with the "reflection post" method
> since the AskBody is not a Gecode type.

spec and "reflection post" are closely related, if you don't have  
spec, you don't need "reflection post" either.  On the other hand, it  
doesn't matter that AskBody is not a "Gecode type".  You just have to  
define appropriate reflection functions.  But as I said, it's not  
vital, and you can ignore it for the moment.

> What do you think about this definition?
> Does it seam reasonable?

Yes.  Another option would be to make AskBody a template argument of  
Ask.  That way, Execute wouldn't have to be virtual, but you'd have to  
instantiate Ask every time (which is no big deal).

Cheers,
	Guido

>
>   class AskBody
>   {
>   protected:
>     Space * home;
>   public:
>     AskBody(Space * homie) {home = homie;}
>     virtual void Execute() { };
>   };
>
>   class Ask : public UnaryPropagator<BoolView,PC_GEN_ASSIGNED> {
>   protected:
>     using UnaryPropagator<BoolView,PC_GEN_ASSIGNED>::x0;
>     AskBody * askbody;
>
>     /// Constructor for cloning \a p
>     Ask(Space* home, bool share, Ask& p);
>     /// Constructor for posting
>     Ask(Space* home, BoolView x, AskBody * askbody);
>   public:
>     /// Copy propagator during cloning
>     virtual Actor*     copy(Space* home, bool share);
>     /// Perform propagation
>     virtual ExecStatus propagate(Space* home, ModEventDelta med);
>     /// Specification for this propagator
>         //virtual Reflection::ActorSpec spec(const Space* home,
>         //                 Reflection::VarMap& m) const;
>     /// Post propagator according to specification
>    // static void post(Space* home, Reflection::VarMap& vars,
>                    //  const Reflection::ActorSpec& spec);
>     /// Mangled propagator name
>     static Support::Symbol ati(void);
>     /// Post ask propagator
>     /// \textbf{blocking\_IF} $<boolean\_var>\ x$ \textbf{then} $<ask 
> \_body>\ askbody$ \textbf{else} $<skip>$
>     static  ExecStatus post(Space* home, BoolView x, AskBody *  
> askbody);
>   };
>
> Thanks for all,
>
> -- 
> Mauricio Toro Bermudez
> Estudiante de Ingeniería de Sistemas
> Pontificia Universidad Javeriana, Colombia
>
> Stagiare à l'Ircam
> 1, place Igor-Stravinsky 75004 Paris,
> France de 2008 à 2009
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users





More information about the gecode-users mailing list