LAMA
lama::Criterion Class Reference

The class Criterion is the base class for all stopping criterions that we can use on a Solver. More...

#include <Criterion.hpp>

Inheritance diagram for lama::Criterion:

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.
Criterionoperator= (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

Detailed Description

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 !.


Member Enumeration Documentation

Defines the operators which can be used to connect Criterions with.

Enumerator:
AND 

stands for logical and composition

OR 

stands for logical or composition


Constructor & Destructor Documentation

Creates a Criterion which evaluates to true.

lama::Criterion::Criterion ( const bool  boolean)

Creates a Criterion which evaluates to the passed boolean.

Parameters:
[in]booleanthe boolean to set the result of this boolean condition to.

Creates a copy of the passed boolean condition.

Parameters:
[in]otherthe 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.

Parameters:
[in]otherthe boolean condition to take a altered copy from
[in]modifierthe bool value to modify the new Criterion with.
lama::Criterion::Criterion ( const CriterionPtr  leftChild,
const CriterionPtr  rightChild,
BooleanOperator  operation 
)
Parameters:
Createsa new Criterion which the logical composition of the passed Criterions.
[in]leftChildthe left operand of the composition
[in]rightChildthe right operand of the composition
[in]operationthe logical operation to connect leftChild and rightChild with.

References LAMA_ASSERT_DEBUG.

Destroys this Criterion.


Member Function Documentation

References mLeftChild.

Referenced by writeAt().

References mRightChild.

Referenced by writeAt().

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().

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.

Parameters:
[in]solverthe solver to check the state of.
Returns:
if this Criterion is true for the state of solver.

Reimplemented in lama::ResidualThreshold, lama::ResidualStagnation, and lama::IterationCount.

References AND, hasLeftChild(), hasRightChild(), mLeftChild, mModifier, mOperation, and mRightChild.

Reimplemented in lama::IterationCount.

Criterion & lama::Criterion::operator= ( const Criterion other)

References mLeftChild, mOperation, and mRightChild.

void lama::Criterion::setLeftChild ( const CriterionPtr  leftChild)

References mLeftChild.

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.

Parameters:
[out]streamthe 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.


Field Documentation

const bool lama::Criterion::mModifier [private]

Referenced by isSatisfied(), and writeAt().


The documentation for this class was generated from the following files: