1

I'm using some integers variables in cplex with c++, like:

  alpha = IloIntVarArray (env, numArcs,0 ,N);

alpha is unidimensional array with range 0 - N...

But my problem is, I'd like to create a x[N][M][K], that would be my integer decisions variables and I don't know any syntax or how to initiate these variables.

1 Answers1

2

Here is an example:

typedef IloArray<IloNumVarArray> NumVarMatrix;
typedef IloArray<NumVarMatrix>   NumVar3Matrix;

/* define the num vars here for the 3-D matrix */
NumVar3Matrix accept(env,nbClients);
/* initialize this matrix */
for(i=0; i< nbClients; i++) {
  accept[i] = NumVarMatrix(env, nbLocations);
for(j=0; j< nbLocations; j++) {
            accept[i][j] = IloNumVarArray(env, nbRoutes);
  for(k=0; k<nbRoutes; k++) {
   accept[i][j][k] = IloNumVar(env, 0.0, 1.0, ILOINT);
   }
  }
 }
serge_k
  • 1,772
  • 2
  • 15
  • 21