Dip
0.92.4
|
Class for preProcessing and postProcessing. More...
#include <CglPreProcess.hpp>
Public Member Functions | |
Main methods | |
OsiSolverInterface * | preProcess (OsiSolverInterface &model, bool makeEquality=false, int numberPasses=5) |
preProcess problem - returning new problem. More... | |
OsiSolverInterface * | preProcessNonDefault (OsiSolverInterface &model, int makeEquality=0, int numberPasses=5, int tuning=0) |
preProcess problem - returning new problem. More... | |
void | postProcess (OsiSolverInterface &model, int deleteStuff=2) |
Creates solution in original model deleteStuff 0 - don't, 1 do (but not if infeasible), 2 always. More... | |
int | tightenPrimalBounds (OsiSolverInterface &model, double factor=0.0) |
Tightens primal bounds to make dual and branch and cutfaster. More... | |
OsiSolverInterface * | someFixed (OsiSolverInterface &model, double fractionToKeep=0.25, bool fixContinuousAsWell=false, char *keep=NULL) const |
Fix some of problem - returning new problem. More... | |
OsiSolverInterface * | cliqueIt (OsiSolverInterface &model, double cliquesNeeded=0.0) const |
Replace cliques by more maximal cliques Returns NULL if rows not reduced by greater than cliquesNeeded*rows. More... | |
int | reducedCostFix (OsiSolverInterface &model) |
If we have a cutoff - fix variables. More... | |
Parameter set/get methods | |
The set methods return true if the parameter was set to the given value, false if the value of the parameter is out of range. The get methods return the value of the parameter. | |
void | setCutoff (double value) |
Set cutoff bound on the objective function. More... | |
double | getCutoff () const |
Get the cutoff bound on the objective function - always as minimize. More... | |
OsiSolverInterface * | originalModel () const |
The original solver associated with this model. More... | |
void | setOriginalModel (OsiSolverInterface *originalModel) |
Set original model (probably acopy) More... | |
OsiSolverInterface * | startModel () const |
Solver after making clique equalities (may == original) More... | |
int | numberSolvers () const |
Number of solvers. More... | |
OsiSolverInterface * | modelAtPass (int iPass) const |
Copies of solver at various stages after presolve. More... | |
OsiSolverInterface * | modifiedModel (int iPass) const |
Copies of solver at various stages after presolve after modifications. More... | |
OsiPresolve * | presolve (int iPass) const |
Matching presolve information. More... | |
void | setPresolve (int iPass, OsiPresolve *presolve) |
Set matching presolve information. More... | |
const int * | originalColumns () |
Return a pointer to the original columns (with possible clique slacks) MUST be called before postProcess otherwise you just get 0,1,2. More... | |
const int * | originalRows () |
Return a pointer to the original rows MUST be called before postProcess otherwise you just get 0,1,2. More... | |
int | numberSOS () const |
Number of SOS if found. More... | |
const int * | typeSOS () const |
Type of each SOS. More... | |
const int * | startSOS () const |
Start of each SOS. More... | |
const int * | whichSOS () const |
Columns in SOS. More... | |
const double * | weightSOS () const |
Weights for each SOS column. More... | |
void | passInProhibited (const char *prohibited, int numberColumns) |
Pass in prohibited columns. More... | |
const char * | prohibited () |
Updated prohibited columns. More... | |
int | numberIterationsPre () const |
Number of iterations PreProcessing. More... | |
int | numberIterationsPost () const |
Number of iterations PostProcessing. More... | |
void | passInRowTypes (const char *rowTypes, int numberRows) |
Pass in row types 0 normal 1 cut rows - will be dropped if remain in At end of preprocess cut rows will be dropped and put into cuts. More... | |
const char * | rowTypes () |
Updated row types - may be NULL Carried around and corresponds to existing rows -1 added by preprocess e.g. More... | |
const CglStored & | cuts () const |
Return cuts from dropped rows. More... | |
const CglStored * | cutsPointer () const |
Return pointer to cuts from dropped rows. More... | |
void | update (const OsiPresolve *pinfo, const OsiSolverInterface *solver) |
Update prohibited and rowType. More... | |
int | options () const |
Get options. More... | |
void | setOptions (int value) |
Set options. More... | |
Cut generator methods | |
int | numberCutGenerators () const |
Get the number of cut generators. More... | |
CglCutGenerator ** | cutGenerators () const |
Get the list of cut generators. More... | |
CglCutGenerator * | cutGenerator (int i) const |
Get the specified cut generator. More... | |
void | addCutGenerator (CglCutGenerator *generator) |
Add one generator - up to user to delete generators. More... | |
Setting/Accessing application data | |
void | setApplicationData (void *appData) |
Set application data. More... | |
void * | getApplicationData () const |
Get application data. More... | |
Message handling | |
void | passInMessageHandler (CoinMessageHandler *handler) |
Pass in Message handler (not deleted at end) More... | |
void | newLanguage (CoinMessages::Language language) |
Set language. More... | |
void | setLanguage (CoinMessages::Language language) |
Pass in Message handler (not deleted at end) More... | |
CoinMessageHandler * | messageHandler () const |
Return handler. More... | |
CoinMessages | messages () |
Return messages. More... | |
CoinMessages * | messagesPointer () |
Return pointer to messages. More... | |
Constructors and destructors etc | |
CglPreProcess () | |
Constructor. More... | |
CglPreProcess (const CglPreProcess &rhs) | |
Copy constructor . More... | |
CglPreProcess & | operator= (const CglPreProcess &rhs) |
Assignment operator. More... | |
~CglPreProcess () | |
Destructor. More... | |
void | gutsOfDestructor () |
Clears out as much as possible. More... | |
void | setTimeLimit (const double timeLimit, const bool useElapsedTime) |
Set time limit. More... | |
void | setKeepColumnNames (const bool keep) |
Keeps original column names. More... | |
Private Member Functions | |
private methods | |
OsiSolverInterface * | modified (OsiSolverInterface *model, bool constraints, int &numberChanges, int iBigPass, int numberPasses) |
Return model with useful modifications. More... | |
void | createOriginalIndices () |
create original columns and rows More... | |
void | makeInteger () |
Make continuous variables integer. More... | |
Private member data | |
OsiSolverInterface * | originalModel_ |
The original solver associated with this model. More... | |
OsiSolverInterface * | startModel_ |
Solver after making clique equalities (may == original) More... | |
int | numberSolvers_ |
Number of solvers at various stages. More... | |
OsiSolverInterface ** | model_ |
Copies of solver at various stages after presolve. More... | |
OsiSolverInterface ** | modifiedModel_ |
Copies of solver at various stages after presolve after modifications. More... | |
OsiPresolve ** | presolve_ |
Matching presolve information. More... | |
CoinMessageHandler * | handler_ |
Message handler. More... | |
bool | defaultHandler_ |
Flag to say if handler_ is the default handler. More... | |
CoinMessages | messages_ |
Cgl messages. More... | |
void * | appData_ |
Pointer to user-defined data structure. More... | |
int * | originalColumn_ |
Original column numbers. More... | |
int * | originalRow_ |
Original row numbers. More... | |
int | numberCutGenerators_ |
Number of cut generators. More... | |
CglCutGenerator ** | generator_ |
Cut generators. More... | |
int | numberSOS_ |
Number of SOS if found. More... | |
int * | typeSOS_ |
Type of each SOS. More... | |
int * | startSOS_ |
Start of each SOS. More... | |
int * | whichSOS_ |
Columns in SOS. More... | |
double * | weightSOS_ |
Weights for each SOS column. More... | |
int | numberProhibited_ |
Number of columns in original prohibition set. More... | |
int | numberIterationsPre_ |
Number of iterations done in PreProcessing. More... | |
int | numberIterationsPost_ |
Number of iterations done in PostProcessing. More... | |
char * | prohibited_ |
Columns which should not be presolved e.g. SOS. More... | |
int | numberRowType_ |
Number of rows in original row types. More... | |
int | options_ |
Options 1 - original model had integer bounds before tightening 2 - don't do probing 4 - don't do duplicate rows 8 - don't do cliques 16 - some heavy probing options 64 - very heavy probing. More... | |
char * | rowType_ |
Row types (may be NULL) Carried around and corresponds to existing rows -1 added by preprocess e.g. More... | |
CglStored | cuts_ |
Cuts from dropped rows. More... | |
bool | useElapsedTime_ |
use elapsed (wallclock time) or cpu time More... | |
double | timeLimit_ |
time limit (default COIN_DBL_MAX) More... | |
bool | keepColumnNames_ |
keep column names More... | |
double | getCurrentCPUTime () const |
current elapsed or cpu time More... | |
Class for preProcessing and postProcessing.
While cuts can be added at any time in the tree, some cuts are actually just stronger versions of existing constraints. In this case they can replace those constraints rather than being added as new constraints. This is awkward in the tree but reasonable at the root node.
This is a general process class which uses other cut generators to strengthen constraints, establish that constraints are redundant, fix variables and find relationships such as x + y == 1.
Presolve will also be done.
If row names existed they may be replaced by R0000000..., unless setKeepColumnNames(true) is set.
Definition at line 37 of file CglPreProcess.hpp.
CglPreProcess::CglPreProcess | ( | ) |
Constructor.
CglPreProcess::CglPreProcess | ( | const CglPreProcess & | rhs | ) |
Copy constructor .
CglPreProcess::~CglPreProcess | ( | ) |
Destructor.
OsiSolverInterface* CglPreProcess::preProcess | ( | OsiSolverInterface & | model, |
bool | makeEquality = false , |
||
int | numberPasses = 5 |
||
) |
preProcess problem - returning new problem.
If makeEquality true then <= cliques converted to ==. Presolve will be done numberPasses times.
Returns NULL if infeasible
This version uses default strategy. For more control copy and edit code from this function i.e. call preProcessNonDefault
OsiSolverInterface* CglPreProcess::preProcessNonDefault | ( | OsiSolverInterface & | model, |
int | makeEquality = 0 , |
||
int | numberPasses = 5 , |
||
int | tuning = 0 |
||
) |
preProcess problem - returning new problem.
If makeEquality true then <= cliques converted to ==. Presolve will be done numberPasses times.
Returns NULL if infeasible
This version assumes user has added cut generators to CglPreProcess object before calling it. As an example use coding in preProcess If makeEquality is 1 add slacks to get cliques, if 2 add slacks to get sos (but only if looks plausible) and keep sos info
void CglPreProcess::postProcess | ( | OsiSolverInterface & | model, |
int | deleteStuff = 2 |
||
) |
Creates solution in original model deleteStuff 0 - don't, 1 do (but not if infeasible), 2 always.
int CglPreProcess::tightenPrimalBounds | ( | OsiSolverInterface & | model, |
double | factor = 0.0 |
||
) |
Tightens primal bounds to make dual and branch and cutfaster.
Unless fixed or integral, bounds are slightly looser than they could be. Returns non-zero if problem infeasible Fudge for branch and bound - put bounds on columns of factor * largest value (at continuous) - should improve stability in branch and bound on infeasible branches (0.0 is off)
OsiSolverInterface* CglPreProcess::someFixed | ( | OsiSolverInterface & | model, |
double | fractionToKeep = 0.25 , |
||
bool | fixContinuousAsWell = false , |
||
char * | keep = NULL |
||
) | const |
Fix some of problem - returning new problem.
Uses reduced costs. Optional signed character array 1 always keep, -1 always discard, 0 use djs
OsiSolverInterface* CglPreProcess::cliqueIt | ( | OsiSolverInterface & | model, |
double | cliquesNeeded = 0.0 |
||
) | const |
Replace cliques by more maximal cliques Returns NULL if rows not reduced by greater than cliquesNeeded*rows.
int CglPreProcess::reducedCostFix | ( | OsiSolverInterface & | model | ) |
If we have a cutoff - fix variables.
void CglPreProcess::setCutoff | ( | double | value | ) |
Set cutoff bound on the objective function.
When using strict comparison, the bound is adjusted by a tolerance to avoid accidentally cutting off the optimal solution.
double CglPreProcess::getCutoff | ( | ) | const |
Get the cutoff bound on the objective function - always as minimize.
|
inline |
The original solver associated with this model.
Definition at line 119 of file CglPreProcess.hpp.
References originalModel_.
Referenced by setOriginalModel().
|
inline |
Set original model (probably acopy)
Definition at line 124 of file CglPreProcess.hpp.
References originalModel(), and originalModel_.
|
inline |
Solver after making clique equalities (may == original)
Definition at line 129 of file CglPreProcess.hpp.
References startModel_.
|
inline |
|
inline |
Copies of solver at various stages after presolve.
Definition at line 139 of file CglPreProcess.hpp.
References model_, and numberSolvers_.
|
inline |
Copies of solver at various stages after presolve after modifications.
Definition at line 147 of file CglPreProcess.hpp.
References modifiedModel_, and numberSolvers_.
|
inline |
Matching presolve information.
Definition at line 155 of file CglPreProcess.hpp.
References numberSolvers_, and presolve_.
Referenced by setPresolve().
|
inline |
Set matching presolve information.
Definition at line 163 of file CglPreProcess.hpp.
References numberSolvers_, presolve(), and presolve_.
const int* CglPreProcess::originalColumns | ( | ) |
Return a pointer to the original columns (with possible clique slacks) MUST be called before postProcess otherwise you just get 0,1,2.
const int* CglPreProcess::originalRows | ( | ) |
Return a pointer to the original rows MUST be called before postProcess otherwise you just get 0,1,2.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Weights for each SOS column.
Definition at line 195 of file CglPreProcess.hpp.
References weightSOS_.
void CglPreProcess::passInProhibited | ( | const char * | prohibited, |
int | numberColumns | ||
) |
Pass in prohibited columns.
|
inline |
Updated prohibited columns.
Definition at line 202 of file CglPreProcess.hpp.
References prohibited_.
|
inline |
Number of iterations PreProcessing.
Definition at line 207 of file CglPreProcess.hpp.
References numberIterationsPre_.
|
inline |
Number of iterations PostProcessing.
Definition at line 212 of file CglPreProcess.hpp.
References numberIterationsPost_.
void CglPreProcess::passInRowTypes | ( | const char * | rowTypes, |
int | numberRows | ||
) |
Pass in row types 0 normal 1 cut rows - will be dropped if remain in At end of preprocess cut rows will be dropped and put into cuts.
|
inline |
Updated row types - may be NULL Carried around and corresponds to existing rows -1 added by preprocess e.g.
x+y=1 0 normal 1 cut rows - can be dropped if wanted
Definition at line 229 of file CglPreProcess.hpp.
References rowType_.
|
inline |
|
inline |
Return pointer to cuts from dropped rows.
Definition at line 239 of file CglPreProcess.hpp.
References cuts_.
void CglPreProcess::update | ( | const OsiPresolve * | pinfo, |
const OsiSolverInterface * | solver | ||
) |
Update prohibited and rowType.
|
inline |
|
inline |
|
inline |
Get the number of cut generators.
Definition at line 260 of file CglPreProcess.hpp.
|
inline |
Get the list of cut generators.
Definition at line 265 of file CglPreProcess.hpp.
References generator_.
|
inline |
Get the specified cut generator.
Definition at line 270 of file CglPreProcess.hpp.
References generator_.
void CglPreProcess::addCutGenerator | ( | CglCutGenerator * | generator | ) |
Add one generator - up to user to delete generators.
void CglPreProcess::setApplicationData | ( | void * | appData | ) |
Set application data.
This is a pointer that the application can store into and retrieve. This field is available for the application to optionally define and use.
void* CglPreProcess::getApplicationData | ( | ) | const |
Get application data.
void CglPreProcess::passInMessageHandler | ( | CoinMessageHandler * | handler | ) |
Pass in Message handler (not deleted at end)
void CglPreProcess::newLanguage | ( | CoinMessages::Language | language | ) |
Set language.
Referenced by setLanguage().
|
inline |
Pass in Message handler (not deleted at end)
Definition at line 302 of file CglPreProcess.hpp.
References newLanguage().
|
inline |
|
inline |
|
inline |
CglPreProcess& CglPreProcess::operator= | ( | const CglPreProcess & | rhs | ) |
Assignment operator.
void CglPreProcess::gutsOfDestructor | ( | ) |
Clears out as much as possible.
void CglPreProcess::setTimeLimit | ( | const double | timeLimit, |
const bool | useElapsedTime | ||
) |
Set time limit.
void CglPreProcess::setKeepColumnNames | ( | const bool | keep | ) |
Keeps original column names.
|
private |
Return model with useful modifications.
If constraints true then adds any x+y=1 or x-y=0 constraints If NULL infeasible
|
private |
create original columns and rows
|
private |
Make continuous variables integer.
|
private |
current elapsed or cpu time
|
private |
The original solver associated with this model.
Definition at line 373 of file CglPreProcess.hpp.
Referenced by originalModel(), and setOriginalModel().
|
private |
Solver after making clique equalities (may == original)
Definition at line 375 of file CglPreProcess.hpp.
Referenced by startModel().
|
private |
Number of solvers at various stages.
Definition at line 377 of file CglPreProcess.hpp.
Referenced by modelAtPass(), modifiedModel(), numberSolvers(), presolve(), and setPresolve().
|
private |
Copies of solver at various stages after presolve.
Definition at line 379 of file CglPreProcess.hpp.
Referenced by modelAtPass().
|
private |
Copies of solver at various stages after presolve after modifications.
Definition at line 381 of file CglPreProcess.hpp.
Referenced by modifiedModel().
|
private |
Matching presolve information.
Definition at line 383 of file CglPreProcess.hpp.
Referenced by presolve(), and setPresolve().
|
private |
|
private |
Flag to say if handler_ is the default handler.
The default handler is deleted when the model is deleted. Other handlers (supplied by the client) will not be deleted.
Definition at line 393 of file CglPreProcess.hpp.
|
private |
Cgl messages.
Definition at line 396 of file CglPreProcess.hpp.
Referenced by messages(), and messagesPointer().
|
private |
Pointer to user-defined data structure.
Definition at line 399 of file CglPreProcess.hpp.
|
private |
Original column numbers.
Definition at line 401 of file CglPreProcess.hpp.
|
private |
Original row numbers.
Definition at line 403 of file CglPreProcess.hpp.
|
private |
Number of cut generators.
Definition at line 405 of file CglPreProcess.hpp.
|
private |
Cut generators.
Definition at line 407 of file CglPreProcess.hpp.
Referenced by cutGenerator(), and cutGenerators().
|
private |
Number of SOS if found.
Definition at line 409 of file CglPreProcess.hpp.
Referenced by numberSOS().
|
private |
|
private |
|
private |
|
private |
Weights for each SOS column.
Definition at line 417 of file CglPreProcess.hpp.
Referenced by weightSOS().
|
private |
Number of columns in original prohibition set.
Definition at line 419 of file CglPreProcess.hpp.
|
private |
Number of iterations done in PreProcessing.
Definition at line 421 of file CglPreProcess.hpp.
Referenced by numberIterationsPre().
|
private |
Number of iterations done in PostProcessing.
Definition at line 423 of file CglPreProcess.hpp.
Referenced by numberIterationsPost().
|
private |
Columns which should not be presolved e.g. SOS.
Definition at line 425 of file CglPreProcess.hpp.
Referenced by prohibited().
|
private |
Number of rows in original row types.
Definition at line 427 of file CglPreProcess.hpp.
|
private |
Options 1 - original model had integer bounds before tightening 2 - don't do probing 4 - don't do duplicate rows 8 - don't do cliques 16 - some heavy probing options 64 - very heavy probing.
Definition at line 436 of file CglPreProcess.hpp.
Referenced by options(), and setOptions().
|
private |
Row types (may be NULL) Carried around and corresponds to existing rows -1 added by preprocess e.g.
x+y=1 0 normal 1 cut rows - can be dropped if wanted
Definition at line 443 of file CglPreProcess.hpp.
Referenced by rowTypes().
|
private |
Cuts from dropped rows.
Definition at line 445 of file CglPreProcess.hpp.
Referenced by cuts(), and cutsPointer().
|
private |
use elapsed (wallclock time) or cpu time
Definition at line 448 of file CglPreProcess.hpp.
|
private |
time limit (default COIN_DBL_MAX)
Definition at line 451 of file CglPreProcess.hpp.
|
private |
keep column names
Definition at line 454 of file CglPreProcess.hpp.