Topic
1 reply Latest Post - ‏2012-08-08T17:47:17Z by hllsen
Ximenes
Ximenes
22 Posts
ACCEPTED ANSWER

Pinned topic how to define a 6-dimmensional array in CPLEX with c++

‏2012-08-06T13:15:54Z |
Hi, everyone, I strongly suspect that my definition of 6-dimmensional array is not perfectly right.
I pasted the related code bellow hoping that somebody can give me some suggestions.

typedef IloArray<IloBoolVarArray> BoolVarMatrix; typedef IloArray<IloNumVarArray> NumVarMatrix; typedef IloArray<BoolVarMatrix> BoolVar3Matrix; typedef IloArray<BoolVar3Matrix> BoolVar4Matrix; typedef IloArray<BoolVar4Matrix> BoolVar5Matrix; typedef IloArray<BoolVar5Matrix> BoolVar6Matrix;

and

BoolVar6Matrix a(env,N);  
//定义a   【a(i,k,m,j,l,h)=z(i,k,m)*z(j,l,h)】 

for(

int i=0;i<N;i++)
{ a[i]=BoolVar5Matrix(env,n[i]); 

for(

int k=0;k<n[i];k++)
{ a[i][k]=BoolVar4Matrix(env,total); 

for(

int m=0;m<total;m++)
{ a[i][k][m]=BoolVar3Matrix(env,N); 

for(

int j=0;j<N;j++)
{ a[i][k][m][j]=BoolVarMatrix(env,n[j]); 

for(

int l=0;l<n[l];l++) a[i][k][m][j][l]=IloBoolVarArray(env,total); 
} 
} 
} 
}

Thank you.
Updated on 2012-08-08T17:47:17Z at 2012-08-08T17:47:17Z by hllsen
  • hllsen
    hllsen
    53 Posts
    ACCEPTED ANSWER

    Re: how to define a 6-dimmensional array in CPLEX with c++

    ‏2012-08-08T17:47:17Z  in response to Ximenes
    I'm not sure whether your definition is correct or wrong but I'm using the definition below:

    BoolVar6Matrix a(env);  //定义a 【a(i,k,m,j,l,h)=z(i,k,m)*z(j,l,h)】
    for(int i=0;i<N;i++){
            a.add( BoolVar5Matrix(env) );
            for(int k=0;k<n[i];k++){
                    a[i].add( BoolVar4Matrix(env) );
                    for(int m=0;m<total;m++){
                            a[i][k].add( BoolVar3Matrix(env) );
                            for(int j=0;j<N;j++){
                                    a[i][k][m].add( BoolVarMatrix(env) );
                                    for(int l=0;l<n[l];l++)
                                            a[i][k][m][j].add( IloBoolVarArray(env,total) );
                            }      
                    }
            }
    }
    


    By the way, the last for-loop looks a little weird ( i.e for(int l=0;l<n[l];l++) ).
    Updated on 2014-03-24T22:53:58Z at 2014-03-24T22:53:58Z by iron-man