Cgl 0.59.7

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CglPreProcess.hpp
Go to the documentation of this file.
1 // Copyright (C) 2005, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 // This code is licensed under the terms of the Eclipse Public License (EPL).
4
5 #ifndef CglPreProcess_H
6 #define CglPreProcess_H
7
8 #include <string>
9 #include <vector>
10
11 #include "CoinMessageHandler.hpp"
12 #include "OsiSolverInterface.hpp"
13 #include "CglStored.hpp"
14 #include "OsiPresolve.hpp"
15 #include "CglCutGenerator.hpp"
16
17 //#############################################################################
18
36 class CglPreProcess {
37
38 public:
39
41
42
51 OsiSolverInterface * preProcess(OsiSolverInterface & model,
52 bool makeEquality=false, int numberPasses=5);
64 OsiSolverInterface * preProcessNonDefault(OsiSolverInterface & model,
65 int makeEquality=0, int numberPasses=5,
66 int tuning=0);
68 void postProcess(OsiSolverInterface &model
69 ,bool deleteStuff=true);
77 int tightenPrimalBounds(OsiSolverInterface & model,double factor=0.0);
84 OsiSolverInterface * someFixed(OsiSolverInterface & model,
85 double fractionToKeep=0.25,
86 bool fixContinuousAsWell=false,
87 char * keep=NULL) const;
92 OsiSolverInterface * cliqueIt(OsiSolverInterface & model,
93 double cliquesNeeded=0.0) const;
95 int reducedCostFix(OsiSolverInterface & model);
97
98 //---------------------------------------------------------------------------
99
114 void setCutoff(double value) ;
115
117 double getCutoff() const;
119 inline OsiSolverInterface * originalModel() const
120 { return originalModel_;}
122 inline OsiSolverInterface * startModel() const
123 { return startModel_;}
125 inline OsiSolverInterface * modelAtPass(int iPass) const
126 { if (iPass>=0&&iPass<numberSolvers_) return model_[iPass]; else return NULL;}
128 inline OsiSolverInterface * modifiedModel(int iPass) const
129 { if (iPass>=0&&iPass<numberSolvers_) return modifiedModel_[iPass]; else return NULL;}
131 inline OsiPresolve * presolve(int iPass) const
132 { if (iPass>=0&&iPass<numberSolvers_) return presolve_[iPass]; else return NULL;}
135 const int * originalColumns();
138 const int * originalRows();
140 inline int numberSOS() const
141 { return numberSOS_;}
143 inline const int * typeSOS() const
144 { return typeSOS_;}
146 inline const int * startSOS() const
147 { return startSOS_;}
149 inline const int * whichSOS() const
150 { return whichSOS_;}
152 inline const double * weightSOS() const
153 { return weightSOS_;}
155 void passInProhibited(const char * prohibited,int numberColumns);
157 inline const char * prohibited()
158 { return prohibited_;}
160 inline int numberIterationsPre() const
161 { return numberIterationsPre_;}
163 inline int numberIterationsPost() const
164 { return numberIterationsPost_;}
171 void passInRowTypes(const char * rowTypes,int numberRows);
178 inline const char * rowTypes()
179 { return rowType_;}
181 inline const CglStored & cuts() const
182 { return cuts_;}
184 inline const CglStored * cutsPointer() const
185 { return &cuts_;}
187 void update(const OsiPresolve * pinfo,const OsiSolverInterface * solver);
189 inline void setOptions(int value)
190 { options_=value;}
192
194
195 inline int numberCutGenerators() const
197 { return numberCutGenerators_;}
199 inline CglCutGenerator ** cutGenerators() const
200 { return generator_;}
202 inline CglCutGenerator * cutGenerator(int i) const
203 { return generator_[i];}
206 void addCutGenerator(CglCutGenerator * generator);
208
218 void setApplicationData (void * appData);
219
221 void * getApplicationData() const;
223
224 //---------------------------------------------------------------------------
225
228 void passInMessageHandler(CoinMessageHandler * handler);
231 void newLanguage(CoinMessages::Language language);
232 inline void setLanguage(CoinMessages::Language language)
233 {newLanguage(language);}
235 inline CoinMessageHandler * messageHandler() const
236 {return handler_;}
238 inline CoinMessages messages()
239 {return messages_;}
241 inline CoinMessages * messagesPointer()
242 {return &messages_;}
244 //---------------------------------------------------------------------------
245
246
248
249 CglPreProcess();
251
253 CglPreProcess(const CglPreProcess & rhs);
254
256 CglPreProcess & operator=(const CglPreProcess& rhs);
257
259 ~CglPreProcess ();
260
262 void gutsOfDestructor();
264 private:
265
267
268
272 OsiSolverInterface * modified(OsiSolverInterface * model,
273 bool constraints,
274 int & numberChanges,
275 int iBigPass,
276 int numberPasses);
278 void createOriginalIndices();
280 void makeInteger();
282
283 //---------------------------------------------------------------------------
284
285 private:
287
288
290 OsiSolverInterface * originalModel_;
292 OsiSolverInterface * startModel_;
294 int numberSolvers_;
296 OsiSolverInterface ** model_;
298 OsiSolverInterface ** modifiedModel_;
300 OsiPresolve ** presolve_;
301
303 CoinMessageHandler * handler_;
304
310 bool defaultHandler_;
311
313 CoinMessages messages_;
314
316 void * appData_;
318 int * originalColumn_;
320 int * originalRow_;
322 int numberCutGenerators_;
324 CglCutGenerator ** generator_;
326 int numberSOS_;
328 int * typeSOS_;
330 int * startSOS_;
332 int * whichSOS_;
334 double * weightSOS_;
336 int numberProhibited_;
338 int numberIterationsPre_;
340 int numberIterationsPost_;
342 char * prohibited_;
344 int numberRowType_;
353 int options_;
360 char * rowType_;
362 CglStored cuts_;
364 };
366 class CglBK {
367
368 public:
369
371
372 void bronKerbosch();
375 OsiSolverInterface * newSolver(const OsiSolverInterface & model);
377
378 //---------------------------------------------------------------------------
379
389
390
391 //---------------------------------------------------------------------------
392
393
395
396 CglBK();
398
400 CglBK(const OsiSolverInterface & model, const char * rowType,
401 int numberElements);
402
404 CglBK(const CglBK & rhs);
405
407 CglBK & operator=(const CglBK& rhs);
408
410 ~CglBK ();
411
413
414 //---------------------------------------------------------------------------
415
416 private:
418
419 int * candidates_;
422 char * mark_;
424 int * start_;
426 int * otherColumn_;
428 int * originalRow_;
430 int * dominated_;
432 CoinPackedMatrix * cliqueMatrix_;
434 const char * rowType_;
436 int numberColumns_;
438 int numberRows_;
440 int numberPossible_;
442 int numberCandidates_;
444 int firstNot_;
446 int numberIn_;
448 int left_;
449 int lastColumn_;
451 };
455 // for hashing
456 typedef struct {
457 int index, next;
458 } CglHashLink;
459 class OsiRowCut;
460 class CglUniqueRowCuts {
461 public:
462
463 CglUniqueRowCuts(int initialMaxSize=0, int hashMultiplier=4 );
464 ~CglUniqueRowCuts();
465 CglUniqueRowCuts(const CglUniqueRowCuts& rhs);
466 CglUniqueRowCuts& operator=(const CglUniqueRowCuts& rhs);
467 inline OsiRowCut * cut(int sequence) const
468 { return rowCut_[sequence];}
469 inline int numberCuts() const
470 { return numberCuts_;}
471 inline int sizeRowCuts() const
472 { return numberCuts_;}
473 inline OsiRowCut * rowCutPtr(int sequence)
474 { return rowCut_[sequence];}
475 void eraseRowCut(int sequence);
476 // insert cut
477 inline void insert(const OsiRowCut & cut)
478 { insertIfNotDuplicate(cut);}
479 // Return 0 if added, 1 if not
480 int insertIfNotDuplicate(const OsiRowCut & cut);
481 // Add in cuts as normal cuts (and delete)
482 void addCuts(OsiCuts & cs);
483 private:
484 OsiRowCut ** rowCut_;
486 CglHashLink *hash_;
487 int size_;
488 int hashMultiplier_;
489 int numberCuts_;
490 int lastHash_;
491 };
492 #endif
CglPreProcess::rowType_
char * rowType_
Row types (may be NULL) Carried around and corresponds to existing rows -1 added by preprocess e...
Definition: CglPreProcess.hpp:360
CglPreProcess::weightSOS
const double * weightSOS() const
Weights for each SOS column.
Definition: CglPreProcess.hpp:152
CglPreProcess::gutsOfDestructor
void gutsOfDestructor()
Clears out as much as possible.
CglUniqueRowCuts::numberCuts
int numberCuts() const
Definition: CglPreProcess.hpp:469
CglPreProcess::tightenPrimalBounds
int tightenPrimalBounds(OsiSolverInterface &model, double factor=0.0)
Tightens primal bounds to make dual and branch and cutfaster.
CglBK
For Bron-Kerbosch.
Definition: CglPreProcess.hpp:366
CglPreProcess::numberRowType_
int numberRowType_
Number of rows in original row types.
Definition: CglPreProcess.hpp:344
CglPreProcess::newLanguage
void newLanguage(CoinMessages::Language language)
Set language.
CglPreProcess::model_
OsiSolverInterface ** model_
Copies of solver at various stages after presolve.
Definition: CglPreProcess.hpp:296
CglUniqueRowCuts::CglUniqueRowCuts
CglUniqueRowCuts(int initialMaxSize=0, int hashMultiplier=4)
CglPreProcess::handler_
CoinMessageHandler * handler_
Message handler.
Definition: CglPreProcess.hpp:303
CglPreProcess::addCutGenerator
void addCutGenerator(CglCutGenerator *generator)
Add one generator - up to user to delete generators.
CglUniqueRowCuts::cut
OsiRowCut * cut(int sequence) const
Definition: CglPreProcess.hpp:467
CglPreProcess::numberIterationsPost_
int numberIterationsPost_
Number of iterations done in PostProcessing.
Definition: CglPreProcess.hpp:340
CglHashLink
Only store unique row cuts.
Definition: CglPreProcess.hpp:456
CglPreProcess::cuts_
CglStored cuts_
Cuts from dropped rows.
Definition: CglPreProcess.hpp:362
CglStored
Stored Cut Generator Class.
Definition: CglStored.hpp:16
CglCutGenerator.hpp
CglPreProcess::cutGenerators
CglCutGenerator ** cutGenerators() const
Get the list of cut generators.
Definition: CglPreProcess.hpp:199
CglPreProcess::update
void update(const OsiPresolve *pinfo, const OsiSolverInterface *solver)
Update prohibited and rowType.
CglUniqueRowCuts::sizeRowCuts
int sizeRowCuts() const
Definition: CglPreProcess.hpp:471
CglBK::left_
int left_
For acceleration.
Definition: CglPreProcess.hpp:448
CglPreProcess::setApplicationData
void setApplicationData(void *appData)
Set application data.
CglBK::dominated_
int * dominated_
How many times each original row dominated.
Definition: CglPreProcess.hpp:430
CglPreProcess::operator=
CglPreProcess & operator=(const CglPreProcess &rhs)
Assignment operator.
OsiCuts
Collections of row cuts and column cuts.
Definition: OsiCuts.hpp:19
CglPreProcess::setLanguage
void setLanguage(CoinMessages::Language language)
Definition: CglPreProcess.hpp:232
CglBK::otherColumn_
int * otherColumn_
Other column/node.
Definition: CglPreProcess.hpp:426
CglHashLink::next
int next
Definition: CglPreProcess.hpp:457
CglPreProcess::weightSOS_
double * weightSOS_
Weights for each SOS column.
Definition: CglPreProcess.hpp:334
CglBK::operator=
CglBK & operator=(const CglBK &rhs)
Assignment operator.
CglBK::numberIn_
int numberIn_
Current number in clique.
Definition: CglPreProcess.hpp:446
CglBK::numberColumns_
int numberColumns_
Number of original columns.
Definition: CglPreProcess.hpp:436
CglPreProcess::presolve_
OsiPresolve ** presolve_
Matching presolve information.
Definition: CglPreProcess.hpp:300
CglBK::~CglBK
~CglBK()
Destructor.
CglBK::numberPossible_
int numberPossible_
Number possible.
Definition: CglPreProcess.hpp:440
CoinMessageHandler
Base class for message handling.
Definition: CoinMessageHandler.hpp:327
CglPreProcess::startModel_
OsiSolverInterface * startModel_
Solver after making clique equalities (may == original)
Definition: CglPreProcess.hpp:292
CglPreProcess::cliqueIt
OsiSolverInterface * cliqueIt(OsiSolverInterface &model, double cliquesNeeded=0.0) const
Replace cliques by more maximal cliques Returns NULL if rows not reduced by greater than cliquesNeede...
CglPreProcess::appData_
void * appData_
Pointer to user-defined data structure.
Definition: CglPreProcess.hpp:316
CglBK::newSolver
OsiSolverInterface * newSolver(const OsiSolverInterface &model)
Creates strengthened smaller model.
OsiSolverInterface
Abstract Base Class for describing an interface to a solver.
Definition: OsiSolverInterface.hpp:62
CglPreProcess::postProcess
void postProcess(OsiSolverInterface &model, bool deleteStuff=true)
Creates solution in original model.
CglBK::lastColumn_
int lastColumn_
Definition: CglPreProcess.hpp:449
CglBK::originalRow_
int * originalRow_
Original row (in parallel with otherColumn_)
Definition: CglPreProcess.hpp:428
CglPreProcess::numberSOS_
int numberSOS_
Number of SOS if found.
Definition: CglPreProcess.hpp:326
CglBK::bronKerbosch
void bronKerbosch()
For recursive Bron-Kerbosch.
CglPreProcess::originalColumn_
int * originalColumn_
Original column numbers.
Definition: CglPreProcess.hpp:318
CglPreProcess::numberIterationsPre_
int numberIterationsPre_
Number of iterations done in PreProcessing.
Definition: CglPreProcess.hpp:338
CglBK::mark_
char * mark_
Array to mark stuff.
Definition: CglPreProcess.hpp:422
CglPreProcess::setOptions
void setOptions(int value)
Set options.
Definition: CglPreProcess.hpp:189
CglBK::candidates_
int * candidates_
Current candidates (created at each level)
Definition: CglPreProcess.hpp:420
CglUniqueRowCuts::size_
int size_
Definition: CglPreProcess.hpp:487
CglPreProcess::preProcessNonDefault
OsiSolverInterface * preProcessNonDefault(OsiSolverInterface &model, int makeEquality=0, int numberPasses=5, int tuning=0)
preProcess problem - returning new problem.
CoinMessageHandler.hpp
This is a first attempt at a message handler.
CglPreProcess::numberIterationsPre
int numberIterationsPre() const
Number of iterations PreProcessing.
Definition: CglPreProcess.hpp:160
CglPreProcess::whichSOS
const int * whichSOS() const
Columns in SOS.
Definition: CglPreProcess.hpp:149
CglPreProcess::someFixed
OsiSolverInterface * someFixed(OsiSolverInterface &model, double fractionToKeep=0.25, bool fixContinuousAsWell=false, char *keep=NULL) const
Fix some of problem - returning new problem.
CglCutGenerator
Cut Generator Base Class.
Definition: CglCutGenerator.hpp:23
CglPreProcess::numberSOS
int numberSOS() const
Number of SOS if found.
Definition: CglPreProcess.hpp:140
CglPreProcess::numberIterationsPost
int numberIterationsPost() const
Number of iterations PostProcessing.
Definition: CglPreProcess.hpp:163
CglPreProcess::numberSolvers_
int numberSolvers_
Number of solvers at various stages.
Definition: CglPreProcess.hpp:294
CglUniqueRowCuts::eraseRowCut
void eraseRowCut(int sequence)
CglUniqueRowCuts::addCuts
void addCuts(OsiCuts &cs)
CglPreProcess::passInMessageHandler
void passInMessageHandler(CoinMessageHandler *handler)
Pass in Message handler (not deleted at end)
OsiPresolve.hpp
CglPreProcess::cutGenerator
CglCutGenerator * cutGenerator(int i) const
Get the specified cut generator.
Definition: CglPreProcess.hpp:202
CglPreProcess::passInRowTypes
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 wi...
CglUniqueRowCuts::insert
void insert(const OsiRowCut &cut)
Definition: CglPreProcess.hpp:477
cut
Definition: Cgl012cut.hpp:153
CglPreProcess::originalModel
OsiSolverInterface * originalModel() const
The original solver associated with this model.
Definition: CglPreProcess.hpp:119
CglUniqueRowCuts::lastHash_
int lastHash_
Definition: CglPreProcess.hpp:490
CglUniqueRowCuts::numberCuts_
int numberCuts_
Definition: CglPreProcess.hpp:489
CglPreProcess::modelAtPass
OsiSolverInterface * modelAtPass(int iPass) const
Copies of solver at various stages after presolve.
Definition: CglPreProcess.hpp:125
CglBK::start_
int * start_
Starts for graph (numberPossible+1)
Definition: CglPreProcess.hpp:424
CglPreProcess::startSOS_
int * startSOS_
Start of each SOS.
Definition: CglPreProcess.hpp:330
CglUniqueRowCuts::hash_
CglHashLink * hash_
Hash table.
Definition: CglPreProcess.hpp:486
CglUniqueRowCuts::operator=
CglUniqueRowCuts & operator=(const CglUniqueRowCuts &rhs)
CglPreProcess::originalColumns
const int * originalColumns()
Return a pointer to the original columns (with possible clique slacks) MUST be called before postProc...
CglPreProcess::modifiedModel_
OsiSolverInterface ** modifiedModel_
Copies of solver at various stages after presolve after modifications.
Definition: CglPreProcess.hpp:298
CglPreProcess::messagesPointer
CoinMessages * messagesPointer()
Return pointer to messages.
Definition: CglPreProcess.hpp:241
OsiRowCut
Row Cut Class.
Definition: OsiRowCut.hpp:29
CglPreProcess::cuts
const CglStored & cuts() const
Return cuts from dropped rows.
Definition: CglPreProcess.hpp:181
CglPreProcess::CglPreProcess
CglPreProcess()
Constructor.
CglPreProcess::createOriginalIndices
void createOriginalIndices()
create original columns and rows
CglPreProcess::numberCutGenerators_
int numberCutGenerators_
Number of cut generators.
Definition: CglPreProcess.hpp:322
CglBK::cliqueMatrix_
CoinPackedMatrix * cliqueMatrix_
Clique entries.
Definition: CglPreProcess.hpp:432
CglPreProcess::modified
OsiSolverInterface * modified(OsiSolverInterface *model, bool constraints, int &numberChanges, int iBigPass, int numberPasses)
Return model with useful modifications.
CglPreProcess::cutsPointer
const CglStored * cutsPointer() const
Return pointer to cuts from dropped rows.
Definition: CglPreProcess.hpp:184
CoinPackedMatrix
Sparse Matrix Base Class.
Definition: CoinPackedMatrix.hpp:79
CglUniqueRowCuts::hashMultiplier_
int hashMultiplier_
Definition: CglPreProcess.hpp:488
OsiPresolve
OSI interface to COIN problem simplification capabilities.
Definition: OsiPresolve.hpp:62
CglPreProcess::whichSOS_
int * whichSOS_
Columns in SOS.
Definition: CglPreProcess.hpp:332
CglBK::rowType_
const char * rowType_
points to row types
Definition: CglPreProcess.hpp:434
CglPreProcess::setCutoff
void setCutoff(double value)
Set cutoff bound on the objective function.
CglPreProcess::originalModel_
OsiSolverInterface * originalModel_
The original solver associated with this model.
Definition: CglPreProcess.hpp:290
CglPreProcess::startModel
OsiSolverInterface * startModel() const
Solver after making clique equalities (may == original)
Definition: CglPreProcess.hpp:122
OsiSolverInterface.hpp
CoinMessages::Language
Language
Supported languages.
Definition: CoinMessageHandler.hpp:136
CglPreProcess::presolve
OsiPresolve * presolve(int iPass) const
Matching presolve information.
Definition: CglPreProcess.hpp:131
CglPreProcess::modifiedModel
OsiSolverInterface * modifiedModel(int iPass) const
Copies of solver at various stages after presolve after modifications.
Definition: CglPreProcess.hpp:128
CglPreProcess::generator_
CglCutGenerator ** generator_
Cut generators.
Definition: CglPreProcess.hpp:324
CglPreProcess::passInProhibited
void passInProhibited(const char *prohibited, int numberColumns)
Pass in prohibited columns.
CglUniqueRowCuts::rowCutPtr
OsiRowCut * rowCutPtr(int sequence)
Definition: CglPreProcess.hpp:473
CglPreProcess::options_
int options_
Options 1 - original model had integer bounds before tightening 2 - don&#39;t do probing 4 - don&#39;t do dup...
Definition: CglPreProcess.hpp:353
CglPreProcess::defaultHandler_
bool defaultHandler_
Flag to say if handler_ is the default handler.
Definition: CglPreProcess.hpp:310
CglPreProcess::preProcess
OsiSolverInterface * preProcess(OsiSolverInterface &model, bool makeEquality=false, int numberPasses=5)
preProcess problem - returning new problem.
CglBK::numberRows_
int numberRows_
Number of original rows.
Definition: CglPreProcess.hpp:438
CglPreProcess::rowTypes
const char * rowTypes()
Updated row types - may be NULL Carried around and corresponds to existing rows -1 added by preproces...
Definition: CglPreProcess.hpp:178
CglPreProcess::typeSOS_
int * typeSOS_
Type of each SOS.
Definition: CglPreProcess.hpp:328
CglBK::firstNot_
int firstNot_
First not (stored backwards from numberPossible_)
Definition: CglPreProcess.hpp:444
CglPreProcess::prohibited_
char * prohibited_
Columns which should not be presolved e.g. SOS.
Definition: CglPreProcess.hpp:342
CglPreProcess::startSOS
const int * startSOS() const
Start of each SOS.
Definition: CglPreProcess.hpp:146
CglPreProcess::numberCutGenerators
int numberCutGenerators() const
Get the number of cut generators.
Definition: CglPreProcess.hpp:196
CglUniqueRowCuts
Definition: CglPreProcess.hpp:460
CglPreProcess::prohibited
const char * prohibited()
Updated prohibited columns.
Definition: CglPreProcess.hpp:157
CglPreProcess::makeInteger
void makeInteger()
Make continuous variables integer.
CglPreProcess
Class for preProcessing and postProcessing.
Definition: CglPreProcess.hpp:36
CglPreProcess::messageHandler
CoinMessageHandler * messageHandler() const
Return handler.
Definition: CglPreProcess.hpp:235
CglUniqueRowCuts::~CglUniqueRowCuts
~CglUniqueRowCuts()
CglUniqueRowCuts::rowCut_
OsiRowCut ** rowCut_
Definition: CglPreProcess.hpp:484
CglPreProcess::messages
CoinMessages messages()
Return messages.
Definition: CglPreProcess.hpp:238
CglPreProcess::getApplicationData
void * getApplicationData() const
Get application data.
CglPreProcess::numberProhibited_
int numberProhibited_
Number of columns in original prohibition set.
Definition: CglPreProcess.hpp:336
CglPreProcess::reducedCostFix
int reducedCostFix(OsiSolverInterface &model)
If we have a cutoff - fix variables.
CglPreProcess::~CglPreProcess
~CglPreProcess()
Destructor.
CglBK::CglBK
CglBK()
Default constructor.
CglPreProcess::getCutoff
double getCutoff() const
Get the cutoff bound on the objective function - always as minimize.
CglPreProcess::originalRows
const int * originalRows()
Return a pointer to the original rows MUST be called before postProcess otherwise you just get 0...
CglStored.hpp
CoinMessages
Class to hold and manipulate an array of massaged messages.
Definition: CoinMessageHandler.hpp:128
CglBK::numberCandidates_
int numberCandidates_
Current number of candidates.
Definition: CglPreProcess.hpp:442
CglPreProcess::typeSOS
const int * typeSOS() const
Type of each SOS.
Definition: CglPreProcess.hpp:143
CglUniqueRowCuts::insertIfNotDuplicate
int insertIfNotDuplicate(const OsiRowCut &cut)
CglPreProcess::messages_
CoinMessages messages_
Cgl messages.
Definition: CglPreProcess.hpp:313
CglPreProcess::originalRow_
int * originalRow_
Original row numbers.
Definition: CglPreProcess.hpp:320