From 8d14593c3eed691bc76297b47ddd6e6a858ca8e1 Mon Sep 17 00:00:00 2001 From: Tiago Gomes Date: Wed, 30 May 2012 17:17:39 +0100 Subject: [PATCH] add an enum for lifted solvers and do some renamings --- packages/CLPBN/horus/Horus.h | 18 +++++++++++++----- packages/CLPBN/horus/HorusCli.cpp | 8 ++++---- packages/CLPBN/horus/HorusYap.cpp | 6 +++--- packages/CLPBN/horus/Util.cpp | 11 +++++++---- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/packages/CLPBN/horus/Horus.h b/packages/CLPBN/horus/Horus.h index 37968d99e..eca23ae9a 100644 --- a/packages/CLPBN/horus/Horus.h +++ b/packages/CLPBN/horus/Horus.h @@ -28,11 +28,18 @@ typedef vector Ranges; typedef unsigned long long ullong; -enum InfAlgorithms +enum LiftedSolvers { - VE, // variable elimination - BP, // belief propagation - CBP // counting belief propagation + FOVE, // first order variable elimination + LBP, // lifted 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 extern unsigned verbosity; -extern InfAlgorithms infAlgorithm; +extern LiftedSolvers liftedSolver; +extern GroundSolvers groundSolver; }; diff --git a/packages/CLPBN/horus/HorusCli.cpp b/packages/CLPBN/horus/HorusCli.cpp index 7766d65f0..868f25130 100644 --- a/packages/CLPBN/horus/HorusCli.cpp +++ b/packages/CLPBN/horus/HorusCli.cpp @@ -161,14 +161,14 @@ void runSolver (const FactorGraph& fg, const VarIds& queryIds) { Solver* solver = 0; - switch (Globals::infAlgorithm) { - case InfAlgorithms::VE: + switch (Globals::groundSolver) { + case GroundSolvers::VE: solver = new VarElimSolver (fg); break; - case InfAlgorithms::BP: + case GroundSolvers::BP: solver = new BpSolver (fg); break; - case InfAlgorithms::CBP: + case GroundSolvers::CBP: solver = new CbpSolver (fg); break; default: diff --git a/packages/CLPBN/horus/HorusYap.cpp b/packages/CLPBN/horus/HorusYap.cpp index f224bb63d..ff4c39d52 100644 --- a/packages/CLPBN/horus/HorusYap.cpp +++ b/packages/CLPBN/horus/HorusYap.cpp @@ -352,7 +352,7 @@ runGroundSolver (void) } vector results; - if (Globals::infAlgorithm == InfAlgorithms::VE) { + if (Globals::groundSolver == GroundSolvers::VE) { runVeSolver (fg, tasks, results); } else { runBpSolver (fg, tasks, results); @@ -417,9 +417,9 @@ void runBpSolver ( //mfg = BayesBall::getMinimalFactorGraph ( // *fg, VarIds (vids.begin(),vids.end())); } - if (Globals::infAlgorithm == InfAlgorithms::BP) { + if (Globals::groundSolver == GroundSolvers::BP) { solver = new BpSolver (*fg); // FIXME - } else if (Globals::infAlgorithm == InfAlgorithms::CBP) { + } else if (Globals::groundSolver == GroundSolvers::CBP) { CFactorGraph::checkForIdenticalFactors = false; solver = new CbpSolver (*fg); // FIXME } else { diff --git a/packages/CLPBN/horus/Util.cpp b/packages/CLPBN/horus/Util.cpp index 0e51e6ee7..dc50c29a0 100644 --- a/packages/CLPBN/horus/Util.cpp +++ b/packages/CLPBN/horus/Util.cpp @@ -13,7 +13,10 @@ bool logDomain = false; 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; } else if (key == "inf_alg") { if ( value == "ve") { - Globals::infAlgorithm = InfAlgorithms::VE; + Globals::groundSolver = GroundSolvers::VE; } else if (value == "bp") { - Globals::infAlgorithm = InfAlgorithms::BP; + Globals::groundSolver = GroundSolvers::BP; } else if (value == "cbp") { - Globals::infAlgorithm = InfAlgorithms::CBP; + Globals::groundSolver = GroundSolvers::CBP; } else { cerr << "warning: invalid value `" << value << "' " ; cerr << "for `" << key << "'" << endl;