#include <dai/lc.h>
Public Member Functions | |
LC () | |
Default constructor. | |
LC (const FactorGraph &fg, const PropertySet &opts) | |
Construct from FactorGraph fg and PropertySet opts. | |
General InfAlg interface | |
virtual LC * | clone () const |
Returns a pointer to a new, cloned copy of *this (i.e., virtual copy constructor). | |
virtual std::string | identify () const |
Identifies itself for logging purposes. | |
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 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 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 | setMaxIter (size_t maxiter) |
Sets maximum number of iterations (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]". | |
Additional interface specific for LC | |
Real | CalcCavityDist (size_t i, const std::string &name, const PropertySet &opts) |
Approximates the cavity distribution of variable i, using the inference algorithm name with parameters opts. | |
Real | InitCavityDists (const std::string &name, const PropertySet &opts) |
Approximates all cavity distributions using inference algorithm name with parameters opts. | |
long | SetCavityDists (std::vector< Factor > &Q) |
Sets approximate cavity distributions to Q. | |
Factor | NewPancake (size_t i, size_t _I, bool &hasNaNs) |
Updates the belief of the Markov blanket of variable i based upon the information from its _I 'th neighboring factor. | |
void | CalcBelief (size_t i) |
Calculates the belief of variable i. | |
const Factor & | pancake (size_t i) const |
Returns the belief of the Markov blanket of variable i (including the variable itself). | |
const Factor & | cavitydist (size_t i) const |
Returns the approximate cavity distribution for variable i. | |
Public Attributes | |
struct dai::LC::Properties | props |
Static Public Attributes | |
static const char * | Name = "LC" |
Name of this inference algorithm. | |
Private Attributes | |
std::vector< Factor > | _pancakes |
Stores for each variable the approximate cavity distribution multiplied with the omitted factors. | |
std::vector< Factor > | _cavitydists |
Stores for each variable the approximate cavity distribution. | |
std::vector< std::vector < Factor > > | _phis |
_phis[i][_I] corresponds to ![]() | |
std::vector< Factor > | _beliefs |
Single variable beliefs. | |
Real | _maxdiff |
Maximum difference encountered so far. | |
size_t | _iters |
Number of iterations needed. | |
Classes | |
struct | Properties |
Parameters for LC. More... |
dai::LC::LC | ( | ) | [inline] |
Default constructor.
dai::LC::LC | ( | const FactorGraph & | fg, | |
const PropertySet & | opts | |||
) |
Construct from FactorGraph fg and PropertySet opts.
fg | Factor graph. | |
opts | Parameters |
virtual LC* dai::LC::clone | ( | ) | const [inline, virtual] |
Returns a pointer to a new, cloned copy of *this
(i.e., virtual copy constructor).
Implements dai::InfAlg.
string dai::LC::identify | ( | ) | const [virtual] |
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.
virtual Factor dai::LC::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 from dai::InfAlg.
virtual std::vector<Factor> dai::LC::beliefs | ( | ) | const [inline, virtual] |
Returns all beliefs (approximate marginal probability distributions) calculated by the algorithm.
Implements dai::InfAlg.
virtual Real dai::LC::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.
void dai::LC::init | ( | ) | [virtual] |
Initializes all data structures of the approximate inference algorithm.
Implements dai::InfAlg.
virtual void dai::LC::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::LC::run | ( | ) | [virtual] |
virtual Real dai::LC::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::LC::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.
virtual void dai::LC::setMaxIter | ( | size_t | ) | [inline, virtual] |
Sets maximum number of iterations (one iteration passes over the complete factorgraph).
NOT_IMPLEMENTED | if not implemented/supported |
Reimplemented from dai::InfAlg.
void dai::LC::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::LC::getProperties | ( | ) | const [virtual] |
Returns parameters of this inference algorithm converted into a PropertySet.
Implements dai::InfAlg.
string dai::LC::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.
Real dai::LC::CalcCavityDist | ( | size_t | i, | |
const std::string & | name, | |||
const PropertySet & | opts | |||
) |
Approximates the cavity distribution of variable i, using the inference algorithm name with parameters opts.
Real dai::LC::InitCavityDists | ( | const std::string & | name, | |
const PropertySet & | opts | |||
) |
Approximates all cavity distributions using inference algorithm name with parameters opts.
long dai::LC::SetCavityDists | ( | std::vector< Factor > & | Q | ) |
Sets approximate cavity distributions to Q.
Factor dai::LC::NewPancake | ( | size_t | i, | |
size_t | _I, | |||
bool & | hasNaNs | |||
) |
Updates the belief of the Markov blanket of variable i based upon the information from its _I 'th neighboring factor.
void dai::LC::CalcBelief | ( | size_t | i | ) |
Calculates the belief of variable i.
const Factor& dai::LC::pancake | ( | size_t | i | ) | const [inline] |
Returns the belief of the Markov blanket of variable i (including the variable itself).
const Factor& dai::LC::cavitydist | ( | size_t | i | ) | const [inline] |
Returns the approximate cavity distribution for variable i.
std::vector<Factor> dai::LC::_pancakes [private] |
Stores for each variable the approximate cavity distribution multiplied with the omitted factors.
std::vector<Factor> dai::LC::_cavitydists [private] |
Stores for each variable the approximate cavity distribution.
std::vector<std::vector<Factor> > dai::LC::_phis [private] |
_phis[i][_I] corresponds to in the paper
std::vector<Factor> dai::LC::_beliefs [private] |
Single variable beliefs.
Real dai::LC::_maxdiff [private] |
Maximum difference encountered so far.
size_t dai::LC::_iters [private] |
Number of iterations needed.
const char * dai::LC::Name = "LC" [static] |
Name of this inference algorithm.