ClpPresolve.hpp
Go to the documentation of this file.
1 /* $Id: ClpPresolve.hpp 1525 2010-02-26 17:27:59Z mjs $ */
2 // Copyright (C) 2002, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 
5 #ifndef ClpPresolve_H
6 #define ClpPresolve_H
7 #include "ClpSimplex.hpp"
8 
9 class CoinPresolveAction;
10 #include "CoinPresolveMatrix.hpp"
14 class ClpPresolve {
15 public:
18 
19  ClpPresolve();
20 
22  virtual ~ClpPresolve();
24 
41  double feasibilityTolerance = 0.0,
42  bool keepIntegers = true,
43  int numberPasses = 5,
44  bool dropNames = false,
45  bool doRowObjective = false);
46 #ifndef CLP_NO_STD
47 
50  int presolvedModelToFile(ClpSimplex &si, std::string fileName,
51  double feasibilityTolerance = 0.0,
52  bool keepIntegers = true,
53  int numberPasses = 5,
54  bool doRowObjective = false);
55 #endif
56 
58  ClpSimplex * model() const;
60  ClpSimplex * originalModel() const;
62  void setOriginalModel(ClpSimplex * model);
63 
65  const int * originalColumns() const;
67  const int * originalRows() const;
72  inline void setNonLinearValue(double value) {
73  nonLinearValue_ = value;
74  }
75  inline double nonLinearValue() const {
76  return nonLinearValue_;
77  }
79  inline bool doDual() const {
80  return (presolveActions_ & 1) == 0;
81  }
82  inline void setDoDual(bool doDual) {
83  if (doDual) presolveActions_ &= ~1;
84  else presolveActions_ |= 1;
85  }
87  inline bool doSingleton() const {
88  return (presolveActions_ & 2) == 0;
89  }
90  inline void setDoSingleton(bool doSingleton) {
91  if (doSingleton) presolveActions_ &= ~2;
92  else presolveActions_ |= 2;
93  }
95  inline bool doDoubleton() const {
96  return (presolveActions_ & 4) == 0;
97  }
98  inline void setDoDoubleton(bool doDoubleton) {
99  if (doDoubleton) presolveActions_ &= ~4;
100  else presolveActions_ |= 4;
101  }
103  inline bool doTripleton() const {
104  return (presolveActions_ & 8) == 0;
105  }
106  inline void setDoTripleton(bool doTripleton) {
107  if (doTripleton) presolveActions_ &= ~8;
108  else presolveActions_ |= 8;
109  }
111  inline bool doTighten() const {
112  return (presolveActions_ & 16) == 0;
113  }
114  inline void setDoTighten(bool doTighten) {
115  if (doTighten) presolveActions_ &= ~16;
116  else presolveActions_ |= 16;
117  }
119  inline bool doForcing() const {
120  return (presolveActions_ & 32) == 0;
121  }
122  inline void setDoForcing(bool doForcing) {
123  if (doForcing) presolveActions_ &= ~32;
124  else presolveActions_ |= 32;
125  }
127  inline bool doImpliedFree() const {
128  return (presolveActions_ & 64) == 0;
129  }
130  inline void setDoImpliedFree(bool doImpliedfree) {
131  if (doImpliedfree) presolveActions_ &= ~64;
132  else presolveActions_ |= 64;
133  }
135  inline bool doDupcol() const {
136  return (presolveActions_ & 128) == 0;
137  }
138  inline void setDoDupcol(bool doDupcol) {
139  if (doDupcol) presolveActions_ &= ~128;
140  else presolveActions_ |= 128;
141  }
143  inline bool doDuprow() const {
144  return (presolveActions_ & 256) == 0;
145  }
146  inline void setDoDuprow(bool doDuprow) {
147  if (doDuprow) presolveActions_ &= ~256;
148  else presolveActions_ |= 256;
149  }
151  inline bool doSingletonColumn() const {
152  return (presolveActions_ & 512) == 0;
153  }
154  inline void setDoSingletonColumn(bool doSingleton) {
155  if (doSingleton) presolveActions_ &= ~512;
156  else presolveActions_ |= 512;
157  }
159  inline bool doGubrow() const {
160  return (presolveActions_ & 1024) == 0;
161  }
162  inline void setDoGubrow(bool doGubrow) {
163  if (doGubrow) presolveActions_ &= ~1024;
164  else presolveActions_ |= 1024;
165  }
167  inline int presolveActions() const {
168  return presolveActions_ & 0xffff;
169  }
170  inline void setPresolveActions(int action) {
171  presolveActions_ = (presolveActions_ & 0xffff0000) | (action & 0xffff);
172  }
174  inline void setSubstitution(int value) {
175  substitution_ = value;
176  }
178  inline void statistics() {
179  presolveActions_ |= 0x80000000;
180  }
181 
190  virtual void postsolve(bool updateStatus = true);
191 
193  void destroyPresolve();
194 
196 private:
199 
213  double * rowObjective_;
215  const CoinPresolveAction *paction_;
216 
222  int ncols_;
223  int nrows_;
224  CoinBigIndex nelems_;
229 #ifndef CLP_NO_STD
230 
231  std::string saveFile_;
232 #endif
233 
238 protected:
242  virtual const CoinPresolveAction *presolve(CoinPresolveMatrix *prob);
243 
249  virtual void postsolve(CoinPostsolveMatrix &prob);
251  virtual ClpSimplex * gutsOfPresolvedModel(ClpSimplex * originalModel,
252  double feasibilityTolerance,
253  bool keepIntegers,
254  int numberPasses,
255  bool dropNames,
256  bool doRowObjective);
257 };
258 #endif