refactor printing of a parfactor

This commit is contained in:
Tiago Gomes 2012-05-15 16:57:50 +01:00
parent 346b70145f
commit 7ec4887e77
2 changed files with 53 additions and 28 deletions

View File

@ -557,6 +557,15 @@ Parfactor::print (bool printParams) const
copy.moveToTop (copy.logVarSet().elements()); copy.moveToTop (copy.logVarSet().elements());
cout << "Tuples: " << copy.tupleSet() << endl; cout << "Tuples: " << copy.tupleSet() << endl;
if (printParams) { if (printParams) {
printParameters();
}
}
void
Parfactor::printParameters (void) const
{
vector<string> jointStrings; vector<string> jointStrings;
StatesIndexer indexer (ranges_); StatesIndexer indexer (ranges_);
while (indexer.valid()) { while (indexer.valid()) {
@ -584,8 +593,20 @@ Parfactor::print (bool printParams) const
cout << "f(" << jointStrings[i] << ")" ; cout << "f(" << jointStrings[i] << ")" ;
cout << " = " << params_[i] << endl; cout << " = " << params_[i] << endl;
} }
}
void
Parfactor::printProjections (void) const
{
ConstraintTree copy (*constr_);
LogVarSet Xs = copy.logVarSet();
for (unsigned i = 0; i < Xs.size(); i++) {
cout << "-> projection of " << Xs[i] << ": " ;
cout << copy.tupleSet ({Xs[i]}) << endl;
} }
cout << endl;
} }

View File

@ -80,6 +80,10 @@ class Parfactor : public TFactor<ProbFormula>
void print (bool = false) const; void print (bool = false) const;
void printParameters (void) const;
void printProjections (void) const;
string getLabel (void) const; string getLabel (void) const;
private: private: