Clp  1.17.6
ClpPresolve.hpp
Go to the documentation of this file.
1 /* $Id$ */
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:
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
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
62  ClpSimplex *model() const;
67 
69  const int *originalColumns() const;
71  const int *originalRows() const;
76  inline void setNonLinearValue(double value)
77  {
78  nonLinearValue_ = value;
79  }
80  inline double nonLinearValue() const
81  {
82  return nonLinearValue_;
83  }
85  inline bool doDual() const
86  {
87  return (presolveActions_ & 1) == 0;
88  }
89  inline void setDoDual(bool doDual)
90  {
91  if (doDual)
92  presolveActions_ &= ~1;
93  else
94  presolveActions_ |= 1;
95  }
97  inline bool doSingleton() const
98  {
99  return (presolveActions_ & 2) == 0;
100  }
101  inline void setDoSingleton(bool doSingleton)
102  {
103  if (doSingleton)
104  presolveActions_ &= ~2;
105  else
106  presolveActions_ |= 2;
107  }
109  inline bool doDoubleton() const
110  {
111  return (presolveActions_ & 4) == 0;
112  }
113  inline void setDoDoubleton(bool doDoubleton)
114  {
115  if (doDoubleton)
116  presolveActions_ &= ~4;
117  else
118  presolveActions_ |= 4;
119  }
121  inline bool doTripleton() const
122  {
123  return (presolveActions_ & 8) == 0;
124  }
125  inline void setDoTripleton(bool doTripleton)
126  {
127  if (doTripleton)
128  presolveActions_ &= ~8;
129  else
130  presolveActions_ |= 8;
131  }
133  inline bool doTighten() const
134  {
135  return (presolveActions_ & 16) == 0;
136  }
137  inline void setDoTighten(bool doTighten)
138  {
139  if (doTighten)
140  presolveActions_ &= ~16;
141  else
142  presolveActions_ |= 16;
143  }
145  inline bool doForcing() const
146  {
147  return (presolveActions_ & 32) == 0;
148  }
149  inline void setDoForcing(bool doForcing)
150  {
151  if (doForcing)
152  presolveActions_ &= ~32;
153  else
154  presolveActions_ |= 32;
155  }
157  inline bool doImpliedFree() const
158  {
159  return (presolveActions_ & 64) == 0;
160  }
161  inline void setDoImpliedFree(bool doImpliedfree)
162  {
163  if (doImpliedfree)
164  presolveActions_ &= ~64;
165  else
166  presolveActions_ |= 64;
167  }
169  inline bool doDupcol() const
170  {
171  return (presolveActions_ & 128) == 0;
172  }
173  inline void setDoDupcol(bool doDupcol)
174  {
175  if (doDupcol)
176  presolveActions_ &= ~128;
177  else
178  presolveActions_ |= 128;
179  }
181  inline bool doDuprow() const
182  {
183  return (presolveActions_ & 256) == 0;
184  }
185  inline void setDoDuprow(bool doDuprow)
186  {
187  if (doDuprow)
188  presolveActions_ &= ~256;
189  else
190  presolveActions_ |= 256;
191  }
193  inline bool doDependency() const
194  {
195  return (presolveActions_ & 32768) != 0;
196  }
197  inline void setDoDependency(bool doDependency)
198  {
199  if (doDependency)
200  presolveActions_ |= 32768;
201  else
202  presolveActions_ &= ~32768;
203  }
205  inline bool doTransfer() const
206  {
207  return (presolveActions_ & 65536) != 0;
208  }
209  inline void setDoTransfer(bool doTransfer)
210  {
211  if (doTransfer)
212  presolveActions_ |= 65536;
213  else
214  presolveActions_ &= ~65536;
215  }
217  inline bool doSingletonColumn() const
218  {
219  return (presolveActions_ & 512) == 0;
220  }
222  {
223  if (doSingleton)
224  presolveActions_ &= ~512;
225  else
226  presolveActions_ |= 512;
227  }
229  inline bool doGubrow() const
230  {
231  return (presolveActions_ & 1024) == 0;
232  }
233  inline void setDoGubrow(bool doGubrow)
234  {
235  if (doGubrow)
236  presolveActions_ &= ~1024;
237  else
238  presolveActions_ |= 1024;
239  }
241  inline bool doTwoxTwo() const
242  {
243  return (presolveActions_ & 2048) != 0;
244  }
245  inline void setDoTwoxtwo(bool doTwoxTwo)
246  {
247  if (!doTwoxTwo)
248  presolveActions_ &= ~2048;
249  else
250  presolveActions_ |= 2048;
251  }
253  inline bool doIntersection() const
254  {
255  return (presolveActions_ & 4096) != 0;
256  }
258  {
259  if (doIntersection)
260  presolveActions_ &= ~4096;
261  else
262  presolveActions_ |= 4096;
263  }
266  inline int zeroSmall() const
267  {
268  return (presolveActions_ & (8192 | 16384)) >> 13;
269  }
270  inline void setZeroSmall(int value)
271  {
272  presolveActions_ &= ~(8192 | 16384);
273  presolveActions_ |= value << 13;
274  }
276  inline int presolveActions() const
277  {
278  return presolveActions_ & 0xffffff;
279  }
280  inline void setPresolveActions(int action)
281  {
282  presolveActions_ = (presolveActions_ & 0xff000000) | (action & 0xffffff);
283  }
285  inline void setSubstitution(int value)
286  {
287  substitution_ = value;
288  }
290  inline void statistics()
291  {
292  presolveActions_ |= 0x80000000;
293  }
295  int presolveStatus() const;
296 
305  virtual void postsolve(bool updateStatus = true);
306 
309 
311 private:
314 
328  double *rowObjective_;
330  const CoinPresolveAction *paction_;
331 
337  int ncols_;
338  int nrows_;
339  CoinBigIndex nelems_;
344 #ifndef CLP_NO_STD
346  std::string saveFile_;
347 #endif
353 
354 protected:
358  virtual const CoinPresolveAction *presolve(CoinPresolveMatrix *prob);
359 
365  virtual void postsolve(CoinPostsolveMatrix &prob);
368  double feasibilityTolerance,
369  bool keepIntegers,
370  int numberPasses,
371  bool dropNames,
372  bool doRowObjective,
373  const char *prohibitedRows = NULL,
374  const char *prohibitedColumns = NULL);
375 };
376 #endif
377 
378 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
379 */
This is the Clp interface to CoinPresolve.
Definition: ClpPresolve.hpp:15
const CoinPresolveAction * paction_
The list of transformations applied.
bool doTwoxTwo() const
Whether we want to do twoxtwo part of presolve.
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.
void setDoDependency(bool doDependency)
void setDoTripleton(bool doTripleton)
void setDoForcing(bool doForcing)
void setDoTwoxtwo(bool doTwoxTwo)
void setDoDuprow(bool doDuprow)
bool doDupcol() const
Whether we want to do dupcol part of presolve.
void statistics()
Asks for statistics.
bool doTighten() const
Whether we want to do tighten part of presolve.
virtual void postsolve(bool updateStatus=true)
double * rowObjective_
Row objective.
bool doSingletonColumn() const
Whether we want to do singleton column part of presolve.
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)
ClpSimplex * originalModel() const
Return pointer to original model.
void setPresolveActions(int action)
void setDoTighten(bool doTighten)
virtual const CoinPresolveAction * presolve(CoinPresolveMatrix *prob)
If you want to apply the individual presolve routines differently, or perhaps add your own to the mix...
bool doIntersection() const
Whether we want to allow duplicate intersections.
virtual void postsolve(CoinPostsolveMatrix &prob)
Postsolving is pretty generic; just apply the transformations in reverse order.
ClpPresolve()
Default constructor.
const int * originalRows() const
return pointer to original rows
int presolveStatus() const
Return presolve status (0,1,2)
int substitution_
Substitution level.
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.
bool doDependency() const
Whether we want to do dependency part of presolve.
void setDoDupcol(bool doDupcol)
void setZeroSmall(int value)
bool doSingleton() const
Whether we want to do singleton part of presolve.
Definition: ClpPresolve.hpp:97
void setDoDoubleton(bool doDoubleton)
std::string saveFile_
Name of saved model file.
const int * originalColumns() const
return pointer to original columns
bool doTransfer() const
Whether we want to do transfer part of presolve.
void setDoTransfer(bool doTransfer)
void setDoIntersection(bool doIntersection)
bool doDoubleton() const
Whether we want to do doubleton part of presolve.
void setDoImpliedFree(bool doImpliedfree)
void setSubstitution(int value)
Substitution level.
bool doImpliedFree() const
Whether we want to do impliedfree part of presolve.
void setOriginalModel(ClpSimplex *model)
Set pointer to original model.
bool doDuprow() const
Whether we want to do duprow part of presolve.
double nonLinearValue_
"Magic" number.
int * originalRow_
Original row numbers.
int zeroSmall() const
How much we want to zero small values from aggregation - ratio 0 - 1.0e-12, 1 1.0e-11,...
void setDoSingleton(bool doSingleton)
double nonLinearValue() const
Definition: ClpPresolve.hpp:80
int presolveActions_
Whether we want to skip dual part of presolve etc.
int * originalColumn_
Original column numbers.
int ncols_
The postsolved problem will expand back to its former size as postsolve transformations are applied.
bool doGubrow() const
Whether we want to do gubrow part of presolve.
void setNonLinearValue(double value)
"Magic" number.
Definition: ClpPresolve.hpp:76
void setDoSingletonColumn(bool doSingleton)
virtual ~ClpPresolve()
Virtual destructor.
int numberPasses_
Number of major passes.
void setDoDual(bool doDual)
Definition: ClpPresolve.hpp:89
bool doForcing() const
Whether we want to do forcing part of presolve.
ClpSimplex * model() const
Return pointer to presolved model, Up to user to destroy.
bool doTripleton() const
Whether we want to do tripleton part of presolve.
bool doDual() const
Whether we want to do dual part of presolve.
Definition: ClpPresolve.hpp:85
void destroyPresolve()
Gets rid of presolve actions (e.g.when infeasible)
void setDoGubrow(bool doGubrow)
ClpSimplex * presolvedModel_
ClpPresolved model - up to user to destroy by deleteClpPresolvedModel.
int presolveActions() const
Set whole group.
CoinBigIndex nelems_
ClpSimplex * originalModel_
Original model - must not be destroyed before postsolve.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:106