[gecode-users] n-dimensional matrices of variables

Mikael Zayenz Lagerkvist zayenz at gmail.com
Thu Nov 30 09:45:13 CET 2006


On 11/29/06, Pieter Thysebaert <pieter.thysebaert at intec.ugent.be> wrote:
> I'm using Gecode 1.2.2 and am wondering if there is a common practice
> for declaring n-dimensional matrices of integer variables, with n > 2
> (From what I see, MiniModel::Matrix is for 2-d matrices).
>
> Can it be done using the available variable array classes? (building
> arrays of arrays of IntVarArrays) ?

Hi,

The Matrix class is, as you've correctly identified, a 2-d matrix class.

Before we had the Matrix class, our common practice for matrices was
to declare an IntVarArray and then to write accessor-functions like to
following

    IntVar& y(int i, int j) {
      return x[i*n*n+j];
    }

This idea can be naturally extended to handle more than two dimensions.

Cheers,
Mikael

-- 
Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/




More information about the gecode-users mailing list