refactor printing of a parfactor
This commit is contained in:
parent
346b70145f
commit
7ec4887e77
@ -557,35 +557,56 @@ 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) {
|
||||||
vector<string> jointStrings;
|
printParameters();
|
||||||
StatesIndexer indexer (ranges_);
|
}
|
||||||
while (indexer.valid()) {
|
}
|
||||||
stringstream ss;
|
|
||||||
for (unsigned i = 0; i < args_.size(); i++) {
|
|
||||||
if (i != 0) ss << ", " ;
|
|
||||||
if (args_[i].isCounting()) {
|
void
|
||||||
unsigned N = constr_->getConditionalCount (
|
Parfactor::printParameters (void) const
|
||||||
args_[i].countedLogVar());
|
{
|
||||||
HistogramSet hs (N, args_[i].range());
|
vector<string> jointStrings;
|
||||||
unsigned c = 0;
|
StatesIndexer indexer (ranges_);
|
||||||
while (c < indexer[i]) {
|
while (indexer.valid()) {
|
||||||
hs.nextHistogram();
|
stringstream ss;
|
||||||
c ++;
|
for (unsigned i = 0; i < args_.size(); i++) {
|
||||||
}
|
if (i != 0) ss << ", " ;
|
||||||
ss << hs;
|
if (args_[i].isCounting()) {
|
||||||
} else {
|
unsigned N = constr_->getConditionalCount (
|
||||||
ss << indexer[i];
|
args_[i].countedLogVar());
|
||||||
}
|
HistogramSet hs (N, args_[i].range());
|
||||||
}
|
unsigned c = 0;
|
||||||
jointStrings.push_back (ss.str());
|
while (c < indexer[i]) {
|
||||||
++ indexer;
|
hs.nextHistogram();
|
||||||
}
|
c ++;
|
||||||
for (unsigned i = 0; i < params_.size(); i++) {
|
}
|
||||||
cout << "f(" << jointStrings[i] << ")" ;
|
ss << hs;
|
||||||
cout << " = " << params_[i] << endl;
|
} else {
|
||||||
}
|
ss << indexer[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jointStrings.push_back (ss.str());
|
||||||
|
++ indexer;
|
||||||
|
}
|
||||||
|
for (unsigned i = 0; i < params_.size(); i++) {
|
||||||
|
cout << "f(" << jointStrings[i] << ")" ;
|
||||||
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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:
|
||||||
|
Reference in New Issue
Block a user