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 
37 
38 public:
39 
41 
42 
52  bool makeEquality=false, int numberPasses=5);
65  int makeEquality=0, int numberPasses=5,
66  int tuning=0);
69  ,bool deleteStuff=true);
77  int tightenPrimalBounds(OsiSolverInterface & model,double factor=0.0);
85  double fractionToKeep=0.25,
86  bool fixContinuousAsWell=false,
87  char * keep=NULL) const;
93  double cliquesNeeded=0.0) const;
97 
98  //---------------------------------------------------------------------------
99 
114  void setCutoff(double value) ;
115 
117  double getCutoff() const;
120  { return originalModel_;}
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 
231  void newLanguage(CoinMessages::Language language);
232  inline void setLanguage(CoinMessages::Language language)
233  {newLanguage(language);}
236  {return handler_;}
239  {return messages_;}
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 
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 
301 
304 
311 
314 
316  void * appData_;
328  int * typeSOS_;
330  int * startSOS_;
332  int * whichSOS_;
334  double * weightSOS_;
342  char * prohibited_;
353  int options_;
360  char * rowType_;
364 };
366 class CglBK {
367 
368 public:
369 
371 
372  void bronKerbosch();
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_;
430  int * dominated_;
434  const char * rowType_;
448  int left_;
451 };
455 // for hashing
456 typedef struct {
457  int index, next;
458 } CglHashLink;
459 class OsiRowCut;
461 public:
462 
463  CglUniqueRowCuts(int initialMaxSize=0, int hashMultiplier=4 );
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:
487  int size_;
491 };
492 #endif
const char * prohibited()
Updated prohibited columns.
int numberCutGenerators() const
Get the number of cut generators.
int numberRowType_
Number of rows in original row types.
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...
char * prohibited_
Columns which should not be presolved e.g. SOS.
int * originalRow_
Original row numbers.
void passInProhibited(const char *prohibited, int numberColumns)
Pass in prohibited columns.
Base class for message handling.
CglUniqueRowCuts(int initialMaxSize=0, int hashMultiplier=4)
double * weightSOS_
Weights for each SOS column.
int * startSOS_
Start of each SOS.
int numberIterationsPre_
Number of iterations done in PreProcessing.
int numberSOS() const
Number of SOS if found.
bool defaultHandler_
Flag to say if handler_ is the default handler.
void bronKerbosch()
For recursive Bron-Kerbosch.
void setLanguage(CoinMessages::Language language)
Pass in Message handler (not deleted at end)
Row Cut Class.
Definition: OsiRowCut.hpp:29
int * originalColumn_
Original column numbers.
int numberRows_
Number of original rows.
int numberIn_
Current number in clique.
Class for preProcessing and postProcessing.
void eraseRowCut(int sequence)
int * candidates_
Current candidates (created at each level)
void passInMessageHandler(CoinMessageHandler *handler)
Pass in Message handler (not deleted at end)
~CglPreProcess()
Destructor.
char * rowType_
Row types (may be NULL) Carried around and corresponds to existing rows -1 added by preprocess e...
CoinMessages * messagesPointer()
Return pointer to messages.
const char * rowTypes()
Updated row types - may be NULL Carried around and corresponds to existing rows -1 added by preproces...
void insert(const OsiRowCut &cut)
const int * originalRows()
Return a pointer to the original rows MUST be called before postProcess otherwise you just get 0...
int numberIterationsPre() const
Number of iterations PreProcessing.
Sparse Matrix Base Class.
CglCutGenerator * cutGenerator(int i) const
Get the specified cut generator.
CglCutGenerator ** cutGenerators() const
Get the list of cut generators.
~CglBK()
Destructor.
Collections of row cuts and column cuts.
Definition: OsiCuts.hpp:19
int numberSolvers_
Number of solvers at various stages.
int numberCandidates_
Current number of candidates.
const int * whichSOS() const
Columns in SOS.
OsiRowCut ** rowCut_
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...
void addCuts(OsiCuts &cs)
int numberProhibited_
Number of columns in original prohibition set.
int numberIterationsPost() const
Number of iterations PostProcessing.
int numberPossible_
Number possible.
void update(const OsiPresolve *pinfo, const OsiSolverInterface *solver)
Update prohibited and rowType.
int firstNot_
First not (stored backwards from numberPossible_)
OsiPresolve * presolve(int iPass) const
Matching presolve information.
OsiSolverInterface * someFixed(OsiSolverInterface &model, double fractionToKeep=0.25, bool fixContinuousAsWell=false, char *keep=NULL) const
Fix some of problem - returning new problem.
OsiSolverInterface * startModel_
Solver after making clique equalities (may == original)
OsiSolverInterface * startModel() const
Solver after making clique equalities (may == original)
OsiSolverInterface * preProcessNonDefault(OsiSolverInterface &model, int makeEquality=0, int numberPasses=5, int tuning=0)
preProcess problem - returning new problem.
void postProcess(OsiSolverInterface &model, bool deleteStuff=true)
Creates solution in original model.
int numberIterationsPost_
Number of iterations done in PostProcessing.
OSI interface to COIN problem simplification capabilities.
Definition: OsiPresolve.hpp:62
const int * originalColumns()
Return a pointer to the original columns (with possible clique slacks) MUST be called before postProc...
OsiSolverInterface * originalModel() const
The original solver associated with this model.
const int * startSOS() const
Start of each SOS.
CglPreProcess()
Constructor.
int * whichSOS_
Columns in SOS.
int numberSOS_
Number of SOS if found.
OsiSolverInterface * modified(OsiSolverInterface *model, bool constraints, int &numberChanges, int iBigPass, int numberPasses)
Return model with useful modifications.
This is a first attempt at a message handler.
int lastColumn_
Current candidates (created at each level)
void setCutoff(double value)
Set cutoff bound on the objective function.
OsiRowCut * cut(int sequence) const
void * appData_
Pointer to user-defined data structure.
Abstract Base Class for describing an interface to a solver.
void makeInteger()
Make continuous variables integer.
CglPreProcess & operator=(const CglPreProcess &rhs)
Assignment operator.
Cut Generator Base Class.
CoinMessageHandler * messageHandler() const
Return handler.
void gutsOfDestructor()
Clears out as much as possible.
int insertIfNotDuplicate(const OsiRowCut &cut)
int * start_
Starts for graph (numberPossible+1)
int options_
Options 1 - original model had integer bounds before tightening 2 - don&#39;t do probing 4 - don&#39;t do dup...
CglStored cuts_
Cuts from dropped rows.
Class to hold and manipulate an array of massaged messages.
int * typeSOS_
Type of each SOS.
const char * rowType_
points to row types
const CglStored * cutsPointer() const
Return pointer to cuts from dropped rows.
void * getApplicationData() const
Get application data.
OsiSolverInterface * modifiedModel(int iPass) const
Copies of solver at various stages after presolve after modifications.
For Bron-Kerbosch.
OsiPresolve ** presolve_
Matching presolve information.
CglUniqueRowCuts & operator=(const CglUniqueRowCuts &rhs)
void newLanguage(CoinMessages::Language language)
Set language.
int reducedCostFix(OsiSolverInterface &model)
If we have a cutoff - fix variables.
OsiRowCut * rowCutPtr(int sequence)
const CglStored & cuts() const
Return cuts from dropped rows.
int * dominated_
How many times each original row dominated.
int numberCuts() const
void setApplicationData(void *appData)
Set application data.
int tightenPrimalBounds(OsiSolverInterface &model, double factor=0.0)
Tightens primal bounds to make dual and branch and cutfaster.
int numberColumns_
Number of original columns.
CoinMessages messages()
Return messages.
Stored Cut Generator Class.
Definition: CglStored.hpp:16
OsiSolverInterface * preProcess(OsiSolverInterface &model, bool makeEquality=false, int numberPasses=5)
preProcess problem - returning new problem.
CglBK & operator=(const CglBK &rhs)
Assignment operator.
CoinMessageHandler * handler_
Message handler.
OsiSolverInterface ** modifiedModel_
Copies of solver at various stages after presolve after modifications.
CoinPackedMatrix * cliqueMatrix_
Clique entries.
OsiSolverInterface * newSolver(const OsiSolverInterface &model)
Creates strengthened smaller model.
CglBK()
Default constructor.
int * originalRow_
Original row (in parallel with otherColumn_)
CoinMessages messages_
Cgl messages.
void addCutGenerator(CglCutGenerator *generator)
Add one generator - up to user to delete generators.
CglCutGenerator ** generator_
Cut generators.
int sizeRowCuts() const
const int * typeSOS() const
Type of each SOS.
Language
Supported languages.
const double * weightSOS() const
Weights for each SOS column.
OsiSolverInterface * originalModel_
The original solver associated with this model.
void createOriginalIndices()
create original columns and rows
void setOptions(int value)
Set options.
CglHashLink * hash_
Hash table.
OsiSolverInterface ** model_
Copies of solver at various stages after presolve.
int numberCutGenerators_
Number of cut generators.
int * otherColumn_
Other column/node.
char * mark_
Array to mark stuff.
double getCutoff() const
Get the cutoff bound on the objective function - always as minimize.
OsiSolverInterface * modelAtPass(int iPass) const
Copies of solver at various stages after presolve.
int left_
For acceleration.