add an enum for lifted solvers and do some renamings

This commit is contained in:
Tiago Gomes 2012-05-30 17:17:39 +01:00
parent ac38e9e6a6
commit 8d14593c3e
4 changed files with 27 additions and 16 deletions

View File

@ -28,11 +28,18 @@ typedef vector<unsigned> Ranges;
typedef unsigned long long ullong; typedef unsigned long long ullong;
enum InfAlgorithms enum LiftedSolvers
{ {
VE, // variable elimination FOVE, // first order variable elimination
BP, // belief propagation LBP, // lifted belief propagation
CBP // counting belief propagation };
enum GroundSolvers
{
VE, // variable elimination
BP, // belief propagation
CBP // counting belief propagation
}; };
@ -43,7 +50,8 @@ extern bool logDomain;
// level of debug information // level of debug information
extern unsigned verbosity; extern unsigned verbosity;
extern InfAlgorithms infAlgorithm; extern LiftedSolvers liftedSolver;
extern GroundSolvers groundSolver;
}; };

View File

@ -161,14 +161,14 @@ void
runSolver (const FactorGraph& fg, const VarIds& queryIds) runSolver (const FactorGraph& fg, const VarIds& queryIds)
{ {
Solver* solver = 0; Solver* solver = 0;
switch (Globals::infAlgorithm) { switch (Globals::groundSolver) {
case InfAlgorithms::VE: case GroundSolvers::VE:
solver = new VarElimSolver (fg); solver = new VarElimSolver (fg);
break; break;
case InfAlgorithms::BP: case GroundSolvers::BP:
solver = new BpSolver (fg); solver = new BpSolver (fg);
break; break;
case InfAlgorithms::CBP: case GroundSolvers::CBP:
solver = new CbpSolver (fg); solver = new CbpSolver (fg);
break; break;
default: default:

View File

@ -352,7 +352,7 @@ runGroundSolver (void)
} }
vector<Params> results; vector<Params> results;
if (Globals::infAlgorithm == InfAlgorithms::VE) { if (Globals::groundSolver == GroundSolvers::VE) {
runVeSolver (fg, tasks, results); runVeSolver (fg, tasks, results);
} else { } else {
runBpSolver (fg, tasks, results); runBpSolver (fg, tasks, results);
@ -417,9 +417,9 @@ void runBpSolver (
//mfg = BayesBall::getMinimalFactorGraph ( //mfg = BayesBall::getMinimalFactorGraph (
// *fg, VarIds (vids.begin(),vids.end())); // *fg, VarIds (vids.begin(),vids.end()));
} }
if (Globals::infAlgorithm == InfAlgorithms::BP) { if (Globals::groundSolver == GroundSolvers::BP) {
solver = new BpSolver (*fg); // FIXME solver = new BpSolver (*fg); // FIXME
} else if (Globals::infAlgorithm == InfAlgorithms::CBP) { } else if (Globals::groundSolver == GroundSolvers::CBP) {
CFactorGraph::checkForIdenticalFactors = false; CFactorGraph::checkForIdenticalFactors = false;
solver = new CbpSolver (*fg); // FIXME solver = new CbpSolver (*fg); // FIXME
} else { } else {

View File

@ -13,7 +13,10 @@ bool logDomain = false;
unsigned verbosity = 0; unsigned verbosity = 0;
InfAlgorithms infAlgorithm = InfAlgorithms::VE; LiftedSolvers liftedSolver = LiftedSolvers::FOVE;
GroundSolvers groundSolver = GroundSolvers::VE;
}; };
@ -208,11 +211,11 @@ setHorusFlag (string key, string value)
ss >> Globals::verbosity; ss >> Globals::verbosity;
} else if (key == "inf_alg") { } else if (key == "inf_alg") {
if ( value == "ve") { if ( value == "ve") {
Globals::infAlgorithm = InfAlgorithms::VE; Globals::groundSolver = GroundSolvers::VE;
} else if (value == "bp") { } else if (value == "bp") {
Globals::infAlgorithm = InfAlgorithms::BP; Globals::groundSolver = GroundSolvers::BP;
} else if (value == "cbp") { } else if (value == "cbp") {
Globals::infAlgorithm = InfAlgorithms::CBP; Globals::groundSolver = GroundSolvers::CBP;
} else { } else {
cerr << "warning: invalid value `" << value << "' " ; cerr << "warning: invalid value `" << value << "' " ;
cerr << "for `" << key << "'" << endl; cerr << "for `" << key << "'" << endl;