From: Joris Mooij Date: Mon, 29 Sep 2008 15:48:14 +0000 (+0200) Subject: Replaced all "protected:" by "private:" or "public:" X-Git-Tag: v0.2.3~126 X-Git-Url: http://git.tuebingen.mpg.de/?p=libdai.git;a=commitdiff_plain;h=578b5243e2b0d5f7ded0c9c009f1a044bea3897c Replaced all "protected:" by "private:" or "public:" --- diff --git a/Makefile b/Makefile index 64a6ab9..94e8723 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ BOOSTLIBS=-lboost_program_options CC=g++ # Flags for the C++ compiler -CCFLAGS=-Wall -W -Wextra -fpic -I./include -Llib -O3 #-pg #-static #-DVERBOSE +CCFLAGS=-Wno-deprecated -Wall -W -Wextra -fpic -I./include -Llib -O3 #-pg #-static #-DVERBOSE ifdef DEBUG CCFLAGS:=$(CCFLAGS) -g -DDAI_DEBUG endif diff --git a/include/dai/factor.h b/include/dai/factor.h index 62b0943..6332f20 100644 --- a/include/dai/factor.h +++ b/include/dai/factor.h @@ -49,7 +49,7 @@ template std::ostream& operator<< (std::ostream& os, const TFactor< // T should be castable from and to double template class TFactor { - protected: + private: VarSet _vs; TProb _p; diff --git a/include/dai/hak.h b/include/dai/hak.h index 159c2f7..01373b5 100644 --- a/include/dai/hak.h +++ b/include/dai/hak.h @@ -35,7 +35,7 @@ namespace dai { /// HAK provides an implementation of the single and double-loop algorithms by Heskes, Albers and Kappen class HAK : public DAIAlgRG { - protected: + private: std::vector _Qa; std::vector _Qb; std::vector > _muab; diff --git a/include/dai/jtree.h b/include/dai/jtree.h index eff98de..032d84d 100644 --- a/include/dai/jtree.h +++ b/include/dai/jtree.h @@ -39,14 +39,14 @@ namespace dai { class JTree : public DAIAlgRG { - protected: - DEdgeVec _RTree; // rooted tree - std::vector _Qa; - std::vector _Qb; + private: std::vector > _mes; double _logZ; public: + DEdgeVec RTree; // rooted tree + std::vector Qa; + std::vector Qb; struct Properties { size_t verbose; DAI_ENUM(UpdateType,HUGIN,SHSH) @@ -57,13 +57,13 @@ class JTree : public DAIAlgRG { public: /// Default constructor - JTree() : DAIAlgRG(), _RTree(), _Qa(), _Qb(), _mes(), _logZ(), props() {} + JTree() : DAIAlgRG(), _mes(), _logZ(), RTree(), Qa(), Qb(), props() {} /// Construct from FactorGraph fg and PropertySet opts JTree( const FactorGraph &fg, const PropertySet &opts, bool automatic=true ); /// Copy constructor - JTree( const JTree &x ) : DAIAlgRG(x), _RTree(x._RTree), _Qa(x._Qa), _Qb(x._Qb), _mes(x._mes), _logZ(x._logZ), props(x.props) {} + JTree( const JTree &x ) : DAIAlgRG(x), _mes(x._mes), _logZ(x._logZ), RTree(x.RTree), Qa(x.Qa), Qb(x.Qb), props(x.props) {} /// Clone *this (virtual copy constructor) virtual JTree* clone() const { return new JTree(*this); } @@ -75,11 +75,11 @@ class JTree : public DAIAlgRG { JTree& operator=( const JTree &x ) { if( this != &x ) { DAIAlgRG::operator=( x ); - _RTree = x._RTree; - _Qa = x._Qa; - _Qb = x._Qb; _mes = x._mes; _logZ = x._logZ; + RTree = x.RTree; + Qa = x.Qa; + Qb = x.Qb; props = x.props; } return *this; diff --git a/include/dai/lc.h b/include/dai/lc.h index b49da41..4f31426 100644 --- a/include/dai/lc.h +++ b/include/dai/lc.h @@ -35,7 +35,7 @@ namespace dai { class LC : public DAIAlgFG { - protected: + private: std::vector _pancakes; // used by all LC types (psi_I is stored in the pancake) std::vector _cavitydists; // used by all LC types to store the approximate cavity distribution /// _phis[i][_I] corresponds to \f$ \phi^{\setminus i}_I(x_{I \setminus i}) \f$ diff --git a/include/dai/mf.h b/include/dai/mf.h index 6daef4b..90e5a4f 100644 --- a/include/dai/mf.h +++ b/include/dai/mf.h @@ -33,7 +33,7 @@ namespace dai { class MF : public DAIAlgFG { - protected: + private: std::vector _beliefs; /// Maximum difference encountered so far double _maxdiff; diff --git a/include/dai/prob.h b/include/dai/prob.h index b0466d2..53c4598 100644 --- a/include/dai/prob.h +++ b/include/dai/prob.h @@ -50,7 +50,7 @@ template TProb max( const TProb &a, const TProb &b ); /// TProb implements a probability vector of type T. /// T should be castable from and to double. template class TProb { - protected: + private: /// The entries std::vector _p; diff --git a/include/dai/regiongraph.h b/include/dai/regiongraph.h index 9d0d924..887515b 100644 --- a/include/dai/regiongraph.h +++ b/include/dai/regiongraph.h @@ -34,7 +34,7 @@ namespace dai { /// A Region is a set of variables with a counting number class Region : public VarSet { - protected: + private: /// Counting number double _c; @@ -66,7 +66,7 @@ class Region : public VarSet { /// A FRegion is a factor with a counting number class FRegion : public Factor { - protected: + private: /// Counting number double _c; @@ -103,7 +103,6 @@ class RegionGraph : public FactorGraph { std::vector ORs; std::vector IRs; - protected: /// Give back the OR index that corresponds to a factor index std::vector fac2OR; diff --git a/include/dai/treeep.h b/include/dai/treeep.h index fd039a6..d98d02f 100644 --- a/include/dai/treeep.h +++ b/include/dai/treeep.h @@ -40,7 +40,7 @@ namespace dai { class TreeEP : public JTree { - protected: + private: /// Maximum difference encountered so far double _maxdiff; /// Number of iterations needed @@ -57,14 +57,14 @@ class TreeEP : public JTree { /// Name of this inference method static const char *Name; - protected: + private: class TreeEPSubTree { - protected: + private: std::vector _Qa; std::vector _Qb; DEdgeVec _RTree; - std::vector _a; // _Qa[alpha] <-> superTree._Qa[_a[alpha]] - std::vector _b; // _Qb[beta] <-> superTree._Qb[_b[beta]] + std::vector _a; // _Qa[alpha] <-> superTree.Qa[_a[alpha]] + std::vector _b; // _Qb[beta] <-> superTree.Qb[_b[beta]] // _Qb[beta] <-> _RTree[beta] const Factor * _I; VarSet _ns; diff --git a/src/jtree.cpp b/src/jtree.cpp index 0f28d5b..3f16a28 100644 --- a/src/jtree.cpp +++ b/src/jtree.cpp @@ -58,7 +58,7 @@ string JTree::printProperties() const { } -JTree::JTree( const FactorGraph &fg, const PropertySet &opts, bool automatic ) : DAIAlgRG(fg), _RTree(), _Qa(), _Qb(), _mes(), _logZ(), props() { +JTree::JTree( const FactorGraph &fg, const PropertySet &opts, bool automatic ) : DAIAlgRG(fg), _mes(), _logZ(), RTree(), Qa(), Qb(), props() { setProperties( opts ); if( !isConnected() ) @@ -102,7 +102,7 @@ void JTree::GenerateJT( const std::vector &Cliques ) { } // Construct maximal spanning tree using Prim's algorithm - _RTree = MaxSpanningTreePrims( JuncGraph ); + RTree = MaxSpanningTreePrims( JuncGraph ); // Construct corresponding region graph @@ -125,29 +125,29 @@ void JTree::GenerateJT( const std::vector &Cliques ) { RecomputeORs(); // Create inner regions and edges - IRs.reserve( _RTree.size() ); + IRs.reserve( RTree.size() ); vector edges; - edges.reserve( 2 * _RTree.size() ); - for( size_t i = 0; i < _RTree.size(); i++ ) { - edges.push_back( Edge( _RTree[i].n1, nrIRs() ) ); - edges.push_back( Edge( _RTree[i].n2, nrIRs() ) ); + edges.reserve( 2 * RTree.size() ); + for( size_t i = 0; i < RTree.size(); i++ ) { + edges.push_back( Edge( RTree[i].n1, nrIRs() ) ); + edges.push_back( Edge( RTree[i].n2, nrIRs() ) ); // inner clusters have counting number -1 - IRs.push_back( Region( Cliques[_RTree[i].n1] & Cliques[_RTree[i].n2], -1.0 ) ); + IRs.push_back( Region( Cliques[RTree[i].n1] & Cliques[RTree[i].n2], -1.0 ) ); } // create bipartite graph G.construct( nrORs(), nrIRs(), edges.begin(), edges.end() ); // Create messages and beliefs - _Qa.clear(); - _Qa.reserve( nrORs() ); + Qa.clear(); + Qa.reserve( nrORs() ); for( size_t alpha = 0; alpha < nrORs(); alpha++ ) - _Qa.push_back( OR(alpha) ); + Qa.push_back( OR(alpha) ); - _Qb.clear(); - _Qb.reserve( nrIRs() ); + Qb.clear(); + Qb.reserve( nrIRs() ); for( size_t beta = 0; beta < nrIRs(); beta++ ) - _Qb.push_back( Factor( IR(beta), 1.0 ) ); + Qb.push_back( Factor( IR(beta), 1.0 ) ); _mes.clear(); _mes.reserve( nrORs() ); @@ -174,17 +174,17 @@ string JTree::identify() const { Factor JTree::belief( const VarSet &ns ) const { vector::const_iterator beta; - for( beta = _Qb.begin(); beta != _Qb.end(); beta++ ) + for( beta = Qb.begin(); beta != Qb.end(); beta++ ) if( beta->vars() >> ns ) break; - if( beta != _Qb.end() ) + if( beta != Qb.end() ) return( beta->marginal(ns) ); else { vector::const_iterator alpha; - for( alpha = _Qa.begin(); alpha != _Qa.end(); alpha++ ) + for( alpha = Qa.begin(); alpha != Qa.end(); alpha++ ) if( alpha->vars() >> ns ) break; - assert( alpha != _Qa.end() ); + assert( alpha != Qa.end() ); return( alpha->marginal(ns) ); } } @@ -193,9 +193,9 @@ Factor JTree::belief( const VarSet &ns ) const { vector JTree::beliefs() const { vector result; for( size_t beta = 0; beta < nrIRs(); beta++ ) - result.push_back( _Qb[beta] ); + result.push_back( Qb[beta] ); for( size_t alpha = 0; alpha < nrORs(); alpha++ ) - result.push_back( _Qa[alpha] ); + result.push_back( Qa[alpha] ); return result; } @@ -208,38 +208,38 @@ Factor JTree::belief( const Var &n ) const { // Needs no init void JTree::runHUGIN() { for( size_t alpha = 0; alpha < nrORs(); alpha++ ) - _Qa[alpha] = OR(alpha); + Qa[alpha] = OR(alpha); for( size_t beta = 0; beta < nrIRs(); beta++ ) - _Qb[beta].fill( 1.0 ); + Qb[beta].fill( 1.0 ); // CollectEvidence _logZ = 0.0; - for( size_t i = _RTree.size(); (i--) != 0; ) { -// Make outer region _RTree[i].n1 consistent with outer region _RTree[i].n2 -// IR(i) = seperator OR(_RTree[i].n1) && OR(_RTree[i].n2) - Factor new_Qb = _Qa[_RTree[i].n2].partSum( IR( i ) ); + for( size_t i = RTree.size(); (i--) != 0; ) { +// Make outer region RTree[i].n1 consistent with outer region RTree[i].n2 +// IR(i) = seperator OR(RTree[i].n1) && OR(RTree[i].n2) + Factor new_Qb = Qa[RTree[i].n2].partSum( IR( i ) ); _logZ += log(new_Qb.normalize()); - _Qa[_RTree[i].n1] *= new_Qb.divided_by( _Qb[i] ); - _Qb[i] = new_Qb; + Qa[RTree[i].n1] *= new_Qb.divided_by( Qb[i] ); + Qb[i] = new_Qb; } - if( _RTree.empty() ) - _logZ += log(_Qa[0].normalize() ); + if( RTree.empty() ) + _logZ += log(Qa[0].normalize() ); else - _logZ += log(_Qa[_RTree[0].n1].normalize()); + _logZ += log(Qa[RTree[0].n1].normalize()); // DistributeEvidence - for( size_t i = 0; i < _RTree.size(); i++ ) { -// Make outer region _RTree[i].n2 consistent with outer region _RTree[i].n1 -// IR(i) = seperator OR(_RTree[i].n1) && OR(_RTree[i].n2) - Factor new_Qb = _Qa[_RTree[i].n1].marginal( IR( i ) ); - _Qa[_RTree[i].n2] *= new_Qb.divided_by( _Qb[i] ); - _Qb[i] = new_Qb; + for( size_t i = 0; i < RTree.size(); i++ ) { +// Make outer region RTree[i].n2 consistent with outer region RTree[i].n1 +// IR(i) = seperator OR(RTree[i].n1) && OR(RTree[i].n2) + Factor new_Qb = Qa[RTree[i].n1].marginal( IR( i ) ); + Qa[RTree[i].n2] *= new_Qb.divided_by( Qb[i] ); + Qb[i] = new_Qb; } // Normalize for( size_t alpha = 0; alpha < nrORs(); alpha++ ) - _Qa[alpha].normalize(); + Qa[alpha].normalize(); } @@ -248,11 +248,11 @@ void JTree::runShaferShenoy() { // First pass _logZ = 0.0; for( size_t e = nrIRs(); (e--) != 0; ) { - // send a message from _RTree[e].n2 to _RTree[e].n1 - // or, actually, from the seperator IR(e) to _RTree[e].n1 + // send a message from RTree[e].n2 to RTree[e].n1 + // or, actually, from the seperator IR(e) to RTree[e].n1 - size_t i = nbIR(e)[1].node; // = _RTree[e].n2 - size_t j = nbIR(e)[0].node; // = _RTree[e].n1 + size_t i = nbIR(e)[1].node; // = RTree[e].n2 + size_t j = nbIR(e)[0].node; // = RTree[e].n1 size_t _e = nbIR(e)[0].dual; Factor piet = OR(i); @@ -265,8 +265,8 @@ void JTree::runShaferShenoy() { // Second pass for( size_t e = 0; e < nrIRs(); e++ ) { - size_t i = nbIR(e)[0].node; // = _RTree[e].n1 - size_t j = nbIR(e)[1].node; // = _RTree[e].n2 + size_t i = nbIR(e)[0].node; // = RTree[e].n1 + size_t j = nbIR(e)[1].node; // = RTree[e].n2 size_t _e = nbIR(e)[1].dual; Factor piet = OR(i); @@ -283,17 +283,17 @@ void JTree::runShaferShenoy() { piet *= message( alpha, k.iter ); if( nrIRs() == 0 ) { _logZ += log( piet.normalize() ); - _Qa[alpha] = piet; - } else if( alpha == nbIR(0)[0].node /*_RTree[0].n1*/ ) { + Qa[alpha] = piet; + } else if( alpha == nbIR(0)[0].node /*RTree[0].n1*/ ) { _logZ += log( piet.normalize() ); - _Qa[alpha] = piet; + Qa[alpha] = piet; } else - _Qa[alpha] = piet.normalized(); + Qa[alpha] = piet.normalized(); } // Only for logZ (and for belief)... for( size_t beta = 0; beta < nrIRs(); beta++ ) - _Qb[beta] = _Qa[nbIR(beta)[0].node].marginal( IR(beta) ); + Qb[beta] = Qa[nbIR(beta)[0].node].marginal( IR(beta) ); } @@ -309,10 +309,10 @@ double JTree::run() { Real JTree::logZ() const { Real sum = 0.0; for( size_t beta = 0; beta < nrIRs(); beta++ ) - sum += IR(beta).c() * _Qb[beta].entropy(); + sum += IR(beta).c() * Qb[beta].entropy(); for( size_t alpha = 0; alpha < nrORs(); alpha++ ) { - sum += OR(alpha).c() * _Qa[alpha].entropy(); - sum += (OR(alpha).log0() * _Qa[alpha]).totalSum(); + sum += OR(alpha).c() * Qa[alpha].entropy(); + sum += (OR(alpha).log0() * Qa[alpha]).totalSum(); } return sum; } @@ -332,7 +332,7 @@ size_t JTree::findEfficientTree( const VarSet& ns, DEdgeVec &Tree, size_t Previo // grow new tree Graph oldTree; - for( DEdgeVec::const_iterator e = _RTree.begin(); e != _RTree.end(); e++ ) + for( DEdgeVec::const_iterator e = RTree.begin(); e != RTree.end(); e++ ) oldTree.insert( UEdge(e->n1, e->n2) ); DEdgeVec newTree = GrowRootedTree( oldTree, maxalpha ); @@ -421,17 +421,17 @@ size_t JTree::findEfficientTree( const VarSet& ns, DEdgeVec &Tree, size_t Previo // assumes that run() has been called already Factor JTree::calcMarginal( const VarSet& ns ) { vector::const_iterator beta; - for( beta = _Qb.begin(); beta != _Qb.end(); beta++ ) + for( beta = Qb.begin(); beta != Qb.end(); beta++ ) if( beta->vars() >> ns ) break; - if( beta != _Qb.end() ) + if( beta != Qb.end() ) return( beta->marginal(ns) ); else { vector::const_iterator alpha; - for( alpha = _Qa.begin(); alpha != _Qa.end(); alpha++ ) + for( alpha = Qa.begin(); alpha != Qa.end(); alpha++ ) if( alpha->vars() >> ns ) break; - if( alpha != _Qa.end() ) + if( alpha != Qa.end() ) return( alpha->marginal(ns) ); else { // Find subtree to do efficient inference @@ -442,26 +442,26 @@ Factor JTree::calcMarginal( const VarSet& ns ) { VarSet nsrem = ns / OR(T.front().n1).vars(); Factor Pns (ns, 0.0); - // Save _Qa and _Qb on the subtree - map _Qa_old; - map _Qb_old; + // Save Qa and Qb on the subtree + map Qa_old; + map Qb_old; vector b(Tsize, 0); for( size_t i = Tsize; (i--) != 0; ) { size_t alpha1 = T[i].n1; size_t alpha2 = T[i].n2; size_t beta; for( beta = 0; beta < nrIRs(); beta++ ) - if( UEdge( _RTree[beta].n1, _RTree[beta].n2 ) == UEdge( alpha1, alpha2 ) ) + if( UEdge( RTree[beta].n1, RTree[beta].n2 ) == UEdge( alpha1, alpha2 ) ) break; assert( beta != nrIRs() ); b[i] = beta; - if( !_Qa_old.count( alpha1 ) ) - _Qa_old[alpha1] = _Qa[alpha1]; - if( !_Qa_old.count( alpha2 ) ) - _Qa_old[alpha2] = _Qa[alpha2]; - if( !_Qb_old.count( beta ) ) - _Qb_old[beta] = _Qb[beta]; + if( !Qa_old.count( alpha1 ) ) + Qa_old[alpha1] = Qa[alpha1]; + if( !Qa_old.count( alpha2 ) ) + Qa_old[alpha2] = Qa[alpha2]; + if( !Qb_old.count( beta ) ) + Qb_old[beta] = Qb[beta]; } // For all states of nsrem @@ -473,28 +473,28 @@ Factor JTree::calcMarginal( const VarSet& ns ) { // IR(i) = seperator OR(T[i].n1) && OR(T[i].n2) for( VarSet::const_iterator n = nsrem.begin(); n != nsrem.end(); n++ ) - if( _Qa[T[i].n2].vars() >> *n ) { + if( Qa[T[i].n2].vars() >> *n ) { Factor piet( *n, 0.0 ); piet[s(*n)] = 1.0; - _Qa[T[i].n2] *= piet; + Qa[T[i].n2] *= piet; } - Factor new_Qb = _Qa[T[i].n2].partSum( IR( b[i] ) ); + Factor new_Qb = Qa[T[i].n2].partSum( IR( b[i] ) ); logZ += log(new_Qb.normalize()); - _Qa[T[i].n1] *= new_Qb.divided_by( _Qb[b[i]] ); - _Qb[b[i]] = new_Qb; + Qa[T[i].n1] *= new_Qb.divided_by( Qb[b[i]] ); + Qb[b[i]] = new_Qb; } - logZ += log(_Qa[T[0].n1].normalize()); + logZ += log(Qa[T[0].n1].normalize()); Factor piet( nsrem, 0.0 ); piet[s] = exp(logZ); - Pns += piet * _Qa[T[0].n1].partSum( ns / nsrem ); // OPTIMIZE ME + Pns += piet * Qa[T[0].n1].partSum( ns / nsrem ); // OPTIMIZE ME // Restore clamped beliefs - for( map::const_iterator alpha = _Qa_old.begin(); alpha != _Qa_old.end(); alpha++ ) - _Qa[alpha->first] = alpha->second; - for( map::const_iterator beta = _Qb_old.begin(); beta != _Qb_old.end(); beta++ ) - _Qb[beta->first] = beta->second; + for( map::const_iterator alpha = Qa_old.begin(); alpha != Qa_old.end(); alpha++ ) + Qa[alpha->first] = alpha->second; + for( map::const_iterator beta = Qb_old.begin(); beta != Qb_old.end(); beta++ ) + Qb[beta->first] = beta->second; } return( Pns.normalized() ); diff --git a/src/treeep.cpp b/src/treeep.cpp index ce7d167..d21ed5f 100644 --- a/src/treeep.cpp +++ b/src/treeep.cpp @@ -269,7 +269,7 @@ void TreeEP::ConstructRG( const DEdgeVec &tree ) { } // Construct maximal spanning tree using Prim's algorithm - _RTree = MaxSpanningTreePrims( JuncGraph ); + RTree = MaxSpanningTreePrims( JuncGraph ); // Construct corresponding region graph @@ -296,14 +296,14 @@ void TreeEP::ConstructRG( const DEdgeVec &tree ) { RecomputeORs(); // Create inner regions and edges - IRs.reserve( _RTree.size() ); + IRs.reserve( RTree.size() ); vector edges; - edges.reserve( 2 * _RTree.size() ); - for( size_t i = 0; i < _RTree.size(); i++ ) { - edges.push_back( Edge( _RTree[i].n1, IRs.size() ) ); - edges.push_back( Edge( _RTree[i].n2, IRs.size() ) ); + edges.reserve( 2 * RTree.size() ); + for( size_t i = 0; i < RTree.size(); i++ ) { + edges.push_back( Edge( RTree[i].n1, IRs.size() ) ); + edges.push_back( Edge( RTree[i].n2, IRs.size() ) ); // inner clusters have counting number -1 - IRs.push_back( Region( Cliques[_RTree[i].n1] & Cliques[_RTree[i].n2], -1.0 ) ); + IRs.push_back( Region( Cliques[RTree[i].n1] & Cliques[RTree[i].n2], -1.0 ) ); } // create bipartite graph @@ -313,15 +313,15 @@ void TreeEP::ConstructRG( const DEdgeVec &tree ) { Check_Counting_Numbers(); // Create messages and beliefs - _Qa.clear(); - _Qa.reserve( nrORs() ); + Qa.clear(); + Qa.reserve( nrORs() ); for( size_t alpha = 0; alpha < nrORs(); alpha++ ) - _Qa.push_back( OR(alpha) ); + Qa.push_back( OR(alpha) ); - _Qb.clear(); - _Qb.reserve( nrIRs() ); + Qb.clear(); + Qb.reserve( nrIRs() ); for( size_t beta = 0; beta < nrIRs(); beta++ ) - _Qb.push_back( Factor( IR(beta), 1.0 ) ); + Qb.push_back( Factor( IR(beta), 1.0 ) ); // DIFF with JTree::GenerateJT: no messages @@ -338,7 +338,7 @@ void TreeEP::ConstructRG( const DEdgeVec &tree ) { //subTree.resize( subTreeSize ); // FIXME // cout << "subtree " << I << " has size " << subTreeSize << endl; - TreeEPSubTree QI( subTree, _RTree, _Qa, _Qb, &factor(I) ); + TreeEPSubTree QI( subTree, RTree, Qa, Qb, &factor(I) ); _Q[I] = QI; } // Previous root of first off-tree factor should be the root of the last off-tree factor @@ -350,7 +350,7 @@ void TreeEP::ConstructRG( const DEdgeVec &tree ) { //subTree.resize( subTreeSize ); // FIXME // cout << "subtree " << I << " has size " << subTreeSize << endl; - TreeEPSubTree QI( subTree, _RTree, _Qa, _Qb, &factor(I) ); + TreeEPSubTree QI( subTree, RTree, Qa, Qb, &factor(I) ); _Q[I] = QI; break; } @@ -395,9 +395,9 @@ double TreeEP::run() { for( _iters=0; _iters < props.maxiter && diffs.maxDiff() > props.tol; _iters++ ) { for( size_t I = 0; I < nrFactors(); I++ ) if( offtree(I) ) { - _Q[I].InvertAndMultiply( _Qa, _Qb ); - _Q[I].HUGIN_with_I( _Qa, _Qb ); - _Q[I].InvertAndMultiply( _Qa, _Qb ); + _Q[I].InvertAndMultiply( Qa, Qb ); + _Q[I].HUGIN_with_I( Qa, Qb ); + _Q[I].InvertAndMultiply( Qa, Qb ); } // calculate new beliefs and compare with old ones @@ -435,18 +435,18 @@ Real TreeEP::logZ() const { // entropy of the tree for( size_t beta = 0; beta < nrIRs(); beta++ ) - sum -= _Qb[beta].entropy(); + sum -= Qb[beta].entropy(); for( size_t alpha = 0; alpha < nrORs(); alpha++ ) - sum += _Qa[alpha].entropy(); + sum += Qa[alpha].entropy(); // energy of the on-tree factors for( size_t alpha = 0; alpha < nrORs(); alpha++ ) - sum += (OR(alpha).log0() * _Qa[alpha]).totalSum(); + sum += (OR(alpha).log0() * Qa[alpha]).totalSum(); // energy of the off-tree factors for( size_t I = 0; I < nrFactors(); I++ ) if( offtree(I) ) - sum += (_Q.find(I))->second.logZ( _Qa, _Qb ); + sum += (_Q.find(I))->second.logZ( Qa, Qb ); return sum; }