I'm working with an array, X[(i,j,l)], which is indexed by 3-dimensional tuples where i and j range from 1 to n, and l ranges from 1 to "layers". This binary array consists of elements that are either 0 or 1.
The array was generated as a result of solving an optimization problem using opl in CPLEX.
Now, I am attempting to access the values of X as a multidimensional array X[i][j][l] through javascript execution code in the model window.
This is my attempt:
var ofile_varx = new IloOplOutputFile("initial_varx.csv");
ofile_varx.writeln(x);
var x_arr=new Array (n);
for (var i=0; i<n; i++) {
x_arr[i]=new Array (n);
for (var j=0; j<n; j++) {
x_arr[i][j]=new Array (layers);
}
}
for (var tup in ijl) {
x_arr[tup.i][tup.j][tup.l]=x[tup];
}
However, when executing this, I encountered an error on the last line stating that it cannot assign a property "null" to the array.
Do you have any suggestions on how I can achieve the desired array x_arr successfully?
Thank you!