[gecode-users] ViewArray <-> VarArgArray

Lars Otten ottenl at student.chalmers.se
Mon Jan 16 00:22:47 CET 2006


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.

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]);
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.

Now I also need to post a propagator Gecode::element(Space*, IntVarArgs&,
IntVar, IntVar). Intuitively I tried calling
	Gecode::element(this, x0, x1[i], x2[j]);
In this case, however, using the array of views as second argument won't
work as the compiler doesn't find a matching function, apparently IntVarArgs
and ViewArray<IntView> are not 'compatible' in this respect.

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?

Thanks in advance,
/Lars




More information about the gecode-users mailing list