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
34 :
public CoinFactorization
70 #ifdef CLP_MULTIPLE_FACTORIZATIONS
89 CoinIndexedVector * regionSparse,
90 CoinIndexedVector * tableauColumn,
93 bool checkBeforeModifying =
false,
94 double acceptablePivot = 1.0e-8);
105 CoinIndexedVector * regionSparse2);
109 CoinIndexedVector * regionSparse2,
110 bool noPermute =
false)
const;
117 CoinIndexedVector * regionSparse2,
118 CoinIndexedVector * regionSparse3,
119 bool noPermuteRegion3 =
false) ;
122 CoinIndexedVector * regionSparse2,
123 bool noPermute =
false)
const;
127 CoinIndexedVector * regionSparse2)
const;
129 #ifdef CLP_MULTIPLE_FACTORIZATIONS
134 if (coinFactorizationA_)
return coinFactorizationA_->numberElements();
135 else return coinFactorizationB_->numberElements() ;
139 if (coinFactorizationA_)
return coinFactorizationA_->permute();
140 else return coinFactorizationB_->permute() ;
144 if (coinFactorizationA_)
return coinFactorizationA_->pivotColumn();
145 else return coinFactorizationB_->permute() ;
149 if (coinFactorizationA_)
return coinFactorizationA_->maximumPivots();
150 else return coinFactorizationB_->maximumPivots() ;
154 if (coinFactorizationA_) coinFactorizationA_->maximumPivots(value);
155 else coinFactorizationB_->maximumPivots(value);
159 if (coinFactorizationA_)
return coinFactorizationA_->pivots();
160 else return coinFactorizationB_->pivots() ;
164 if (coinFactorizationA_)
return coinFactorizationA_->areaFactor();
169 if (coinFactorizationA_) coinFactorizationA_->areaFactor(value);
173 if (coinFactorizationA_)
return coinFactorizationA_->zeroTolerance();
174 else return coinFactorizationB_->zeroTolerance() ;
178 if (coinFactorizationA_) coinFactorizationA_->zeroTolerance(value);
179 else coinFactorizationB_->zeroTolerance(value);
185 if (coinFactorizationA_)
return coinFactorizationA_->sparseThreshold();
190 if (coinFactorizationA_) coinFactorizationA_->sparseThreshold(value);
194 if (coinFactorizationA_)
return coinFactorizationA_->status();
195 else return coinFactorizationB_->status() ;
199 if (coinFactorizationA_) coinFactorizationA_->setStatus(value);
200 else coinFactorizationB_->setStatus(value) ;
204 if (coinFactorizationA_)
return coinFactorizationA_->numberDense();
210 if (coinFactorizationA_)
return coinFactorizationA_->numberElementsU();
215 if (coinFactorizationA_)
return coinFactorizationA_->numberElementsL();
220 if (coinFactorizationA_)
return coinFactorizationA_->numberElementsR();
225 if (coinFactorizationA_) {
226 return (coinFactorizationA_->pivots() * 3 > coinFactorizationA_->maximumPivots() * 2 &&
227 coinFactorizationA_->numberElementsR() * 3 > (coinFactorizationA_->numberElementsL() +
228 coinFactorizationA_->numberElementsU()) * 2 + 1000 &&
229 !coinFactorizationA_->numberDense());
231 return coinFactorizationB_->pivots() > coinFactorizationB_->numberRows() / 2.45 + 20;
236 if (coinFactorizationA_)
return coinFactorizationA_->messageLevel();
241 if (coinFactorizationA_) coinFactorizationA_->messageLevel(value);
245 if (coinFactorizationA_)
246 coinFactorizationA_->clearArrays();
247 else if (coinFactorizationB_)
248 coinFactorizationB_->clearArrays();
252 if (coinFactorizationA_)
return coinFactorizationA_->numberRows();
253 else return coinFactorizationB_->numberRows() ;
257 if (coinFactorizationA_)
return coinFactorizationA_->denseThreshold();
262 if (coinFactorizationA_) coinFactorizationA_->setDenseThreshold(value);
266 if (coinFactorizationA_)
return coinFactorizationA_->pivotTolerance();
267 else if (coinFactorizationB_)
return coinFactorizationB_->pivotTolerance();
272 if (coinFactorizationA_) coinFactorizationA_->pivotTolerance(value);
273 else if (coinFactorizationB_) coinFactorizationB_->pivotTolerance(value);
277 if (coinFactorizationA_) coinFactorizationA_->relaxAccuracyCheck(value);
285 if (coinFactorizationA_)
return coinFactorizationA_->persistenceFlag();
289 if (coinFactorizationA_) coinFactorizationA_->setPersistenceFlag(value);
293 if (coinFactorizationA_)
294 coinFactorizationA_->almostDestructor();
295 else if (coinFactorizationB_)
296 coinFactorizationB_->clearArrays();
300 if (coinFactorizationA_)
return coinFactorizationA_->adjustedAreaFactor();
304 if (coinFactorizationA_) coinFactorizationA_->setBiasLU(value);
308 if (coinFactorizationA_) coinFactorizationA_->setForrestTomlin(value);
312 if (coinFactorizationA_) {
314 #ifndef COIN_FAST_CODE
315 coinFactorizationA_->slackValue(-1.0);
317 coinFactorizationA_->zeroTolerance(1.0e-13);
324 return goOslThreshold_;
328 goOslThreshold_ = value;
332 return goDenseThreshold_;
336 goDenseThreshold_ = value;
340 return goSmallThreshold_;
344 goSmallThreshold_ = value;
352 return coinFactorizationB_ ? 1 : 0;
363 #ifndef COIN_FAST_CODE
369 inline void goDense() {}
384 return (networkBasis_ != NULL);
405 #ifdef CLP_MULTIPLE_FACTORIZATIONS
406 CoinFactorization * coinFactorizationA_;
409 CoinOtherFactorization * coinFactorizationB_;
410 #ifdef CLP_REUSE_ETAS
419 int goSmallThreshold_;
421 int goDenseThreshold_;
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.