#include <dai/daialg.h>
Public Member Functions | |
Constructors/destructors | |
virtual | ~InfAlg () |
Virtual destructor (needed because this class contains virtual functions). | |
virtual InfAlg * | clone () const =0 |
Returns a pointer to a new, cloned copy of *this (i.e., virtual copy constructor). | |
Queries | |
virtual std::string | identify () const =0 |
Identifies itself for logging purposes. | |
virtual FactorGraph & | fg ()=0 |
Returns reference to underlying FactorGraph. | |
virtual const FactorGraph & | fg () const =0 |
Returns constant reference to underlying FactorGraph. | |
Inference interface | |
virtual void | init ()=0 |
Initializes all data structures of the approximate inference algorithm. | |
virtual void | init (const VarSet &vs)=0 |
Initializes all data structures corresponding to some set of variables. | |
virtual Real | run ()=0 |
Runs the approximate inference algorithm. | |
virtual Factor | belief (const Var &v) const |
Returns the (approximate) marginal probability distribution of a variable. | |
virtual Factor | belief (const VarSet &vs) const =0 |
Returns the (approximate) marginal probability distribution of a set of variables. | |
virtual Factor | beliefV (size_t i) const |
Returns the (approximate) marginal probability distribution of the variable with index i. | |
virtual Factor | beliefF (size_t I) const |
Returns the (approximate) marginal probability distribution of the variables on which factor I depends. | |
virtual std::vector< Factor > | beliefs () const =0 |
Returns all beliefs (approximate marginal probability distributions) calculated by the algorithm. | |
virtual Real | logZ () const =0 |
Returns the logarithm of the (approximated) partition sum (normalizing constant of the factor graph). | |
virtual std::vector< std::size_t > | findMaximum () const |
Calculates the joint state of all variables that has maximum probability. | |
virtual Real | maxDiff () const |
Returns maximum difference between single variable beliefs in the last iteration. | |
virtual size_t | Iterations () const |
Returns number of iterations done (one iteration passes over the complete factorgraph). | |
virtual void | setMaxIter (size_t) |
Sets maximum number of iterations (one iteration passes over the complete factorgraph). | |
Changing the factor graph | |
virtual void | clamp (size_t i, size_t x, bool backup=false)=0 |
Clamp variable with index i to value x (i.e. multiply with a Kronecker delta ![]() | |
virtual void | makeCavity (size_t i, bool backup=false)=0 |
Sets all factors interacting with variable with index i to one. | |
Backup/restore mechanism for factors | |
virtual void | backupFactor (size_t I)=0 |
Make a backup copy of factor I. | |
virtual void | backupFactors (const VarSet &vs)=0 |
Make backup copies of all factors involving the variables in vs. | |
virtual void | restoreFactor (size_t I)=0 |
Restore factor I from its backup copy. | |
virtual void | restoreFactors (const VarSet &vs)=0 |
Restore the factors involving the variables in vs from their backup copies. | |
Managing parameters | |
virtual void | setProperties (const PropertySet &opts)=0 |
Set parameters of this inference algorithm. | |
virtual PropertySet | getProperties () const =0 |
Returns parameters of this inference algorithm converted into a PropertySet. | |
virtual std::string | printProperties () const =0 |
Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]". |
example_imagesegmentation.cpp, example_sprinkler_em.cpp, and uai2010-aie-solver.cpp.
virtual dai::InfAlg::~InfAlg | ( | ) | [inline, virtual] |
Virtual destructor (needed because this class contains virtual functions).
virtual InfAlg* dai::InfAlg::clone | ( | ) | const [pure virtual] |
Returns a pointer to a new, cloned copy of *this
(i.e., virtual copy constructor).
Implemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::FBP, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, dai::MR, dai::TreeEP, and dai::TRWBP.
virtual std::string dai::InfAlg::identify | ( | ) | const [pure virtual] |
Identifies itself for logging purposes.
Implemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::FBP, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, dai::MR, dai::TreeEP, and dai::TRWBP.
virtual FactorGraph& dai::InfAlg::fg | ( | ) | [pure virtual] |
Returns reference to underlying FactorGraph.
Implemented in dai::DAIAlg< GRM >, dai::DAIAlg< dai::RegionGraph >, and dai::DAIAlg< dai::FactorGraph >.
virtual const FactorGraph& dai::InfAlg::fg | ( | ) | const [pure virtual] |
Returns constant reference to underlying FactorGraph.
Implemented in dai::DAIAlg< GRM >, dai::DAIAlg< dai::RegionGraph >, and dai::DAIAlg< dai::FactorGraph >.
virtual void dai::InfAlg::init | ( | ) | [pure virtual] |
Initializes all data structures of the approximate inference algorithm.
Implemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, dai::MR, and dai::TreeEP.
virtual void dai::InfAlg::init | ( | const VarSet & | vs | ) | [pure virtual] |
Initializes all data structures corresponding to some set of variables.
This method can be used to do a partial initialization after a part of the factor graph has changed. Instead of initializing all data structures, it only initializes those involving the variables in vs.
NOT_IMPLEMENTED | if not implemented/supported |
Implemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, dai::MR, and dai::TreeEP.
virtual Real dai::InfAlg::run | ( | ) | [pure virtual] |
Runs the approximate inference algorithm.
Implemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, dai::MR, and dai::TreeEP.
Returns the (approximate) marginal probability distribution of a variable.
Reimplemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::Gibbs, dai::LC, dai::MF, and dai::MR.
Returns the (approximate) marginal probability distribution of a set of variables.
NOT_IMPLEMENTED | if not implemented/supported. | |
BELIEF_NOT_AVAILABLE | if the requested belief cannot be calculated with this algorithm. |
Implemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, and dai::MR.
virtual Factor dai::InfAlg::beliefV | ( | size_t | i | ) | const [inline, virtual] |
Returns the (approximate) marginal probability distribution of the variable with index i.
For some approximate inference algorithms, using beliefV() is preferred to belief() for performance reasons.
Reimplemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::Gibbs, dai::LC, dai::MF, and dai::MR.
virtual Factor dai::InfAlg::beliefF | ( | size_t | I | ) | const [inline, virtual] |
Returns the (approximate) marginal probability distribution of the variables on which factor I depends.
For some approximate inference algorithms, using beliefF() is preferred to belief() for performance reasons.
Reimplemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, and dai::Gibbs.
virtual std::vector<Factor> dai::InfAlg::beliefs | ( | ) | const [pure virtual] |
Returns all beliefs (approximate marginal probability distributions) calculated by the algorithm.
Implemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, and dai::MR.
virtual Real dai::InfAlg::logZ | ( | ) | const [pure virtual] |
Returns the logarithm of the (approximated) partition sum (normalizing constant of the factor graph).
NOT_IMPLEMENTED | if not implemented/supported |
Implemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::FBP, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, dai::MR, dai::TreeEP, and dai::TRWBP.
virtual std::vector<std::size_t> dai::InfAlg::findMaximum | ( | ) | const [inline, virtual] |
Calculates the joint state of all variables that has maximum probability.
NOT_IMPLEMENTED | if not implemented/supported |
Reimplemented in dai::BP, dai::DecMAP, dai::ExactInf, dai::Gibbs, and dai::JTree.
virtual Real dai::InfAlg::maxDiff | ( | ) | const [inline, virtual] |
Returns maximum difference between single variable beliefs in the last iteration.
NOT_IMPLEMENTED | if not implemented/supported |
Reimplemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, dai::MR, and dai::TreeEP.
virtual size_t dai::InfAlg::Iterations | ( | ) | const [inline, virtual] |
Returns number of iterations done (one iteration passes over the complete factorgraph).
NOT_IMPLEMENTED | if not implemented/supported |
Reimplemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, dai::MR, and dai::TreeEP.
virtual void dai::InfAlg::setMaxIter | ( | size_t | ) | [inline, virtual] |
Sets maximum number of iterations (one iteration passes over the complete factorgraph).
NOT_IMPLEMENTED | if not implemented/supported |
Reimplemented in dai::BP, dai::CBP, dai::Gibbs, dai::HAK, dai::LC, dai::MF, and dai::TreeEP.
virtual void dai::InfAlg::clamp | ( | size_t | i, | |
size_t | x, | |||
bool | backup = false | |||
) | [pure virtual] |
Clamp variable with index i to value x (i.e. multiply with a Kronecker delta ).
If backup == true
, make a backup of all factors that are changed.
Implemented in dai::DAIAlg< GRM >, dai::DAIAlg< dai::RegionGraph >, and dai::DAIAlg< dai::FactorGraph >.
virtual void dai::InfAlg::makeCavity | ( | size_t | i, | |
bool | backup = false | |||
) | [pure virtual] |
Sets all factors interacting with variable with index i to one.
If backup == true
, make a backup of all factors that are changed.
Implemented in dai::DAIAlg< GRM >, dai::DAIAlg< dai::RegionGraph >, and dai::DAIAlg< dai::FactorGraph >.
virtual void dai::InfAlg::backupFactor | ( | size_t | I | ) | [pure virtual] |
Make a backup copy of factor I.
MULTIPLE_UNDO | if a backup already exists |
Implemented in dai::DAIAlg< GRM >, dai::DAIAlg< dai::RegionGraph >, and dai::DAIAlg< dai::FactorGraph >.
virtual void dai::InfAlg::backupFactors | ( | const VarSet & | vs | ) | [pure virtual] |
Make backup copies of all factors involving the variables in vs.
MULTIPLE_UNDO | if a backup already exists |
Implemented in dai::DAIAlg< GRM >, dai::DAIAlg< dai::RegionGraph >, and dai::DAIAlg< dai::FactorGraph >.
virtual void dai::InfAlg::restoreFactor | ( | size_t | I | ) | [pure virtual] |
Restore factor I from its backup copy.
Implemented in dai::DAIAlg< GRM >, dai::DAIAlg< dai::RegionGraph >, and dai::DAIAlg< dai::FactorGraph >.
virtual void dai::InfAlg::restoreFactors | ( | const VarSet & | vs | ) | [pure virtual] |
Restore the factors involving the variables in vs from their backup copies.
Implemented in dai::DAIAlg< GRM >, dai::DAIAlg< dai::RegionGraph >, and dai::DAIAlg< dai::FactorGraph >.
virtual void dai::InfAlg::setProperties | ( | const PropertySet & | opts | ) | [pure virtual] |
Set parameters of this inference algorithm.
The parameters are set according to the PropertySet opts. The values can be stored either as std::string or as the type of the corresponding MF::props member.
Implemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, dai::MR, dai::TreeEP, and dai::TRWBP.
virtual PropertySet dai::InfAlg::getProperties | ( | ) | const [pure virtual] |
Returns parameters of this inference algorithm converted into a PropertySet.
Implemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, dai::MR, dai::TreeEP, and dai::TRWBP.
virtual std::string dai::InfAlg::printProperties | ( | ) | const [pure virtual] |
Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]".
Implemented in dai::BP, dai::CBP, dai::DecMAP, dai::ExactInf, dai::Gibbs, dai::HAK, dai::JTree, dai::LC, dai::MF, dai::MR, dai::TreeEP, and dai::TRWBP.