Clp 1.17.10
Loading...
Searching...
No Matches
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
10class CoinPresolveAction;
11#include "CoinPresolveMatrix.hpp"
16public:
19
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 }
84
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
95 }
96
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 }
108
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 }
120
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 }
132
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 }
144
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 }
156
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 }
168
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 }
180
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 }
192
193 inline bool doDependency() const
194 {
195 return (presolveActions_ & 32768) != 0;
196 }
198 {
199 if (doDependency)
200 presolveActions_ |= 32768;
201 else
202 presolveActions_ &= ~32768;
203 }
204
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 }
216
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 }
228
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 }
240
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 }
252
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 }
264
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 }
275
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 }
284
285 inline void setSubstitution(int value)
286 {
287 substitution_ = value;
288 }
289
290 inline void statistics()
291 {
292 presolveActions_ |= 0x80000000;
293 }
294
295 int presolveStatus() const;
296
305 virtual void postsolve(bool updateStatus = true);
306
308 void destroyPresolve();
309
311private:
314
330 const CoinPresolveAction *paction_;
331
339 CoinBigIndex nelems_;
344#ifndef CLP_NO_STD
346 std::string saveFile_;
347#endif
353
354protected:
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*/
bool doTwoxTwo() const
Whether we want to do twoxtwo part of presolve.
const int * originalColumns() const
return pointer to original columns
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.
*The postsolved problem will expand back to its former size *as postsolve transformations are applied *It is efficient to allocate data structures for the final size *of the problem rather than expand them as needed *These fields give the size of the original problem int ncols_
bool doSingletonColumn() const
Whether we want to do singleton column part of presolve.
void setPresolveActions(int action)
void setDoTighten(bool doTighten)
bool doIntersection() const
Whether we want to allow duplicate intersections.
*Number of major passes int numberPasses_
ClpPresolve()
Default constructor.
int presolveStatus() const
Return presolve status (0,1,2).
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.
void setDoDoubleton(bool doDoubleton)
bool doTransfer() const
Whether we want to do transfer part of presolve.
*The list of transformations applied const CoinPresolveAction * paction_
ClpSimplex * originalModel() const
Return pointer to original model.
void setDoTransfer(bool doTransfer)
*ClpPresolved model up to user to destroy by deleteClpPresolvedModel ClpSimplex * presolvedModel_
void setDoIntersection(bool doIntersection)
bool doDoubleton() const
Whether we want to do doubleton part of presolve.
void setDoImpliedFree(bool doImpliedfree)
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.
const int * originalRows() const
return pointer to original rows
*Original row numbers int * originalRow_
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 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)
*If you want to apply the individual presolve routines *or perhaps add your own to the *define a derived class and override this method virtual const CoinPresolveAction * presolve(CoinPresolveMatrix *prob)
just apply the transformations *in reverse order *You will probably only be interested in overriding this method *if you want to add code to test for consistency *while debugging new presolve virtual techniques void postsolve(CoinPostsolveMatrix &prob)
double nonLinearValue() const
int presolveActions_
Whether we want to skip dual part of presolve etc.
*Original column numbers int * originalColumn_
bool doGubrow() const
Whether we want to do gubrow part of presolve.
*Substitution level int substitution_
void setNonLinearValue(double value)
"Magic" number.
void setDoSingletonColumn(bool doSingleton)
*Original model must not be destroyed before postsolve ClpSimplex * originalModel_
virtual ~ClpPresolve()
Virtual destructor.
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)
void setDoDual(bool doDual)
bool doForcing() const
Whether we want to do forcing part of presolve.
bool doTripleton() const
Whether we want to do tripleton part of presolve.
ClpSimplex * model() const
Return pointer to presolved model, Up to user to destroy.
*Name of saved model file std::string saveFile_
bool doDual() const
Whether we want to do dual part of presolve.
void setDoGubrow(bool doGubrow)
int presolveActions() const
Set whole group.
CoinBigIndex nelems_
*Row objective double * rowObjective_
This solves LPs using the simplex method.