Technote (FAQ)
Question
How do I print (and iterate over) the conflicts in and relaxations for my infeasible model using OPL script.
Answer
The following sample shows one such approach for a simple model:
dvar int x1 in 0..40;
dvar int+ x2;
dvar int+ x3;
maximize x1 + 2*x2 - 3*x3;
subject to{
c1: x2 + x3 <= 20;
c2: x1 - 3*x2 + x3 <= 30;
c3: x1 <= 20;
c4: x1 >= 40;
}
main{
thisOplModel.generate();
if(cplex.solve()){
writeln("Solve successful; solve status="+cplex.getCplexStatus());
writeln("Objective value="+cplex.getObjValue());
}
else{
writeln("Solve failed; CPLEX status="+cplex.getCplexStatus());
writeln("Calling printConflict (CONFLICT REFINER)");
writeln(thisOplModel.printConflict());
writeln("Printing conflicts using conflictIterator");
var confIter = thisOplModel.conflictIterator;
for(var x in confIter){
writeln("Member name:"+x.ct.name);
writeln("Conflict type:"+x.info);
}
writeln("Calling printRelaxation (FEASOPT)");
writeln(thisOplModel.printRelaxation());
writeln("Printing relaxations using relaxationIterator");
var relaxIter = thisOplModel.relaxationIterator;
for(x in relaxIter){
writeln("Member name:"+x.ct.name);
writeln("Old bound:"+x.info);
writeln("New bound:"+x.info2);
writeln("Bound changed to:"+x.info3);
}
}
}
| Segment | Product | Component | Platform | Version | Edition |
|---|---|---|---|---|---|
| Business Integration | IBM ILOG CPLEX Optimization Studio | Area:ILOG Script for OPL/OPL Script | AIX, HP-UX, Linux, Mac OS, Solaris, Windows | 12.4, 12.3, 12.2.0.1, 12.2 | All Editions |
Rate this page:
Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.