implement a printSolverParameters in ground solvers

This commit is contained in:
Tiago Gomes 2012-04-13 15:22:24 +01:00
parent f3be68a552
commit 00faccd940
7 changed files with 76 additions and 0 deletions

View File

@ -48,6 +48,28 @@ BpSolver::solveQuery (VarIds queryVids)
void
BpSolver::printSolverFlags (void) const
{
stringstream ss;
ss << "belief propagation [" ;
ss << "schedule=" ;
typedef BpOptions::Schedule Sch;
switch (BpOptions::schedule) {
case Sch::SEQ_FIXED: ss << "seq_fixed"; break;
case Sch::SEQ_RANDOM: ss << "seq_random"; break;
case Sch::PARALLEL: ss << "parallel"; break;
case Sch::MAX_RESIDUAL: ss << "max_residual"; break;
}
ss << ",maxiter=" << Util::toString (BpOptions::maxIter);
ss << ",accuracy=" << Util::toString (BpOptions::accuracy);
ss << ",log_domain=" << Util::toString (Globals::logDomain);
ss << "]" ;
cout << ss.str() << endl;
}
Params
BpSolver::getPosterioriOf (VarId vid)
{

View File

@ -97,6 +97,8 @@ class BpSolver : public Solver
Params solveQuery (VarIds);
virtual void printSolverFlags (void) const;
virtual Params getPosterioriOf (VarId);
virtual Params getJointDistributionOf (const VarIds&);

View File

@ -40,6 +40,32 @@ CbpSolver::~CbpSolver (void)
void
CbpSolver::printSolverFlags (void) const
{
stringstream ss;
ss << "counting bp [" ;
ss << "schedule=" ;
typedef BpOptions::Schedule Sch;
switch (BpOptions::schedule) {
case Sch::SEQ_FIXED: ss << "seq_fixed"; break;
case Sch::SEQ_RANDOM: ss << "seq_random"; break;
case Sch::PARALLEL: ss << "parallel"; break;
case Sch::MAX_RESIDUAL: ss << "max_residual"; break;
}
ss << ",max_iter=" << BpOptions::maxIter;
ss << ",accuracy=" << BpOptions::accuracy;
ss << ",log_domain=" << Util::toString (Globals::logDomain);
ss << ",order_vars=" << Util::toString (FactorGraph::orderVariables);
ss << ",chkif=" <<
Util::toString (CFactorGraph::checkForIdenticalFactors);
ss << "]" ;
cout << ss.str() << endl;
}
Params
CbpSolver::getPosterioriOf (VarId vid)
{

View File

@ -39,6 +39,8 @@ class CbpSolver : public BpSolver
~CbpSolver (void);
void printSolverFlags (void) const;
Params getPosterioriOf (VarId);
Params getJointDistributionOf (const VarIds&);

View File

@ -18,6 +18,8 @@ class Solver
virtual Params solveQuery (VarIds queryVids) = 0;
virtual void printSolverFlags (void) const = 0;
void printAnswer (const VarIds& vids);
void printAllPosterioris (void);

View File

@ -32,6 +32,26 @@ VarElimSolver::solveQuery (VarIds queryVids)
void
VarElimSolver::printSolverFlags (void) const
{
stringstream ss;
ss << "variable elimination [" ;
ss << "elim_heuristic=" ;
ElimHeuristic eh = ElimGraph::getEliminationHeuristic();
switch (eh) {
case MIN_NEIGHBORS: ss << "min_neighbors"; break;
case MIN_WEIGHT: ss << "min_weight"; break;
case MIN_FILL: ss << "min_fill"; break;
case WEIGHTED_MIN_FILL: ss << "weighted_min_fill"; break;
}
ss << ",log_domain=" << Util::toString (Globals::logDomain);
ss << "]" ;
cout << ss.str() << endl;
}
void
VarElimSolver::createFactorList (void)
{

View File

@ -20,6 +20,8 @@ class VarElimSolver : public Solver
Params solveQuery (VarIds);
void printSolverFlags (void) const;
private:
void createFactorList (void);