Improve documentation:
- exactinf.h
mf.h
bp.h
jtree.h
/// Implements BBP (Back-Belief-Propagation) [\ref EaG09]
class BBP {
protected:
- /// @name Inputs
- //@{
+ /// \name Inputs
+ //@{
BP_dual _bp_dual;
const FactorGraph *_fg;
const InfAlg *_ia;
- //@}
+ //@}
/// Number of iterations done
size_t _iters;
- /// @name Outputs
- //@{
+ /// \name Outputs
+ //@{
/// Variable factor adjoints
std::vector<Prob> _adj_psi_V;
/// Factor adjoints
std::vector<Prob> _adj_b_V;
/// Normalized factor belief adjoints
std::vector<Prob> _adj_b_F;
- //@}
+ //@}
- /// @name Helper quantities computed from the BP messages
- //@{
+ /// \name Helper quantities computed from the BP messages
+ //@{
/// _T[i][_I] (see eqn. (41) in [\ref EaG09])
std::vector<std::vector<Prob > > _T;
/// _U[I][_i] (see eqn. (42) in [\ref EaG09])
std::vector<std::vector<std::vector<Prob > > > _S;
/// _R[I][_i][_J] (see eqn. (44) in [\ref EaG09])
std::vector<std::vector<std::vector<Prob > > > _R;
- //@}
+ //@}
/// Unnormalized variable belief adjoints
std::vector<Prob> _adj_b_V_unnorm;
/// Updated normalized factor->variable message adjoint (indexed [i][_I])
std::vector<std::vector<Prob> > _new_adj_m;
- /// @name Optimized indexing (for performance)
- //@{
+ /// \name Optimized indexing (for performance)
+ //@{
/// Calculates _indices, which is a cache of IndexFor @see bp.cpp
void RegenerateInds();
std::vector<std::vector<_ind_t> > _indices;
/// Returns an index from the cache
const _ind_t& _index(size_t i, size_t _I) const { return _indices[i][_I]; }
- //@}
+ //@}
- /// @name Initialization
- //@{
+ /// \name Initialization
+ //@{
/// Calculate T values; see eqn. (41) in [\ref EaG09]
void RegenerateT();
/// Calculate U values; see eqn. (42) in [\ref EaG09]
* than updating _adj_n (and friends) which are unused in the sequential algorithm.
*/
void RegenerateSeqMessageAdjoints();
- //@}
+ //@}
/// Returns reference to T value; see eqn. (41) in [\ref EaG09]
Prob & T(size_t i, size_t _I) { return _T[i][_I]; }
/// Returns constant reference to R value; see eqn. (44) in [\ref EaG09]
const Prob & R(size_t I, size_t _i, size_t _J) const { return _R[I][_i][_J]; }
- /// @name Parallel algorithm
- //@{
+ /// \name Parallel algorithm
+ //@{
/// Calculates new variable->factor message adjoint
/** Increases variable factor adjoint according to eqn. (27) in [\ref EaG09] and
* calculates the new variable->factor message adjoint according to eqn. (29) in [\ref EaG09].
void upMsgM( size_t i, size_t _I );
/// Do one parallel update of all message adjoints
void doParUpdate();
- //@}
+ //@}
- /// @name Sequential algorithm
- //@{
+ /// \name Sequential algorithm
+ //@{
/// Helper function for sendSeqMsgM: increases factor->variable message adjoint by p and calculates the corresponding unnormalized adjoint
void incrSeqMsgM( size_t i, size_t _I, const Prob& p );
// DISABLED BECAUSE IT IS BUGGY:
void sendSeqMsgN( size_t i, size_t _I, const Prob &f );
/// Implements routine Send-m in Figure 5 in [\ref EaG09]
void sendSeqMsgM( size_t i, size_t _I );
- //@}
+ //@}
/// Calculates averaged L-1 norm of unnormalized message adjoints
Real getUnMsgMag();
};
// OBSOLETE
- /// @name Backwards compatibility layer (to be removed soon)
+ /// \name Backwards compatibility layer (to be removed soon)
//@{
/// Enable backwards compatibility layer?
bool _edge_indexed;
//@}
public:
- /// @name Constructors and destructors
+ /// \name Constructors and destructors
//@{
/// Default constructor (creates an empty bipartite graph)
BipartiteGraph() : _nb1(), _nb2(), _edge_indexed(false) {}
}
//@}
- /// @name Accessors and mutators
+ /// \name Accessors and mutators
//@{
/// Returns constant reference to the \a _i2 'th neighbor of node \a i1 of type 1
const Neighbor & nb1( size_t i1, size_t _i2 ) const {
}
//@}
- /// @name Adding nodes and edges
+ /// \name Adding nodes and edges
//@{
/// (Re)constructs BipartiteGraph from a range of edges.
/** \tparam EdgeInputIterator Iterator that iterates over instances of BipartiteGraph::Edge.
void addEdge( size_t n1, size_t n2, bool check = true );
//@}
- /// @name Erasing nodes and edges
+ /// \name Erasing nodes and edges
//@{
/// Removes node \a n1 of type 1 and all incident edges; indices of other nodes are changed accordingly.
void erase1( size_t n1 );
void eraseEdge( size_t n1, size_t n2 );
//@}
- /// @name Queries
+ /// \name Queries
//@{
/// Returns number of nodes of type 1
size_t nr1() const { return _nb1.size(); }
void checkConsistency() const;
//@}
- /// @name Input and output
+ /// \name Input and output
//@{
/// Writes this BipartiteGraph to an output stream in GraphViz .dot syntax
void printDot( std::ostream& os ) const;
//@}
// OBSOLETE
- /// @name Backwards compatibility layer (to be removed soon)
+ /// \name Backwards compatibility layer (to be removed soon)
//@{
void indexEdges() {
std::cerr << "Warning: this BipartiteGraph edge interface is obsolete!" << std::endl;
construct();
}
-
- /// @name General InfAlg interface
- //@{
+ /// \name General InfAlg interface
+ //@{
virtual BP* clone() const { return new BP(*this); }
virtual std::string identify() const;
virtual Factor belief( const Var &n ) const;
virtual Factor belief( const VarSet &ns ) const;
+ virtual Factor beliefV( size_t i ) const;
+ virtual Factor beliefF( size_t I ) const;
virtual std::vector<Factor> beliefs() const;
virtual Real logZ() const;
virtual void init();
virtual Real run();
virtual Real maxDiff() const { return _maxdiff; }
virtual size_t Iterations() const { return _iters; }
- //@}
-
-
- /// @name Additional interface specific for BP
- //@{
- Factor beliefV( size_t i ) const;
- Factor beliefF( size_t I ) const;
- //@}
+ //@}
+ /// \name Additional interface specific for BP
+ //@{
/// Calculates the joint state of all variables that has maximum probability
/** Assumes that run() has been called and that props.inference == MAXPROD
*/
void clearSentMessages() {
_sentMessages.clear();
}
+ //@}
+
+ /// \name Managing parameters (which are stored in BP::props)
+ //@{
+ /// Set parameters of this inference algorithm.
+ /** The parameters are set according to \a opts.
+ * The values can be stored either as std::string or as the type of the corresponding BP::props member.
+ */
+ void setProperties( const PropertySet &opts );
+ /// Returns parameters of this inference algorithm converted into a PropertySet.
+ PropertySet getProperties() const;
+ /// Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]".
+ std::string printProperties() const;
+ //@}
private:
const Prob & message(size_t i, size_t _I) const { return _edges[i][_I].message; }
void calcBeliefF( size_t I, Prob &p ) const;
void construct();
- /// Set Props according to the PropertySet opts, where the values can be stored as std::strings or as the type of the corresponding Props member
- void setProperties( const PropertySet &opts );
- PropertySet getProperties() const;
- std::string printProperties() const;
};
/// Name of this inference algorithm
static const char *Name;
- /// @name General InfAlg interface
- //@{
+ /// \name General InfAlg interface
+ //@{
virtual CBP* clone() const { return new CBP(*this); }
virtual std::string identify() const { return std::string(Name) + props.toString(); }
virtual Factor belief (const Var &n) const { return _beliefsV[findVar(n)]; }
virtual Factor belief (const VarSet &) const { DAI_THROW(NOT_IMPLEMENTED); }
+ virtual Factor beliefV( size_t i ) const { return _beliefsV[i]; }
+ virtual Factor beliefF( size_t I ) const { return _beliefsF[I]; }
virtual std::vector<Factor> beliefs() const { return concat(_beliefsV, _beliefsF); }
virtual Real logZ() const { return _logZ; }
virtual void init() {};
virtual Real run();
virtual Real maxDiff() const { return _maxdiff; }
virtual size_t Iterations() const { return _iters; }
- //@}
-
- Factor beliefV( size_t i ) const { return _beliefsV[i]; }
- Factor beliefF( size_t I ) const { return _beliefsF[I]; }
+ //@}
//----------------------------------------------------------------
/// Using all of the currently added expectations, make new factors with maximized parameters and set them in the FactorGraph.
void maximize( FactorGraph &fg );
- /// @name Iterator interface
- //@{
+ /// \name Iterator interface
+ //@{
typedef std::vector<SharedParameters>::iterator iterator;
typedef std::vector<SharedParameters>::const_iterator const_iterator;
iterator begin() { return _params.begin(); }
const_iterator begin() const { return _params.begin(); }
iterator end() { return _params.end(); }
const_iterator end() const { return _params.end(); }
- //@}
+ //@}
};
/// Iterate until termination conditions are satisfied
void run();
- /// @name Iterator interface
- //@{
+ /// \name Iterator interface
+ //@{
typedef std::vector<MaximizationStep>::iterator s_iterator;
typedef std::vector<MaximizationStep>::const_iterator const_s_iterator;
s_iterator s_begin() { return _msteps.begin(); }
const_s_iterator s_begin() const { return _msteps.begin(); }
s_iterator s_end() { return _msteps.end(); }
const_s_iterator s_end() const { return _msteps.end(); }
- //@}
+ //@}
};
/// Returns number of stored samples
size_t nrSamples() const { return _samples.size(); }
- /// @name Iterator interface
- //@{
+ /// \name Iterator interface
+ //@{
/// Iterator over the elements
typedef std::vector<Observation>::iterator iterator;
/// Constant iterator over the elements
iterator end() { return _samples.end(); }
/// Returns constant iterator that points beyond the last element
const_iterator end() const { return _samples.end(); }
- //@}
+ //@}
};
/// \file
-/// \brief Defines ExactInf class
-/// \todo Improve documentation
+/// \brief Defines ExactInf class, which can be used for exact inference on small factor graphs.
#ifndef __defined_libdai_exactinf_h
/// Exact inference algorithm using brute force enumeration (mainly useful for testing purposes)
+/** Inference is done simply by multiplying all factors together into one large factor,
+ * and then calculating marginals and partition sum from the product.
+ * \note This inference method can easily exhaust all available memory; in that case, one
+ * may try the JTree class instead.
+ */
class ExactInf : public DAIAlgFG {
public:
/// Parameters of this inference algorithm
static const char *Name;
private:
+ /// All single variable marginals
std::vector<Factor> _beliefsV;
+ /// All factor variable marginals
std::vector<Factor> _beliefsF;
+ /// Logarithm of partition sum
Real _logZ;
public:
+ /// \name Constructors/destructors
+ //@{
/// Default constructor
ExactInf() : DAIAlgFG(), props(), _beliefsV(), _beliefsF(), _logZ(0) {}
- /// Construct from FactorGraph fg and PropertySet opts
+ /// Construct from FactorGraph \a fg and PropertySet \a opts
ExactInf( const FactorGraph &fg, const PropertySet &opts ) : DAIAlgFG(fg), props(), _beliefsV(), _beliefsF(), _logZ() {
setProperties( opts );
construct();
}
+ //@}
-
- /// @name General InfAlg interface
- //@{
+ /// \name General InfAlg interface
+ //@{
virtual ExactInf* clone() const { return new ExactInf(*this); }
virtual std::string identify() const;
virtual Factor belief( const Var &n ) const { return beliefV( findVar( n ) ); }
virtual Factor belief( const VarSet &ns ) const;
+ virtual Factor beliefV( size_t i ) const { return _beliefsV[i]; }
+ virtual Factor beliefF( size_t I ) const { return _beliefsF[I]; }
virtual std::vector<Factor> beliefs() const;
virtual Real logZ() const { return _logZ; }
virtual void init();
virtual Real run();
virtual Real maxDiff() const { DAI_THROW(NOT_IMPLEMENTED); return 0.0; }
virtual size_t Iterations() const { DAI_THROW(NOT_IMPLEMENTED); return 0; }
- //@}
-
-
- /// @name Additional interface specific for ExactInf
- //@{
- Factor beliefV( size_t i ) const { return _beliefsV[i]; }
- Factor beliefF( size_t I ) const { return _beliefsF[I]; }
- //@}
-
- private:
- void construct();
+ //@}
+
+ /// \name Managing parameters (which are stored in ExactInf::props)
+ //@{
+ /// Set parameters of this inference algorithm.
+ /** The parameters are set according to \a opts.
+ * The values can be stored either as std::string or as the type of the corresponding ExactInf::props member.
+ */
void setProperties( const PropertySet &opts );
+ /// Returns parameters of this inference algorithm converted into a PropertySet.
PropertySet getProperties() const;
+ /// Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]".
std::string printProperties() const;
+ //@}
+
+ private:
+ /// Helper function for constructors
+ void construct();
};
}
- /// @name General InfAlg interface
- //@{
+ /// \name General InfAlg interface
+ //@{
virtual Gibbs* clone() const { return new Gibbs(*this); }
virtual std::string identify() const { return std::string(Name) + printProperties(); }
virtual Factor belief( const Var &n ) const;
virtual Factor belief( const VarSet &ns ) const;
+ virtual Factor beliefV( size_t i ) const;
+ virtual Factor beliefF( size_t I ) const;
virtual std::vector<Factor> beliefs() const;
virtual Real logZ() const { DAI_THROW(NOT_IMPLEMENTED); return 0.0; }
virtual void init();
virtual Real run();
virtual Real maxDiff() const { DAI_THROW(NOT_IMPLEMENTED); return 0.0; }
virtual size_t Iterations() const { return props.iters; }
- //@}
+ //@}
- /// @name Additional interface specific for Gibbs
- //@{
- Factor beliefV( size_t i ) const;
- Factor beliefF( size_t I ) const;
+ /// \name Additional interface specific for Gibbs
+ //@{
void randomizeState();
- //@}
-
/// Return reference to current state vector
std::vector<size_t>& state() { return _state; }
/// Return const reference to current state vector
const std::vector<size_t>& state() const { return _state; }
+ //@}
+
+ /// \name Managing parameters (which are stored in Gibbs::props)
+ //@{
+ /// Set parameters of this inference algorithm.
+ /** The parameters are set according to \a opts.
+ * The values can be stored either as std::string or as the type of the corresponding Gibbs::props member.
+ */
+ void setProperties( const PropertySet &opts );
+ /// Returns parameters of this inference algorithm converted into a PropertySet.
+ PropertySet getProperties() const;
+ /// Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]".
+ std::string printProperties() const;
+ //@}
private:
void updateCounts();
size_t getFactorEntryDiff( size_t I, size_t i );
void construct();
- /// Set Props according to the PropertySet opts, where the values can be stored as std::strings or as the type of the corresponding Props member
- void setProperties( const PropertySet &opts );
- PropertySet getProperties() const;
- std::string printProperties() const;
};
HAK( const RegionGraph &rg, const PropertySet &opts );
- /// @name General InfAlg interface
- //@{
+ /// \name General InfAlg interface
+ //@{
virtual HAK* clone() const { return new HAK(*this); }
virtual std::string identify() const;
virtual Factor belief( const Var &n ) const;
virtual Real run();
virtual Real maxDiff() const { return _maxdiff; }
virtual size_t Iterations() const { return _iters; }
- //@}
+ //@}
- /// @name Additional interface specific for HAK
- //@{
+ /// \name Additional interface specific for HAK
+ //@{
Factor & muab( size_t alpha, size_t _beta ) { return _muab[alpha][_beta]; }
Factor & muba( size_t alpha, size_t _beta ) { return _muba[alpha][_beta]; }
const Factor& Qa( size_t alpha ) const { return _Qa[alpha]; };
Real doGBP();
Real doDoubleLoop();
- //@}
+ //@}
+
+ /// \name Managing parameters (which are stored in HAK::props)
+ //@{
+ /// Set parameters of this inference algorithm.
+ /** The parameters are set according to \a opts.
+ * The values can be stored either as std::string or as the type of the corresponding HAK::props member.
+ */
+ void setProperties( const PropertySet &opts );
+ /// Returns parameters of this inference algorithm converted into a PropertySet.
+ PropertySet getProperties() const;
+ /// Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]".
+ std::string printProperties() const;
+ //@}
private:
void constructMessages();
void findLoopClusters( const FactorGraph &fg, std::set<VarSet> &allcl, VarSet newcl, const Var & root, size_t length, VarSet vars );
-
- void setProperties( const PropertySet &opts );
- PropertySet getProperties() const;
- std::string printProperties() const;
};
JTree( const FactorGraph &fg, const PropertySet &opts, bool automatic=true );
- /// @name General InfAlg interface
- //@{
+ /// \name General InfAlg interface
+ //@{
virtual JTree* clone() const { return new JTree(*this); }
virtual std::string identify() const;
virtual Factor belief( const Var &n ) const;
virtual Real run();
virtual Real maxDiff() const { return 0.0; }
virtual size_t Iterations() const { return 1UL; }
- //@}
+ //@}
- /// @name Additional interface specific for JTree
- //@{
+ /// \name Additional interface specific for JTree
+ //@{
void GenerateJT( const std::vector<VarSet> &Cliques );
/// Returns reference the message from outer region alpha to its _beta'th neighboring inner region
/** Assumes that run() has been called and that props.inference == MAXPROD
*/
std::vector<std::size_t> findMaximum() const;
- //@}
+ //@}
- private:
+ /// \name Managing parameters (which are stored in JTree::props)
+ //@{
+ /// Set parameters of this inference algorithm.
+ /** The parameters are set according to \a opts.
+ * The values can be stored either as std::string or as the type of the corresponding JTree::props member.
+ */
void setProperties( const PropertySet &opts );
+ /// Returns parameters of this inference algorithm converted into a PropertySet.
PropertySet getProperties() const;
+ /// Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]".
std::string printProperties() const;
+ //@}
};
LC( const FactorGraph &fg, const PropertySet &opts );
- /// @name General InfAlg interface
- //@{
+ /// \name General InfAlg interface
+ //@{
virtual LC* clone() const { return new LC(*this); }
virtual std::string identify() const;
virtual Factor belief( const Var &n ) const { return( _beliefs[findVar(n)] ); }
virtual Factor belief( const VarSet &/*ns*/ ) const { DAI_THROW(NOT_IMPLEMENTED); return Factor(); }
+ virtual Factor beliefV( size_t i ) const { return _beliefs[i]; }
virtual std::vector<Factor> beliefs() const { return _beliefs; }
virtual Real logZ() const { DAI_THROW(NOT_IMPLEMENTED); return 0.0; }
virtual void init();
virtual Real run();
virtual Real maxDiff() const { return _maxdiff; }
virtual size_t Iterations() const { return _iters; }
- //@}
+ //@}
- Factor beliefV( size_t i ) const { return _beliefs[i]; }
-
- /// @name Additional interface specific for LC
- //@{
+ /// \name Additional interface specific for LC
+ //@{
Real CalcCavityDist( size_t i, const std::string &name, const PropertySet &opts );
Real InitCavityDists( const std::string &name, const PropertySet &opts );
long SetCavityDists( std::vector<Factor> &Q );
const Factor &belief (size_t i) const { return _beliefs[i]; };
const Factor &pancake (size_t i) const { return _pancakes[i]; };
const Factor &cavitydist (size_t i) const { return _cavitydists[i]; };
- //@}
-
- private:
+ //@}
+
+ /// \name Managing parameters (which are stored in LC::props)
+ //@{
+ /// Set parameters of this inference algorithm.
+ /** The parameters are set according to \a opts.
+ * The values can be stored either as std::string or as the type of the corresponding LC::props member.
+ */
void setProperties( const PropertySet &opts );
+ /// Returns parameters of this inference algorithm converted into a PropertySet.
PropertySet getProperties() const;
+ /// Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]".
std::string printProperties() const;
+ //@}
};
}
- /// @name General InfAlg interface
- //@{
+ /// \name General InfAlg interface
+ //@{
virtual MF* clone() const { return new MF(*this); }
virtual std::string identify() const;
virtual Factor belief( const Var &n ) const;
virtual Real run();
virtual Real maxDiff() const { return _maxdiff; }
virtual size_t Iterations() const { return _iters; }
- //@}
+ //@}
- /// @name Additional interface specific for MF
- //@{
+ /// \name Additional interface specific for MF
+ //@{
Factor calcNewBelief( size_t i );
- //@}
-
- private:
- void construct();
+ //@}
+
+ /// \name Managing parameters (which are stored in MF::props)
+ //@{
+ /// Set parameters of this inference algorithm.
+ /** The parameters are set according to \a opts.
+ * The values can be stored either as std::string or as the type of the corresponding MF::props member.
+ */
void setProperties( const PropertySet &opts );
+ /// Returns parameters of this inference algorithm converted into a PropertySet.
PropertySet getProperties() const;
+ /// Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]".
std::string printProperties() const;
+ //@}
+
+ private:
+ void construct();
};
MR( const FactorGraph &fg, const PropertySet &opts );
- /// @name General InfAlg interface
- //@{
+ /// \name General InfAlg interface
+ //@{
virtual MR* clone() const { return new MR(*this); }
virtual std::string identify() const;
virtual Factor belief( const Var &n ) const;
virtual Real run();
virtual Real maxDiff() const { return _maxdiff; }
virtual size_t Iterations() const { return _iters; }
- //@}
-
-
- /// @name Additional interface specific for MR
- //@{
- //@}
+ //@}
+
+ /// \name Managing parameters (which are stored in MR::props)
+ //@{
+ /// Set parameters of this inference algorithm.
+ /** The parameters are set according to \a opts.
+ * The values can be stored either as std::string or as the type of the corresponding MR::props member.
+ */
+ void setProperties( const PropertySet &opts );
+ /// Returns parameters of this inference algorithm converted into a PropertySet.
+ PropertySet getProperties() const;
+ /// Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]".
+ std::string printProperties() const;
+ //@}
private:
void init(size_t Nin, Real *_w, Real *_th);
void sum_subs(size_t j, sub_nb A, Real *sum_even, Real *sum_odd);
Real sign(Real a) { return (a >= 0) ? 1.0 : -1.0; }
-
- void setProperties( const PropertySet &opts );
- PropertySet getProperties() const;
- std::string printProperties() const;
};
/// Reverse iterator over the elements
typedef typename std::vector<T>::reverse_iterator reverse_iterator;
- /// @name Iterator interface
+ /// \name Iterator interface
//@{
/// Returns iterator that points to the first element
iterator begin() { return _p.begin(); }
std::vector<T> _elements;
public:
- /// @name Constructors and destructors
+ /// \name Constructors and destructors
//@{
/// Default constructor (constructs an empty set)
SmallSet() : _elements() {}
}
//@}
- /// @name Operators for set-theoretic operations
+ /// \name Operators for set-theoretic operations
//@{
/// Set-minus operator: returns all elements in \c *this, except those in \a x
SmallSet operator/ ( const SmallSet& x ) const {
}
//@}
- /// @name Queries
+ /// \name Queries
//@{
/// Returns \c true if \c *this and \a x have elements in common
bool intersects( const SmallSet& x ) const {
/// Reverse iterator over the elements
typedef typename std::vector<T>::reverse_iterator reverse_iterator;
- /// @name Iterator interface
+ /// \name Iterator interface
//@{
/// Returns iterator that points to the first element
iterator begin() { return _elements.begin(); }
const_reverse_iterator rend() const { return _elements.rend(); }
//@}
- /// @name Comparison operators
+ /// \name Comparison operators
//@{
/// Returns \c true if \a a and \a b are identical
friend bool operator==( const SmallSet &a, const SmallSet &b ) {
TreeEP( const FactorGraph &fg, const PropertySet &opts );
- /// @name General InfAlg interface
- //@{
+ /// \name General InfAlg interface
+ //@{
virtual TreeEP* clone() const { return new TreeEP(*this); }
virtual std::string identify() const;
virtual Real logZ() const;
virtual Real run();
virtual Real maxDiff() const { return _maxdiff; }
virtual size_t Iterations() const { return _iters; }
- //@}
+ //@}
- /// @name Additional interface specific for TreeEP
- //@{
- //@}
+ /// \name Managing parameters (which are stored in TreeEP::props)
+ //@{
+ /// Set parameters of this inference algorithm.
+ /** The parameters are set according to \a opts.
+ * The values can be stored either as std::string or as the type of the corresponding TreeEP::props member.
+ */
+ void setProperties( const PropertySet &opts );
+ /// Returns parameters of this inference algorithm converted into a PropertySet.
+ PropertySet getProperties() const;
+ /// Returns parameters of this inference algorithm formatted as a string in the format "[key1=val1,key2=val2,...,keyn=valn]".
+ std::string printProperties() const;
+ //@}
private:
void ConstructRG( const DEdgeVec &tree );
bool offtree( size_t I ) const { return (fac2OR[I] == -1U); }
-
- void setProperties( const PropertySet &opts );
- PropertySet getProperties() const;
- std::string printProperties() const;
};
*/
class VarSet : public SmallSet<Var> {
public:
- /// @name Constructors and destructors
+ /// \name Constructors and destructors
//@{
/// Default constructor (constructs an empty set)
VarSet() : SmallSet<Var>() {}
VarSet( VarIterator begin, VarIterator end, size_t sizeHint=0 ) : SmallSet<Var>(begin,end,sizeHint) {}
//@}
- /// @name Queries
+ /// \name Queries
//@{
/// Calculates the number of states of this VarSet, which is simply the number of possible joint states of the variables in \c *this.
/** The number of states of the Cartesian product of the variables in this VarSet
}
//@}
- /// @name Input and output
+ /// \name Input and output
//@{
/// Writes a VarSet to an output stream
friend std::ostream& operator<<( std::ostream &os, const VarSet &vs ) {