LAMA
|
Stagnation stopping criterion. More...
#include <ResidualStagnation.hpp>
Public Types | |
enum | BooleanOperator { AND, OR } |
Defines the operators which can be used to connect Criterions with. More... | |
Public Member Functions | |
ResidualStagnation (NormPtr norm) | |
Creates a new Stagnation based stopping criterion. | |
ResidualStagnation (NormPtr norm, IndexType lookback, Scalar precision) | |
Creates a new Stagnation based stopping criterion. | |
ResidualStagnation (const ResidualStagnation &other) | |
virtual | ~ResidualStagnation () |
virtual Criterion * | copy () const |
virtual bool | isSatisfied (const IterativeSolver &solver) |
Checks if the criterion is satisfied. | |
IndexType | getLookback () const |
Gets the amount of calculations used for the criterion check. | |
const NormPtr | getNorm () const |
Gets the Norm which the criterion uses for the check. | |
const Scalar | getPrecision () const |
Returns the precision for floating point number calculations related to the Norm. | |
void | setLookback (const IndexType lookback) |
Sets the amount of calculations used for the criterion check. | |
void | setPrecision (const Scalar precision) |
Sets the precision for floating point number calculations related to the Norm. | |
virtual void | writeAt (std::ostream &stream) const |
Writes some Information about this to the passed stream. | |
const CriterionPtr | getLeftChild () const |
const CriterionPtr | getRightChild () const |
BooleanOperator | getOperation () const |
void | setLeftChild (const CriterionPtr leftChild) |
void | setRightChild (const CriterionPtr rightChild) |
void | setOperation (const BooleanOperator operation) |
bool | hasLeftChild () const |
Returns true if the boolean condition has a left child Do not use getLeftChild() to compare pointers. | |
bool | hasRightChild () const |
Returns true if the boolean condition has a right child Do not use getRightChild() to compare pointers. | |
Protected Member Functions | |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
Private Attributes | |
const NormPtr | mNorm |
The norm used in the residual-norm-calculation. | |
IndexType | mLookback |
The amount of calculations used for the criterion check. | |
std::vector< Scalar > | mLastResidualNorms |
Stores the results of the residual-norm-calculations. | |
IndexType | mNextEntry |
Index. | |
bool | mEntriesReady |
Used to check, if enough data have been gathered to check the criterion. | |
Scalar | mPrecision |
The precision used for the stagnation check. |
Stagnation stopping criterion.
IterativeSolver | The type solver in which this criterion is used. Most commonly this is the abstract sblas::IterativeSolver type. |
enum lama::Criterion::BooleanOperator [inherited] |
Creates a new Stagnation based stopping criterion.
norm | The norm which shall be used to check the criterion. Has to be compatible with the Matrix/Vector types of the solver. |
Referenced by copy().
lama::ResidualStagnation::ResidualStagnation | ( | NormPtr | norm, |
IndexType | lookback, | ||
Scalar | precision | ||
) |
Creates a new Stagnation based stopping criterion.
norm | The norm which shall be used to check the criterion. Has to be compatible with the Matrix/Vector types of the solver. |
lookback | The amount of residual-norm-calculation results used for the criterion check. |
lama::ResidualStagnation::ResidualStagnation | ( | const ResidualStagnation & | other | ) |
lama::ResidualStagnation::~ResidualStagnation | ( | ) | [virtual] |
Criterion * lama::ResidualStagnation::copy | ( | ) | const [virtual] |
References ResidualStagnation().
const CriterionPtr lama::Criterion::getLeftChild | ( | ) | const [inherited] |
References lama::Criterion::mLeftChild.
Referenced by lama::Criterion::writeAt().
int lama::ResidualStagnation::getLookback | ( | ) | const |
const NormPtr lama::ResidualStagnation::getNorm | ( | ) | const |
Criterion::BooleanOperator lama::Criterion::getOperation | ( | ) | const [inherited] |
References lama::Criterion::mOperation.
Referenced by lama::Criterion::writeAt().
const Scalar lama::ResidualStagnation::getPrecision | ( | ) | const |
Returns the precision for floating point number calculations related to the Norm.
References mPrecision.
Referenced by writeAt().
const CriterionPtr lama::Criterion::getRightChild | ( | ) | const [inherited] |
References lama::Criterion::mRightChild.
Referenced by lama::Criterion::writeAt().
bool lama::Criterion::hasLeftChild | ( | ) | const [inherited] |
Returns true if the boolean condition has a left child Do not use getLeftChild() to compare pointers.
Logical operations are overwritten
return Returns true if the boolean condition has a left child. If pointer is not set: false
References lama::Criterion::mLeftChild.
Referenced by lama::Criterion::isSatisfied(), and lama::Criterion::writeAt().
bool lama::Criterion::hasRightChild | ( | ) | const [inherited] |
Returns true if the boolean condition has a right child Do not use getRightChild() to compare pointers.
Logical operations are overwritten
return Returns true if the boolean condition has a right child. If pointer is not set: false
References lama::Criterion::mRightChild.
Referenced by lama::Criterion::isSatisfied(), and lama::Criterion::writeAt().
bool lama::ResidualStagnation::isSatisfied | ( | const IterativeSolver & | solver | ) | [virtual] |
Checks if the criterion is satisfied.
The Stagnation criterion needs a certain amount (specified by m_lookback) to be able to perform the check. If this method is called and not enough data has been gathered, false is returned. Anyhow the norm of the residual is calculated and stored. This process continues, until enough data has been gathered.
solver | The solver which calls this method. Needed for residual computation. |
Reimplemented from lama::Criterion.
References lama::Solver::getResidual(), lama::max(), mEntriesReady, lama::min(), mLastResidualNorms, mLookback, mNextEntry, and mPrecision.
lama::Criterion::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [protected, inherited] |
Reimplemented in lama::IterationCount.
void lama::Criterion::setLeftChild | ( | const CriterionPtr | leftChild | ) | [inherited] |
References lama::Criterion::mLeftChild.
void lama::ResidualStagnation::setLookback | ( | const IndexType | lookback | ) |
Sets the amount of calculations used for the criterion check.
References mLookback.
void lama::Criterion::setOperation | ( | const BooleanOperator | operation | ) | [inherited] |
References lama::Criterion::mOperation.
void lama::ResidualStagnation::setPrecision | ( | const Scalar | precision | ) |
Sets the precision for floating point number calculations related to the Norm.
precision | The precision given in a Scalar object. |
References mPrecision.
void lama::Criterion::setRightChild | ( | const CriterionPtr | rightChild | ) | [inherited] |
References lama::Criterion::mRightChild.
void lama::ResidualStagnation::writeAt | ( | std::ostream & | stream | ) | const [virtual] |
Writes some Information about this to the passed stream.
If a deriving class does not overrides writeAt, typeid(this).name() is written to stream.
[out] | stream | the stream to write to. |
Reimplemented from lama::Criterion.
References getLookback(), and getPrecision().
bool lama::ResidualStagnation::mEntriesReady [private] |
Used to check, if enough data have been gathered to check the criterion.
Referenced by isSatisfied().
std::vector<Scalar> lama::ResidualStagnation::mLastResidualNorms [private] |
Stores the results of the residual-norm-calculations.
Referenced by isSatisfied().
IndexType lama::ResidualStagnation::mLookback [private] |
The amount of calculations used for the criterion check.
Referenced by getLookback(), isSatisfied(), and setLookback().
const NormPtr lama::ResidualStagnation::mNorm [private] |
The norm used in the residual-norm-calculation.
Referenced by getNorm().
Scalar lama::ResidualStagnation::mPrecision [private] |
The precision used for the stagnation check.
Referenced by getPrecision(), isSatisfied(), and setPrecision().