print statistics for bayesnet and bayestree
parent
4e2aae0121
commit
7a9dd715e7
|
|
@ -26,6 +26,7 @@
|
|||
#include <boost/assign/std/vector.hpp> // for +=
|
||||
using boost::assign::operator+=;
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
|
|
@ -39,6 +40,24 @@ namespace gtsam {
|
|||
conditional->print();
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template<class CONDITIONAL>
|
||||
void BayesNet<CONDITIONAL>::printStats(const std::string& s) const {
|
||||
std::cout << s;
|
||||
const size_t n = conditionals_.size();
|
||||
size_t max_size = 0;
|
||||
size_t total = 0;
|
||||
BOOST_REVERSE_FOREACH(sharedConditional conditional, conditionals_) {
|
||||
max_size = std::max(max_size, conditional->size());
|
||||
total += conditional->size();
|
||||
}
|
||||
std::cout << s
|
||||
<< "maximum clique size = " << max_size << std::endl
|
||||
<< "average clique size = " << total / n << std::endl
|
||||
<< "density = " << 100.0 * total / (double) (n*(n+1)/2) << " %" << std::endl
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template<class CONDITIONAL>
|
||||
bool BayesNet<CONDITIONAL>::equals(const BayesNet& cbn, double tol) const {
|
||||
|
|
|
|||
|
|
@ -90,6 +90,9 @@ public:
|
|||
/** print */
|
||||
void print(const std::string& s = "") const;
|
||||
|
||||
/** print statistics */
|
||||
void printStats(const std::string& s = "") const;
|
||||
|
||||
/** check equality */
|
||||
bool equals(const BayesNet& other, double tol = 1e-9) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -102,6 +102,18 @@ namespace gtsam {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************************* */
|
||||
template<class CONDITIONAL, class CLIQUE>
|
||||
void BayesTree<CONDITIONAL,CLIQUE>::CliqueStats::print(const std::string& s) const {
|
||||
std::cout << s
|
||||
<<"\navg Conditional Size: " << avgConditionalSize
|
||||
<< "\nmax Conditional Size: " << maxConditionalSize
|
||||
<< "\navg Separator Size: " << avgSeparatorSize
|
||||
<< "\nmax Separator Size: " << maxSeparatorSize
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template<class CONDITIONAL, class CLIQUE>
|
||||
typename BayesTree<CONDITIONAL,CLIQUE>::CliqueStats
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ namespace gtsam {
|
|||
std::size_t maxConditionalSize;
|
||||
double avgSeparatorSize;
|
||||
std::size_t maxSeparatorSize;
|
||||
void print(const std::string& s = "") const ;
|
||||
};
|
||||
|
||||
/** store all the sizes */
|
||||
|
|
|
|||
|
|
@ -118,13 +118,7 @@ void NonlinearISAM::print(const string& s, const KeyFormatter& keyFormatter) con
|
|||
|
||||
/* ************************************************************************* */
|
||||
void NonlinearISAM::printStats() const {
|
||||
gtsam::GaussianISAM::CliqueData data = isam_.getCliqueData();
|
||||
gtsam::GaussianISAM::CliqueStats stats = data.getStats();
|
||||
cout << "\navg Conditional Size: " << stats.avgConditionalSize;
|
||||
cout << "\nmax Conditional Size: " << stats.maxConditionalSize;
|
||||
cout << "\navg Separator Size: " << stats.avgSeparatorSize;
|
||||
cout << "\nmax Separator Size: " << stats.maxSeparatorSize;
|
||||
cout << endl;
|
||||
isam_.getCliqueData().getStats().print();
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
|
|||
Loading…
Reference in New Issue