【问题标题】:Creating a tridimensional IloIntVarArray in Cplex with c++使用 c++ 在 Cplex 中创建三维 IloIntVarArray
【发布时间】:2016-05-31 23:31:36
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: c++ cplex integer-programming operations-research


    【解决方案1】:

    这里是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);
       }
      }
     }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-03
      • 2018-05-14
      • 1970-01-01
      • 2020-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多