Loading...
Searching...
No Matches
ClpFactorization.hpp
Go to the documentation of this file.
/* $Id$ */
// Copyright (C) 2002, International Business Machines
// Corporation and others. All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).
#ifndef ClpFactorization_H
#define ClpFactorization_H
#include "CoinPragma.hpp"
#include "CoinFactorization.hpp"
class ClpMatrixBase;
class ClpSimplex;
class ClpNetworkBasis;
class CoinOtherFactorization;
#ifndef CLP_MULTIPLE_FACTORIZATIONS
#define CLP_MULTIPLE_FACTORIZATIONS 4
#endif
#ifdef CLP_MULTIPLE_FACTORIZATIONS
#include "CoinDenseFactorization.hpp"
#include "ClpSimplex.hpp"
#endif
#ifndef COIN_FAST_CODE
#define COIN_FAST_CODE
#endif
#ifndef CLP_FACTORIZATION_NEW_TIMING
#define CLP_FACTORIZATION_NEW_TIMING 1
#endif
class ClpFactorization
#ifndef CLP_MULTIPLE_FACTORIZATIONS
: public CoinFactorization
#endif
{
//friend class CoinFactorization;
public:
int factorize(ClpSimplex *model, int solveType, bool valuesPass);
ClpFactorization();
~ClpFactorization();
ClpFactorization(const CoinFactorization &);
ClpFactorization(const ClpFactorization &, int denseIfSmaller = 0);
#ifdef CLP_MULTIPLE_FACTORIZATIONS
ClpFactorization(const CoinOtherFactorization &);
#endif
ClpFactorization &operator=(const ClpFactorization &);
/* **** below here is so can use networkish basis */
int replaceColumn(const ClpSimplex *model,
CoinIndexedVector *regionSparse,
CoinIndexedVector *tableauColumn,
int pivotRow,
double pivotCheck,
bool checkBeforeModifying = false,
double acceptablePivot = 1.0e-8);
#if ABOCA_LITE_FACTORIZATION
void replaceColumn1(CoinIndexedVector *regionSparse, int pivotRow);
int replaceColumn2(CoinIndexedVector *regionSparse,
int pivotRow,
double pivotCheck);
#endif
int updateColumnFT(CoinIndexedVector *regionSparse,
CoinIndexedVector *regionSparse2);
int updateColumn(CoinIndexedVector *regionSparse,
CoinIndexedVector *regionSparse2,
bool noPermute = false) const;
int updateTwoColumnsFT(CoinIndexedVector *regionSparse1,
CoinIndexedVector *regionSparse2,
CoinIndexedVector *regionSparse3,
bool noPermuteRegion3 = false);
int updateColumnForDebug(CoinIndexedVector *regionSparse,
CoinIndexedVector *regionSparse2,
bool noPermute = false) const;
int updateColumnTranspose(CoinIndexedVector *regionSparse,
CoinIndexedVector *regionSparse2) const;
void updateTwoColumnsTranspose(CoinIndexedVector *regionSparse,
CoinIndexedVector *regionSparse2,
CoinIndexedVector *regionSparse3) const;
#ifdef CLP_MULTIPLE_FACTORIZATIONS
inline int numberElements() const
{
if (coinFactorizationA_)
return coinFactorizationA_->numberElements();
else
return coinFactorizationB_->numberElements();
}
inline int *permute() const
{
if (coinFactorizationA_)
return coinFactorizationA_->permute();
else
return coinFactorizationB_->permute();
}
inline int *pivotColumn() const
{
if (coinFactorizationA_)
return coinFactorizationA_->pivotColumn();
else
return coinFactorizationB_->permute();
}
inline int maximumPivots() const
{
if (coinFactorizationA_)
return coinFactorizationA_->maximumPivots();
else
return coinFactorizationB_->maximumPivots();
}
inline void maximumPivots(int value)
{
if (coinFactorizationA_)
coinFactorizationA_->maximumPivots(value);
else
coinFactorizationB_->maximumPivots(value);
}
inline int pivots() const
{
if (coinFactorizationA_)
return coinFactorizationA_->pivots();
else
return coinFactorizationB_->pivots();
}
inline double areaFactor() const
{
if (coinFactorizationA_)
return coinFactorizationA_->areaFactor();
else
return 0.0;
}
inline void areaFactor(double value)
{
if (coinFactorizationA_)
coinFactorizationA_->areaFactor(value);
}
inline double zeroTolerance() const
{
if (coinFactorizationA_)
return coinFactorizationA_->zeroTolerance();
else
return coinFactorizationB_->zeroTolerance();
}
inline void zeroTolerance(double value)
{
if (coinFactorizationA_)
coinFactorizationA_->zeroTolerance(value);
else
coinFactorizationB_->zeroTolerance(value);
}
void saferTolerances(double zeroTolerance, double pivotTolerance);
inline int sparseThreshold() const
{
if (coinFactorizationA_)
return coinFactorizationA_->sparseThreshold();
else
return 0;
}
inline void sparseThreshold(int value)
{
if (coinFactorizationA_)
coinFactorizationA_->sparseThreshold(value);
}
inline int status() const
{
if (coinFactorizationA_)
return coinFactorizationA_->status();
else
return coinFactorizationB_->status();
}
inline void setStatus(int value)
{
if (coinFactorizationA_)
coinFactorizationA_->setStatus(value);
else
coinFactorizationB_->setStatus(value);
}
inline int numberDense() const
{
if (coinFactorizationA_)
return coinFactorizationA_->numberDense();
else
return 0;
}
#if 1
inline CoinBigIndex numberElementsU() const
{
if (coinFactorizationA_)
return coinFactorizationA_->numberElementsU();
else
return -1;
}
inline CoinBigIndex numberElementsL() const
{
if (coinFactorizationA_)
return coinFactorizationA_->numberElementsL();
else
return -1;
}
inline CoinBigIndex numberElementsR() const
{
if (coinFactorizationA_)
return coinFactorizationA_->numberElementsR();
else
return 0;
}
#endif
bool timeToRefactorize() const;
#if CLP_FACTORIZATION_NEW_TIMING > 1
void statsRefactor(char when) const;
#endif
inline int messageLevel() const
{
if (coinFactorizationA_)
return coinFactorizationA_->messageLevel();
else
return 1;
}
inline void messageLevel(int value)
{
if (coinFactorizationA_)
coinFactorizationA_->messageLevel(value);
}
inline void clearArrays()
{
if (coinFactorizationA_)
coinFactorizationA_->clearArrays();
else if (coinFactorizationB_)
coinFactorizationB_->clearArrays();
}
inline int numberRows() const
{
if (coinFactorizationA_)
return coinFactorizationA_->numberRows();
else
return coinFactorizationB_->numberRows();
}
inline int denseThreshold() const
{
if (coinFactorizationA_)
return coinFactorizationA_->denseThreshold();
else
return 0;
}
inline void setDenseThreshold(int value)
{
if (coinFactorizationA_)
coinFactorizationA_->setDenseThreshold(value);
}
inline double pivotTolerance() const
{
if (coinFactorizationA_)
return coinFactorizationA_->pivotTolerance();
else if (coinFactorizationB_)
return coinFactorizationB_->pivotTolerance();
return 1.0e-8;
}
inline void pivotTolerance(double value)
{
if (coinFactorizationA_)
coinFactorizationA_->pivotTolerance(value);
else if (coinFactorizationB_)
coinFactorizationB_->pivotTolerance(value);
}
inline void relaxAccuracyCheck(double value)
{
if (coinFactorizationA_)
coinFactorizationA_->relaxAccuracyCheck(value);
}
inline int persistenceFlag() const
{
if (coinFactorizationA_)
return coinFactorizationA_->persistenceFlag();
else
return 0;
}
inline void setPersistenceFlag(int value)
{
if (coinFactorizationA_)
coinFactorizationA_->setPersistenceFlag(value);
}
inline void almostDestructor()
{
if (coinFactorizationA_)
coinFactorizationA_->almostDestructor();
else if (coinFactorizationB_)
coinFactorizationB_->clearArrays();
}
inline double adjustedAreaFactor() const
{
if (coinFactorizationA_)
return coinFactorizationA_->adjustedAreaFactor();
else
return 0.0;
}
inline void setBiasLU(int value)
{
if (coinFactorizationA_)
coinFactorizationA_->setBiasLU(value);
}
inline void setForrestTomlin(bool value)
{
if (coinFactorizationA_)
coinFactorizationA_->setForrestTomlin(value);
}
inline void setDefaultValues()
{
if (coinFactorizationA_) {
// row activities have negative sign
#ifndef COIN_FAST_CODE
coinFactorizationA_->slackValue(-1.0);
#endif
coinFactorizationA_->zeroTolerance(1.0e-13);
}
}
void forceOtherFactorization(int which);
inline int goOslThreshold() const
{
return goOslThreshold_;
}
inline void setGoOslThreshold(int value)
{
goOslThreshold_ = value;
}
inline int goDenseThreshold() const
{
return goDenseThreshold_;
}
inline void setGoDenseThreshold(int value)
{
goDenseThreshold_ = value;
}
inline int goSmallThreshold() const
{
return goSmallThreshold_;
}
inline void setGoSmallThreshold(int value)
{
goSmallThreshold_ = value;
}
void goDenseOrSmall(int numberRows);
void setFactorization(ClpFactorization &factorization);
inline int isDenseOrSmall() const
{
return coinFactorizationB_ ? 1 : 0;
}
inline CoinFactorization *coinFactorization() const
{
return coinFactorizationA_;
}
#else
inline bool timeToRefactorize() const
{
return (pivots() * 3 > maximumPivots() * 2 && numberElementsR() * 3 > (numberElementsL() + numberElementsU()) * 2 + 1000 && !numberDense());
}
inline void setDefaultValues()
{
// row activities have negative sign
#ifndef COIN_FAST_CODE
slackValue(-1.0);
#endif
zeroTolerance(1.0e-13);
}
inline void goDense() {}
#endif
void goSparse();
void cleanUp();
bool needToReorder() const;
inline void doStatistics(bool trueFalse) const
{
doStatistics_ = trueFalse;
}
#ifndef SLIM_CLP
inline bool networkBasis() const
{
return (networkBasis_ != NULL);
}
#else
inline bool networkBasis() const
{
return false;
}
#endif
void getWeights(int *weights) const;
private:
#ifndef SLIM_CLP
ClpNetworkBasis *networkBasis_;
#endif
#ifdef CLP_MULTIPLE_FACTORIZATIONS
CoinFactorization *coinFactorizationA_;
CoinOtherFactorization *coinFactorizationB_;
#ifdef CLP_REUSE_ETAS
ClpSimplex *model_;
#endif
int forceB_;
int goOslThreshold_;
int goSmallThreshold_;
int goDenseThreshold_;
#endif
#ifdef CLP_FACTORIZATION_NEW_TIMING
mutable double shortestAverage_;
mutable double totalInR_;
mutable double totalInIncreasingU_;
mutable int endLengthU_;
mutable int lastNumberPivots_;
mutable int effectiveStartNumberU_;
#endif
mutable bool doStatistics_;
};
#endif
/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
*/
CLP_MULTIPLE_FACTORIZATIONS
#define CLP_MULTIPLE_FACTORIZATIONS
Definition ClpFactorization.hpp:17
ClpSimplex.hpp
ClpFactorization::numberElements
int numberElements() const
Total number of elements in factorization.
Definition ClpFactorization.hpp:149
ClpFactorization::numberDense
int numberDense() const
Returns number of dense rows.
Definition ClpFactorization.hpp:259
ClpFactorization::doStatistics
void doStatistics(bool trueFalse) const
To switch statistics on or off.
Definition ClpFactorization.hpp:492
ClpFactorization::updateTwoColumnsFT
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.
ClpFactorization::pivotTolerance
void pivotTolerance(double value)
Set pivot tolerance.
Definition ClpFactorization.hpp:350
ClpFactorization::goSparse
void goSparse()
makes a row copy of L for speed and to allow very sparse problems
ClpFactorization::saferTolerances
void saferTolerances(double zeroTolerance, double pivotTolerance)
Set tolerances to safer of existing and given.
ClpFactorization::permute
int * permute() const
Returns address of permute region.
Definition ClpFactorization.hpp:157
ClpFactorization::factorize
int factorize(ClpSimplex *model, int solveType, bool valuesPass)
When part of LP - given by basic variables.
ClpFactorization::networkBasis
bool networkBasis() const
Says if a network basis.
Definition ClpFactorization.hpp:498
ClpFactorization::setDenseThreshold
void setDenseThreshold(int value)
Sets dense threshold.
Definition ClpFactorization.hpp:335
ClpFactorization::pivotTolerance
double pivotTolerance() const
Pivot tolerance.
Definition ClpFactorization.hpp:341
ClpFactorization::shortestAverage_
double shortestAverage_
For guessing when to re-factorize.
Definition ClpFactorization.hpp:541
ClpFactorization::zeroTolerance
double zeroTolerance() const
Zero tolerance.
Definition ClpFactorization.hpp:211
ClpFactorization::status
int status() const
Returns status.
Definition ClpFactorization.hpp:243
ClpFactorization::updateTwoColumnsTranspose
void updateTwoColumnsTranspose(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, CoinIndexedVector *regionSparse3) const
Updates two columns (BTRAN) from regionSparse2 and 3 regionSparse starts as zero and is zero at end N...
ClpFactorization::forceB_
int forceB_
If nonzero force use of 1,dense 2,small 3,osl.
Definition ClpFactorization.hpp:531
ClpFactorization::networkBasis_
ClpNetworkBasis * networkBasis_
Pointer to network basis.
Definition ClpFactorization.hpp:519
ClpFactorization::needToReorder
bool needToReorder() const
Says whether to redo pivot order.
ClpFactorization::sparseThreshold
int sparseThreshold() const
get sparse threshold
Definition ClpFactorization.hpp:229
ClpFactorization::ClpFactorization
ClpFactorization(const CoinFactorization &)
The copy constructor from an CoinFactorization.
ClpFactorization::setPersistenceFlag
void setPersistenceFlag(int value)
Definition ClpFactorization.hpp:375
ClpFactorization::sparseThreshold
void sparseThreshold(int value)
Set sparse threshold.
Definition ClpFactorization.hpp:237
ClpFactorization::pivotColumn
int * pivotColumn() const
Returns address of pivotColumn region (also used for permuting).
Definition ClpFactorization.hpp:165
ClpFactorization::denseThreshold
int denseThreshold() const
Gets dense threshold.
Definition ClpFactorization.hpp:327
ClpFactorization::adjustedAreaFactor
double adjustedAreaFactor() const
Returns areaFactor but adjusted for dense.
Definition ClpFactorization.hpp:389
ClpFactorization::coinFactorizationB_
CoinOtherFactorization * coinFactorizationB_
Pointer to CoinOtherFactorization.
Definition ClpFactorization.hpp:525
ClpFactorization::numberElementsR
CoinBigIndex numberElementsR() const
Returns number in R area.
Definition ClpFactorization.hpp:284
ClpFactorization::coinFactorizationA_
CoinFactorization * coinFactorizationA_
Pointer to CoinFactorization.
Definition ClpFactorization.hpp:523
ClpFactorization::zeroTolerance
void zeroTolerance(double value)
Set zero tolerance.
Definition ClpFactorization.hpp:219
ClpFactorization::totalInR_
double totalInR_
Definition ClpFactorization.hpp:542
ClpFactorization::updateColumnForDebug
int updateColumnForDebug(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2, bool noPermute=false) const
For debug (no statistics update).
ClpFactorization::goOslThreshold
int goOslThreshold() const
Get switch to osl if number rows <= this.
Definition ClpFactorization.hpp:421
ClpFactorization::getWeights
void getWeights(int *weights) const
Fills weighted row list.
ClpFactorization::setGoDenseThreshold
void setGoDenseThreshold(int value)
Set switch to dense if number rows <= this.
Definition ClpFactorization.hpp:436
ClpFactorization::replaceColumn
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::~ClpFactorization
~ClpFactorization()
Destructor.
ClpFactorization::doStatistics_
bool doStatistics_
To switch statistics on or off.
Definition ClpFactorization.hpp:549
ClpFactorization::messageLevel
void messageLevel(int value)
Set level of detail of messages.
Definition ClpFactorization.hpp:305
ClpFactorization::updateColumnFT
int updateColumnFT(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2)
Updates one column (FTRAN) from region2 Tries to do FT update number returned is negative if no room ...
ClpFactorization::pivots
int pivots() const
Returns number of pivots since factorization.
Definition ClpFactorization.hpp:189
ClpFactorization::ClpFactorization
ClpFactorization(const ClpFactorization &, int denseIfSmaller=0)
The copy constructor.
ClpFactorization::effectiveStartNumberU_
int effectiveStartNumberU_
Definition ClpFactorization.hpp:546
ClpFactorization::timeToRefactorize
bool timeToRefactorize() const
ClpFactorization::messageLevel
int messageLevel() const
Level of detail of messages.
Definition ClpFactorization.hpp:297
ClpFactorization::lastNumberPivots_
int lastNumberPivots_
Definition ClpFactorization.hpp:545
ClpFactorization::numberElementsU
CoinBigIndex numberElementsU() const
Returns number in U area.
Definition ClpFactorization.hpp:268
ClpFactorization::almostDestructor
void almostDestructor()
Delete all stuff (leaves as after CoinFactorization()).
Definition ClpFactorization.hpp:381
ClpFactorization::relaxAccuracyCheck
void relaxAccuracyCheck(double value)
Allows change of pivot accuracy check 1.0 == none >1.0 relaxed.
Definition ClpFactorization.hpp:358
ClpFactorization::endLengthU_
int endLengthU_
Definition ClpFactorization.hpp:544
ClpFactorization::operator=
ClpFactorization & operator=(const ClpFactorization &)
ClpFactorization::setBiasLU
void setBiasLU(int value)
Definition ClpFactorization.hpp:396
ClpFactorization::isDenseOrSmall
int isDenseOrSmall() const
Return 1 if dense code.
Definition ClpFactorization.hpp:455
ClpFactorization::goDenseThreshold_
int goDenseThreshold_
Switch to dense if number rows <= this.
Definition ClpFactorization.hpp:537
ClpFactorization::numberElementsL
CoinBigIndex numberElementsL() const
Returns number in L area.
Definition ClpFactorization.hpp:276
ClpFactorization::updateColumnTranspose
int updateColumnTranspose(CoinIndexedVector *regionSparse, CoinIndexedVector *regionSparse2) const
Updates one column (BTRAN) from region2 region1 starts as zero and is zero at end.
ClpFactorization::setGoSmallThreshold
void setGoSmallThreshold(int value)
Set switch to small if number rows <= this.
Definition ClpFactorization.hpp:446
ClpFactorization::setGoOslThreshold
void setGoOslThreshold(int value)
Set switch to osl if number rows <= this.
Definition ClpFactorization.hpp:426
ClpFactorization::areaFactor
void areaFactor(double value)
Set whether larger areas needed.
Definition ClpFactorization.hpp:205
ClpFactorization::maximumPivots
int maximumPivots() const
Maximum number of pivots between factorizations.
Definition ClpFactorization.hpp:173
ClpFactorization::persistenceFlag
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...
Definition ClpFactorization.hpp:368
ClpFactorization::setFactorization
void setFactorization(ClpFactorization &factorization)
Sets factorization.
ClpFactorization::goSmallThreshold
int goSmallThreshold() const
Get switch to small if number rows <= this.
Definition ClpFactorization.hpp:441
ClpFactorization::goOslThreshold_
int goOslThreshold_
Switch to osl if number rows <= this.
Definition ClpFactorization.hpp:533
ClpFactorization::goDenseThreshold
int goDenseThreshold() const
Get switch to dense if number rows <= this.
Definition ClpFactorization.hpp:431
ClpFactorization::totalInIncreasingU_
double totalInIncreasingU_
Definition ClpFactorization.hpp:543
ClpFactorization::coinFactorization
CoinFactorization * coinFactorization() const
Return coinFactorizationA_.
Definition ClpFactorization.hpp:460
ClpFactorization::maximumPivots
void maximumPivots(int value)
Set maximum number of pivots between factorizations.
Definition ClpFactorization.hpp:181
ClpFactorization::clearArrays
void clearArrays()
Get rid of all memory.
Definition ClpFactorization.hpp:311
ClpFactorization::goDenseOrSmall
void goDenseOrSmall(int numberRows)
Go over to dense or small code if small enough.
ClpFactorization::numberRows
int numberRows() const
Number of Rows after factorization.
Definition ClpFactorization.hpp:319
ClpFactorization::ClpFactorization
ClpFactorization(const CoinOtherFactorization &)
The copy constructor from an CoinOtherFactorization.
ClpFactorization::setDefaultValues
void setDefaultValues()
Sets default values.
Definition ClpFactorization.hpp:408
ClpFactorization::setStatus
void setStatus(int value)
Sets status.
Definition ClpFactorization.hpp:251
ClpFactorization::cleanUp
void cleanUp()
Cleans up i.e. gets rid of network basis.
ClpFactorization::forceOtherFactorization
void forceOtherFactorization(int which)
If nonzero force use of 1,dense 2,small 3,osl.
ClpFactorization::areaFactor
double areaFactor() const
Whether larger areas needed.
Definition ClpFactorization.hpp:197
ClpFactorization::setForrestTomlin
void setForrestTomlin(bool value)
true if Forrest Tomlin update, false if PFI
Definition ClpFactorization.hpp:402
ClpFactorization::updateColumn
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::ClpFactorization
ClpFactorization()
Default constructor.
ClpFactorization::goSmallThreshold_
int goSmallThreshold_
Switch to small if number rows <= this.
Definition ClpFactorization.hpp:535
ClpMatrixBase
Abstract base class for Clp Matrices.
Definition ClpMatrixBase.hpp:38
ClpNetworkBasis
This deals with Factorization and Updates for network structures.
Definition ClpNetworkBasis.hpp:25
ClpSimplex
This solves LPs using the simplex method.
Definition ClpSimplex.hpp:106