Cbc  2.10.5
 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 
38 
39 public:
41 
42 
52  bool makeEquality = false, int numberPasses = 5);
65  int makeEquality = 0, int numberPasses = 5,
66  int tuning = 0);
69  void postProcess(OsiSolverInterface &model, int deleteStuff = 2);
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  {
121  return originalModel_;
122  }
125  {
127  }
130  {
131  return startModel_;
132  }
134  inline int numberSolvers() const
135  {
136  return numberSolvers_;
137  }
139  inline OsiSolverInterface *modelAtPass(int iPass) const
140  {
141  if (iPass >= 0 && iPass < numberSolvers_)
142  return model_[iPass];
143  else
144  return NULL;
145  }
147  inline OsiSolverInterface *modifiedModel(int iPass) const
148  {
149  if (iPass >= 0 && iPass < numberSolvers_)
150  return modifiedModel_[iPass];
151  else
152  return NULL;
153  }
155  inline OsiPresolve *presolve(int iPass) const
156  {
157  if (iPass >= 0 && iPass < numberSolvers_)
158  return presolve_[iPass];
159  else
160  return NULL;
161  }
163  inline void setPresolve(int iPass, OsiPresolve *presolve)
164  {
165  if (iPass >= 0 && iPass < numberSolvers_)
166  presolve_[iPass] = presolve;
167  }
170  const int *originalColumns();
173  const int *originalRows();
175  inline int numberSOS() const
176  {
177  return numberSOS_;
178  }
180  inline const int *typeSOS() const
181  {
182  return typeSOS_;
183  }
185  inline const int *startSOS() const
186  {
187  return startSOS_;
188  }
190  inline const int *whichSOS() const
191  {
192  return whichSOS_;
193  }
195  inline const double *weightSOS() const
196  {
197  return weightSOS_;
198  }
200  void passInProhibited(const char *prohibited, int numberColumns);
202  inline const char *prohibited()
203  {
204  return prohibited_;
205  }
207  inline int numberIterationsPre() const
208  {
209  return numberIterationsPre_;
210  }
212  inline int numberIterationsPost() const
213  {
214  return numberIterationsPost_;
215  }
222  void passInRowTypes(const char *rowTypes, int numberRows);
229  inline const char *rowTypes()
230  {
231  return rowType_;
232  }
234  inline const CglStored &cuts() const
235  {
236  return cuts_;
237  }
239  inline const CglStored *cutsPointer() const
240  {
241  return &cuts_;
242  }
244  void update(const OsiPresolve *pinfo, const OsiSolverInterface *solver);
246  inline int options() const
247  {
248  return options_;
249  }
251  inline void setOptions(int value)
252  {
253  options_ = value;
254  }
256 
258 
259  inline int numberCutGenerators() const
261  {
262  return numberCutGenerators_;
263  }
266  {
267  return generator_;
268  }
270  inline CglCutGenerator *cutGenerator(int i) const
271  {
272  return generator_[i];
273  }
276  void addCutGenerator(CglCutGenerator *generator);
278 
288  void setApplicationData(void *appData);
289 
291  void *getApplicationData() const;
293 
294  //---------------------------------------------------------------------------
295 
301  void newLanguage(CoinMessages::Language language);
302  inline void setLanguage(CoinMessages::Language language)
303  {
304  newLanguage(language);
305  }
308  {
309  return handler_;
310  }
313  {
314  return messages_;
315  }
318  {
319  return &messages_;
320  }
322  //---------------------------------------------------------------------------
323 
325 
326  CglPreProcess();
328 
330  CglPreProcess(const CglPreProcess &rhs);
331 
334 
336  ~CglPreProcess();
337 
339  void gutsOfDestructor();
340 
342  void setTimeLimit(const double timeLimit, const bool useElapsedTime);
343 
345  void setKeepColumnNames(const bool keep);
346 
348 private:
350 
351 
356  bool constraints,
357  int &numberChanges,
358  int iBigPass,
359  int numberPasses);
361  void createOriginalIndices();
363  void makeInteger();
365 
366  //---------------------------------------------------------------------------
367 
368 private:
370 
371 
384 
387 
394 
397 
399  void *appData_;
411  int *typeSOS_;
413  int *startSOS_;
415  int *whichSOS_;
417  double *weightSOS_;
425  char *prohibited_;
436  int options_;
443  char *rowType_;
446 
449 
451  double timeLimit_;
452 
455 
457  double getCurrentCPUTime() const;
458 
460 };
461 
463 class CglBK {
464 
465 public:
467 
468  void bronKerbosch();
473 
474  //---------------------------------------------------------------------------
475 
485 
486 
487  //---------------------------------------------------------------------------
488 
490 
491  CglBK();
493 
495  CglBK(const OsiSolverInterface &model, const char *rowType,
496  int numberElements);
497 
499  CglBK(const CglBK &rhs);
500 
502  CglBK &operator=(const CglBK &rhs);
503 
505  ~CglBK();
506 
508 
509  //---------------------------------------------------------------------------
510 
511 private:
513 
514  int *candidates_;
517  char *mark_;
529  const char *rowType_;
543  int left_;
546 };
550 // for hashing
551 typedef struct {
552  int index, next;
553 } CglHashLink;
554 class OsiRowCut;
556 public:
557  CglUniqueRowCuts(int initialMaxSize = 0, int hashMultiplier = 4);
561  inline OsiRowCut *cut(int sequence) const
562  {
563  return rowCut_[sequence];
564  }
565  inline int numberCuts() const
566  {
567  return numberCuts_;
568  }
569  inline int sizeRowCuts() const
570  {
571  return numberCuts_;
572  }
573  inline OsiRowCut *rowCutPtr(int sequence)
574  {
575  return rowCut_[sequence];
576  }
577  void eraseRowCut(int sequence);
578  // insert cut
579  inline void insert(const OsiRowCut &cut)
580  {
582  }
583  // Return 0 if added, 1 if not
584  int insertIfNotDuplicate(const OsiRowCut &cut);
585  // Add in cuts as normal cuts (and delete)
586  void addCuts(OsiCuts &cs);
587 
588 private:
592  int size_;
596 };
597 #endif
598 
599 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
600 */
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.
int numberSolvers() const
Number of solvers.
CglUniqueRowCuts(int initialMaxSize=0, int hashMultiplier=4)
CoinMessageHandler * handler_
Message handler.
double timeLimit_
time limit (default COIN_DBL_MAX)
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.
bool keepColumnNames_
keep column names
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.
void setOriginalModel(OsiSolverInterface *originalModel)
Set original model (probably acopy)
double getCurrentCPUTime() const
current elapsed or cpu time
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.
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.
bool useElapsedTime_
use elapsed (wallclock time) or cpu time
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 * 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:59
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.
int CoinBigIndex
OsiSolverInterface * modifiedModel(int iPass) const
Copies of solver at various stages after presolve after modifications.
void postProcess(OsiSolverInterface &model, int deleteStuff=2)
Creates solution in original model deleteStuff 0 - don&#39;t, 1 do (but not if infeasible), 2 always.
CglCutGenerator ** generator_
Cut generators.
void passInProhibited(const char *prohibited, int numberColumns)
Pass in prohibited columns.
OsiRowCut * rowCutPtr(int sequence)
void setTimeLimit(const double timeLimit, const bool useElapsedTime)
Set time limit.
int options_
Options 1 - original model had integer bounds before tightening 2 - don&#39;t do probing 4 - don&#39;t do dup...
CoinBigIndex * start_
Starts for graph (numberPossible+1)
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.
void setKeepColumnNames(const bool keep)
Keeps original column names.
Class for preProcessing and postProcessing.
int options() const
Get options.
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...
void setPresolve(int iPass, OsiPresolve *presolve)
Set matching presolve information.
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.