Originally posted by: behi
Hi
when I try to save the optimal value of an opl decision variable (z[j][k]) in to a variable (currentz[j][k]) in script I got the following error:
"cannot add properties to this value: null." I checked that z takes value and is type of Boolean in opl.
Also when I try to update the data using element: currentvv=sub2.vv; sometimes I get the following error:
"cannot convert to a number: [a IloNumVar]."
but when I write currentvv=Math.round(sub2.vv); the error is resolved! please advise me...
thank you in advance.
this is part of my code:
var currentvv;
var currentteta;
var currentc= new Array;
var currenttt= new Array;
var currentttp=new Array;
var currentz=new Array;
var source2 = new IloOplModelSource("sub2.mod");
var Def2 = new IloOplModelDefinition(source2);
var sub2 = new IloOplModel(Def2,cplex);
var sub2Data= new IloOplDataSource("sub2.dat");
sub2.addDataSource(sub2Data);
sub2.generate();
sub2Data=sub2.dataElements;
sub2Data.teta[1]=currentteta;
for (var j in sub2.part)
{
sub2Data.c[j]=currentc[j];
}
if (cplex.solve())
{
for (var k in sub2.batch)
{
currenttt[k]=Math.round(sub2.tt[k]);
currentttp[k]=Math.round(sub2.ttp[k]);
for (var j in sub2.part)
{
currentz[j][k]=sub2.z[j][k]; <<<Error>>> "cannot add properties to this value: null."
}
}
currentvv=Math.round(sub2.vv);
var z1=Math.round(sub2.z1);
UB=Ilomin(UB,z1+teta2);
writeln("UB obtained from sub2=",UB);
}
else
{
writeln("No solution3");
}
sub2.end();
#DecisionOptimization#OPLusingCPLEXOptimizer