[gecode-users] complementview question
Guido Tack
tack at ps.uni-sb.de
Tue Nov 6 19:38:53 CET 2007
Hi Alberto,
Alberto Delgado wrote:
> I need to implement a function that returns a variable with the
> complement of a setvar given as a parameter (pretty much as FS.compl
> from Mozart-Oz).
> I ran into complementview and i tought i could use it to get it
> done. The thing is it seems i can't initialize a setvar with a
> complementview, or even cast the complementview<setview> to a
> setview. Since i don't want to implement my own complement
> algorithm is there any way to get this done in gecode?
Views in Gecode are only used inside propagators, so you can't use the
ComplementView directly. However, the function you describe can be
implemented quite easily:
SetVar complement(Space* home, const SetVar& s) {
SetVar c(home);
rel(home, c, SRT_CMPL, s);
return c;
}
The propagator that gets posted actually uses a ComplementView
internally.
> I also like know something, a view from a variable is a reference
> to the variable, so i can declare as many views as i need and it
> won't be adding any extra stuff to the space, am i correct??
Yes, both the SetVar/IntVar/BoolVar and all the views are just
"handles" for the actual variable implementations.
> By the way, I'm working with the trunk version of gecode, hope
> this won't be the problem.
The trunk is pretty stable by now, we're not far away from releasing
it, so this should be fine.
Cheers,
Guido
More information about the gecode-users
mailing list