[Gecode] Some more details on posting...

Christian Schulte schulte at imit.kth.se
Thu May 6 15:52:03 CEST 2004


There are two more things to be taken into account for posting.

The first is that one needs to make sure that a propagator is never posted
in a failed space (as there is not guarantee that the datastructures in a
failed space obey the invariants). Therefore a post-function first needs to
check whether the space is failed or not. You might want to use the macro
GECODE_CFAILED() for that (see kernel/macros.hh).

The second issue has to with the two different array types: ArgsArray<...>
and VarArray<...> (such as SetVarArgs and VarArray<SetVar>). The former is
reserved for passing arrays to post-functions, and that ONLY by const& (that
is the type must be const SetVarArgs&). The latter are the arrays with which
propagators compute. The propagator post function is the only function which
takes the type VarArray<SetVar>. The constructors always take
VarArray<SetVar>&. Why: when passing a ArgsArray to something that expects a
VarArray a copy of the array is created (coercion). This of course should
only happen when it is really needed and this is in the post-function. If it
were to happen in the static propagator post method, each time you would
invoke that you would do that copy!

I know changed the propagator abstractions to follow that rule which broke
the set stuff. If you want to look for an example check out the distinct or
bool stuff: This is also interesting to see where to do inlinining and where
not.

Christian

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





More information about the gecode-users mailing list