Dip
0.92.4
|
Validate cuts against a known solution. More...
#include <OsiRowCutDebugger.hpp>
Public Member Functions | |
Validate Row Cuts | |
Check that the specified cuts do not cut off the known solution. | |
virtual int | validateCuts (const OsiCuts &cs, int first, int last) const |
Check that the set of cuts does not cut off the solution known to the debugger. More... | |
virtual bool | invalidCut (const OsiRowCut &rowcut) const |
Check that the cut does not cut off the solution known to the debugger. More... | |
bool | onOptimalPath (const OsiSolverInterface &si) const |
Returns true if the solution held in the solver is compatible with the known solution. More... | |
Activate the Debugger | |
The debugger is considered to be active when it holds a known solution. | |
bool | activate (const OsiSolverInterface &si, const char *model) |
Activate a debugger using the name of a problem. More... | |
bool | activate (const OsiSolverInterface &si, const double *solution, bool keepContinuous=false) |
Activate a debugger using a full solution array. More... | |
bool | active () const |
Returns true if the debugger is active. More... | |
Query or Manipulate the Known Solution | |
const double * | optimalSolution () const |
Return the known solution. More... | |
int | numberColumns () const |
Return the number of columns in the known solution. More... | |
double | optimalValue () const |
Return the value of the objective for the known solution. More... | |
void | redoSolution (int numberColumns, const int *originalColumns) |
Edit the known solution to reflect column changes. More... | |
int | printOptimalSolution (const OsiSolverInterface &si) const |
Print optimal solution (returns -1 bad debug, 0 on optimal, 1 not) More... | |
Constructors and Destructors | |
OsiRowCutDebugger () | |
Default constructor - no checking. More... | |
OsiRowCutDebugger (const OsiSolverInterface &si, const char *model) | |
Constructor with name of model. More... | |
OsiRowCutDebugger (const OsiSolverInterface &si, const double *solution, bool enforceOptimality=false) | |
Constructor with full solution. More... | |
OsiRowCutDebugger (const OsiRowCutDebugger &) | |
Copy constructor. More... | |
OsiRowCutDebugger & | operator= (const OsiRowCutDebugger &rhs) |
Assignment operator. More... | |
virtual | ~OsiRowCutDebugger () |
Destructor. More... | |
Private Attributes | |
Private member data | |
double | knownValue_ |
Value of known solution. More... | |
int | numberColumns_ |
Number of columns in known solution. More... | |
bool * | integerVariable_ |
array specifying integer variables More... | |
double * | knownSolution_ |
array specifying known solution More... | |
Friends | |
void | OsiRowCutDebuggerUnitTest (const OsiSolverInterface *siP, const std::string &mpsDir) |
A function that tests the methods in the OsiRowCutDebugger class. More... | |
Validate cuts against a known solution.
OsiRowCutDebugger provides a facility for validating cuts against a known solution for a problem. The debugger knows an optimal solution for many of the miplib3 problems. Check the source for activate(const OsiSolverInterface&,const char*) in OsiRowCutDebugger.cpp for the full set of known problems.
A full solution vector can be supplied as a parameter with (activate(const OsiSolverInterface&,const double*,bool)). Only the integer values need to be valid. The default behaviour is to solve an lp relaxation with the integer variables fixed to the specified values and use the optimal solution to fill in the continuous variables in the solution. The debugger can be instructed to preserve the continuous variables (useful when debugging solvers where the linear relaxation doesn't capture all the constraints).
Note that the solution must match the problem held in the solver interface. If you want to use the row cut debugger on a problem after applying presolve transformations, your solution must match the presolved problem. (But see redoSolution().)
Definition at line 42 of file OsiRowCutDebugger.hpp.
OsiRowCutDebugger::OsiRowCutDebugger | ( | ) |
Default constructor - no checking.
OsiRowCutDebugger::OsiRowCutDebugger | ( | const OsiSolverInterface & | si, |
const char * | model | ||
) |
Constructor with name of model.
OsiRowCutDebugger::OsiRowCutDebugger | ( | const OsiSolverInterface & | si, |
const double * | solution, | ||
bool | enforceOptimality = false |
||
) |
Constructor with full solution.
OsiRowCutDebugger::OsiRowCutDebugger | ( | const OsiRowCutDebugger & | ) |
Copy constructor.
|
virtual |
Destructor.
|
virtual |
Check that the set of cuts does not cut off the solution known to the debugger.
Check if any generated cuts cut off the solution known to the debugger! If so then print offending cuts. Return the number of invalid cuts.
|
virtual |
Check that the cut does not cut off the solution known to the debugger.
Return true if cut is invalid
bool OsiRowCutDebugger::onOptimalPath | ( | const OsiSolverInterface & | si | ) | const |
Returns true if the solution held in the solver is compatible with the known solution.
More specifically, returns true if the known solution satisfies the column bounds held in the solver.
bool OsiRowCutDebugger::activate | ( | const OsiSolverInterface & | si, |
const char * | model | ||
) |
Activate a debugger using the name of a problem.
The debugger knows an optimal solution for most of miplib3. Check the source code for the full list. Returns true if the debugger is successfully activated.
bool OsiRowCutDebugger::activate | ( | const OsiSolverInterface & | si, |
const double * | solution, | ||
bool | keepContinuous = false |
||
) |
Activate a debugger using a full solution array.
The solution must have one entry for every variable, but only the entries for integer values are used. By default the debugger will solve an lp relaxation with the integer variables fixed and fill in values for the continuous variables from this solution. If the debugger should preserve the given values for the continuous variables, set keepContinuous
to true
.
Returns true if debugger activates successfully.
bool OsiRowCutDebugger::active | ( | ) | const |
Returns true if the debugger is active.
|
inline |
Return the known solution.
Definition at line 110 of file OsiRowCutDebugger.hpp.
|
inline |
Return the number of columns in the known solution.
Definition at line 116 of file OsiRowCutDebugger.hpp.
References numberColumns_.
|
inline |
Return the value of the objective for the known solution.
Definition at line 119 of file OsiRowCutDebugger.hpp.
References knownValue_.
void OsiRowCutDebugger::redoSolution | ( | int | numberColumns, |
const int * | originalColumns | ||
) |
Edit the known solution to reflect column changes.
Given a translation array originalColumns
[numberColumns] which can translate current column indices to original column indices, this method will edit the solution held in the debugger so that it matches the current set of columns.
Useful when the original problem is preprocessed prior to cut generation. The debugger does keep a record of the changes.
int OsiRowCutDebugger::printOptimalSolution | ( | const OsiSolverInterface & | si | ) | const |
Print optimal solution (returns -1 bad debug, 0 on optimal, 1 not)
OsiRowCutDebugger& OsiRowCutDebugger::operator= | ( | const OsiRowCutDebugger & | rhs | ) |
Assignment operator.
|
friend |
A function that tests the methods in the OsiRowCutDebugger class.
|
private |
Value of known solution.
Definition at line 171 of file OsiRowCutDebugger.hpp.
Referenced by optimalValue().
|
private |
Number of columns in known solution.
This must match the number of columns reported by the solver.
Definition at line 177 of file OsiRowCutDebugger.hpp.
Referenced by numberColumns().
|
private |
array specifying integer variables
Definition at line 180 of file OsiRowCutDebugger.hpp.
|
private |
array specifying known solution
Definition at line 183 of file OsiRowCutDebugger.hpp.