Clp  1.15.10
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ClpPresolve.hpp
Go to the documentation of this file.
1 /* $Id: ClpPresolve.hpp 1928 2013-04-06 12:54:16Z stefan $ */
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef ClpPresolve_H
7 #define ClpPresolve_H
8 #include "ClpSimplex.hpp"
9 
10 class CoinPresolveAction;
11 #include "CoinPresolveMatrix.hpp"
15 class ClpPresolve {
16 public:
19  ClpPresolve();
21 
23  virtual ~ClpPresolve();
25 
42  double feasibilityTolerance = 0.0,
43  bool keepIntegers = true,
44  int numberPasses = 5,
45  bool dropNames = false,
46  bool doRowObjective = false,
47  const char * prohibitedRows=NULL,
48  const char * prohibitedColumns=NULL);
49 #ifndef CLP_NO_STD
50 
53  int presolvedModelToFile(ClpSimplex &si, std::string fileName,
54  double feasibilityTolerance = 0.0,
55  bool keepIntegers = true,
56  int numberPasses = 5,
57  bool dropNames = false,
58  bool doRowObjective = false);
59 #endif
60 
62  ClpSimplex * model() const;
64  ClpSimplex * originalModel() const;
66  void setOriginalModel(ClpSimplex * model);
67 
69  const int * originalColumns() const;
71  const int * originalRows() const;
76  inline void setNonLinearValue(double value) {
77  nonLinearValue_ = value;
78  }
79  inline double nonLinearValue() const {
80  return nonLinearValue_;
81  }
83  inline bool doDual() const {
84  return (presolveActions_ & 1) == 0;
85  }
86  inline void setDoDual(bool doDual) {
87  if (doDual) presolveActions_ &= ~1;
88  else presolveActions_ |= 1;
89  }
91  inline bool doSingleton() const {
92  return (presolveActions_ & 2) == 0;
93  }
94  inline void setDoSingleton(bool doSingleton) {
95  if (doSingleton) presolveActions_ &= ~2;
96  else presolveActions_ |= 2;
97  }
99  inline bool doDoubleton() const {
100  return (presolveActions_ & 4) == 0;
101  }
102  inline void setDoDoubleton(bool doDoubleton) {
103  if (doDoubleton) presolveActions_ &= ~4;
104  else presolveActions_ |= 4;
105  }
107  inline bool doTripleton() const {
108  return (presolveActions_ & 8) == 0;
109  }
110  inline void setDoTripleton(bool doTripleton) {
111  if (doTripleton) presolveActions_ &= ~8;
112  else presolveActions_ |= 8;
113  }
115  inline bool doTighten() const {
116  return (presolveActions_ & 16) == 0;
117  }
118  inline void setDoTighten(bool doTighten) {
119  if (doTighten) presolveActions_ &= ~16;
120  else presolveActions_ |= 16;
121  }
123  inline bool doForcing() const {
124  return (presolveActions_ & 32) == 0;
125  }
126  inline void setDoForcing(bool doForcing) {
127  if (doForcing) presolveActions_ &= ~32;
128  else presolveActions_ |= 32;
129  }
131  inline bool doImpliedFree() const {
132  return (presolveActions_ & 64) == 0;
133  }
134  inline void setDoImpliedFree(bool doImpliedfree) {
135  if (doImpliedfree) presolveActions_ &= ~64;
136  else presolveActions_ |= 64;
137  }
139  inline bool doDupcol() const {
140  return (presolveActions_ & 128) == 0;
141  }
142  inline void setDoDupcol(bool doDupcol) {
143  if (doDupcol) presolveActions_ &= ~128;
144  else presolveActions_ |= 128;
145  }
147  inline bool doDuprow() const {
148  return (presolveActions_ & 256) == 0;
149  }
150  inline void setDoDuprow(bool doDuprow) {
151  if (doDuprow) presolveActions_ &= ~256;
152  else presolveActions_ |= 256;
153  }
155  inline bool doSingletonColumn() const {
156  return (presolveActions_ & 512) == 0;
157  }
158  inline void setDoSingletonColumn(bool doSingleton) {
159  if (doSingleton) presolveActions_ &= ~512;
160  else presolveActions_ |= 512;
161  }
163  inline bool doGubrow() const {
164  return (presolveActions_ & 1024) == 0;
165  }
166  inline void setDoGubrow(bool doGubrow) {
167  if (doGubrow) presolveActions_ &= ~1024;
168  else presolveActions_ |= 1024;
169  }
171  inline bool doTwoxTwo() const {
172  return (presolveActions_ & 2048) != 0;
173  }
174  inline void setDoTwoxtwo(bool doTwoxTwo) {
175  if (!doTwoxTwo) presolveActions_ &= ~2048;
176  else presolveActions_ |= 2048;
177  }
179  inline int presolveActions() const {
180  return presolveActions_ & 0xffff;
181  }
182  inline void setPresolveActions(int action) {
183  presolveActions_ = (presolveActions_ & 0xffff0000) | (action & 0xffff);
184  }
186  inline void setSubstitution(int value) {
187  substitution_ = value;
188  }
190  inline void statistics() {
191  presolveActions_ |= 0x80000000;
192  }
194  int presolveStatus() const;
195 
204  virtual void postsolve(bool updateStatus = true);
205 
207  void destroyPresolve();
208 
210 private:
212  ClpSimplex * originalModel_;
213 
215  ClpSimplex * presolvedModel_;
221  double nonLinearValue_;
223  int * originalColumn_;
225  int * originalRow_;
227  double * rowObjective_;
229  const CoinPresolveAction *paction_;
230 
236  int ncols_;
237  int nrows_;
238  CoinBigIndex nelems_;
240  int numberPasses_;
242  int substitution_;
243 #ifndef CLP_NO_STD
244  std::string saveFile_;
246 #endif
247 
251  int presolveActions_;
252 protected:
256  virtual const CoinPresolveAction *presolve(CoinPresolveMatrix *prob);
257 
263  virtual void postsolve(CoinPostsolveMatrix &prob);
265  virtual ClpSimplex * gutsOfPresolvedModel(ClpSimplex * originalModel,
266  double feasibilityTolerance,
267  bool keepIntegers,
268  int numberPasses,
269  bool dropNames,
270  bool doRowObjective,
271  const char * prohibitedRows=NULL,
272  const char * prohibitedColumns=NULL);
273 };
274 #endif
ClpSimplex * originalModel() const
Return pointer to original model.
double nonLinearValue() const
Definition: ClpPresolve.hpp:79
bool doSingletonColumn() const
Whether we want to do singleton column part of presolve.
void setDoTighten(bool doTighten)
bool doTighten() const
Whether we want to do tighten part of presolve.
void setDoDual(bool doDual)
Definition: ClpPresolve.hpp:86
int presolveActions() const
Set whole group.
void setDoTripleton(bool doTripleton)
void setDoDuprow(bool doDuprow)
bool doSingleton() const
Whether we want to do singleton part of presolve.
Definition: ClpPresolve.hpp:91
bool doDuprow() const
Whether we want to do duprow part of presolve.
bool doDual() const
Whether we want to do dual part of presolve.
Definition: ClpPresolve.hpp:83
void setDoImpliedFree(bool doImpliedfree)
ClpSimplex * presolvedModel(ClpSimplex &si, double feasibilityTolerance=0.0, bool keepIntegers=true, int numberPasses=5, bool dropNames=false, bool doRowObjective=false, const char *prohibitedRows=NULL, const char *prohibitedColumns=NULL)
bool doTripleton() const
Whether we want to do tripleton part of presolve.
ClpPresolve()
Default constructor.
void setSubstitution(int value)
Substitution level.
void setDoSingleton(bool doSingleton)
Definition: ClpPresolve.hpp:94
bool doGubrow() const
Whether we want to do gubrow part of presolve.
const int * originalRows() const
return pointer to original rows
bool doForcing() const
Whether we want to do forcing part of presolve.
void setDoDoubleton(bool doDoubleton)
void setDoForcing(bool doForcing)
void setDoTwoxtwo(bool doTwoxTwo)
virtual ClpSimplex * gutsOfPresolvedModel(ClpSimplex *originalModel, double feasibilityTolerance, bool keepIntegers, int numberPasses, bool dropNames, bool doRowObjective, const char *prohibitedRows=NULL, const char *prohibitedColumns=NULL)
This is main part of Presolve.
virtual void postsolve(bool updateStatus=true)
virtual ~ClpPresolve()
Virtual destructor.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:55
void setPresolveActions(int action)
bool doTwoxTwo() const
Whether we want to do twoxtwo part of presolve.
This is the Clp interface to CoinPresolve.
Definition: ClpPresolve.hpp:15
bool doDupcol() const
Whether we want to do dupcol part of presolve.
const int * originalColumns() const
return pointer to original columns
void setDoGubrow(bool doGubrow)
int presolvedModelToFile(ClpSimplex &si, std::string fileName, double feasibilityTolerance=0.0, bool keepIntegers=true, int numberPasses=5, bool dropNames=false, bool doRowObjective=false)
This version saves data in a file.
void setOriginalModel(ClpSimplex *model)
Set pointer to original model.
bool doImpliedFree() const
Whether we want to do impliedfree part of presolve.
ClpSimplex * model() const
Return pointer to presolved model, Up to user to destroy.
void setDoSingletonColumn(bool doSingleton)
bool doDoubleton() const
Whether we want to do doubleton part of presolve.
Definition: ClpPresolve.hpp:99
virtual const CoinPresolveAction * presolve(CoinPresolveMatrix *prob)
If you want to apply the individual presolve routines differently, or perhaps add your own to the mix...
int presolveStatus() const
Return presolve status (0,1,2)
void destroyPresolve()
Gets rid of presolve actions (e.g.when infeasible)
void statistics()
Asks for statistics.
void setNonLinearValue(double value)
"Magic" number.
Definition: ClpPresolve.hpp:76
void setDoDupcol(bool doDupcol)