[gecode-users] A constrain with 3 IntVar

Guido Tack tack at ps.uni-sb.de
Mon Aug 31 11:02:26 CEST 2009


amina kemmar wrote:

> Hi,
>
> I am writing a new constraint "NewConstraint", which takes 3 IntVar  
> as arguments :
>
> #include <algorithm>
> #include <gecode/int.hh>
>
> namespace Gecode {
>
>   using namespace Int;
>
>   void NewConstraint(Space& home, IntVar x0, IntVar x1, IntVar x3) {
>
>     if (home.failed()) return;
>
>     //  Creation of an array x, which contains the 3 variables  
> x0,x1,x2;
>     //  .....
>
>     // ViewArray<IntView> xv(home,x);
>     // GECODE_ES_FAIL(home,  
> NewConstraint::Diff<IntView>::post(home,xv));
>   }
> }
>
> To post the constraint  i need to create a ViewArray, but i don't  
> understand how to create an IntVarArg  containing these variables ?

Just fill the array manually, no need for IntVarArgs:

xv[0] = x0; xv[1] = x1; xv[2] = x2;

Or change the definition of the NewConstraint class to take three  
views instead of one ViewArray.

Cheers,
	Guido





More information about the gecode-users mailing list