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  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  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
void setSubstitution(int value)
Substitution level.
int substitution_
Substitution level.
void setDoGubrow(bool doGubrow)
This version saves data in a file.
CoinBigIndex nelems_
Original model - must not be destroyed before postsolve.
bool doSingletonColumn() const
Whether we want to do singleton column part of presolve.
bool doTighten() const
Whether we want to do tighten part of presolve.
bool doDupcol() const
Whether we want to do dupcol part of presolve.
const int * originalColumns() const
return pointer to original columns
double nonLinearValue() const
This version saves data in a file.
Definition: ClpPresolve.hpp:75
void setOriginalModel(ClpSimplex *model)
Set pointer to original model.
int ncols_
The postsolved problem will expand back to its former size as postsolve transformations are applied...
int * originalRow_
Original row numbers.
void setDoForcing(bool doForcing)
This version saves data in a file.
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 * presolvedModel(ClpSimplex &si, double feasibilityTolerance=0.0, bool keepIntegers=true, int numberPasses=5, bool dropNames=false, bool doRowObjective=false)
This version saves data in a file.
void setDoDoubleton(bool doDoubleton)
This version saves data in a file.
Definition: ClpPresolve.hpp:98
virtual void postsolve(bool updateStatus=true)
Gets rid of presolve actions (e.g.when infeasible)
const CoinPresolveAction * paction_
The list of transformations applied.
bool doTripleton() const
Whether we want to do tripleton part of presolve.
int numberPasses_
Number of major passes.
std::string saveFile_
Name of saved model file.
virtual ClpSimplex * gutsOfPresolvedModel(ClpSimplex *originalModel, double feasibilityTolerance, bool keepIntegers, int numberPasses, bool dropNames, bool doRowObjective)
This is main part of Presolve.
int presolveActions_
Whether we want to skip dual part of presolve etc.
const int * originalRows() const
return pointer to original rows
bool doDuprow() const
Whether we want to do duprow part of presolve.
ClpPresolve()
Default constructor.
ClpSimplex * model() const
Return pointer to presolved model, Up to user to destroy.
This is the Clp interface to CoinPresolve.
Definition: ClpPresolve.hpp:14
void setNonLinearValue(double value)
"Magic" number.
Definition: ClpPresolve.hpp:72
double nonLinearValue_
"Magic" number.
void setDoDual(bool doDual)
This version saves data in a file.
Definition: ClpPresolve.hpp:82
void setDoSingleton(bool doSingleton)
This version saves data in a file.
Definition: ClpPresolve.hpp:90
int presolveActions() const
Set whole group.
int * originalColumn_
Original column numbers.
bool doDoubleton() const
Whether we want to do doubleton part of presolve.
Definition: ClpPresolve.hpp:95
void destroyPresolve()
Gets rid of presolve actions (e.g.when infeasible)
void setDoTripleton(bool doTripleton)
This version saves data in a file.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:49
bool doForcing() const
Whether we want to do forcing part of presolve.
void setDoImpliedFree(bool doImpliedfree)
This version saves data in a file.
bool doGubrow() const
Whether we want to do gubrow part of presolve.
void setPresolveActions(int action)
This version saves data in a file.
bool doSingleton() const
Whether we want to do singleton part of presolve.
Definition: ClpPresolve.hpp:87
void setDoDupcol(bool doDupcol)
This version saves data in a file.
ClpSimplex * originalModel() const
Return pointer to original model.
int presolvedModelToFile(ClpSimplex &si, std::string fileName, double feasibilityTolerance=0.0, bool keepIntegers=true, int numberPasses=5, bool doRowObjective=false)
This version saves data in a file.
ClpSimplex * presolvedModel_
ClpPresolved model - up to user to destroy by deleteClpPresolvedModel.
double * rowObjective_
Row objective.
void statistics()
Asks for statistics.
bool doDual() const
Whether we want to do dual part of presolve.
Definition: ClpPresolve.hpp:79
void setDoSingletonColumn(bool doSingleton)
This version saves data in a file.
void setDoTighten(bool doTighten)
This version saves data in a file.
void setDoDuprow(bool doDuprow)
This version saves data in a file.
ClpSimplex * originalModel_
Original model - must not be destroyed before postsolve.
int nrows_
Original model - must not be destroyed before postsolve.
virtual ~ClpPresolve()
Virtual destructor.
bool doImpliedFree() const
Whether we want to do impliedfree part of presolve.