calculating the number of nonzero entries in R corresponding to the Bayes tree
parent
d850e2837c
commit
e86c9465bb
|
|
@ -221,12 +221,14 @@ namespace gtsam {
|
||||||
int maxClique = 0;
|
int maxClique = 0;
|
||||||
double avgClique = 0;
|
double avgClique = 0;
|
||||||
int numCliques = 0;
|
int numCliques = 0;
|
||||||
|
int nnzR = 0;
|
||||||
if (counter>0) { // cannot call on empty tree
|
if (counter>0) { // cannot call on empty tree
|
||||||
GaussianISAM2_P::CliqueData cdata = this->getCliqueData();
|
GaussianISAM2_P::CliqueData cdata = this->getCliqueData();
|
||||||
GaussianISAM2_P::CliqueStats cstats = cdata.getStats();
|
GaussianISAM2_P::CliqueStats cstats = cdata.getStats();
|
||||||
maxClique = cstats.maxConditionalSize;
|
maxClique = cstats.maxConditionalSize;
|
||||||
avgClique = cstats.avgConditionalSize;
|
avgClique = cstats.avgConditionalSize;
|
||||||
numCliques = cdata.conditionalSizes.size();
|
numCliques = cdata.conditionalSizes.size();
|
||||||
|
nnzR = calculate_nnz(this->root());
|
||||||
}
|
}
|
||||||
counter++;
|
counter++;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -267,7 +269,7 @@ namespace gtsam {
|
||||||
#ifdef PRINT_STATS
|
#ifdef PRINT_STATS
|
||||||
cout << "linear: #newKeys: " << newKeys.size() << " #affectedVariables: " << affectedKeys.size()
|
cout << "linear: #newKeys: " << newKeys.size() << " #affectedVariables: " << affectedKeys.size()
|
||||||
<< " #affectedFactors: " << factors.size() << " maxCliqueSize: " << maxClique
|
<< " #affectedFactors: " << factors.size() << " maxCliqueSize: " << maxClique
|
||||||
<< " avgCliqueSize: " << avgClique << " #Cliques: " << numCliques << endl;
|
<< " avgCliqueSize: " << avgClique << " #Cliques: " << numCliques << " nnzR: " << nnzR << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
toc("linear_lookup1");
|
toc("linear_lookup1");
|
||||||
|
|
|
||||||
|
|
@ -53,4 +53,31 @@ VectorConfig optimize2(const GaussianISAM2_P& bayesTree, double threshold) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
void nnz_internal(const GaussianISAM2::sharedClique& clique, int& result) {
|
||||||
|
// go through the conditionals of this clique
|
||||||
|
GaussianISAM2::Clique::const_reverse_iterator it;
|
||||||
|
for (it = clique->rbegin(); it!=clique->rend(); it++) {
|
||||||
|
GaussianConditional::shared_ptr cg = *it;
|
||||||
|
int dimSep = 0;
|
||||||
|
for (GaussianConditional::const_iterator matrix_it = cg->parentsBegin(); matrix_it != cg->parentsEnd(); matrix_it++) {
|
||||||
|
dimSep += matrix_it->second.size2();
|
||||||
|
}
|
||||||
|
int dimR = cg->dim();
|
||||||
|
result += (dimR+1)*dimR/2 + dimSep*dimR;
|
||||||
|
}
|
||||||
|
// traverse the children
|
||||||
|
BOOST_FOREACH(const GaussianISAM2::sharedClique& child, clique->children_) {
|
||||||
|
nnz_internal(child, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
int calculate_nnz(const GaussianISAM2::sharedClique& clique) {
|
||||||
|
int result = 0;
|
||||||
|
// starting from the root, add up entries of frontal and conditional matrices of each conditional
|
||||||
|
nnz_internal(clique, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
} /// namespace gtsam
|
} /// namespace gtsam
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,7 @@ namespace gtsam {
|
||||||
// optimize the BayesTree, starting from the root
|
// optimize the BayesTree, starting from the root
|
||||||
VectorConfig optimize2(const GaussianISAM2_P& bayesTree, double threshold = 0.);
|
VectorConfig optimize2(const GaussianISAM2_P& bayesTree, double threshold = 0.);
|
||||||
|
|
||||||
|
// calculate the number of non-zero entries for the tree starting at clique (use root for complete matrix)
|
||||||
|
int calculate_nnz(const GaussianISAM2::sharedClique& clique);
|
||||||
|
|
||||||
}/// namespace gtsam
|
}/// namespace gtsam
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue