[gecode-users] ViewArray <-> VarArgArray

Guido Tack tack at ps.uni-sb.de
Mon Jan 16 16:53:23 CET 2006


> For the element propagator, however, it is not that simple. While my class
> currently has fields of type ViewArray<IntView>, something of type
> IdxView<IntView>* is required for the array argument of
> Element::ViewDom<IntView,IntView>::post(...).
>
> My first idea was to introduce a new field in my propagator of just that
> type -- but then I'd have two views for the same variable array, which
> seems somehow redundant to me. So I decided to replace the respective field
> of type ViewArray<IntView> with the IdxView<IntView>* thing, which entailed
> several other changes.

Ok, I see. There indeed seems to be an inconsistency in the library. Normally, 
you should simply create a new IdxView<IntView>* thing, just like in 
element.cc. You don't have to use that as your own view array, just create it 
when you want to post the element propagator. Now creating an 
IdxView<IntView>* currently is only possible using IntVarArgs (that's the 
small inconsistency). However, you can easily create your own IntVarArgs. 
Suppose x is an IntView array:

IntVarArgs xa(size);
for (int i=size; i--; ) {
   IntVar v(x[i]);
   xa[i] = v;
}

Hope this helps,

	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