Originally posted by: SystemAdmin
Hi,
Can you clarify what you mean by a 3D array cannot be initialized externally?
Here is an example of how a 3D array could be initialized in a .dat file:
actns = [ [[111,112],[121,122],[131,132],[141,142]], [[211,212],[221,222],[231,232],[241,242]], [[311,312],[321,322],[331,332],[341,342]] ];
with the array declared as
tuple Link
{
int i;
int j;
}
{Link
} links =
{<1,1>, <1,2>, <1,3>
};
int actns[links][1..4][1..2]=...;
Then in your main script, you can update your array as follows:
main
{ thisOplModel.generate(); var masterDef = thisOplModel.modelDefinition; var masterCplex = cplex; var dataElts = thisOplModel.dataElements;
if (cplex.solve())
{ writeln(
"obj1 = ",cplex.getObjValue());
//update array actns
for (var x in thisOplModel.actnsi) dataElts.actns[x.segment][x.t][x.n]=thisOplModel.actnsm[x.segment][x.t][x.n]+5; var opl2 =
new IloOplModel(masterDef,masterCplex); opl2.addDataSource(dataElts); opl2.generate(); masterCplex.solve(); writeln(
"obj2 = ",masterCplex.getObjValue());
}
}
If this doesn't answer your question, can you post a reduced sample that illustrates the issue you're facing?
#DecisionOptimization#OPLusingCPLEXOptimizer