Clp 1.16.9
Loading...
Searching...
No Matches
ClpFactorization.hpp
Go to the documentation of this file.
1/* $Id: ClpFactorization.hpp 2078 2015-01-05 12:39:49Z forrest $ */
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 ClpFactorization_H
7#define ClpFactorization_H
8
9
10#include "CoinPragma.hpp"
11
12#include "CoinFactorization.hpp"
13class ClpMatrixBase;
14class ClpSimplex;
15class ClpNetworkBasis;
16class CoinOtherFactorization;
17#ifndef CLP_MULTIPLE_FACTORIZATIONS
18#define CLP_MULTIPLE_FACTORIZATIONS 4
19#endif
20#ifdef CLP_MULTIPLE_FACTORIZATIONS
21#include "CoinDenseFactorization.hpp"
22#include "ClpSimplex.hpp"
23#endif
24#ifndef COIN_FAST_CODE
25#define COIN_FAST_CODE
26#endif
27#ifndef CLP_FACTORIZATION_NEW_TIMING
28#define CLP_FACTORIZATION_NEW_TIMING 1
29#endif
30
37 : public CoinFactorization
38#endif
39{
40
41 //friend class CoinFactorization;
42
43public:
55 int factorize (ClpSimplex * model, int solveType, bool valuesPass);
57
58
66
70 ClpFactorization(const CoinFactorization&);
72 ClpFactorization(const ClpFactorization&, int denseIfSmaller = 0);
73#ifdef CLP_MULTIPLE_FACTORIZATIONS
75 ClpFactorization(const CoinOtherFactorization&);
76#endif
79
80 /* **** below here is so can use networkish basis */
83
91 int replaceColumn ( const ClpSimplex * model,
92 CoinIndexedVector * regionSparse,
93 CoinIndexedVector * tableauColumn,
94 int pivotRow,
95 double pivotCheck ,
96 bool checkBeforeModifying = false,
97 double acceptablePivot = 1.0e-8);
99
107 int updateColumnFT ( CoinIndexedVector * regionSparse,
108 CoinIndexedVector * regionSparse2);
111 int updateColumn ( CoinIndexedVector * regionSparse,
112 CoinIndexedVector * regionSparse2,
113 bool noPermute = false) const;
119 int updateTwoColumnsFT ( CoinIndexedVector * regionSparse1,
120 CoinIndexedVector * regionSparse2,
121 CoinIndexedVector * regionSparse3,
122 bool noPermuteRegion3 = false) ;
124 int updateColumnForDebug ( CoinIndexedVector * regionSparse,
125 CoinIndexedVector * regionSparse2,
126 bool noPermute = false) const;
129 int updateColumnTranspose ( CoinIndexedVector * regionSparse,
130 CoinIndexedVector * regionSparse2) const;
132#ifdef CLP_MULTIPLE_FACTORIZATIONS
136 inline int numberElements ( ) const {
137 if (coinFactorizationA_) return coinFactorizationA_->numberElements();
138 else return coinFactorizationB_->numberElements() ;
139 }
141 inline int *permute ( ) const {
142 if (coinFactorizationA_) return coinFactorizationA_->permute();
143 else return coinFactorizationB_->permute() ;
144 }
146 inline int *pivotColumn ( ) const {
147 if (coinFactorizationA_) return coinFactorizationA_->pivotColumn();
148 else return coinFactorizationB_->permute() ;
149 }
151 inline int maximumPivots ( ) const {
152 if (coinFactorizationA_) return coinFactorizationA_->maximumPivots();
153 else return coinFactorizationB_->maximumPivots() ;
154 }
156 inline void maximumPivots ( int value) {
157 if (coinFactorizationA_) coinFactorizationA_->maximumPivots(value);
158 else coinFactorizationB_->maximumPivots(value);
159 }
161 inline int pivots ( ) const {
162 if (coinFactorizationA_) return coinFactorizationA_->pivots();
163 else return coinFactorizationB_->pivots() ;
164 }
166 inline double areaFactor ( ) const {
167 if (coinFactorizationA_) return coinFactorizationA_->areaFactor();
168 else return 0.0 ;
169 }
171 inline void areaFactor ( double value) {
172 if (coinFactorizationA_) coinFactorizationA_->areaFactor(value);
173 }
175 inline double zeroTolerance ( ) const {
176 if (coinFactorizationA_) return coinFactorizationA_->zeroTolerance();
177 else return coinFactorizationB_->zeroTolerance() ;
178 }
180 inline void zeroTolerance ( double value) {
181 if (coinFactorizationA_) coinFactorizationA_->zeroTolerance(value);
182 else coinFactorizationB_->zeroTolerance(value);
183 }
187 inline int sparseThreshold ( ) const {
188 if (coinFactorizationA_) return coinFactorizationA_->sparseThreshold();
189 else return 0 ;
190 }
192 inline void sparseThreshold ( int value) {
193 if (coinFactorizationA_) coinFactorizationA_->sparseThreshold(value);
194 }
196 inline int status ( ) const {
197 if (coinFactorizationA_) return coinFactorizationA_->status();
198 else return coinFactorizationB_->status() ;
199 }
201 inline void setStatus ( int value) {
202 if (coinFactorizationA_) coinFactorizationA_->setStatus(value);
203 else coinFactorizationB_->setStatus(value) ;
204 }
206 inline int numberDense() const {
207 if (coinFactorizationA_) return coinFactorizationA_->numberDense();
208 else return 0 ;
209 }
210#if 1
212 inline CoinBigIndex numberElementsU ( ) const {
213 if (coinFactorizationA_) return coinFactorizationA_->numberElementsU();
214 else return -1 ;
215 }
217 inline CoinBigIndex numberElementsL ( ) const {
218 if (coinFactorizationA_) return coinFactorizationA_->numberElementsL();
219 else return -1 ;
220 }
222 inline CoinBigIndex numberElementsR ( ) const {
223 if (coinFactorizationA_) return coinFactorizationA_->numberElementsR();
224 else return 0 ;
225 }
226#endif
227 bool timeToRefactorize() const;
228#if CLP_FACTORIZATION_NEW_TIMING>1
229 void statsRefactor(char when) const;
230#endif
232 inline int messageLevel ( ) const {
233 if (coinFactorizationA_) return coinFactorizationA_->messageLevel();
234 else return 1 ;
235 }
237 inline void messageLevel ( int value) {
238 if (coinFactorizationA_) coinFactorizationA_->messageLevel(value);
239 }
241 inline void clearArrays() {
242 if (coinFactorizationA_)
243 coinFactorizationA_->clearArrays();
244 else if (coinFactorizationB_)
245 coinFactorizationB_->clearArrays();
246 }
248 inline int numberRows ( ) const {
249 if (coinFactorizationA_) return coinFactorizationA_->numberRows();
250 else return coinFactorizationB_->numberRows() ;
251 }
253 inline int denseThreshold() const {
254 if (coinFactorizationA_) return coinFactorizationA_->denseThreshold();
255 else return 0 ;
256 }
258 inline void setDenseThreshold(int value) {
259 if (coinFactorizationA_) coinFactorizationA_->setDenseThreshold(value);
260 }
262 inline double pivotTolerance ( ) const {
263 if (coinFactorizationA_) return coinFactorizationA_->pivotTolerance();
264 else if (coinFactorizationB_) return coinFactorizationB_->pivotTolerance();
265 return 1.0e-8 ;
266 }
268 inline void pivotTolerance ( double value) {
269 if (coinFactorizationA_) coinFactorizationA_->pivotTolerance(value);
270 else if (coinFactorizationB_) coinFactorizationB_->pivotTolerance(value);
271 }
273 inline void relaxAccuracyCheck(double value) {
274 if (coinFactorizationA_) coinFactorizationA_->relaxAccuracyCheck(value);
275 }
281 inline int persistenceFlag() const {
282 if (coinFactorizationA_) return coinFactorizationA_->persistenceFlag();
283 else return 0 ;
284 }
285 inline void setPersistenceFlag(int value) {
286 if (coinFactorizationA_) coinFactorizationA_->setPersistenceFlag(value);
287 }
289 inline void almostDestructor() {
290 if (coinFactorizationA_)
291 coinFactorizationA_->almostDestructor();
292 else if (coinFactorizationB_)
293 coinFactorizationB_->clearArrays();
294 }
296 inline double adjustedAreaFactor() const {
297 if (coinFactorizationA_) return coinFactorizationA_->adjustedAreaFactor();
298 else return 0.0 ;
299 }
300 inline void setBiasLU(int value) {
301 if (coinFactorizationA_) coinFactorizationA_->setBiasLU(value);
302 }
304 inline void setForrestTomlin(bool value) {
305 if (coinFactorizationA_) coinFactorizationA_->setForrestTomlin(value);
306 }
308 inline void setDefaultValues() {
309 if (coinFactorizationA_) {
310 // row activities have negative sign
311#ifndef COIN_FAST_CODE
312 coinFactorizationA_->slackValue(-1.0);
313#endif
314 coinFactorizationA_->zeroTolerance(1.0e-13);
315 }
316 }
318 void forceOtherFactorization(int which);
320 inline int goOslThreshold() const {
321 return goOslThreshold_;
322 }
324 inline void setGoOslThreshold(int value) {
325 goOslThreshold_ = value;
326 }
328 inline int goDenseThreshold() const {
329 return goDenseThreshold_;
330 }
332 inline void setGoDenseThreshold(int value) {
333 goDenseThreshold_ = value;
334 }
336 inline int goSmallThreshold() const {
337 return goSmallThreshold_;
338 }
340 inline void setGoSmallThreshold(int value) {
341 goSmallThreshold_ = value;
342 }
346 void setFactorization(ClpFactorization & factorization);
348 inline int isDenseOrSmall() const {
349 return coinFactorizationB_ ? 1 : 0;
350 }
351#else
352 inline bool timeToRefactorize() const {
353 return (pivots() * 3 > maximumPivots() * 2 &&
354 numberElementsR() * 3 > (numberElementsL() + numberElementsU()) * 2 + 1000 &&
355 !numberDense());
356 }
358 inline void setDefaultValues() {
359 // row activities have negative sign
360#ifndef COIN_FAST_CODE
361 slackValue(-1.0);
362#endif
363 zeroTolerance(1.0e-13);
364 }
366 inline void goDense() {}
367#endif
369
373 void goSparse();
375 void cleanUp();
377 bool needToReorder() const;
378#ifndef SLIM_CLP
380 inline bool networkBasis() const {
381 return (networkBasis_ != NULL);
382 }
383#else
385 inline bool networkBasis() const {
386 return false;
387 }
388#endif
390 void getWeights(int * weights) const;
392
394private:
395
399#ifndef SLIM_CLP
400 ClpNetworkBasis * networkBasis_;
401#endif
402#ifdef CLP_MULTIPLE_FACTORIZATIONS
404 CoinFactorization * coinFactorizationA_;
406 CoinOtherFactorization * coinFactorizationB_;
407#ifdef CLP_REUSE_ETAS
409 ClpSimplex * model_;
410#endif
412 int forceB_;
414 int goOslThreshold_;
416 int goSmallThreshold_;
418 int goDenseThreshold_;
419#endif
420#ifdef CLP_FACTORIZATION_NEW_TIMING
422 mutable double shortestAverage_;
423 mutable double totalInR_;
424 mutable double totalInIncreasingU_;
425 mutable int endLengthU_;
426 mutable int lastNumberPivots_;
427 mutable int effectiveStartNumberU_;
428#endif
430};
431
432#endif
#define CLP_MULTIPLE_FACTORIZATIONS
This just implements CoinFactorization when an ClpMatrixBase object is passed.
int numberElements() const
Total number of elements in factorization.
int numberDense() const
Returns number of dense rows.
int updateTwoColumnsFT(CoinIndexedVector *regionSparse1, CoinIndexedVector *regionSparse2, CoinIndexedVector *regionSparse3, bool noPermuteRegion3=false)
Updates one column (FTRAN) from region2 Tries to do FT update number returned is negative if no room.
void pivotTolerance(double value)
Set pivot tolerance.
void goSparse()
makes a row copy of L for speed and to allow very sparse problems
void saferTolerances(double zeroTolerance, double pivotTolerance)
Set tolerances to safer of existing and given.
int * permute() const
Returns address of permute region.
int factorize(ClpSimplex *model, int solveType, bool valuesPass)
When part of LP - given by basic variables.
bool networkBasis() const
Says if a network basis.
void setDenseThreshold(int value)
Sets dense threshold.
double pivotTolerance() const
Pivot tolerance.
double zeroTolerance() const
Zero tolerance.
int status() const
Returns status.
bool needToReorder() const
Says whether to redo pivot order.
int sparseThreshold() const
get sparse threshold
ClpFactorization(const CoinFactorization &)
The copy constructor from an CoinFactorization.
void setPersistenceFlag(int value)
void sparseThreshold(int value)
Set sparse threshold.
int * pivotColumn() const
Returns address of pivotColumn region (also used for permuting)
int denseThreshold() const
Gets dense threshold.
double adjustedAreaFactor() const
Returns areaFactor but adjusted for dense.
CoinBigIndex numberElementsR() const
Returns number in R area.
void zeroTolerance(double value)
Set zero tolerance.
int updateColumnForDebug(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, bool noPermute=false) const
For debug (no statistics update)
int goOslThreshold() const
Get switch to osl if number rows <= this.
void getWeights(int *weights) const
Fills weighted row list.
void setGoDenseThreshold(int value)
Set switch to dense if number rows <= this.
int replaceColumn(const ClpSimplex *model, CoinIndexedVector *regionSparse, CoinIndexedVector *tableauColumn, int pivotRow, double pivotCheck, bool checkBeforeModifying=false, double acceptablePivot=1.0e-8)
Replaces one Column to basis, returns 0=OK, 1=Probably OK, 2=singular, 3=no room If checkBeforeModify...
~ClpFactorization()
Destructor.
void messageLevel(int value)
Set level of detail of messages.
int updateColumnFT(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2)
Updates one column (FTRAN) from region2 Tries to do FT update number returned is negative if no room ...
int pivots() const
Returns number of pivots since factorization.
ClpFactorization(const ClpFactorization &, int denseIfSmaller=0)
The copy constructor.
bool timeToRefactorize() const
int messageLevel() const
Level of detail of messages.
CoinBigIndex numberElementsU() const
Returns number in U area.
void almostDestructor()
Delete all stuff (leaves as after CoinFactorization())
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.
ClpFactorization & operator=(const ClpFactorization &)
void setBiasLU(int value)
int isDenseOrSmall() const
Return 1 if dense code.
CoinBigIndex numberElementsL() const
Returns number in L area.
int updateColumnTranspose(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2) const
Updates one column (BTRAN) from region2 region1 starts as zero and is zero at end.
void setGoSmallThreshold(int value)
Set switch to small if number rows <= this.
void setGoOslThreshold(int value)
Set switch to osl if number rows <= this.
void areaFactor(double value)
Set whether larger areas needed.
int maximumPivots() const
Maximum number of pivots between factorizations.
int persistenceFlag() const
Array persistence flag If 0 then as now (delete/new) 1 then only do arrays if bigger needed 2 as 1 bu...
void setFactorization(ClpFactorization &factorization)
Sets factorization.
int goSmallThreshold() const
Get switch to small if number rows <= this.
int goDenseThreshold() const
Get switch to dense if number rows <= this.
void maximumPivots(int value)
Set maximum number of pivots between factorizations.
void clearArrays()
Get rid of all memory.
void goDenseOrSmall(int numberRows)
Go over to dense or small code if small enough.
int numberRows() const
Number of Rows after factorization.
ClpFactorization(const CoinOtherFactorization &)
The copy constructor from an CoinOtherFactorization.
void setDefaultValues()
Sets default values.
void setStatus(int value)
Sets status.
void cleanUp()
Cleans up i.e. gets rid of network basis.
void forceOtherFactorization(int which)
If nonzero force use of 1,dense 2,small 3,osl.
double areaFactor() const
Whether larger areas needed.
void setForrestTomlin(bool value)
true if Forrest Tomlin update, false if PFI
int updateColumn(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, bool noPermute=false) const
Updates one column (FTRAN) from region2 region1 starts as zero and is zero at end.
ClpFactorization()
Default constructor.
Abstract base class for Clp Matrices.
This deals with Factorization and Updates for network structures.
This solves LPs using the simplex method.
Definition: ClpSimplex.hpp:70