13 #ifndef __defined_libdai_mf_h
14 #define __defined_libdai_mf_h
81 MF() :
DAIAlgFG(), _beliefs(), _maxdiff(0.0), _iters(0U), props() {}
98 virtual std::string
name()
const {
return "MF"; }
102 virtual std::vector<Factor>
beliefs()
const;
virtual Real logZ() const
Returns the logarithm of the (approximated) partition sum (normalizing constant of the factor graph)...
Definition: mf.cpp:198
virtual Real maxDiff() const
Returns maximum difference between single variable beliefs in the last iteration. ...
Definition: mf.h:107
void construct()
Helper function for constructors.
Definition: mf.cpp:77
Real damping
Damping constant (0.0 means no damping, 1.0 is maximum damping)
Definition: mf.h:69
virtual PropertySet getProperties() const
Returns parameters of this inference algorithm converted into a PropertySet.
Definition: mf.cpp:52
Approximate inference algorithm "Mean Field".
Definition: mf.h:41
Represents a factor graph.
Definition: factorgraph.h:65
FactorGraph & fg()
Returns reference to underlying FactorGraph.
Definition: daialg.h:221
InitType init
How to initialize the messages/beliefs.
Definition: mf.h:72
virtual void setProperties(const PropertySet &opts)
Set parameters of this inference algorithm.
Definition: mf.cpp:27
double Real
Real number (alias for double, which could be changed to long double if necessary) ...
Definition: util.h:98
std::vector< Factor > _beliefs
Current approximations of single variable marginals.
Definition: mf.h:44
virtual Real run()
Runs the approximate inference algorithm.
Definition: mf.cpp:117
virtual std::string printProperties() const
Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1...
Definition: mf.cpp:64
virtual MF * clone() const
Returns a pointer to a new, cloned copy of *this (i.e., virtual copy constructor) ...
Definition: mf.h:96
virtual std::vector< Factor > beliefs() const
Returns all beliefs (approximate marginal probability distributions) calculated by the algorithm...
Definition: mf.cpp:190
Defines the DAI_ENUM macro, which can be used to define an enum with additional functionality.
virtual size_t Iterations() const
Returns number of iterations done (one iteration passes over the complete factorgraph).
Definition: mf.h:108
Represents a set of variables.
Definition: varset.h:94
Factor calcNewBelief(size_t i)
Calculates an updated belief of variable i.
Definition: mf.cpp:96
DAI_ENUM(InitType, UNIFORM, RANDOM)
Enumeration of possible message initializations.
size_t verbose
Verbosity (amount of output sent to stderr)
Definition: mf.h:60
virtual Factor beliefV(size_t i) const
Returns the (approximate) marginal probability distribution of the variable with index i...
Definition: mf.cpp:173
virtual MF * construct(const FactorGraph &fg, const PropertySet &opts) const
Returns a pointer to a newly constructed inference algorithm.
Definition: mf.h:97
virtual void init()
Initializes all data structures of the approximate inference algorithm.
Definition: mf.cpp:86
Defines the Property and PropertySet classes, which are mainly used for managing parameters of infere...
Represents a set of properties, mapping keys (of type PropertyKey) to values (of type PropertyValue) ...
Definition: properties.h:73
MF()
Default constructor.
Definition: mf.h:82
Represents a discrete random variable.
Definition: var.h:37
Namespace for libDAI.
Definition: alldai.cpp:16
Defines the FactorGraph class, which represents factor graphs (e.g., Bayesian networks or Markov rand...
Defines the general interface for inference methods in libDAI (classes InfAlg, DaiAlg<>, DaiAlgFG and DaiAlgRG).
Real tol
Tolerance for convergence test.
Definition: mf.h:66
Allows the user to specify which algorithms will be built into libDAI.
size_t maxiter
Maximum number of iterations.
Definition: mf.h:63
Parameters for MF.
Definition: mf.h:52
size_t _iters
Number of iterations needed.
Definition: mf.h:48
Combines the abstract base class InfAlg with a graphical model (e.g., a FactorGraph or RegionGraph)...
Definition: daialg.h:207
UpdateType updates
How to update the messages/beliefs.
Definition: mf.h:75
virtual Factor belief(const Var &v) const
Returns the (approximate) marginal probability distribution of a variable.
Definition: mf.h:99
MF(const FactorGraph &fg, const PropertySet &opts)
Construct from FactorGraph fg and PropertySet opts.
Definition: mf.h:88
virtual void setMaxIter(size_t maxiter)
Sets maximum number of iterations (one iteration passes over the complete factorgraph).
Definition: mf.h:109
virtual std::string name() const
Returns the name of the algorithm.
Definition: mf.h:98
Real _maxdiff
Maximum difference encountered so far.
Definition: mf.h:46