[gecode-users] constraint with matrix

Gustavo Gutierrez gustavo.ggutierrez at gmail.com
Wed Jul 10 15:46:23 CEST 2013

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:


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.


On Wed, Jul 10, 2013 at 7:20 AM, manel askri <askri.manel1 at 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 at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users

Gustavo Gutierrez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20130710/0e34eb92/attachment.html>

More information about the users mailing list