coin-Cgl
CglPreProcess.hpp
Go to the documentation of this file.
1 // Copyright (C) 2005, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 #ifndef CglPreProcess_H
4 #define CglPreProcess_H
5 
6 #include <string>
7 #include <vector>
8 
9 #include "CoinFinite.hpp"
10 #include "CoinMessageHandler.hpp"
11 #include "OsiSolverInterface.hpp"
12 #include "CglStored.hpp"
13 #include "OsiPresolve.hpp"
14 #include "CglCutGenerator.hpp"
15 
16 //#############################################################################
17 
36 
37 public:
38 
40 
41 
50  OsiSolverInterface * preProcess(OsiSolverInterface & model,
51  bool makeEquality=false, int numberPasses=5);
63  OsiSolverInterface * preProcessNonDefault(OsiSolverInterface & model,
64  int makeEquality=0, int numberPasses=5,
65  int tuning=0);
67  void postProcess(OsiSolverInterface &model);
75  int tightenPrimalBounds(OsiSolverInterface & model,double factor=0.0);
82  OsiSolverInterface * someFixed(OsiSolverInterface & model,
83  double fractionToKeep=0.25,
84  bool fixContinuousAsWell=false,
85  char * keep=NULL) const;
87  int reducedCostFix(OsiSolverInterface & model);
89 
90  //---------------------------------------------------------------------------
91 
106  void setCutoff(double value) ;
107 
109  double getCutoff() const;
111  inline OsiSolverInterface * originalModel() const
112  { return originalModel_;}
114  inline OsiSolverInterface * startModel() const
115  { return startModel_;}
117  inline OsiSolverInterface * modelAtPass(int iPass) const
118  { if (iPass>=0&&iPass<numberSolvers_) return model_[iPass]; else return NULL;}
120  inline OsiSolverInterface * modifiedModel(int iPass) const
121  { if (iPass>=0&&iPass<numberSolvers_) return modifiedModel_[iPass]; else return NULL;}
123  inline OsiPresolve * presolve(int iPass) const
124  { if (iPass>=0&&iPass<numberSolvers_) return presolve_[iPass]; else return NULL;}
127  const int * originalColumns() const;
130  const int * originalRows() const;
132  inline int numberSOS() const
133  { return numberSOS_;}
135  inline const int * typeSOS() const
136  { return typeSOS_;}
138  inline const int * startSOS() const
139  { return startSOS_;}
141  inline const int * whichSOS() const
142  { return whichSOS_;}
144  inline const double * weightSOS() const
145  { return weightSOS_;}
147  void passInProhibited(const char * prohibited,int numberColumns);
149  inline const char * prohibited()
150  { return prohibited_;}
152  inline int numberIterationsPre() const
153  { return numberIterationsPre_;}
155  inline int numberIterationsPost() const
156  { return numberIterationsPost_;}
163  void passInRowTypes(const char * rowTypes,int numberRows);
170  inline const char * rowTypes()
171  { return rowType_;}
173  inline const CglStored & cuts() const
174  { return cuts_;}
176  inline const CglStored * cutsPointer() const
177  { return &cuts_;}
179  void update(const OsiPresolve * pinfo,const OsiSolverInterface * solver);
181  inline void setOptions(int value)
182  { options_=value;}
184 
186 
187  inline int numberCutGenerators() const
189  { return numberCutGenerators_;}
191  inline CglCutGenerator ** cutGenerators() const
192  { return generator_;}
194  inline CglCutGenerator * cutGenerator(int i) const
195  { return generator_[i];}
198  void addCutGenerator(CglCutGenerator * generator);
200 
210  void setApplicationData (void * appData);
211 
213  void * getApplicationData() const;
215 
216  //---------------------------------------------------------------------------
217 
220  void passInMessageHandler(CoinMessageHandler * handler);
223  void newLanguage(CoinMessages::Language language);
224  inline void setLanguage(CoinMessages::Language language)
225  {newLanguage(language);}
227  inline CoinMessageHandler * messageHandler() const
228  {return handler_;}
230  inline CoinMessages messages()
231  {return messages_;}
233  inline CoinMessages * messagesPointer()
234  {return &messages_;}
236  //---------------------------------------------------------------------------
237 
238 
240 
241  CglPreProcess();
243 
245  CglPreProcess(const CglPreProcess & rhs);
246 
248  CglPreProcess & operator=(const CglPreProcess& rhs);
249 
251  ~CglPreProcess ();
252 
254  void gutsOfDestructor();
256 private:
257 
259 
260 
264  OsiSolverInterface * modified(OsiSolverInterface * model,
265  bool constraints,
266  int & numberChanges,
267  int iBigPass,
268  int numberPasses);
270  void createOriginalIndices() const;
272  void makeInteger();
274 
275 //---------------------------------------------------------------------------
276 
277 private:
279 
280 
282  OsiSolverInterface * originalModel_;
284  OsiSolverInterface * startModel_;
288  OsiSolverInterface ** model_;
290  OsiSolverInterface ** modifiedModel_;
292  OsiPresolve ** presolve_;
293 
295  CoinMessageHandler * handler_;
296 
303 
305  CoinMessages messages_;
306 
308  void * appData_;
310  mutable int * originalColumn_;
312  mutable int * originalRow_;
320  int * typeSOS_;
322  int * startSOS_;
324  int * whichSOS_;
326  double * weightSOS_;
334  char * prohibited_;
340  int options_;
347  char * rowType_;
351 };
352 
353 #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.
void createOriginalIndices() const
create original columns and rows
int * originalRow_
Original row numbers.
void passInProhibited(const char *prohibited, int numberColumns)
Pass in prohibited columns.
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 setLanguage(CoinMessages::Language language)
Pass in Message handler (not deleted at end)
int * originalColumn_
Original column numbers.
const int * originalRows() const
Return a pointer to the original rows MUST be called before postProcess otherwise you just get 0...
Class for preProcessing and postProcessing.
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 postProcess(OsiSolverInterface &model)
Creates solution in original model.
const int * originalColumns() const
Return a pointer to the original columns (with possible clique slacks) MUST be called before postProc...
int numberIterationsPre() const
Number of iterations PreProcessing.
CglCutGenerator * cutGenerator(int i) const
Get the specified cut generator.
CglCutGenerator ** cutGenerators() const
Get the list of cut generators.
int numberSolvers_
Number of solvers at various stages.
const int * whichSOS() const
Columns in SOS.
int numberProhibited_
Number of columns in original prohibition set.
int numberIterationsPost() const
Number of iterations PostProcessing.
void update(const OsiPresolve *pinfo, const OsiSolverInterface *solver)
Update prohibited and rowType.
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.
int numberIterationsPost_
Number of iterations done in PostProcessing.
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.
void setCutoff(double value)
Set cutoff bound on the objective function.
void * appData_
Pointer to user-defined data structure.
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 options_
Options 1 - original model had integer bounds before tightening.
CglStored cuts_
Cuts from dropped rows.
int * typeSOS_
Type of each SOS.
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.
OsiPresolve ** presolve_
Matching presolve information.
void newLanguage(CoinMessages::Language language)
Set language.
int reducedCostFix(OsiSolverInterface &model)
If we have a cutoff - fix variables.
const CglStored & cuts() const
Return cuts from dropped rows.
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.
CoinMessages messages()
Return messages.
Stored Cut Generator Class.
Definition: CglStored.hpp:13
OsiSolverInterface * preProcess(OsiSolverInterface &model, bool makeEquality=false, int numberPasses=5)
preProcess problem - returning new problem.
CoinMessageHandler * handler_
Message handler.
OsiSolverInterface ** modifiedModel_
Copies of solver at various stages after presolve after modifications.
CoinMessages messages_
Cgl messages.
void addCutGenerator(CglCutGenerator *generator)
Add one generator - up to user to delete generators.
CglCutGenerator ** generator_
Cut generators.
const int * typeSOS() const
Type of each SOS.
const double * weightSOS() const
Weights for each SOS column.
OsiSolverInterface * originalModel_
The original solver associated with this model.
void setOptions(int value)
Set options.
OsiSolverInterface ** model_
Copies of solver at various stages after presolve.
int numberCutGenerators_
Number of cut generators.
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.