Public Member Functions |
| MR () |
| Default constructor.
|
| MR (const FactorGraph &fg, const PropertySet &opts) |
| Construct from FactorGraph fg and PropertySet opts.
|
|
virtual MR * | clone () const |
| Returns a pointer to a new, cloned copy of *this (i.e., virtual copy constructor)
|
virtual MR * | 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 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 | 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]".
|
| DAIAlg () |
| Default constructor.
|
| DAIAlg (const GRM &grm) |
| Construct from GRM.
|
FactorGraph & | fg () |
| Returns reference to underlying FactorGraph.
|
const FactorGraph & | fg () const |
| Returns constant reference to underlying FactorGraph.
|
void | clamp (size_t i, size_t x, bool backup=false) |
| Clamp variable with index i to value x (i.e. multiply with a Kronecker delta )
|
void | makeCavity (size_t i, bool backup=false) |
| Sets all factors interacting with variable with index i to one.
|
void | backupFactor (size_t I) |
| Make a backup copy of factor I.
|
void | backupFactors (const VarSet &vs) |
| Make backup copies of all factors involving the variables in vs.
|
void | restoreFactor (size_t I) |
| Restore factor I from its backup copy.
|
void | restoreFactors (const VarSet &vs) |
| Restore the factors involving the variables in vs from their backup copies.
|
virtual | ~InfAlg () |
| Virtual destructor (needed because this class contains virtual functions)
|
virtual std::string | identify () const |
| Identifies itself for logging purposes.
|
virtual Factor | beliefF (size_t I) const |
| Returns the (approximate) marginal probability distribution of the variables on which factor I depends.
|
virtual std::vector< std::size_t > | findMaximum () const |
| Calculates the joint state of all variables that has maximum probability.
|
virtual void | setMaxIter (size_t) |
| Sets maximum number of iterations (one iteration passes over the complete factorgraph).
|
Private Member Functions |
Real | calcCavityCorrelations () |
| Initialize cors.
|
void | propagateCavityFields () |
| Iterate update equations for cavity fields.
|
void | calcMagnetizations () |
| Calculate magnetizations.
|
Real | _tJ (size_t i, sub_nb A) |
| Calculate the product of all tJ[i][_j] for _j in A.
|
Real | Omega (size_t i, size_t _j, size_t _l) |
| Calculate as defined in [MoR05] eqn. (2.15)
|
Real | T (size_t i, sub_nb A) |
| Calculate as defined in [MoR05] eqn. (2.17) with .
|
Real | T (size_t i, size_t _j) |
| Calculates where j is the _j 'th neighbor of i.
|
Real | Gamma (size_t i, size_t _j, size_t _l1, size_t _l2) |
| Calculates as defined in [MoR05] eqn. (2.16)
|
Real | Gamma (size_t i, size_t _l1, size_t _l2) |
| Calculates as defined in [MoK07] on page 1141.
|
Real | appM (size_t i, sub_nb A) |
| Approximates moments of variables in A.
|
void | sum_subs (size_t j, sub_nb A, Real *sum_even, Real *sum_odd) |
| Calculate sum over all even/odd subsets B of A of _tJ(j,B) appM(j,B)
|
Private Attributes |
bool | supported |
| Is the underlying factor graph supported?
|
GraphAL | G |
| The interaction graph (Markov graph)
|
std::vector< std::vector< Real > > | tJ |
| tJ[i][_j] is the hyperbolic tangent of the interaction between spin i and its neighbour G.nb(i,_j)
|
std::vector< Real > | theta |
| theta[i] is the local field on spin i
|
std::vector< std::vector< Real > > | M |
| M[i][_j] is .
|
std::vector< std::vector
< std::vector< Real > > > | cors |
| Cavity correlations.
|
std::vector< Real > | Mag |
| Magnetizations.
|
Real | _maxdiff |
| Maximum difference encountered so far.
|
size_t | _iters |
| Number of iterations needed.
|
Approximate inference algorithm by Montanari and Rizzo [MoR05].
- Author
- Bastian Wemmenhove wrote the original implementation before it was merged into libDAI
Approximates moments of variables in A.
Calculate the moment of variables in A from M and cors, neglecting higher order cumulants, defined as the sum over all partitions of A into subsets of cardinality two at most of the product of the cumulants (either first order, i.e. M, or second order, i.e. cors) of the entries of the partitions.
- Parameters
-
i | variable index |
A | subset of neighbors of variable i |