1

我在 c++ 中使用了一些整数变量,例如:

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

alpha 是范围为 0 - N 的一维数组...

但我的问题是,我想创建 ax[N][M][K],这将是我的整数决策变量,我不知道任何语法或如何启动这些变量。

4

1 回答 1

2

这是一个例子

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);
   }
  }
 }
于 2016-06-01T06:49:27.033 回答