[gecode-users] define a domain for a SetVar using a IntVar

Guido Tack tack at gecode.org
Thu Mar 10 08:32:43 CET 2011


Steven Villegas wrote:
> Actually, i'm trying to implement a musical CSP using GECODE; in this
> CSP i have to define a set based on the result based on the result of
> the multiplication of two IntVar (each one define the root and
> interval of a chord) and int (this define the number of notes of the
> chord).
> My Question is: how i define the domain of a SetVar using a IntVar??
> that's possible???

I'm not sure I understand your description.  If you have an IntVarArray x, and IntVarArray y, and an IntArgs c, do you want to express the following:

s = { x[i]*y[i]*c[i] | i in 0...x.size()-1 }

That would be easy to do (not tested, but you should get the idea):

IntVarArgs z(x.size());
for (int i=0; i<x.size(); i++) {
  z[i] = expr(home, c[i]*x[i]*y[i]);
}
rel(home, SOT_UNION, z, s);

Cheers,
	Guido

-- 
Guido Tack, http://people.cs.kuleuven.be/~guido.tack/






More information about the users mailing list