This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/CLPBN/clpbn/bp/Solver.h
2011-05-17 12:00:33 +01:00

51 lines
1.1 KiB
C++

#ifndef BP_SOLVER_H
#define BP_SOLVER_H
#include <iomanip>
#include "GraphicalModel.h"
#include "Variable.h"
using namespace std;
class Solver
{
public:
Solver (const GraphicalModel* gm)
{
gm_ = gm;
}
virtual void runSolver (void) = 0;
virtual ParamSet getPosterioriOf (const Variable*) const = 0;
void printPosterioriOf (const Variable* var) const
{
cout << endl;
cout << setw (20) << left << var->getLabel() << "posteriori" ;
cout << endl;
cout << "------------------------------" ;
cout << endl;
const Domain& domain = var->getDomain();
ParamSet results = getPosterioriOf (var);
for (int xi = 0; xi < var->getDomainSize(); xi++) {
cout << setw (20) << domain[xi];
cout << setprecision (PRECISION) << results[xi];
cout << endl;
}
cout << endl;
}
void printAllPosterioris (void) const
{
VarSet vars = gm_->getVariables();
for (unsigned i = 0; i < vars.size(); i++) {
printPosterioriOf (vars[i]);
}
}
private:
const GraphicalModel* gm_;
};
#endif