I am solving an iterative optimization problem in cplex opl using the main function. However, I am getting errors while printing a matrix value. Please help me in solving this issue.
int Nod=41;
range NodRange = 1..Nod;
int nr=140;
range RRange = 1..nr;
int TSlot = 96;
range TRange = 1..TSlot;
int ncs=6;
range csrange=1..ncs;
int piles=12;
range np=1..piles;
int nv=3;
range nvrange=1..nv;
main {
var source = new IloOplModelSource("subvalue.mod");
var cplex = new IloCplex;
var def = new IloOplModelDefinition(source);
var pa= new int [np][TRange];
for(var v=1;v<=3;v++)
{
var opl = new IloOplModel(def, cplex);
var data = new IloOplDataSource("MultipleEtoCS.dat");
var data2=new IloOplDataElements();
data2.cev=v;
opl.addDataSource(data2);
opl.addDataSource(data);
opl.generate();
if (!cplex.solve()) {
writeln("No solution exists. Stopping.");
}else{
opl.postProcess();
writeln(" solution is =" + cplex.getObjValue());
for (var j in opl.csrange){
if(j<=opl.sreq)
opl.pa[opl.vpile[v]][opl.cslot+1+j]=+1;
}
}
}
opl.end();
}
How to print the pa matrix. I am getting the error as a scripting parser error. In the code sreq[nvrange],vpile[nvrange] and cslot[nvrange] are integer decision variables, defined in the subvalue.mod file. How can I implement this logic correctly to print the pa matrix for all values of v.