Originally posted by: Mathsg
Hi,
I am using column generation method to solve planning problem. In the scripting part of main model I have called sub model which give me reduced cost but the value of reduced cost is very big value. i am wonder weather the value of sub problem is right or not as it too big value. In the scripting part of main problem i am going to use the solution value of sub model and put/update the value of main model for next iteration but it give me an error like Scripting runtime error: data element does not exist
Now i have two question
1) As my reduced cost of sub model generate too big value e.g., -28662. is it seems to be right nor not?
2) i am getting syntax error e.g., Scripting runtime error: data element does not exist when i am going to add the sub model solution value in the master problem for next iteration in script part. Kindly guide me how to get rid of this error. It would be highly appricated and i am looking froward to hearing from my respected seniors and IBM administration team. Thank you very much
main {
var status = 0;
thisOplModel.generate();
var RC_EPS = 1.0e-6;
var masterDef = thisOplModel.modelDefinition;
var masterCplex = cplex;
var masterData = thisOplModel.dataElements;
var subSource = new IloOplModelSource("PP_Jan.mod");
var subDef = new IloOplModelDefinition(subSource);
var subData = new IloOplDataElements();
var subCplex = new IloCplex();
var best;
var curr = Infinity;
while ( best != curr ) {
best = curr;
var masterOpl = new IloOplModel(masterDef, masterCplex);
masterOpl.addDataSource(masterData);
masterOpl.generate();
masterOpl.convertAllIntVars();
writeln("Solve master.");
if ( masterCplex.solve() ) {
curr = masterCplex.getObjValue();
writeln();
writeln("OBJECTIVE: ",curr);
}
else {
writeln("No solution!");
masterOpl.end();
break;
}
subData.nmbr_routes = masterOpl.nmbr_routes;
subData.nbnodes = masterOpl.nbnodes;
subData.flows = masterOpl.flows;
subData.Lincards = masterOpl.Lincards;
subData.hope_count = masterOpl.hope_count;
subData.link = masterOpl.link;
subData.q = masterOpl.q;
subData.ECcards = masterOpl.ECcards;
subData.Duals = masterOpl.Duals;
for (var i in masterOpl.routes) {
subData.Duals[i] = masterOpl.Const10[i].dual;
}
var subOpl = new IloOplModel(subDef, subCplex);
subOpl.addDataSource(subData);
subOpl.generate();
writeln("Solve sub.");
if ( subCplex.solve() ) {
writeln();
writeln("OBJECTIVE: ",subCplex.getObjValue());
}
else {
writeln("No solution!");
subOpl.end();
masterOpl.end();
break;
}
if (subCplex.getObjValue() >-RC_EPS) {
subOpl.end();
masterOpl.end();
break;
}
// Prepare the next iteration:
//masterData.routes.add(masterData.routes.size,1,subOpl.getObjValue());
for ( var j in subOpl.routes){
masterData.lemda[j][1][1].add(masterData.lemda[j][1][1].size,1,subOpl.lemda[j][1][1].solutionValue); // Getting Error here(Scripting runtime error: data element lemda does not exist)
// writeln("===>",subOpl.f[Opl.first(subOpl.Lincards)][j][1][1].solutionValue);
}
//masterData.routes.add(subOpl.getObjValue());
subOpl.end();
masterOpl.end();
}
writeln("Relaxed model search end.");
masterOpl = new IloOplModel(masterDef,masterCplex);
masterOpl.addDataSource(masterData);
masterOpl.generate();
writeln("Solve integer master.");
if ( masterCplex.solve() ) {
writeln();
writeln("OBJECTIVE: ",masterCplex.getObjValue());
if (Math.abs(masterCplex.getObjValue() - 122)>=0.0001) {
writeln("Unexpected objective value");
status = -1;
}
/*for(i in masterData.Patterns) {
if (masterOpl.Cut[i].solutionValue > 0) {
writeln("Pattern : ", i, " used ", masterOpl.Cut[i].solutionValue << " times");
}
}*/
}
masterOpl.end();
status;
}
#CPLEXOptimizers#DecisionOptimization