|
libDAI
|
Approximate inference algorithm "Tree-Reweighted Belief Propagation" [WJW03]. More...
#include <dai/trwbp.h>
Public Member Functions | |
Constructors/destructors | |
| TRWBP () | |
| Default constructor. | |
| TRWBP (const FactorGraph &fg, const PropertySet &opts) | |
| Construct from FactorGraph fg and PropertySet opts. | |
General InfAlg interface | |
| virtual TRWBP * | clone () const |
Returns a pointer to a new, cloned copy of *this (i.e., virtual copy constructor) | |
| virtual TRWBP * | 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 Real | logZ () const |
| Returns the logarithm of the (approximated) partition sum (normalizing constant of the factor graph). | |
| virtual void | setProperties (const PropertySet &opts) |
| 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 | |
| size_t | nrtrees |
| Size of sample of trees used to set the weights. | |
Protected Attributes | |
| std::vector< Real > | _weight |
| "Edge weights" (indexed by factor ID) | |
TRWBP accessors/mutators for scale parameters | |
| Real | Weight (size_t I) const |
| Returns weight corresponding to the I 'th factor. | |
| const std::vector< Real > & | Weights () const |
| Returns constant reference to vector of all weights. | |
| void | setWeight (size_t I, Real c) |
| Sets the weight of the I 'th factor to c. | |
| void | setWeights (const std::vector< Real > &c) |
| Sets the weights of all factors simultaenously. | |
| void | addTreeToWeights (const RootedTree &tree) |
| Increases weights corresponding to pairwise factors in tree with 1. | |
| void | sampleWeights (size_t nrTrees) |
| Samples weights from a sample of nrTrees random spanning trees. | |
| virtual Prob | calcIncomingMessageProduct (size_t I, bool without_i, size_t i) const |
| Calculate the product of factor I and the incoming messages. | |
| virtual void | calcBeliefV (size_t i, Prob &p) const |
| Calculates unnormalized belief of variable i. | |
| virtual void | calcBeliefF (size_t I, Prob &p) const |
| Calculates unnormalized belief of factor I. | |
| virtual void | construct () |
| Helper function for constructors. | |
Approximate inference algorithm "Tree-Reweighted Belief Propagation" [WJW03].
The Tree-Reweighted Belief Propagation algorithm is like Belief Propagation, but associates each factor with a scale parameter. which controls the divergence measure being minimized.
The messages
are passed from factors
to variables
. The update equation is given by:
After convergence, the variable beliefs are calculated by:
and the factor beliefs are calculated by:
The logarithm of the partition sum is approximated by:
where the variable weights are defined as
| dai::TRWBP::TRWBP | ( | ) | [inline] |
Default constructor.
| dai::TRWBP::TRWBP | ( | const FactorGraph & | fg, |
| const PropertySet & | opts | ||
| ) | [inline] |
Construct from FactorGraph fg and PropertySet opts.
There is an additional property "nrtrees" which allows to specify the number of random spanning trees used to set the scale parameters.
| fg | Factor graph. |
| opts | Parameters |
| virtual TRWBP* dai::TRWBP::clone | ( | ) | const [inline, virtual] |
Returns a pointer to a new, cloned copy of *this (i.e., virtual copy constructor)
Reimplemented from dai::BP.
| virtual TRWBP* dai::TRWBP::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; |
Reimplemented from dai::BP.
| virtual std::string dai::TRWBP::name | ( | ) | const [inline, virtual] |
Returns the name of the algorithm.
Reimplemented from dai::BP.
| Real dai::TRWBP::logZ | ( | ) | const [virtual] |
| void dai::TRWBP::setProperties | ( | const PropertySet & | opts | ) | [virtual] |
| PropertySet dai::TRWBP::getProperties | ( | ) | const [virtual] |
Returns parameters of this inference algorithm converted into a PropertySet.
Reimplemented from dai::BP.
| string dai::TRWBP::printProperties | ( | ) | const [virtual] |
Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]".
Reimplemented from dai::BP.
| Real dai::TRWBP::Weight | ( | size_t | I | ) | const [inline] |
Returns weight corresponding to the I 'th factor.
| const std::vector<Real>& dai::TRWBP::Weights | ( | ) | const [inline] |
Returns constant reference to vector of all weights.
| void dai::TRWBP::setWeight | ( | size_t | I, |
| Real | c | ||
| ) | [inline] |
Sets the weight of the I 'th factor to c.
| void dai::TRWBP::setWeights | ( | const std::vector< Real > & | c | ) | [inline] |
Sets the weights of all factors simultaenously.
| void dai::TRWBP::addTreeToWeights | ( | const RootedTree & | tree | ) |
Increases weights corresponding to pairwise factors in tree with 1.
| void dai::TRWBP::sampleWeights | ( | size_t | nrTrees | ) |
Samples weights from a sample of nrTrees random spanning trees.
| Prob dai::TRWBP::calcIncomingMessageProduct | ( | size_t | I, |
| bool | without_i, | ||
| size_t | i | ||
| ) | const [protected, virtual] |
Calculate the product of factor I and the incoming messages.
If without_i == true, the message coming from variable i is omitted from the product
Reimplemented from dai::BP.
| void dai::TRWBP::calcBeliefV | ( | size_t | i, |
| Prob & | p | ||
| ) | const [protected, virtual] |
Calculates unnormalized belief of variable i.
Reimplemented from dai::BP.
| virtual void dai::TRWBP::calcBeliefF | ( | size_t | I, |
| Prob & | p | ||
| ) | const [inline, protected, virtual] |
Calculates unnormalized belief of factor I.
Reimplemented from dai::BP.
| void dai::TRWBP::construct | ( | ) | [protected, virtual] |
Helper function for constructors.
Reimplemented from dai::BP.
std::vector<Real> dai::TRWBP::_weight [protected] |
| size_t dai::TRWBP::nrtrees |
Size of sample of trees used to set the weights.
1.7.4