Cbc  2.10.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ClpPresolve.hpp
Go to the documentation of this file.
1 /* $Id: ClpPresolve.hpp 2385 2019-01-06 19:43:06Z unxusr $ */
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  {
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 
308  void destroyPresolve();
309 
311 private:
314 
328  double *rowObjective_;
331 
337  int ncols_;
338  int nrows_;
344 #ifndef CLP_NO_STD
345  std::string saveFile_;
347 #endif
348 
353 
354 protected:
358  virtual const CoinPresolveAction *presolve(CoinPresolveMatrix *prob);
359 
365  virtual void postsolve(CoinPostsolveMatrix &prob);
367  virtual ClpSimplex *gutsOfPresolvedModel(ClpSimplex *originalModel,
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 */
ClpSimplex * originalModel() const
Return pointer to original model.
double nonLinearValue() const
Definition: ClpPresolve.hpp:80
bool doSingletonColumn() const
Whether we want to do singleton column part of presolve.
void setDoTighten(bool doTighten)
int numberPasses_
Number of major passes.
void setDoIntersection(bool doIntersection)
bool doTighten() const
Whether we want to do tighten part of presolve.
void setDoDual(bool doDual)
Definition: ClpPresolve.hpp:89
int presolveActions() const
Set whole group.
Abstract base class of all presolve routines.
void setDoTripleton(bool doTripleton)
void setDoDuprow(bool doDuprow)
bool doSingleton() const
Whether we want to do singleton part of presolve.
Definition: ClpPresolve.hpp:97
bool doDependency() const
Whether we want to do dependency part of presolve.
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:85
std::string saveFile_
Name of saved model file.
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)
bool doGubrow() const
Whether we want to do gubrow part of presolve.
const int * originalRows() const
return pointer to original rows
Declarations for CoinPresolveMatrix and CoinPostsolveMatrix and their common base class CoinPrePostso...
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.
int substitution_
Substitution level.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:106
void setPresolveActions(int action)
int zeroSmall() const
How much we want to zero small values from aggregation - ratio 0 - 1.0e-12, 1 1.0e-11, 2 1.0e-10, 3 1.0e-9.
bool doTwoxTwo() const
Whether we want to do twoxtwo part of presolve.
This is the Clp interface to CoinPresolve.
Definition: ClpPresolve.hpp:15
double * rowObjective_
Row objective.
const CoinPresolveAction * paction_
The list of transformations applied.
int * originalColumn_
Original column numbers.
bool doTransfer() const
Whether we want to do transfer part of presolve.
bool doIntersection() const
Whether we want to allow duplicate intersections.
Augments CoinPrePostsolveMatrix with information about the problem that is only needed during postsol...
bool doDupcol() const
Whether we want to do dupcol part of presolve.
const int * originalColumns() const
return pointer to original columns
void setDoDependency(bool doDependency)
void setDoGubrow(bool doGubrow)
Augments CoinPrePostsolveMatrix with information about the problem that is only needed during presolv...
void setZeroSmall(int value)
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.
int presolveActions_
Whether we want to skip dual part of presolve etc.
int CoinBigIndex
int ncols_
The postsolved problem will expand back to its former size as postsolve transformations are applied...
ClpSimplex * model() const
Return pointer to presolved model, Up to user to destroy.
void setDoSingletonColumn(bool doSingleton)
ClpSimplex * presolvedModel_
ClpPresolved model - up to user to destroy by deleteClpPresolvedModel.
bool doDoubleton() const
Whether we want to do doubleton part of presolve.
int * originalRow_
Original row numbers.
virtual const CoinPresolveAction * presolve(CoinPresolveMatrix *prob)
If you want to apply the individual presolve routines differently, or perhaps add your own to the mix...
ClpSimplex * originalModel_
Original model - must not be destroyed before postsolve.
int presolveStatus() const
Return presolve status (0,1,2)
CoinBigIndex nelems_
void setDoTransfer(bool doTransfer)
void destroyPresolve()
Gets rid of presolve actions (e.g.when infeasible)
void statistics()
Asks for statistics.
void setNonLinearValue(double value)
&quot;Magic&quot; number.
Definition: ClpPresolve.hpp:76
double nonLinearValue_
&quot;Magic&quot; number.
void setDoDupcol(bool doDupcol)