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