|
libDAI
|
Approximate inference algorithm DecMAP, which constructs a MAP state by decimation. More...
#include <dai/decmap.h>
Classes | |
| struct | Properties |
| Parameters for DecMAP. More... | |
Public Member Functions | |
| DecMAP () | |
| Default constructor. | |
| DecMAP (const FactorGraph &fg, const PropertySet &opts) | |
| Construct from FactorGraph fg and PropertySet opts. | |
General InfAlg interface | |
| virtual DecMAP * | clone () const |
Returns a pointer to a new, cloned copy of *this (i.e., virtual copy constructor) | |
| virtual DecMAP * | construct (const FactorGraph &fg, const PropertySet &opts) const |
| Returns a pointer to a newly constructed inference algorithm. | |
| virtual std::string | name () const |
| Returns the name of the algorithm. | |
| virtual Factor | belief (const Var &v) const |
| Returns the (approximate) marginal probability distribution of a variable. | |
| virtual Factor | belief (const VarSet &) const |
| 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 |
| Returns all beliefs (approximate marginal probability distributions) calculated by the algorithm. | |
| virtual Real | logZ () const |
| Returns the logarithm of the (approximated) partition sum (normalizing constant of the factor graph). | |
| virtual std::vector< size_t > | findMaximum () const |
| Calculates the joint state of all variables that has maximum probability. | |
| virtual void | init () |
| Initializes all data structures of the approximate inference algorithm. | |
| virtual void | init (const VarSet &) |
| Initializes all data structures corresponding to some set of variables. | |
| virtual Real | run () |
| Runs the approximate inference algorithm. | |
| 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 | setProperties (const PropertySet &opts) |
| Set parameters of this inference algorithm. | |
| virtual PropertySet | getProperties () const |
| Returns parameters of this inference algorithm converted into a PropertySet. | |
| virtual std::string | printProperties () const |
| Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]". | |
Public Attributes | |
| struct dai::DecMAP::Properties | props |
Private Attributes | |
| std::vector< size_t > | _state |
| Stores the final MAP state. | |
| Real | _logp |
| Stores the log probability of the MAP state. | |
| Real | _maxdiff |
| Maximum difference encountered so far. | |
| size_t | _iters |
| Number of iterations needed. | |
Approximate inference algorithm DecMAP, which constructs a MAP state by decimation.
Decimation involves repeating the following two steps until no free variables remain:
| dai::DecMAP::DecMAP | ( | ) | [inline] |
Default constructor.
| dai::DecMAP::DecMAP | ( | const FactorGraph & | fg, |
| const PropertySet & | opts | ||
| ) |
Construct from FactorGraph fg and PropertySet opts.
| fg | Factor graph. |
| opts | Parameters |
| virtual DecMAP* dai::DecMAP::clone | ( | ) | const [inline, virtual] |
Returns a pointer to a new, cloned copy of *this (i.e., virtual copy constructor)
Implements dai::InfAlg.
| virtual DecMAP* dai::DecMAP::construct | ( | const FactorGraph & | fg, |
| const PropertySet & | opts | ||
| ) | const [inline, virtual] |
Returns a pointer to a newly constructed inference algorithm.
| fg | Factor graph on which to perform the inference algorithm; |
| opts | Parameters passed to constructor of inference algorithm; |
Implements dai::InfAlg.
| virtual std::string dai::DecMAP::name | ( | ) | const [inline, virtual] |
Returns the name of the algorithm.
Implements dai::InfAlg.
Returns the (approximate) marginal probability distribution of a variable.
Reimplemented from dai::InfAlg.
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. |
Implements dai::InfAlg.
| Factor dai::DecMAP::beliefV | ( | size_t | i | ) | const [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 from dai::InfAlg.
| virtual Factor dai::DecMAP::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 from dai::InfAlg.
| vector< Factor > dai::DecMAP::beliefs | ( | ) | const [virtual] |
Returns all beliefs (approximate marginal probability distributions) calculated by the algorithm.
Implements dai::InfAlg.
| virtual Real dai::DecMAP::logZ | ( | ) | const [inline, virtual] |
Returns the logarithm of the (approximated) partition sum (normalizing constant of the factor graph).
| NOT_IMPLEMENTED | if not implemented/supported |
Implements dai::InfAlg.
| virtual std::vector<size_t> dai::DecMAP::findMaximum | ( | ) | const [inline, virtual] |
Calculates the joint state of all variables that has maximum probability.
| NOT_IMPLEMENTED | if not implemented/supported |
Reimplemented from dai::InfAlg.
| virtual void dai::DecMAP::init | ( | ) | [inline, virtual] |
Initializes all data structures of the approximate inference algorithm.
Implements dai::InfAlg.
| virtual void dai::DecMAP::init | ( | const VarSet & | vs | ) | [inline, 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 |
Implements dai::InfAlg.
| Real dai::DecMAP::run | ( | ) | [virtual] |
| virtual Real dai::DecMAP::maxDiff | ( | ) | const [inline, virtual] |
Returns maximum difference between single variable beliefs in the last iteration.
| NOT_IMPLEMENTED | if not implemented/supported |
Reimplemented from dai::InfAlg.
| virtual size_t dai::DecMAP::Iterations | ( | ) | const [inline, virtual] |
Returns number of iterations done (one iteration passes over the complete factorgraph).
| NOT_IMPLEMENTED | if not implemented/supported |
Reimplemented from dai::InfAlg.
| void dai::DecMAP::setProperties | ( | const PropertySet & | opts | ) | [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.
Implements dai::InfAlg.
| PropertySet dai::DecMAP::getProperties | ( | ) | const [virtual] |
Returns parameters of this inference algorithm converted into a PropertySet.
Implements dai::InfAlg.
| string dai::DecMAP::printProperties | ( | ) | const [virtual] |
Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]".
Implements dai::InfAlg.
std::vector<size_t> dai::DecMAP::_state [private] |
Stores the final MAP state.
Real dai::DecMAP::_logp [private] |
Stores the log probability of the MAP state.
Real dai::DecMAP::_maxdiff [private] |
Maximum difference encountered so far.
size_t dai::DecMAP::_iters [private] |
Number of iterations needed.
1.7.4