Display conflict and relaxation information for infeasible models using OPL script

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);
  }
 }
}


Cross reference information
Segment Product Component Platform Version Edition
Commerce 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:

(0 users)Average rating

Add comments

Document information


More support for:

IBM ILOG CPLEX Optimization Studio
Area:ILOG Script for OPL/OPL Script

Software version:

12.2, 12.3, 12.4

Operating system(s):

Platform Independent

Software edition:

All Editions

Reference #:

1615786

Modified date:

2012-11-14

Translate my page

Machine Translation

Content navigation