Originally posted by: hllsen
To use in a MIP model, I created 3D variable X_{k,j,t} with sizes
n, m and
H, respectively. Type definition and initialization is like this:
typedef IloArray<IloArray<IloNumVarArray > > IloNumVarArray3; IloNumVarArray3 X( env );
Then array is filled like this:
X.add( m, IloArray<IloNumVarArray >( env ) );
for (k = 0; k < m; ++k ) X[k].add( n, IloNumVarArray( env, H, 0, IloInfinity, IloNumVar::Float ));
After considerable amount of debugging time, I noticed that this method does not create
n*m*H number of variables. That is, "id" of different
k or
j index variables has the same "id". Therefore, I ended up with only
H number of variables.
Variable id
X[0][0][0] 1
X[0][1][0] 1
X[1][2][0] 1
X[0][0][1] 2
X[0][1][1] 2
X[1][2][1] 2
But, the code below just works fine and creates
n*m*H number of variables.
for (k = 0; k < m; ++k )
{ X.add( IloArray<IloNumVarArray >( env ) );
for (j = 0; j < n; ++j)
{ X[k].add( IloNumVarArray( env, H, 0, IloInfinity, IloNumVar::Float ) );
}
}
AFAIK, my problem is solved but I still couldn't quite understand why first method does not work. An explanation would be very much appreciated. Thank you.
#CPLEXOptimizers#DecisionOptimization