#include <dai/hak.h>
Public Member Functions | |
Constructors/destructors | |
HAK () | |
Default constructor. | |
HAK (const FactorGraph &fg, const PropertySet &opts) | |
Construct from FactorGraph fg and PropertySet opts. | |
HAK (const RegionGraph &rg, const PropertySet &opts) | |
Construct from RegionGraph rg and PropertySet opts. | |
General InfAlg interface | |
virtual HAK * | 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 VarSet &vs) const |
Returns the (approximate) marginal probability distribution of a set of variables. | |
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 &vs) |
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 HAK | |
Factor & | muab (size_t alpha, size_t _beta) |
Returns reference to message from outer region alpha to its _beta 'th neighboring inner region. | |
Factor & | muba (size_t alpha, size_t _beta) |
Returns reference to message the _beta 'th neighboring inner region of outer region alpha to that outer region. | |
const Factor & | Qa (size_t alpha) const |
Returns belief of outer region alpha. | |
const Factor & | Qb (size_t beta) const |
Returns belief of inner region beta. | |
Real | doGBP () |
Runs single-loop algorithm (algorithm 1 in [HAK03]). | |
Real | doDoubleLoop () |
Runs double-loop algorithm (as described in section 4.2 of [HAK03]), which always convergences. | |
Public Attributes | |
struct dai::HAK::Properties | props |
Static Public Attributes | |
static const char * | Name = "HAK" |
Name of this inference algorithm. | |
Private Member Functions | |
void | construct () |
Helper function for constructors. | |
void | findLoopClusters (const FactorGraph &fg, std::set< VarSet > &allcl, VarSet newcl, const Var &root, size_t length, VarSet vars) |
Recursive procedure for finding clusters of variables containing loops of length at most length. | |
Private Attributes | |
std::vector< Factor > | _Qa |
Outer region beliefs. | |
std::vector< Factor > | _Qb |
Inner region beliefs. | |
std::vector< std::vector < Factor > > | _muab |
Messages from outer to inner regions. | |
std::vector< std::vector < Factor > > | _muba |
Messages from inner to outer regions. | |
Real | _maxdiff |
Maximum difference encountered so far. | |
size_t | _iters |
Number of iterations needed. | |
Classes | |
struct | Properties |
Parameters for HAK. More... |
dai::HAK::HAK | ( | ) | [inline] |
Default constructor.
dai::HAK::HAK | ( | const FactorGraph & | fg, | |
const PropertySet & | opts | |||
) |
Construct from FactorGraph fg and PropertySet opts.
fg | Factor graph. | |
opts | Parameters |
dai::HAK::HAK | ( | const RegionGraph & | rg, | |
const PropertySet & | opts | |||
) |
Construct from RegionGraph rg and PropertySet opts.
virtual HAK* dai::HAK::clone | ( | ) | const [inline, virtual] |
Returns a pointer to a new, cloned copy of *this
(i.e., virtual copy constructor).
Implements dai::InfAlg.
string dai::HAK::identify | ( | ) | const [virtual] |
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.
vector< Factor > dai::HAK::beliefs | ( | ) | const [virtual] |
Returns all beliefs (approximate marginal probability distributions) calculated by the algorithm.
Implements dai::InfAlg.
Real dai::HAK::logZ | ( | ) | const [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::HAK::init | ( | ) | [virtual] |
Initializes all data structures of the approximate inference algorithm.
Implements dai::InfAlg.
void dai::HAK::init | ( | const VarSet & | vs | ) | [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::HAK::run | ( | ) | [virtual] |
virtual Real dai::HAK::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::HAK::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::HAK::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::HAK::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::HAK::getProperties | ( | ) | const [virtual] |
Returns parameters of this inference algorithm converted into a PropertySet.
Implements dai::InfAlg.
string dai::HAK::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.
Factor& dai::HAK::muab | ( | size_t | alpha, | |
size_t | _beta | |||
) | [inline] |
Returns reference to message from outer region alpha to its _beta 'th neighboring inner region.
Factor& dai::HAK::muba | ( | size_t | alpha, | |
size_t | _beta | |||
) | [inline] |
Returns reference to message the _beta 'th neighboring inner region of outer region alpha to that outer region.
const Factor& dai::HAK::Qa | ( | size_t | alpha | ) | const [inline] |
Returns belief of outer region alpha.
const Factor& dai::HAK::Qb | ( | size_t | beta | ) | const [inline] |
Returns belief of inner region beta.
Real dai::HAK::doDoubleLoop | ( | ) |
Runs double-loop algorithm (as described in section 4.2 of [HAK03]), which always convergences.
void dai::HAK::construct | ( | ) | [private] |
Helper function for constructors.
void dai::HAK::findLoopClusters | ( | const FactorGraph & | fg, | |
std::set< VarSet > & | allcl, | |||
VarSet | newcl, | |||
const Var & | root, | |||
size_t | length, | |||
VarSet | vars | |||
) | [private] |
Recursive procedure for finding clusters of variables containing loops of length at most length.
fg | the factor graph | |
allcl | the clusters found so far | |
newcl | partial candidate cluster | |
root | start (and end) point of the loop | |
length | number of variables that may be added to newcl | |
vars | neighboring variables of newcl |
std::vector<Factor> dai::HAK::_Qa [private] |
Outer region beliefs.
std::vector<Factor> dai::HAK::_Qb [private] |
Inner region beliefs.
std::vector<std::vector<Factor> > dai::HAK::_muab [private] |
Messages from outer to inner regions.
std::vector<std::vector<Factor> > dai::HAK::_muba [private] |
Messages from inner to outer regions.
Real dai::HAK::_maxdiff [private] |
Maximum difference encountered so far.
size_t dai::HAK::_iters [private] |
Number of iterations needed.
const char * dai::HAK::Name = "HAK" [static] |
Name of this inference algorithm.