removed MakeFactorCavity(size_t)
removed ExactMarginal(const VarSet &)
removed ExactlogZ()
- moved isConnected() to BipartiteGraph
removed updatedFactor(size_t)
removed _normtype and NormType()
- WriteToDotFile(const char *filename) -> display( std::ostream& os )
+ removed hasShortLoops(...) and removeShortLoops(...)
+ WriteToDotFile(const char *filename) -> printDot( std::ostream& os )
undoProb(size_t) -> restoreFactor(size_t)
saveProb(size_t) -> backupFactor(size_t)
undoProbs(const VarSet &) -> restoreFactors(const VarSet &)
saveProbs(const VarSet &) -> backupFactors(const VarSet &)
+ ReadFromFile(const char*) returns void (throws on error)
+ WriteToFile(const char*) returns void (throws on error)
+ removed hasNegatives()
- RegionGraph::
nr_ORs() -> nrORs()
nr_IRs() -> nrIRs()
return 1;
} else {
FactorGraph fg;
+ fg.ReadFromFile(argv[1]);
- if( fg.ReadFromFile(argv[1]) ) {
- cout << "Error reading " << argv[1] << endl;
- return 2;
- } else {
- size_t maxiter = 10000;
- double tol = 1e-9;
- size_t verb = 1;
-
- PropertySet opts;
- opts.Set("maxiter",maxiter);
- opts.Set("tol",tol);
- opts.Set("verbose",verb);
-
- JTree jt( fg, opts("updates",string("HUGIN")) );
- jt.init();
- jt.run();
-
- BP bp(fg, opts("updates",string("SEQFIX"))("logdomain",false));
- bp.init();
- bp.run();
-
- cout << "Exact single node marginals:" << endl;
- for( size_t i = 0; i < fg.nrVars(); i++ )
- cout << jt.belief(fg.var(i)) << endl;
-
- cout << "Approximate (loopy belief propagation) single node marginals:" << endl;
- for( size_t i = 0; i < fg.nrVars(); i++ )
- cout << bp.belief(fg.var(i)) << endl;
-
- cout << "Exact factor marginals:" << endl;
- for( size_t I = 0; I < fg.nrFactors(); I++ )
- cout << jt.belief(fg.factor(I).vars()) << endl;
-
- cout << "Approximate (loopy belief propagation) factor marginals:" << endl;
- for( size_t I = 0; I < fg.nrFactors(); I++ )
- cout << bp.belief(fg.factor(I).vars()) << "=" << bp.beliefF(I) << endl;
-
- cout << "Exact log partition sum: " << jt.logZ() << endl;
- cout << "Approximate (loopy belief propagation) log partition sum: " << bp.logZ() << endl;
- }
+ size_t maxiter = 10000;
+ double tol = 1e-9;
+ size_t verb = 1;
+
+ PropertySet opts;
+ opts.Set("maxiter",maxiter);
+ opts.Set("tol",tol);
+ opts.Set("verbose",verb);
+
+ JTree jt( fg, opts("updates",string("HUGIN")) );
+ jt.init();
+ jt.run();
+
+ BP bp(fg, opts("updates",string("SEQFIX"))("logdomain",false));
+ bp.init();
+ bp.run();
+
+ cout << "Exact single node marginals:" << endl;
+ for( size_t i = 0; i < fg.nrVars(); i++ )
+ cout << jt.belief(fg.var(i)) << endl;
+
+ cout << "Approximate (loopy belief propagation) single node marginals:" << endl;
+ for( size_t i = 0; i < fg.nrVars(); i++ )
+ cout << bp.belief(fg.var(i)) << endl;
+
+ cout << "Exact factor marginals:" << endl;
+ for( size_t I = 0; I < fg.nrFactors(); I++ )
+ cout << jt.belief(fg.factor(I).vars()) << endl;
+
+ cout << "Approximate (loopy belief propagation) factor marginals:" << endl;
+ for( size_t I = 0; I < fg.nrFactors(); I++ )
+ cout << bp.belief(fg.factor(I).vars()) << "=" << bp.beliefF(I) << endl;
+
+ cout << "Exact log partition sum: " << jt.logZ() << endl;
+ cout << "Approximate (loopy belief propagation) log partition sum: " << bp.logZ() << endl;
}
return 0;
bool isTree() const;
/// Stream to output stream os in graphviz .dot syntax
- void display( std::ostream& os ) const;
+ void printDot( std::ostream& os ) const;
/// Checks internal consistency
void check() const;
Real logZ() const;
void init( const VarSet &ns );
- void undoProbs( const VarSet &ns ) { FactorGraph::undoProbs(ns); init(ns); }
+ void restoreFactors( const VarSet &ns ) { FactorGraph::restoreFactors(ns); init(ns); }
/// 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 );
virtual double run() = 0;
/// Save factor I
- virtual void saveProb( size_t I ) = 0;
+ virtual void backupFactor( size_t I ) = 0;
/// Save Factors involving ns
- virtual void saveProbs( const VarSet &ns ) = 0;
+ virtual void backupFactors( const VarSet &ns ) = 0;
/// Restore factor I
- virtual void undoProb( size_t I ) = 0;
+ virtual void restoreFactor( size_t I ) = 0;
/// Restore Factors involving ns
- virtual void undoProbs( const VarSet &ns ) = 0;
+ virtual void restoreFactors( const VarSet &ns ) = 0;
/// Clamp variable n to value i (i.e. multiply with a Kronecker delta \f$\delta_{x_n, i}\f$)
virtual void clamp( const Var & n, size_t i ) = 0;
/// Copy constructor
DAIAlg( const DAIAlg & x ) : InfAlg(x), T(x) {}
- /// Save factor I (using T::saveProb)
- void saveProb( size_t I ) { T::saveProb( I ); }
- /// Save Factors involving ns (using T::saveProbs)
- void saveProbs( const VarSet &ns ) { T::saveProbs( ns ); }
+ /// Save factor I (using T::backupFactor)
+ void backupFactor( size_t I ) { T::backupFactor( I ); }
+ /// Save Factors involving ns (using T::backupFactors)
+ void backupFactors( const VarSet &ns ) { T::backupFactors( ns ); }
- /// Restore factor I (using T::undoProb)
- void undoProb( size_t I ) { T::undoProb( I ); }
- /// Restore Factors involving ns (using T::undoProbs)
- void undoProbs( const VarSet &ns ) { T::undoProbs( ns ); }
+ /// Restore factor I (using T::restoreFactor)
+ void restoreFactor( size_t I ) { T::restoreFactor( I ); }
+ /// Restore Factors involving ns (using T::restoreFactors)
+ void restoreFactors( const VarSet &ns ) { T::restoreFactors( ns ); }
/// Clamp variable n to value i (i.e. multiply with a Kronecker delta \f$\delta_{x_n, i}\f$) (using T::clamp)
void clamp( const Var & n, size_t i ) { T::clamp( n, i ); }
static const char *Name;
void create();
- void undoProbs( const VarSet &ns ) { FactorGraph::undoProbs(ns); init(ns); }
+ void restoreFactors( const VarSet &ns ) { FactorGraph::restoreFactors(ns); init(ns); }
void setProperties( const PropertySet &opts );
PropertySet getProperties() const;
std::string printProperties() const;
typedef BipartiteGraph::Edge Edge;
private:
- std::map<size_t,Factor> _backupFactors;
+ std::map<size_t,Factor> _backup;
public:
/// Default constructor
- FactorGraph() : G(), vars(), factors(), _backupFactors() {}
+ FactorGraph() : G(), vars(), factors(), _backup() {}
/// Copy constructor
- FactorGraph(const FactorGraph & x) : G(x.G), vars(x.vars), factors(x.factors), _backupFactors(x._backupFactors) {}
+ FactorGraph(const FactorGraph & x) : G(x.G), vars(x.vars), factors(x.factors), _backup(x._backup) {}
/// Construct FactorGraph from vector of Factors
FactorGraph(const std::vector<Factor> &P);
// Construct a FactorGraph from given factor and variable iterators
G = x.G;
vars = x.vars;
factors = x.factors;
- _backupFactors = x._backupFactors;
+ _backup = x._backup;
}
return *this;
}
void ReadFromFile(const char *filename);
void WriteToFile(const char *filename) const;
- void display( std::ostream& os ) const;
+ void printDot( std::ostream& os ) const;
std::vector<VarSet> Cliques() const;
bool isPairwise() const;
bool isBinary() const;
- private:
void restoreFactor( size_t I );
void backupFactor( size_t I );
void restoreFactors( const VarSet &ns );
// assumes that the set of variables in [var_begin,var_end) is the union of the variables in the factors in [fact_begin, fact_end)
template<typename FactorInputIterator, typename VarInputIterator>
-FactorGraph::FactorGraph(FactorInputIterator fact_begin, FactorInputIterator fact_end, VarInputIterator var_begin, VarInputIterator var_end, size_t nr_fact_hint, size_t nr_var_hint ) : G(), _backupFactors() {
+FactorGraph::FactorGraph(FactorInputIterator fact_begin, FactorInputIterator fact_end, VarInputIterator var_begin, VarInputIterator var_end, size_t nr_fact_hint, size_t nr_var_hint ) : G(), _backup() {
// add factors
size_t nrEdges = 0;
factors.reserve( nr_fact_hint );
Real logZ () const;
void init( const VarSet &ns );
- void undoProbs( const VarSet &ns ) { RegionGraph::undoProbs( ns ); init( ns ); }
+ void restoreFactors( const VarSet &ns ) { RegionGraph::restoreFactors( ns ); init( ns ); }
void setProperties( const PropertySet &opts );
PropertySet getProperties() const;
std::string printProperties() const;
Real logZ() const;
void init( const VarSet &/*ns*/ ) {}
- void undoProbs( const VarSet &ns ) { RegionGraph::undoProbs( ns ); init( ns ); }
+ void restoreFactors( const VarSet &ns ) { RegionGraph::restoreFactors( ns ); init( ns ); }
size_t findEfficientTree( const VarSet& ns, DEdgeVec &Tree, size_t PreviousRoot=(size_t)-1 ) const;
Factor calcMarginal( const VarSet& ns );
void clamp( const Var &/*n*/, size_t /*i*/ ) {
DAI_THROW(NOT_IMPLEMENTED);
}
- void undoProbs( const VarSet &/*ns*/ ) {
+ void restoreFactors( const VarSet &/*ns*/ ) {
DAI_THROW(NOT_IMPLEMENTED);
}
- void saveProbs( const VarSet &/*ns*/ ) {
+ void backupFactors( const VarSet &/*ns*/ ) {
DAI_THROW(NOT_IMPLEMENTED);
}
virtual void makeCavity(const Var & /*n*/) {
Real logZ() const;
void init( const VarSet &ns );
- void undoProbs( const VarSet &ns ) { FactorGraph::undoProbs(ns); init(ns); }
+ void restoreFactors( const VarSet &ns ) { FactorGraph::restoreFactors(ns); init(ns); }
void setProperties( const PropertySet &opts );
PropertySet getProperties() const;
std::string printProperties() const;
/// We have to overload FactorGraph::makeCavity because the corresponding outer regions have to be recomputed
void makeCavity( size_t i ) { FactorGraph::makeCavity( i ); RecomputeORs( var(i) ); }
- /// We have to overload FactorGraph::undoProbs because the corresponding outer regions have to be recomputed
- void undoProbs( const VarSet &ns ) { FactorGraph::restoreFactors( ns ); RecomputeORs( ns ); }
+ /// We have to overload FactorGraph::restoreFactors because the corresponding outer regions have to be recomputed
+ void restoreFactors( const VarSet &ns ) { FactorGraph::restoreFactors( ns ); RecomputeORs( ns ); }
- /// We have to overload FactorGraph::undoProb because the corresponding outer regions have to be recomputed
- void undoProb( size_t I ) { FactorGraph::restoreFactor( I ); RecomputeOR( I ); }
+ /// We have to overload FactorGraph::restoreFactor because the corresponding outer regions have to be recomputed
+ void restoreFactor( size_t I ) { FactorGraph::restoreFactor( I ); RecomputeOR( I ); }
/// Send RegionGraph to output stream
friend std::ostream & operator << ( std::ostream & os, const RegionGraph & rg );
bool offtree( size_t I ) const { return (fac2OR[I] == -1U); }
void init( const VarSet &/*ns*/ ) { init(); }
- void undoProbs( const VarSet &ns ) { RegionGraph::undoProbs( ns ); init( ns ); }
+ void restoreFactors( const VarSet &ns ) { RegionGraph::restoreFactors( ns ); init( ns ); }
void setProperties( const PropertySet &opts );
PropertySet getProperties() const;
}
-void BipartiteGraph::display( std::ostream& os ) const {
+void BipartiteGraph::printDot( std::ostream& os ) const {
using namespace std;
os << "graph G {" << endl;
os << "node[shape=circle,width=0.4,fixedsize=true];" << endl;
Real logZ0 = 0.0;
for( State s(ns); s.valid(); s++ ) {
// save unclamped factors connected to ns
- clamped->saveProbs( ns );
+ clamped->backupFactors( ns );
// set clamping Factors to delta functions
for( VarSet::const_iterator n = ns.begin(); n != ns.end(); n++ )
Pns[s] = Z;
// restore clamped factors
- clamped->undoProbs( ns );
+ clamped->restoreFactors( ns );
}
delete clamped;
// clamp Var j to its possible values
for( size_t j_val = 0; j_val < vns[j].states(); j_val++ ) {
// save unclamped factors connected to ns
- clamped->saveProbs( ns );
+ clamped->backupFactors( ns );
clamped->clamp( vns[j], j_val );
if( reInit )
}
// restore clamped factors
- clamped->undoProbs( ns );
+ clamped->restoreFactors( ns );
}
}
for( size_t j_val = 0; j_val < nj->states(); j_val++ )
for( size_t k_val = 0; k_val < nk->states(); k_val++ ) {
// save unclamped factors connected to ns
- clamped->saveProbs( ns );
+ clamped->backupFactors( ns );
clamped->clamp( *nj, j_val );
clamped->clamp( *nk, k_val );
pairbelief[j_val + (k_val * nj->states())] = Z_xj;
// restore clamped factors
- clamped->undoProbs( ns );
+ clamped->restoreFactors( ns );
}
result.push_back( pairbelief );
using namespace std;
-FactorGraph::FactorGraph( const std::vector<Factor> &P ) : G(), _undoProbs() {
+FactorGraph::FactorGraph( const std::vector<Factor> &P ) : G(), _backup() {
// add factors, obtain variables
set<Var> _vars;
factors.reserve( P.size() );
}
-void FactorGraph::display( ostream &os ) const {
+void FactorGraph::printDot( std::ostream &os ) const {
os << "graph G {" << endl;
os << "node[shape=circle,width=0.4,fixedsize=true];" << endl;
for( size_t i = 0; i < nrVars(); i++ )
void FactorGraph::backupFactor( size_t I ) {
- map<size_t,Factor>::iterator it = _backupFactors.find( I );
- if( it != _backupFactors.end() )
+ map<size_t,Factor>::iterator it = _backup.find( I );
+ if( it != _backup.end() )
DAI_THROW( MULTIPLE_UNDO );
- _backupFactors[I] = factor(I);
+ _backup[I] = factor(I);
}
void FactorGraph::restoreFactor( size_t I ) {
- map<size_t,Factor>::iterator it = _backupFactors.find( I );
- if( it != _backupFactors.end() ) {
+ map<size_t,Factor>::iterator it = _backup.find( I );
+ if( it != _backup.end() ) {
setFactor(I, it->second);
- _backupFactors.erase(it);
+ _backup.erase(it);
}
}
void FactorGraph::restoreFactors( const VarSet &ns ) {
map<size_t,Factor> facs;
- for( map<size_t,Factor>::iterator uI = _backupFactors.begin(); uI != _backupFactors.end(); ) {
+ for( map<size_t,Factor>::iterator uI = _backup.begin(); uI != _backup.end(); ) {
if( factor(uI->first).vars().intersects( ns ) ) {
facs.insert( *uI );
- _backupFactors.erase(uI++);
+ _backup.erase(uI++);
} else
uI++;
}
void FactorGraph::restoreFactors() {
- setFactors( _backupFactors );
- _backupFactors.clear();
+ setFactors( _backup );
+ _backup.clear();
}
void FactorGraph::backupFactors( const std::set<size_t> & facs ) {
for( size_t I = 0; I < nrFactors(); I++ )
facs[newindex[maxfac[I]]] *= factor(I);
- return FactorGraph( facs.begin(), facs.end(), vars().begin(), vars().end(), facs.size(), nrVars() );
+ return FactorGraph( facs.begin(), facs.end(), vars.begin(), vars.end(), facs.size(), nrVars() );
}
TreeEP::TreeEP( const FactorGraph &fg, const PropertySet &opts ) : JTree(fg, opts("updates",string("HUGIN")), false), props(), maxdiff(0.0) {
setProperties( opts );
- assert( fg.G.isConnected() );
+ assert( fg.isConnected() );
if( opts.hasKey("tree") ) {
ConstructRG( opts.GetAs<DEdgeVec>("tree") );
}
FactorGraph fg;
- if( fg.ReadFromFile(filename.c_str()) ) {
- cout << "Error reading " << filename << endl;
- return 2;
- } else {
- vector<Factor> q0;
- double logZ0 = 0.0;
-
- cout << "# " << filename << endl;
+ fg.ReadFromFile(filename.c_str());
+
+ vector<Factor> q0;
+ double logZ0 = 0.0;
+
+ cout << "# " << filename << endl;
+ cout.width( 40 );
+ cout << left << "# METHOD" << " ";
+ if( report_time ) {
+ cout.width( 10 );
+ cout << right << "SECONDS" << " ";
+ }
+ cout.width( 10 );
+ cout << "MAX ERROR" << " ";
+ cout.width( 10 );
+ cout << "AVG ERROR" << " ";
+ cout.width( 10 );
+ cout << "LOGZ ERROR" << " ";
+ cout.width( 10 );
+ cout << "MAXDIFF" << endl;
+
+ for( size_t m = 0; m < methods.size(); m++ ) {
+ pair<string, PropertySet> meth = parseMethod( methods[m], Aliases );
+
+ if( vm.count("tol") )
+ meth.second.Set("tol",tol);
+ if( vm.count("maxiter") )
+ meth.second.Set("maxiter",maxiter);
+ if( vm.count("verbose") )
+ meth.second.Set("verbose",verbose);
+ TestAI piet(fg, meth.first, meth.second );
+ piet.doAI();
+ if( m == 0 ) {
+ q0 = piet.q;
+ logZ0 = piet.logZ;
+ }
+ piet.calcErrs(q0);
+
cout.width( 40 );
- cout << left << "# METHOD" << " ";
+// cout << left << piet.identify() << " ";
+ cout << left << methods[m] << " ";
if( report_time ) {
cout.width( 10 );
- cout << right << "SECONDS" << " ";
+ cout << right << piet.time << " ";
}
- cout.width( 10 );
- cout << "MAX ERROR" << " ";
- cout.width( 10 );
- cout << "AVG ERROR" << " ";
- cout.width( 10 );
- cout << "LOGZ ERROR" << " ";
- cout.width( 10 );
- cout << "MAXDIFF" << endl;
-
- for( size_t m = 0; m < methods.size(); m++ ) {
- pair<string, PropertySet> meth = parseMethod( methods[m], Aliases );
-
- if( vm.count("tol") )
- meth.second.Set("tol",tol);
- if( vm.count("maxiter") )
- meth.second.Set("maxiter",maxiter);
- if( vm.count("verbose") )
- meth.second.Set("verbose",verbose);
- TestAI piet(fg, meth.first, meth.second );
- piet.doAI();
- if( m == 0 ) {
- q0 = piet.q;
- logZ0 = piet.logZ;
- }
- piet.calcErrs(q0);
- cout.width( 40 );
-// cout << left << piet.identify() << " ";
- cout << left << methods[m] << " ";
- if( report_time ) {
- cout.width( 10 );
- cout << right << piet.time << " ";
+ if( m > 0 ) {
+ cout.setf( ios_base::scientific );
+ cout.precision( 3 );
+ cout.width( 10 );
+ double me = clipdouble( piet.maxErr(), 1e-9 );
+ cout << me << " ";
+ cout.width( 10 );
+ double ae = clipdouble( piet.avgErr(), 1e-9 );
+ cout << ae << " ";
+ cout.width( 10 );
+ if( piet.has_logZ ) {
+ double le = clipdouble( piet.logZ / logZ0 - 1.0, 1e-9 );
+ cout << le << " ";
+ } else {
+ cout << "N/A ";
}
-
- if( m > 0 ) {
- cout.setf( ios_base::scientific );
- cout.precision( 3 );
- cout.width( 10 );
- double me = clipdouble( piet.maxErr(), 1e-9 );
- cout << me << " ";
- cout.width( 10 );
- double ae = clipdouble( piet.avgErr(), 1e-9 );
- cout << ae << " ";
- cout.width( 10 );
- if( piet.has_logZ ) {
- double le = clipdouble( piet.logZ / logZ0 - 1.0, 1e-9 );
- cout << le << " ";
- } else {
- cout << "N/A ";
- }
- cout.width( 10 );
- if( piet.has_maxdiff ) {
- double md = clipdouble( piet.maxdiff, 1e-9 );
- if( isnan( me ) )
- md = me;
- if( isnan( ae ) )
- md = ae;
- cout << md << endl;
- } else {
- cout << "N/A ";
- }
- } else
- cout << endl;
-
- if( marginals ) {
- for( size_t i = 0; i < piet.q.size(); i++ )
- cout << "# " << piet.q[i] << endl;
+ cout.width( 10 );
+ if( piet.has_maxdiff ) {
+ double md = clipdouble( piet.maxdiff, 1e-9 );
+ if( isnan( me ) )
+ md = me;
+ if( isnan( ae ) )
+ md = ae;
+ cout << md << endl;
+ } else {
+ cout << "N/A ";
}
+ } else
+ cout << endl;
+
+ if( marginals ) {
+ for( size_t i = 0; i < piet.q.size(); i++ )
+ cout << "# " << piet.q[i] << endl;
}
}
} catch(const char *e) {
throw "Please specify all required arguments";
do {
MakeHOIFG( N, K, k, beta, fg );
- } while( !fg.G.isConnected() );
+ } while( !fg.isConnected() );
cout << "# N = " << N << endl;
cout << "# K = " << K << endl;
#include <iostream>
+#include <fstream>
#include <cstdlib>
#include <string>
#include <dai/factorgraph.h>
FactorGraph fg;
char *infile = argv[1];
- if( fg.ReadFromFile( infile ) ) {
- cerr << "Error reading file " << infile << endl;
- return 2;
- } else {
- if( string( argv[2] ) != "-" )
- fg.WriteToDotFile( argv[2] );
- else {
- cout << "graph G {" << endl;
- cout << "graph[size=\"9,9\"];" << endl;
- cout << "node[shape=circle,width=0.4,fixedsize=true];" << endl;
- for( size_t i = 0; i < fg.nrVars(); i++ )
- cout << "\tx" << fg.var(i).label() << ";" << endl;
- cout << "node[shape=box,style=filled,color=lightgrey,width=0.3,height=0.3,fixedsize=true];" << endl;
- for( size_t I = 0; I < fg.nrFactors(); I++ )
- cout << "\tp" << I << ";" << endl;
- for( size_t i = 0; i < fg.nrVars(); i++ )
- foreach( const FactorGraph::Neighbor &I, fg.nbV(i) )
- cout << "\tx" << fg.var(i).label() << " -- p" << I << ";" << endl;
- cout << "}" << endl;
- }
+ fg.ReadFromFile( infile );
- return 0;
+ ostream *os = &cout;
+ ofstream outfile;
+ if( string( argv[2] ) != "-" ) {
+ outfile.open( argv[2] );
+ if( !outfile.is_open() ) {
+ cerr << "Cannot open " << argv[2] << " for writing" << endl;
+ return 1;
+ }
+ os = &outfile;
}
+
+ fg.printDot( *os );
+
+ return 0;
}
}
FactorGraph fg;
char *infile = argv[1];
- if( fg.ReadFromFile( infile ) ) {
- cerr << "Error reading file " << infile << endl;
- return 2;
- } else {
- cout << "Number of variables: " << fg.nrVars() << endl;
- cout << "Number of factors: " << fg.nrFactors() << endl;
- cout << "Connected: " << fg.G.isConnected() << endl;
+ fg.ReadFromFile( infile );
+ cout << "Number of variables: " << fg.nrVars() << endl;
+ cout << "Number of factors: " << fg.nrFactors() << endl;
+ cout << "Connected: " << fg.isConnected() << endl;
+ cout << "Binary variables? " << fg.isBinary() << endl;
+ cout << "Pairwise interactions? " << fg.isPairwise() << endl;
// cout << "Treewidth: " << endl;
- double cavsum_lcbp = 0.0;
- double cavsum_lcbp2 = 0.0;
- size_t max_Delta_size = 0;
- for( size_t i = 0; i < fg.nrVars(); i++ ) {
- VarSet di = fg.delta(i);
- size_t Ds = fg.Delta(i).states();
- if( Ds > max_Delta_size )
- max_Delta_size = Ds;
- cavsum_lcbp += di.states();
- for( VarSet::const_iterator j = di.begin(); j != di.end(); j++ )
- cavsum_lcbp2 += j->states();
- }
- cout << "Maximum pancake has " << max_Delta_size << " states" << endl;
- cout << "LCBP with full cavities needs " << cavsum_lcbp << " BP runs" << endl;
- cout << "LCBP with only pairinteractions needs " << cavsum_lcbp2 << " BP runs" << endl;
-
- return 0;
+ double cavsum_lcbp = 0.0;
+ double cavsum_lcbp2 = 0.0;
+ size_t max_Delta_size = 0;
+ for( size_t i = 0; i < fg.nrVars(); i++ ) {
+ VarSet di = fg.delta(i);
+ size_t Ds = fg.Delta(i).states();
+ if( Ds > max_Delta_size )
+ max_Delta_size = Ds;
+ cavsum_lcbp += di.states();
+ for( VarSet::const_iterator j = di.begin(); j != di.end(); j++ )
+ cavsum_lcbp2 += j->states();
}
+ cout << "Maximum pancake has " << max_Delta_size << " states" << endl;
+ cout << "LCBP with full cavities needs " << cavsum_lcbp << " BP runs" << endl;
+ cout << "LCBP with only pairinteractions needs " << cavsum_lcbp2 << " BP runs" << endl;
+
+ return 0;
}
}