[gecode-users] ViewArray <-> VarArgArray
Guido Tack
tack at ps.uni-sb.de
Mon Jan 16 09:47:00 CET 2006
Hi!
Lars Otten wrote:
> Hello everyone,
>
> I am currently trying to extend Gecode with some custom propagators as
> preparation for my thesis project, and although it's not always been easy
> I've managed to implement a few things already.
Great. Please keep us informed of your progress!
> Currently I'm working on a propagator for a constraint that relates three
> arrays of variables. Among other things, at some point during propagation,
> I need to post some other constraints, like Gecode::eq(Space*, IntVar,
> IntVar).
>
> The propagator class has three fields of type ViewArray<IntView>, say x0,
> x1, and x2. Now, when posting the additional equality constraints mentioned
> above I've just called e.g.
> Gecode::eq(this,x0[i],x1[j]);
To create a new propagator during propagation, you need to call the
propagator's post method instead of posting it through the modelling
interface as you do now.
You find an example for posting new propagators e.g. in the file
int/distinct/dom.icc, where an Nq propagator is created. The propagator post
methods take Views and ViewArrays as arguments, so this will solve your
problem. The only thing you need to take care of is the return value of the
post method: you must check whether it returned failure with the
GECODE_ES_CHECK macro.
> and things went smoothly, although, technically, x0[i] is of type IntView
> and not IntVar -- but this fit my understanding of IntView as some sort of
> wrapper for an IntVar.
Actually, it is not a wrapper for an IntVar, but both are wrappers for an
IntVarImp. The vars provide the "read-only" interface you need for modelling,
and the views export an interface that includes the tell operations for the
propagators.
> [...]
> I've already searched the reference documentation for quite a while, but
> haven't found anything that helped me here. My assumption is that I need to
> 'convert' the ViewArray<IntView> into something of type IntVarArgs (i.e.
> VarArgArray<IntVar>), but maybe I'm wrong...? Is there any straightforward
> way to do this that I've been missing so far?
This is not mentioned anywhere in the reference documentation, so you couldn't
find it. It will be part of the Gecode tutorial that we are writing.
> Thanks in advance,
You're welcome!
Cheers,
Guido
--
Guido Tack
Programming Systems Lab, Saarland University, Saarbrücken
http://www.ps.uni-sb.de/~tack
More information about the gecode-users
mailing list