13 #ifndef __defined_libdai_jtree_h
14 #define __defined_libdai_jtree_h
48 std::vector<std::vector<Factor> >
_mes;
58 std::vector<Factor>
Qa;
61 std::vector<Factor>
Qb;
89 DAI_ENUM(HeuristicType,MINNEIGHBORS,MINWEIGHT,MINFILL,WEIGHTEDMINFILL);
110 JTree() :
DAIAlgRG(), _mes(), _logZ(), RTree(), Qa(), Qb(), props() {}
126 virtual std::string
name()
const {
return "JTREE"; }
128 virtual std::vector<Factor>
beliefs()
const;
169 const Factor &
message(
size_t alpha,
size_t _beta )
const {
return _mes[alpha][_beta]; }
171 Factor &
message(
size_t alpha,
size_t _beta ) {
return _mes[alpha][_beta]; }
virtual std::string name() const
Returns the name of the algorithm.
Definition: jtree.h:126
Parameters for JTree.
Definition: jtree.h:64
Factor & message(size_t alpha, size_t _beta)
Returns reference to the message from outer region alpha to its _beta 'th neighboring inner region...
Definition: jtree.h:171
Exact inference algorithm using junction tree.
Definition: jtree.h:45
Factor calcMarginal(const VarSet &vs)
Calculates the marginal of a set of variables (using cutset conditioning, if necessary) ...
Definition: jtree.cpp:466
virtual PropertySet getProperties() const
Returns parameters of this inference algorithm converted into a PropertySet.
Definition: jtree.cpp:47
std::vector< size_t > findMaximum() const
Definition: jtree.cpp:585
Defines some utility functions for (weighted) undirected graphs, trees and rooted trees...
Represents a factor graph.
Definition: factorgraph.h:65
Defines the VarSet class, which represents a set of random variables.
std::vector< Factor > Qa
Outer region beliefs.
Definition: jtree.h:58
virtual size_t Iterations() const
Returns number of iterations done (one iteration passes over the complete factorgraph).
Definition: jtree.h:137
FactorGraph & fg()
Returns reference to underlying FactorGraph.
Definition: daialg.h:221
double Real
Real number (alias for double, which could be changed to long double if necessary) ...
Definition: util.h:98
UpdateType updates
Type of updates.
Definition: jtree.h:95
void runHUGIN()
Runs junction tree algorithm using HUGIN (message-free) updates.
Definition: jtree.cpp:265
JTree()
Default constructor.
Definition: jtree.h:111
virtual std::string printProperties() const
Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1...
Definition: jtree.cpp:58
virtual void setProperties(const PropertySet &opts)
Set parameters of this inference algorithm.
Definition: jtree.cpp:24
virtual Real logZ() const
Returns the logarithm of the (approximated) partition sum (normalizing constant of the factor graph)...
Definition: jtree.cpp:384
size_t(* eliminationCostFunction)(const ClusterGraph &, size_t)
Type of cost functions to be used for greedy variable elimination.
Definition: clustergraph.h:289
void runShaferShenoy()
Runs junction tree algorithm using Shafer-Shenoy updates.
Definition: jtree.cpp:312
size_t maxmem
Maximum memory to use in bytes (0 means unlimited)
Definition: jtree.h:104
size_t verbose
Verbosity (amount of output sent to stderr)
Definition: jtree.h:92
virtual std::vector< Factor > beliefs() const
Returns all beliefs (approximate marginal probability distributions) calculated by the algorithm...
Definition: jtree.cpp:255
Defines the DAI_ENUM macro, which can be used to define an enum with additional functionality.
Represents a set of variables.
Definition: varset.h:94
HeuristicType heuristic
Heuristic to use for constructing the junction tree.
Definition: jtree.h:101
InfType inference
Type of inference.
Definition: jtree.h:98
virtual void init(const VarSet &)
Initializes all data structures corresponding to some set of variables.
Definition: jtree.h:134
std::vector< Factor > Qb
Inner region beliefs.
Definition: jtree.h:61
const Factor & message(size_t alpha, size_t _beta) const
Returns constant reference to the message from outer region alpha to its _beta 'th neighboring inner ...
Definition: jtree.h:169
Real _logZ
Stores the logarithm of the partition sum.
Definition: jtree.h:51
Defines class ClusterGraph, which is used by JTree, TreeEP and HAK.
DAI_ENUM(UpdateType, HUGIN, SHSH)
Enumeration of possible JTree updates.
virtual Real run()
Runs the approximate inference algorithm.
Definition: jtree.cpp:375
Defines the Property and PropertySet classes, which are mainly used for managing parameters of infere...
Defines classes Region, FRegion and RegionGraph, which implement a particular subclass of region grap...
void GenerateJT(const FactorGraph &fg, const std::vector< VarSet > &cl)
Constructs a junction tree based on the cliques cl (corresponding to some elimination sequence)...
Definition: jtree.cpp:209
Represents a rooted tree, implemented as a vector of directed edges.
Definition: weightedgraph.h:157
virtual void init()
Initializes all data structures of the approximate inference algorithm.
Definition: jtree.h:133
Represents a set of properties, mapping keys (of type PropertyKey) to values (of type PropertyValue) ...
Definition: properties.h:73
Namespace for libDAI.
Definition: alldai.cpp:16
Defines the FactorGraph class, which represents factor graphs (e.g., Bayesian networks or Markov rand...
std::vector< std::vector< Factor > > _mes
Stores the messages.
Definition: jtree.h:48
Defines the general interface for inference methods in libDAI (classes InfAlg, DaiAlg<>, DaiAlgFG and DaiAlgRG).
virtual Factor belief(const VarSet &vs) const
Returns the (approximate) marginal probability distribution of a set of variables.
Definition: jtree.cpp:227
Allows the user to specify which algorithms will be built into libDAI.
virtual JTree * clone() const
Returns a pointer to a new, cloned copy of *this (i.e., virtual copy constructor) ...
Definition: jtree.h:124
Combines the abstract base class InfAlg with a graphical model (e.g., a FactorGraph or RegionGraph)...
Definition: daialg.h:207
size_t findEfficientTree(const VarSet &vs, RootedTree &Tree, size_t PreviousRoot=(size_t)-1) const
Finds an efficient subtree for calculating the marginal of the variables in vs.
Definition: jtree.cpp:398
RootedTree RTree
The junction tree (stored as a rooted tree)
Definition: jtree.h:55
virtual Real maxDiff() const
Returns maximum difference between single variable beliefs in the last iteration. ...
Definition: jtree.h:136
virtual JTree * construct(const FactorGraph &fg, const PropertySet &opts) const
Returns a pointer to a newly constructed inference algorithm.
Definition: jtree.h:125