Hi Manel,

I think you want something that looks like this:

int n = 8;
int m = 10;
IntVarArray a(*this,n*m,0,1); // Array of n*m boolean variables
Matrix<IntVarArray> mat(x,n,m); // Matrix "view" of the array a

Now, to post a constraint on every row in the matrix you can use the method
row of the Matrix class. That will return you exactly what you need. For
instance, to post that the row i has pairwise distinct values:

distinct(*this,mat.row(i));

Be careful, that is just an example that is (probably) not going to work
because of the use of boolean variables. In any case you will find more
information on section 7.2 in MPG about using Matrix.

Regards,
Gustavo


On Wed, Jul 10, 2013 at 7:20 AM, manel askri <askri.man...@gmail.com> wrote:

> hi!
>
> i'm trying to write a model which uses matrix, and in my case i use a
> matrix X as flowing :
>
>             l=IntVar(*this, 0,1);
>  Matrix <IntVar> X (l,n,m);
>
> and i declared an array rows with n elements so  and i have to constraint
> evry row in the array rows by this constraint :
>
>              for (int i =0, i<n; i++)
>                   {
>                          rows[i]= linear(*this,sum(X[i]),IRT_EQ,1);
>
>                    }
>
> So my question here is : how can i write down this constraint
> it is possible to affect a result of a constraint to variable or not ????
>
> i'm sorry to be bothring you but i really did read over and over the MPG
>
> thanks for evry help
>
>
>
>
>
> _______________________________________________
> Gecode users mailing list
> users@gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users
>
>


-- 
Gustavo Gutierrez
_______________________________________________
Gecode users mailing list
users@gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to