LAMA
|
The class Criterion is the base class for all stopping criterions that we can use on a Solver. More...
#include <Criterion.hpp>
Public Types | |
enum | BooleanOperator { AND, OR } |
Defines the operators which can be used to connect Criterions with. More... | |
Public Member Functions | |
Criterion () | |
Creates a Criterion which evaluates to true. | |
Criterion (const bool boolean) | |
Creates a Criterion which evaluates to the passed boolean. | |
Criterion (const Criterion &other) | |
Creates a copy of the passed boolean condition. | |
Criterion (const CriterionPtr other, const bool modifier) | |
Creates a copy of the passed Criterion, which is altered by the passed modifier. | |
Criterion (const CriterionPtr leftChild, const CriterionPtr rightChild, BooleanOperator operation) | |
virtual | ~Criterion () |
Destroys this Criterion. | |
virtual bool | isSatisfied (const IterativeSolver &solver) |
Checks if this Criterion is true for the state of the passed solver. | |
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. | |
Criterion & | operator= (const Criterion &other) |
virtual void | writeAt (std::ostream &stream) const |
Writes some Information about this to the passed stream. | |
Protected Member Functions | |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
Private Attributes | |
CriterionPtr | mLeftChild |
CriterionPtr | mRightChild |
BooleanOperator | mOperation |
const bool | mModifier |
The class Criterion is the base class for all stopping criterions that we can use on a Solver.
Criterion can be composed with the logical operators &&, ||, and !.
Creates a Criterion which evaluates to true.
lama::Criterion::Criterion | ( | const bool | boolean | ) |
Creates a Criterion which evaluates to the passed boolean.
[in] | boolean | the boolean to set the result of this boolean condition to. |
lama::Criterion::Criterion | ( | const Criterion & | other | ) |
Creates a copy of the passed boolean condition.
[in] | other | the boolean condition to copy. |
lama::Criterion::Criterion | ( | const CriterionPtr | other, |
const bool | modifier | ||
) |
Creates a copy of the passed Criterion, which is altered by the passed modifier.
Creates a copy of the passed Criterion, which is altered by the passed modifier. The new Criterion behaves like
other.isSatisfied() != modifier
which is equivalent to other.isSatisfied() XOR modifier.
[in] | other | the boolean condition to take a altered copy from |
[in] | modifier | the bool value to modify the new Criterion with. |
lama::Criterion::Criterion | ( | const CriterionPtr | leftChild, |
const CriterionPtr | rightChild, | ||
BooleanOperator | operation | ||
) |
Creates | a new Criterion which the logical composition of the passed Criterions. | |
[in] | leftChild | the left operand of the composition |
[in] | rightChild | the right operand of the composition |
[in] | operation | the logical operation to connect leftChild and rightChild with. |
References LAMA_ASSERT_DEBUG.
lama::Criterion::~Criterion | ( | ) | [virtual] |
Destroys this Criterion.
const CriterionPtr lama::Criterion::getLeftChild | ( | ) | const |
References mLeftChild.
Referenced by writeAt().
References mOperation.
Referenced by writeAt().
const CriterionPtr lama::Criterion::getRightChild | ( | ) | const |
References mRightChild.
Referenced by writeAt().
bool lama::Criterion::hasLeftChild | ( | ) | const |
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 mLeftChild.
Referenced by isSatisfied(), and writeAt().
bool lama::Criterion::hasRightChild | ( | ) | const |
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 mRightChild.
Referenced by isSatisfied(), and writeAt().
bool lama::Criterion::isSatisfied | ( | const IterativeSolver & | solver | ) | [virtual] |
Checks if this Criterion is true for the state of the passed solver.
[in] | solver | the solver to check the state of. |
Reimplemented in lama::ResidualThreshold, lama::ResidualStagnation, and lama::IterationCount.
References AND, hasLeftChild(), hasRightChild(), mLeftChild, mModifier, mOperation, and mRightChild.
lama::Criterion::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [protected] |
Reimplemented in lama::IterationCount.
References mLeftChild, mOperation, and mRightChild.
void lama::Criterion::setLeftChild | ( | const CriterionPtr | leftChild | ) |
References mLeftChild.
void lama::Criterion::setOperation | ( | const BooleanOperator | operation | ) |
References mOperation.
void lama::Criterion::setRightChild | ( | const CriterionPtr | rightChild | ) |
References mRightChild.
void lama::Criterion::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 Printable.
Reimplemented in lama::ResidualStagnation, lama::ResidualThreshold, and lama::IterationCount.
References AND, getLeftChild(), getOperation(), getRightChild(), hasLeftChild(), hasRightChild(), and mModifier.
CriterionPtr lama::Criterion::mLeftChild [private] |
Referenced by getLeftChild(), hasLeftChild(), isSatisfied(), operator=(), and setLeftChild().
const bool lama::Criterion::mModifier [private] |
Referenced by isSatisfied(), and writeAt().
BooleanOperator lama::Criterion::mOperation [private] |
Referenced by getOperation(), isSatisfied(), operator=(), and setOperation().
CriterionPtr lama::Criterion::mRightChild [private] |
Referenced by getRightChild(), hasRightChild(), isSatisfied(), operator=(), and setRightChild().