6 #ifndef ClpFactorization_H
7 #define ClpFactorization_H
10 #include "CoinPragma.hpp"
12 #include "CoinFactorization.hpp"
16 class CoinOtherFactorization;
17 #ifndef CLP_MULTIPLE_FACTORIZATIONS
18 #define CLP_MULTIPLE_FACTORIZATIONS 4
20 #ifdef CLP_MULTIPLE_FACTORIZATIONS
21 #include "CoinDenseFactorization.hpp"
24 #ifndef COIN_FAST_CODE
25 #define COIN_FAST_CODE
27 #ifndef CLP_FACTORIZATION_NEW_TIMING
28 #define CLP_FACTORIZATION_NEW_TIMING 1
37 :
public CoinFactorization
73 #ifdef CLP_MULTIPLE_FACTORIZATIONS
92 CoinIndexedVector * regionSparse,
93 CoinIndexedVector * tableauColumn,
96 bool checkBeforeModifying =
false,
97 double acceptablePivot = 1.0e-8);
108 CoinIndexedVector * regionSparse2);
112 CoinIndexedVector * regionSparse2,
113 bool noPermute =
false)
const;
120 CoinIndexedVector * regionSparse2,
121 CoinIndexedVector * regionSparse3,
122 bool noPermuteRegion3 =
false) ;
125 CoinIndexedVector * regionSparse2,
126 bool noPermute =
false)
const;
130 CoinIndexedVector * regionSparse2)
const;
132 #ifdef CLP_MULTIPLE_FACTORIZATIONS
137 if (coinFactorizationA_)
return coinFactorizationA_->numberElements();
138 else return coinFactorizationB_->numberElements() ;
142 if (coinFactorizationA_)
return coinFactorizationA_->permute();
143 else return coinFactorizationB_->permute() ;
147 if (coinFactorizationA_)
return coinFactorizationA_->pivotColumn();
148 else return coinFactorizationB_->permute() ;
152 if (coinFactorizationA_)
return coinFactorizationA_->maximumPivots();
153 else return coinFactorizationB_->maximumPivots() ;
157 if (coinFactorizationA_) coinFactorizationA_->maximumPivots(value);
158 else coinFactorizationB_->maximumPivots(value);
162 if (coinFactorizationA_)
return coinFactorizationA_->pivots();
163 else return coinFactorizationB_->pivots() ;
167 if (coinFactorizationA_)
return coinFactorizationA_->areaFactor();
172 if (coinFactorizationA_) coinFactorizationA_->areaFactor(value);
176 if (coinFactorizationA_)
return coinFactorizationA_->zeroTolerance();
177 else return coinFactorizationB_->zeroTolerance() ;
181 if (coinFactorizationA_) coinFactorizationA_->zeroTolerance(value);
182 else coinFactorizationB_->zeroTolerance(value);
188 if (coinFactorizationA_)
return coinFactorizationA_->sparseThreshold();
193 if (coinFactorizationA_) coinFactorizationA_->sparseThreshold(value);
197 if (coinFactorizationA_)
return coinFactorizationA_->status();
198 else return coinFactorizationB_->status() ;
202 if (coinFactorizationA_) coinFactorizationA_->setStatus(value);
203 else coinFactorizationB_->setStatus(value) ;
207 if (coinFactorizationA_)
return coinFactorizationA_->numberDense();
213 if (coinFactorizationA_)
return coinFactorizationA_->numberElementsU();
218 if (coinFactorizationA_)
return coinFactorizationA_->numberElementsL();
223 if (coinFactorizationA_)
return coinFactorizationA_->numberElementsR();
228 #if CLP_FACTORIZATION_NEW_TIMING>1
229 void statsRefactor(
char when)
const;
233 if (coinFactorizationA_)
return coinFactorizationA_->messageLevel();
238 if (coinFactorizationA_) coinFactorizationA_->messageLevel(value);
242 if (coinFactorizationA_)
243 coinFactorizationA_->clearArrays();
244 else if (coinFactorizationB_)
245 coinFactorizationB_->clearArrays();
249 if (coinFactorizationA_)
return coinFactorizationA_->numberRows();
250 else return coinFactorizationB_->numberRows() ;
254 if (coinFactorizationA_)
return coinFactorizationA_->denseThreshold();
259 if (coinFactorizationA_) coinFactorizationA_->setDenseThreshold(value);
263 if (coinFactorizationA_)
return coinFactorizationA_->pivotTolerance();
264 else if (coinFactorizationB_)
return coinFactorizationB_->pivotTolerance();
269 if (coinFactorizationA_) coinFactorizationA_->pivotTolerance(value);
270 else if (coinFactorizationB_) coinFactorizationB_->pivotTolerance(value);
274 if (coinFactorizationA_) coinFactorizationA_->relaxAccuracyCheck(value);
282 if (coinFactorizationA_)
return coinFactorizationA_->persistenceFlag();
286 if (coinFactorizationA_) coinFactorizationA_->setPersistenceFlag(value);
290 if (coinFactorizationA_)
291 coinFactorizationA_->almostDestructor();
292 else if (coinFactorizationB_)
293 coinFactorizationB_->clearArrays();
297 if (coinFactorizationA_)
return coinFactorizationA_->adjustedAreaFactor();
301 if (coinFactorizationA_) coinFactorizationA_->setBiasLU(value);
305 if (coinFactorizationA_) coinFactorizationA_->setForrestTomlin(value);
309 if (coinFactorizationA_) {
311 #ifndef COIN_FAST_CODE
312 coinFactorizationA_->slackValue(-1.0);
314 coinFactorizationA_->zeroTolerance(1.0e-13);
321 return goOslThreshold_;
325 goOslThreshold_ = value;
329 return goDenseThreshold_;
333 goDenseThreshold_ = value;
337 return goSmallThreshold_;
341 goSmallThreshold_ = value;
349 return coinFactorizationB_ ? 1 : 0;
360 #ifndef COIN_FAST_CODE
366 inline void goDense() {}
381 return (networkBasis_ != NULL);
402 #ifdef CLP_MULTIPLE_FACTORIZATIONS
403 CoinFactorization * coinFactorizationA_;
406 CoinOtherFactorization * coinFactorizationB_;
407 #ifdef CLP_REUSE_ETAS
416 int goSmallThreshold_;
418 int goDenseThreshold_;
420 #ifdef CLP_FACTORIZATION_NEW_TIMING
421 mutable double shortestAverage_;
423 mutable double totalInR_;
424 mutable double totalInIncreasingU_;
425 mutable int endLengthU_;
426 mutable int lastNumberPivots_;
427 mutable int effectiveStartNumberU_;
int pivots() const
Returns number of pivots since factorization.
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.
void setGoOslThreshold(int value)
Set switch to osl if number rows <= this.
void setGoSmallThreshold(int value)
Set switch to small if number rows <= this.
void sparseThreshold(int value)
Set sparse threshold.
Abstract base class for Clp Matrices.
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 setStatus(int value)
Sets status.
int goDenseThreshold() const
Get switch to dense if number rows <= this.
int factorize(ClpSimplex *model, int solveType, bool valuesPass)
When part of LP - given by basic variables.
void setDenseThreshold(int value)
Sets dense threshold.
double pivotTolerance() const
Pivot tolerance.
void almostDestructor()
Delete all stuff (leaves as after CoinFactorization())
void forceOtherFactorization(int which)
If nonzero force use of 1,dense 2,small 3,osl.
void setFactorization(ClpFactorization &factorization)
Sets factorization.
double areaFactor() const
Whether larger areas needed.
CoinBigIndex numberElementsR() const
Returns number in R area.
void saferTolerances(double zeroTolerance, double pivotTolerance)
Set tolerances to safer of existing and given.
void setGoDenseThreshold(int value)
Set switch to dense if number rows <= this.
void setDefaultValues()
Sets default values.
double adjustedAreaFactor() const
Returns areaFactor but adjusted for dense.
int status() const
Returns status.
This deals with Factorization and Updates for network structures.
This just implements CoinFactorization when an ClpMatrixBase object is passed.
void setBiasLU(int value)
CoinBigIndex numberElementsL() const
Returns number in L area.
void setPersistenceFlag(int value)
#define CLP_MULTIPLE_FACTORIZATIONS
bool networkBasis() const
Says if a network basis.
int sparseThreshold() const
get sparse threshold
CoinBigIndex numberElementsU() const
Returns number in U area.
void maximumPivots(int value)
Set maximum number of pivots between factorizations.
~ClpFactorization()
Destructor.
int denseThreshold() const
Gets dense threshold.
void cleanUp()
Cleans up i.e. gets rid of network basis.
This solves LPs using the simplex method.
int updateColumnTranspose(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2) const
Updates one column (BTRAN) from region2 region1 starts as zero and is zero at end.
void goDenseOrSmall(int numberRows)
Go over to dense or small code if small enough.
void clearArrays()
Get rid of all memory.
int goSmallThreshold() const
Get switch to small if number rows <= this.
ClpFactorization()
Default constructor.
int numberRows() const
Number of Rows after factorization.
void zeroTolerance(double value)
Set zero tolerance.
int maximumPivots() const
Maximum number of pivots between factorizations.
ClpFactorization & operator=(const ClpFactorization &)
void goSparse()
makes a row copy of L for speed and to allow very sparse problems
double zeroTolerance() const
Zero tolerance.
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...
int goOslThreshold() const
Get switch to osl if number rows <= this.
int numberDense() const
Returns number of dense rows.
int * permute() const
Returns address of permute region.
void messageLevel(int value)
Set level of detail of messages.
int * pivotColumn() const
Returns address of pivotColumn region (also used for permuting)
bool needToReorder() const
Says whether to redo pivot order.
int isDenseOrSmall() const
Return 1 if dense code.
int numberElements() const
Total number of elements in factorization.
bool timeToRefactorize() const
int updateColumnFT(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2)
Updates one column (FTRAN) from region2 Tries to do FT update number returned is negative if no room ...
void getWeights(int *weights) const
Fills weighted row list.
int messageLevel() const
Level of detail of messages.
int updateColumnForDebug(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, bool noPermute=false) const
For debug (no statistics update)
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 pivotTolerance(double value)
Set pivot tolerance.
void setForrestTomlin(bool value)
true if Forrest Tomlin update, false if PFI
void areaFactor(double value)
Set whether larger areas needed.
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.