Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

OsiRowCutDebugger Class Reference

#include <OsiRowCutDebugger.hpp>

List of all members.

Public Member Functions

Validate Row Cuts
virtual int validateCuts (const OsiCuts &cs, int first, int last) const
virtual bool invalidCut (const OsiRowCut &rowcut) const
 check one cut. Return true if cut is invalid

const double * optimalSolution () const
 Return optimal solution.

Activate Debugger
bool activate (const OsiSolverInterface &si, const char *model)
Test if on Optimal Path
bool onOptimalPath (const OsiSolverInterface &si) const
Test if debugger active
bool active () const
 Returns true if debugger is active.

Constructors and destructors
 OsiRowCutDebugger ()
 Default constructor - no checking.

 OsiRowCutDebugger (const OsiSolverInterface &si, const char *model)
 OsiRowCutDebugger (const OsiRowCutDebugger &)
 Copy constructor.

OsiRowCutDebuggeroperator= (const OsiRowCutDebugger &rhs)
 Assignment operator.

virtual ~OsiRowCutDebugger ()
 Destructor.


Private Attributes

Private member data
int numberColumns_
 number of columns in problem

bool * integerVariable_
 Whether integer or not.

double * optimalSolution_
 Optimal column solution.


Friends

void OsiRowCutDebuggerUnitTest (const OsiSolverInterface *siP, const std::string &mpsDir)


Detailed Description

Validate Row Cut Generator

Definition at line 12 of file OsiRowCutDebugger.hpp.


Constructor & Destructor Documentation

OsiRowCutDebugger::OsiRowCutDebugger const OsiSolverInterface si,
const char *  model
 

Constructor with name of model. It may or may not work if problem presolved


Member Function Documentation

bool OsiRowCutDebugger::activate const OsiSolverInterface si,
const char *  model
 

Activate debugger using name of model. It may or may not work if problem presolved. Returns true if debugger activated.

bool OsiRowCutDebugger::onOptimalPath const OsiSolverInterface si  )  const
 

Returns whether still on optimal path. This should normally be invoked from OsiSolverInterface::rowCutDebugger()

virtual int OsiRowCutDebugger::validateCuts const OsiCuts cs,
int  first,
int  last
const [virtual]
 

If we are on the path to the optimal integer solution then check if any generated cuts cut off the optimal solution!

If so then print offending cuts and return non-zero code

Up to user to check if on optimalPath (using function of same name). This is normally handled by rowCutDebugger() in OsiSolverInterface.

Return number of invalid cuts.


Friends And Related Function Documentation

void OsiRowCutDebuggerUnitTest const OsiSolverInterface siP,
const std::string &  mpsDir
[friend]
 

A function that tests the methods in the OsiRowCut class. The only reason for it not to be a member method is that this way it doesn't have to be compiled into the library. And that's a gain, because the library should be compiled with optimization on, but this method should be compiled with debugging.

Definition at line 19 of file OsiRowCutDebuggerTest.cpp.

00021 {
00022   
00023   CoinRelFltEq eq;
00024   
00025   // Test default constructor
00026   {
00027     OsiRowCutDebugger r;
00028     assert( r.integerVariable_==NULL );
00029     assert( r.optimalSolution_==NULL );
00030     assert( r.numberColumns_==0);
00031   }
00032   
00033   {
00034     // Get non trivial instance
00035     OsiSolverInterface * imP = baseSiP->clone();
00036     std::string fn = mpsDir+"exmip1";
00037     imP->readMps(fn.c_str(),"mps");
00038     //std::cerr <<imP->getNumRows() <<std::endl;
00039     assert( imP->getNumRows() == 5);
00040     
00041     // activate debugger
00042     imP->activateRowCutDebugger("ab cd /x/ /exmip1.asc");
00043     
00044     int i;
00045     
00046     // return debugger
00047     const OsiRowCutDebugger * debugger = imP->getRowCutDebugger();
00048     // check 
00049     assert (debugger!=NULL);
00050     
00051     assert (debugger->numberColumns_==8);
00052     
00053     const bool type[]={0,0,1,1,0,0,0,0};
00054     const double values[]= {2.5, 0, 1, 1, 0.5, 3, 0, 0.26315789473684253};
00055     CoinPackedVector objCoefs(8,imP->getObjCoefficients());
00056    
00057 #if 0
00058     for (i=0;i<8;i++) {
00059       assert(type[i]==debugger->integerVariable_[i]);
00060       std::cerr <<i  <<" " <<values[i] <<" " <<debugger->optimalSolution_[i] <<std::endl;
00061     }
00062 #endif
00063     
00064     double objValue = objCoefs.dotProduct(values);
00065     double debuggerObjValue = objCoefs.dotProduct(debugger->optimalSolution_);
00066     //std::cerr <<objValue <<" " <<debuggerObjValue <<std::endl;
00067     assert( eq(objValue,debuggerObjValue) );
00068     
00069     OsiRowCutDebugger rhs;
00070     {
00071       OsiRowCutDebugger rC1(*debugger);
00072       
00073       assert (rC1.numberColumns_==8);
00074       for (i=0;i<8;i++) {
00075         assert(type[i]==rC1.integerVariable_[i]);
00076       }
00077       assert( eq(objValue,objCoefs.dotProduct(rC1.optimalSolution_)) );
00078       
00079       rhs=rC1;
00080       assert (rhs.numberColumns_==8);
00081       for (i=0;i<8;i++) {
00082         assert(type[i]==rhs.integerVariable_[i]);
00083       }
00084       assert( eq(objValue,objCoefs.dotProduct(rhs.optimalSolution_)) );
00085     }
00086     // Test that rhs has correct values even though lhs has gone out of scope
00087     assert (rhs.numberColumns_==8);
00088     for (i=0;i<8;i++) {
00089       assert(type[i]==rhs.integerVariable_[i]);
00090     }
00091     assert( eq(objValue,objCoefs.dotProduct(rhs.optimalSolution_)) );
00092     OsiRowCut cut[2];
00093     
00094     const int ne = 3;
00095     int inx[ne] = { 0, 2, 3 };
00096     double el[ne] = { 1., 1., 1. };
00097     cut[0].setRow(ne,inx,el);
00098     cut[0].setUb(5.);
00099     
00100     el[1]=5;
00101     cut[1].setRow(ne,inx,el);
00102     cut[1].setUb(5);
00103     OsiCuts cs; 
00104     cs.insert(cut[0]);
00105     cs.insert(cut[1]);
00106     assert(!debugger->invalidCut(cut[0]));
00107     assert( debugger->invalidCut(cut[1]));
00108     assert(debugger->validateCuts(cs,0,2)==1);
00109     assert(debugger->validateCuts(cs,0,1)==0);
00110     delete imP;
00111   }
00112 }


The documentation for this class was generated from the following file:
Generated on Wed Dec 3 14:35:42 2003 for Osi by doxygen 1.3.5