Put the code inside a horus namespace

This commit is contained in:
Tiago Gomes 2013-02-07 23:53:13 +00:00
parent 4267465f53
commit 6f83ceb6f5
52 changed files with 270 additions and 53 deletions

View File

@ -3,6 +3,8 @@
#include "BayesBall.h" #include "BayesBall.h"
namespace horus {
BayesBall::BayesBall (FactorGraph& fg) BayesBall::BayesBall (FactorGraph& fg)
: fg_(fg) , dag_(fg.getStructure()) : fg_(fg) , dag_(fg.getStructure())
{ {
@ -93,3 +95,5 @@ BayesBall::constructGraph (FactorGraph* fg) const
} }
} }
} // namespace horus

View File

@ -9,6 +9,7 @@
#include "BayesBallGraph.h" #include "BayesBallGraph.h"
#include "Horus.h" #include "Horus.h"
namespace horus {
struct ScheduleInfo struct ScheduleInfo
{ {
@ -69,5 +70,7 @@ BayesBall::scheduleChilds (const BBNode* n, Scheduling& sch) const
} }
} }
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_BAYESBALL_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_BAYESBALL_H_

View File

@ -8,6 +8,8 @@
#include "Util.h" #include "Util.h"
namespace horus {
void void
BayesBallGraph::addNode (BBNode* n) BayesBallGraph::addNode (BBNode* n)
{ {
@ -103,3 +105,5 @@ BayesBallGraph::exportToGraphViz (const char* fileName)
out.close(); out.close();
} }
} // namespace horus

View File

@ -7,6 +7,8 @@
#include "Var.h" #include "Var.h"
#include "Horus.h" #include "Horus.h"
namespace horus {
class BBNode : public Var class BBNode : public Var
{ {
public: public:
@ -76,5 +78,7 @@ class BayesBallGraph
std::unordered_map<VarId, BBNode*> varMap_; std::unordered_map<VarId, BBNode*> varMap_;
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_BAYESBALLGRAPH_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_BAYESBALLGRAPH_H_

View File

@ -9,6 +9,8 @@
#include "Horus.h" #include "Horus.h"
namespace horus {
BpLink::BpLink (FacNode* fn, VarNode* vn) BpLink::BpLink (FacNode* fn, VarNode* vn)
{ {
fac_ = fn; fac_ = fn;
@ -570,3 +572,5 @@ BeliefProp::printLinkInformation (void) const
} }
} }
} // namespace horus

View File

@ -9,6 +9,8 @@
#include "FactorGraph.h" #include "FactorGraph.h"
namespace horus {
enum MsgSchedule { enum MsgSchedule {
SEQ_FIXED, SEQ_FIXED,
SEQ_RANDOM, SEQ_RANDOM,
@ -168,5 +170,7 @@ BeliefProp::ninf (const FacNode* fac) const
return facsI_[fac->getIndex()]; return facsI_[fac->getIndex()];
} }
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_BELIEFPROP_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_BELIEFPROP_H_

View File

@ -7,6 +7,8 @@
#include "Util.h" #include "Util.h"
namespace horus {
void void
CTNode::mergeSubtree (CTNode* n, bool updateLevels) CTNode::mergeSubtree (CTNode* n, bool updateLevels)
{ {
@ -1186,3 +1188,5 @@ ConstraintTree::split (
} }
} }
} // namespace horus

View File

@ -12,6 +12,8 @@
#include "LiftedUtils.h" #include "LiftedUtils.h"
namespace horus {
class CTNode; class CTNode;
class ConstraintTree; class ConstraintTree;
@ -242,5 +244,7 @@ ConstraintTree::nrLogVars (void) const
assert (LogVarSet (logVars_) == logVarSet_); assert (LogVarSet (logVars_) == logVarSet_);
} }
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_CONSTRAINTTREE_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_CONSTRAINTTREE_H_

View File

@ -7,6 +7,8 @@
#include "WeightedBp.h" #include "WeightedBp.h"
namespace horus {
bool CountingBp::fif_ = true; bool CountingBp::fif_ = true;
@ -427,3 +429,5 @@ CountingBp::printGroups (
} }
} }
} // namespace horus

View File

@ -9,6 +9,8 @@
#include "Horus.h" #include "Horus.h"
namespace horus {
class VarCluster; class VarCluster;
class FacCluster; class FacCluster;
class WeightedBp; class WeightedBp;
@ -36,6 +38,8 @@ inline size_t hash_combine (size_t seed, const T& v)
return seed ^ (std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2)); return seed ^ (std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2));
} }
} // namespace horus
namespace std { namespace std {
@ -43,7 +47,7 @@ template <typename T1, typename T2> struct hash<std::pair<T1,T2>>
{ {
size_t operator() (const std::pair<T1,T2>& p) const size_t operator() (const std::pair<T1,T2>& p) const
{ {
return hash_combine (std::hash<T1>()(p.first), p.second); return horus::hash_combine (std::hash<T1>()(p.first), p.second);
} }
}; };
@ -55,15 +59,17 @@ template <typename T> struct hash<std::vector<T>>
typename std::vector<T>::const_iterator first = vec.begin(); typename std::vector<T>::const_iterator first = vec.begin();
typename std::vector<T>::const_iterator last = vec.end(); typename std::vector<T>::const_iterator last = vec.end();
for (; first != last; ++first) { for (; first != last; ++first) {
h = hash_combine (h, *first); h = horus::hash_combine (h, *first);
} }
return h; return h;
} }
}; };
} } // namespace std
namespace horus {
class VarCluster class VarCluster
{ {
public: public:
@ -214,5 +220,7 @@ CountingBp::setColor (const FacNode* fn, Color c)
facColors_[fn->getIndex()] = c; facColors_[fn->getIndex()] = c;
} }
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_COUNTINGBP_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_COUNTINGBP_H_

View File

@ -3,6 +3,9 @@
#include "ElimGraph.h" #include "ElimGraph.h"
namespace horus {
ElimHeuristic ElimGraph::elimHeuristic_ = MIN_NEIGHBORS; ElimHeuristic ElimGraph::elimHeuristic_ = MIN_NEIGHBORS;
@ -238,3 +241,5 @@ ElimGraph::connectAllNeighbors (const EgNode* n)
} }
} }
} // namespace horus

View File

@ -11,6 +11,8 @@
#include "Horus.h" #include "Horus.h"
namespace horus {
class EgNode; class EgNode;
typedef TinySet<EgNode*> EGNeighs; typedef TinySet<EgNode*> EGNeighs;
@ -171,5 +173,7 @@ ElimGraph::neighbors (EgNode* n1, EgNode* n2) const
return n1->isNeighbor (n2); return n1->isNeighbor (n2);
} }
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_ELIMGRAPH_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_ELIMGRAPH_H_

View File

@ -8,6 +8,8 @@
#include "Var.h" #include "Var.h"
namespace horus {
Factor::Factor (const Factor& g) Factor::Factor (const Factor& g)
{ {
clone (g); clone (g);
@ -233,3 +235,5 @@ Factor::clone (const Factor& g)
distId_ = g.distId(); distId_ = g.distId();
} }
} // namespace horus

View File

@ -9,6 +9,9 @@
#include "Indexer.h" #include "Indexer.h"
#include "Util.h" #include "Util.h"
namespace horus {
template <typename T> template <typename T>
class TFactor class TFactor
{ {
@ -363,5 +366,7 @@ class Factor : public TFactor<VarId>
DISALLOW_ASSIGN (Factor); DISALLOW_ASSIGN (Factor);
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_FACTOR_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_FACTOR_H_

View File

@ -8,6 +8,8 @@
#include "Util.h" #include "Util.h"
namespace horus {
bool FactorGraph::exportLd_ = false; bool FactorGraph::exportLd_ = false;
bool FactorGraph::exportUai_ = false; bool FactorGraph::exportUai_ = false;
bool FactorGraph::exportGv_ = false; bool FactorGraph::exportGv_ = false;
@ -480,3 +482,5 @@ FactorGraph::containsCycle (
return false; // no cycle detected in this component return false; // no cycle detected in this component
} }
} // namespace horus

View File

@ -10,6 +10,9 @@
#include "BayesBallGraph.h" #include "BayesBallGraph.h"
#include "Horus.h" #include "Horus.h"
namespace horus {
class FacNode; class FacNode;
@ -179,6 +182,7 @@ struct sortByVarId
} }
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_FACTORGRAPH_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_FACTORGRAPH_H_

View File

@ -11,6 +11,8 @@
#include "Util.h" #include "Util.h"
namespace horus {
void void
GroundSolver::printAnswer (const VarIds& vids) GroundSolver::printAnswer (const VarIds& vids)
{ {
@ -112,3 +114,5 @@ GroundSolver::getJointByConditioning (
return prevBeliefs; return prevBeliefs;
} }
} // namespace horus

View File

@ -5,6 +5,8 @@
#include "Horus.h" #include "Horus.h"
namespace horus {
class GroundSolver class GroundSolver
{ {
public: public:
@ -30,5 +32,7 @@ class GroundSolver
DISALLOW_COPY_AND_ASSIGN (GroundSolver); DISALLOW_COPY_AND_ASSIGN (GroundSolver);
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_GROUNDSOLVER_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_GROUNDSOLVER_H_

View File

@ -7,6 +7,8 @@
#include "Util.h" #include "Util.h"
namespace horus {
HistogramSet::HistogramSet (unsigned size, unsigned range) HistogramSet::HistogramSet (unsigned size, unsigned range)
{ {
size_ = size; size_ = size;
@ -145,3 +147,5 @@ operator<< (std::ostream& os, const HistogramSet& hs)
return os; return os;
} }
} // namespace horus

View File

@ -9,6 +9,8 @@
typedef std::vector<unsigned> Histogram; typedef std::vector<unsigned> Histogram;
namespace horus {
class HistogramSet class HistogramSet
{ {
public: public:
@ -44,5 +46,7 @@ class HistogramSet
DISALLOW_COPY_AND_ASSIGN (HistogramSet); DISALLOW_COPY_AND_ASSIGN (HistogramSet);
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_HISTOGRAM_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_HISTOGRAM_H_

View File

@ -14,6 +14,9 @@
#include <vector> #include <vector>
#include <string> #include <string>
namespace horus {
class Var; class Var;
class Factor; class Factor;
class VarNode; class VarNode;
@ -57,7 +60,7 @@ extern unsigned verbosity;
extern LiftedSolverType liftedSolver; extern LiftedSolverType liftedSolver;
extern GroundSolverType groundSolver; extern GroundSolverType groundSolver;
}; }
namespace Constants { namespace Constants {
@ -70,7 +73,9 @@ const int NO_EVIDENCE = -1;
// number of digits to show when printing a parameter // number of digits to show when printing a parameter
const unsigned PRECISION = 6; const unsigned PRECISION = 6;
}; }
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_HORUS_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_HORUS_H_

View File

@ -11,11 +11,12 @@
int readHorusFlags (int, const char* []); int readHorusFlags (int, const char* []);
void readFactorGraph (FactorGraph&, const char*); void readFactorGraph (horus::FactorGraph&, const char*);
VarIds readQueryAndEvidence (FactorGraph&, int, const char* [], int); horus::VarIds readQueryAndEvidence (
horus::FactorGraph&, int, const char* [], int);
void runSolver (const FactorGraph&, const VarIds&); void runSolver (const horus::FactorGraph&, const horus::VarIds&);
const std::string USAGE = "usage: ./hcli [solver=hve|bp|cbp] \ const std::string USAGE = "usage: ./hcli [solver=hve|bp|cbp] \
[<OPTION>=<VALUE>]... <FILE> [<VAR>|<VAR>=<EVIDENCE>]... " ; [<OPTION>=<VALUE>]... <FILE> [<VAR>|<VAR>=<EVIDENCE>]... " ;
@ -26,27 +27,27 @@ main (int argc, const char* argv[])
{ {
if (argc <= 1) { if (argc <= 1) {
std::cerr << "Error: no probabilistic graphical model was given." ; std::cerr << "Error: no probabilistic graphical model was given." ;
std::cerr << std::endl; std::cerr << std::endl << USAGE << std::endl;
std::cerr << USAGE << std::endl;
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
int idx = readHorusFlags (argc, argv); int idx = readHorusFlags (argc, argv);
FactorGraph fg; horus::FactorGraph fg;
readFactorGraph (fg, argv[idx]); readFactorGraph (fg, argv[idx]);
VarIds queryIds = readQueryAndEvidence (fg, argc, argv, idx + 1); horus::VarIds queryIds
if (FactorGraph::exportToLibDai()) { = readQueryAndEvidence (fg, argc, argv, idx + 1);
if (horus::FactorGraph::exportToLibDai()) {
fg.exportToLibDai ("model.fg"); fg.exportToLibDai ("model.fg");
} }
if (FactorGraph::exportToUai()) { if (horus::FactorGraph::exportToUai()) {
fg.exportToUai ("model.uai"); fg.exportToUai ("model.uai");
} }
if (FactorGraph::exportGraphViz()) { if (horus::FactorGraph::exportGraphViz()) {
fg.exportToGraphViz ("model.dot"); fg.exportToGraphViz ("model.dot");
} }
if (FactorGraph::printFactorGraph()) { if (horus::FactorGraph::printFactorGraph()) {
fg.print(); fg.print();
} }
if (Globals::verbosity > 0) { if (horus::Globals::verbosity > 0) {
std::cout << "factor graph contains " ; std::cout << "factor graph contains " ;
std::cout << fg.nrVarNodes() << " variables and " ; std::cout << fg.nrVarNodes() << " variables and " ;
std::cout << fg.nrFacNodes() << " factors " << std::endl; std::cout << fg.nrFacNodes() << " factors " << std::endl;
@ -79,7 +80,7 @@ readHorusFlags (int argc, const char* argv[])
std::cerr << USAGE << std::endl; std::cerr << USAGE << std::endl;
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
Util::setHorusFlag (leftArg, rightArg); horus::Util::setHorusFlag (leftArg, rightArg);
} }
return i + 1; return i + 1;
} }
@ -87,7 +88,7 @@ readHorusFlags (int argc, const char* argv[])
void void
readFactorGraph (FactorGraph& fg, const char* s) readFactorGraph (horus::FactorGraph& fg, const char* s)
{ {
std::string fileName (s); std::string fileName (s);
std::string extension = fileName.substr (fileName.find_last_of ('.') + 1); std::string extension = fileName.substr (fileName.find_last_of ('.') + 1);
@ -104,25 +105,25 @@ readFactorGraph (FactorGraph& fg, const char* s)
VarIds horus::VarIds
readQueryAndEvidence ( readQueryAndEvidence (
FactorGraph& fg, horus::FactorGraph& fg,
int argc, int argc,
const char* argv[], const char* argv[],
int start) int start)
{ {
VarIds queryIds; horus::VarIds queryIds;
for (int i = start; i < argc; i++) { for (int i = start; i < argc; i++) {
const std::string& arg = argv[i]; const std::string& arg = argv[i];
if (arg.find ('=') == std::string::npos) { if (arg.find ('=') == std::string::npos) {
if (Util::isInteger (arg) == false) { if (horus::Util::isInteger (arg) == false) {
std::cerr << "Error: `" << arg << "' " ; std::cerr << "Error: `" << arg << "' " ;
std::cerr << "is not a variable id." ; std::cerr << "is not a variable id." ;
std::cerr << std::endl; std::cerr << std::endl;
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
VarId vid = Util::stringToUnsigned (arg); horus::VarId vid = horus::Util::stringToUnsigned (arg);
VarNode* queryVar = fg.getVarNode (vid); horus::VarNode* queryVar = fg.getVarNode (vid);
if (queryVar == false) { if (queryVar == false) {
std::cerr << "Error: unknow variable with id " ; std::cerr << "Error: unknow variable with id " ;
std::cerr << "`" << vid << "'." << std::endl; std::cerr << "`" << vid << "'." << std::endl;
@ -138,13 +139,13 @@ readQueryAndEvidence (
std::cerr << USAGE << std::endl; std::cerr << USAGE << std::endl;
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
if (Util::isInteger (leftArg) == false) { if (horus::Util::isInteger (leftArg) == false) {
std::cerr << "Error: `" << leftArg << "' " ; std::cerr << "Error: `" << leftArg << "' " ;
std::cerr << "is not a variable id." << std::endl; std::cerr << "is not a variable id." << std::endl;
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
VarId vid = Util::stringToUnsigned (leftArg); horus::VarId vid = horus::Util::stringToUnsigned (leftArg);
VarNode* observedVar = fg.getVarNode (vid); horus::VarNode* observedVar = fg.getVarNode (vid);
if (observedVar == false) { if (observedVar == false) {
std::cerr << "Error: unknow variable with id " ; std::cerr << "Error: unknow variable with id " ;
std::cerr << "`" << vid << "'." << std::endl; std::cerr << "`" << vid << "'." << std::endl;
@ -155,12 +156,12 @@ readQueryAndEvidence (
std::cerr << USAGE << std::endl; std::cerr << USAGE << std::endl;
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
if (Util::isInteger (rightArg) == false) { if (horus::Util::isInteger (rightArg) == false) {
std::cerr << "Error: `" << rightArg << "' " ; std::cerr << "Error: `" << rightArg << "' " ;
std::cerr << "is not a state index." << std::endl; std::cerr << "is not a state index." << std::endl;
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
unsigned stateIdx = Util::stringToUnsigned (rightArg); unsigned stateIdx = horus::Util::stringToUnsigned (rightArg);
if (observedVar->isValidState (stateIdx) == false) { if (observedVar->isValidState (stateIdx) == false) {
std::cerr << "Error: `" << stateIdx << "' " ; std::cerr << "Error: `" << stateIdx << "' " ;
std::cerr << "is not a valid state index for variable with id " ; std::cerr << "is not a valid state index for variable with id " ;
@ -176,23 +177,25 @@ readQueryAndEvidence (
void void
runSolver (const FactorGraph& fg, const VarIds& queryIds) runSolver (
const horus::FactorGraph& fg,
const horus::VarIds& queryIds)
{ {
GroundSolver* solver = 0; horus::GroundSolver* solver = 0;
switch (Globals::groundSolver) { switch (horus::Globals::groundSolver) {
case GroundSolverType::VE: case horus::GroundSolverType::VE:
solver = new VarElim (fg); solver = new horus::VarElim (fg);
break; break;
case GroundSolverType::BP: case horus::GroundSolverType::BP:
solver = new BeliefProp (fg); solver = new horus::BeliefProp (fg);
break; break;
case GroundSolverType::CBP: case horus::GroundSolverType::CBP:
solver = new CountingBp (fg); solver = new horus::CountingBp (fg);
break; break;
default: default:
assert (false); assert (false);
} }
if (Globals::verbosity > 0) { if (horus::Globals::verbosity > 0) {
solver->printSolverFlags(); solver->printSolverFlags();
std::cout << std::endl; std::cout << std::endl;
} }

View File

@ -20,6 +20,7 @@
#include "ElimGraph.h" #include "ElimGraph.h"
#include "BayesBall.h" #include "BayesBall.h"
namespace horus {
typedef std::pair<ParfactorList*, ObservedFormulas*> LiftedNetwork; typedef std::pair<ParfactorList*, ObservedFormulas*> LiftedNetwork;
@ -581,3 +582,5 @@ init_predicates (void)
freeGroundNetwork, 1); freeGroundNetwork, 1);
} }
} // namespace horus

View File

@ -10,6 +10,8 @@
#include "Util.h" #include "Util.h"
namespace horus {
class Indexer class Indexer
{ {
public: public:
@ -361,5 +363,7 @@ operator<< (std::ostream &os, const MapIndexer& indexer)
return os; return os;
} }
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_INDEXER_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_INDEXER_H_

View File

@ -8,6 +8,8 @@
#include "FactorGraph.h" #include "FactorGraph.h"
namespace horus {
LiftedBp::LiftedBp (const ParfactorList& parfactorList) LiftedBp::LiftedBp (const ParfactorList& parfactorList)
: LiftedSolver (parfactorList) : LiftedSolver (parfactorList)
{ {
@ -235,3 +237,5 @@ LiftedBp::getJointByConditioning (
return prevBeliefs; return prevBeliefs;
} }
} // namespace horus

View File

@ -7,6 +7,8 @@
#include "ParfactorList.h" #include "ParfactorList.h"
namespace horus {
class FactorGraph; class FactorGraph;
class WeightedBp; class WeightedBp;
@ -43,5 +45,7 @@ class LiftedBp : public LiftedSolver
DISALLOW_COPY_AND_ASSIGN (LiftedBp); DISALLOW_COPY_AND_ASSIGN (LiftedBp);
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDBP_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDBP_H_

View File

@ -7,6 +7,8 @@
#include "Indexer.h" #include "Indexer.h"
namespace horus {
OrNode::~OrNode (void) OrNode::~OrNode (void)
{ {
delete leftBranch_; delete leftBranch_;
@ -1316,3 +1318,5 @@ LiftedKc::printSolverFlags (void) const
std::cout << ss.str() << std::endl; std::cout << ss.str() << std::endl;
} }
} // namespace horus

View File

@ -11,6 +11,8 @@
#include "ParfactorList.h" #include "ParfactorList.h"
namespace horus {
enum CircuitNodeType { enum CircuitNodeType {
OR_NODE, OR_NODE,
AND_NODE, AND_NODE,
@ -303,5 +305,7 @@ class LiftedKc : public LiftedSolver
DISALLOW_COPY_AND_ASSIGN (LiftedKc); DISALLOW_COPY_AND_ASSIGN (LiftedKc);
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDKC_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDKC_H_

View File

@ -5,6 +5,8 @@
#include "LiftedOperations.h" #include "LiftedOperations.h"
namespace horus {
void void
LiftedOperations::shatterAgainstQuery ( LiftedOperations::shatterAgainstQuery (
ParfactorList& pfList, ParfactorList& pfList,
@ -273,3 +275,5 @@ LiftedOperations::absorve (
return absorvedPfs; return absorvedPfs;
} }
} // namespace horus

View File

@ -3,6 +3,9 @@
#include "ParfactorList.h" #include "ParfactorList.h"
namespace horus {
class LiftedOperations class LiftedOperations
{ {
public: public:
@ -25,5 +28,7 @@ class LiftedOperations
DISALLOW_COPY_AND_ASSIGN (LiftedOperations); DISALLOW_COPY_AND_ASSIGN (LiftedOperations);
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDOPERATIONS_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDOPERATIONS_H_

View File

@ -4,6 +4,8 @@
#include "ParfactorList.h" #include "ParfactorList.h"
namespace horus {
class LiftedSolver class LiftedSolver
{ {
public: public:
@ -23,5 +25,7 @@ class LiftedSolver
DISALLOW_COPY_AND_ASSIGN (LiftedSolver); DISALLOW_COPY_AND_ASSIGN (LiftedSolver);
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDSOLVER_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDSOLVER_H_

View File

@ -5,6 +5,8 @@
#include "LiftedUtils.h" #include "LiftedUtils.h"
namespace horus {
namespace LiftedUtils { namespace LiftedUtils {
std::unordered_map<std::string, unsigned> symbolDict; std::unordered_map<std::string, unsigned> symbolDict;
@ -130,3 +132,5 @@ operator<< (std::ostream& os, const Substitution& theta)
return os; return os;
} }
} // namespace horus

View File

@ -10,6 +10,8 @@
#include "Util.h" #include "Util.h"
namespace horus {
class Symbol class Symbol
{ {
public: public:
@ -67,25 +69,28 @@ LogVar::valid (void) const
return id_ != Util::maxUnsigned(); return id_ != Util::maxUnsigned();
} }
} // namespace horus
namespace std { namespace std {
template <> struct hash<Symbol> { template <> struct hash<horus::Symbol> {
size_t operator() (const Symbol& s) const { size_t operator() (const horus::Symbol& s) const {
return std::hash<unsigned>() (s); return std::hash<unsigned>() (s);
} }
}; };
template <> struct hash<LogVar> { template <> struct hash<horus::LogVar> {
size_t operator() (const LogVar& X) const { size_t operator() (const horus::LogVar& X) const {
return std::hash<unsigned>() (X); return std::hash<unsigned>() (X);
} }
}; };
}; } // namespace std
namespace horus {
typedef std::vector<Symbol> Symbols; typedef std::vector<Symbol> Symbols;
typedef std::vector<Symbol> Tuple; typedef std::vector<Symbol> Tuple;
typedef std::vector<Tuple> Tuples; typedef std::vector<Tuple> Tuples;
@ -205,5 +210,7 @@ Substitution::nrReplacements (void) const
return subs_.size(); return subs_.size();
} }
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDUTILS_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDUTILS_H_

View File

@ -12,6 +12,8 @@
#include "Util.h" #include "Util.h"
namespace horus {
std::vector<LiftedOperator*> std::vector<LiftedOperator*>
LiftedOperator::getValidOps ( LiftedOperator::getValidOps (
ParfactorList& pfList, ParfactorList& pfList,
@ -732,3 +734,5 @@ LiftedVe::getBestOperation (const Grounds& query)
return bestOp; return bestOp;
} }
} // namespace horus

View File

@ -8,6 +8,8 @@
#include "ParfactorList.h" #include "ParfactorList.h"
namespace horus {
class LiftedOperator class LiftedOperator
{ {
public: public:
@ -167,5 +169,7 @@ class LiftedVe : public LiftedSolver
DISALLOW_COPY_AND_ASSIGN (LiftedVe); DISALLOW_COPY_AND_ASSIGN (LiftedVe);
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDVE_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDVE_H_

View File

@ -8,6 +8,8 @@
#include "Indexer.h" #include "Indexer.h"
namespace horus {
bool bool
Literal::isGround (ConstraintTree constr, LogVarSet ipgLogVars) const Literal::isGround (ConstraintTree constr, LogVarSet ipgLogVars) const
{ {
@ -660,3 +662,5 @@ LiftedWCNF::printClauses (void) const
Clause::printClauses (clauses_); Clause::printClauses (clauses_);
} }
}

View File

@ -9,6 +9,8 @@
#include "ParfactorList.h" #include "ParfactorList.h"
namespace horus {
class ConstraintTree; class ConstraintTree;
enum LogVarType enum LogVarType
@ -241,5 +243,7 @@ class LiftedWCNF
DISALLOW_COPY_AND_ASSIGN (LiftedWCNF); DISALLOW_COPY_AND_ASSIGN (LiftedWCNF);
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDWCNF_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDWCNF_H_

View File

@ -10,6 +10,8 @@
#include "Horus.h" #include "Horus.h"
namespace horus {
Parfactor::Parfactor ( Parfactor::Parfactor (
const ProbFormulas& formulas, const ProbFormulas& formulas,
const Params& params, const Params& params,
@ -946,3 +948,5 @@ Parfactor::alignLogicalVars (Parfactor* g1, Parfactor* g2)
g2->applySubstitution (theta2); g2->applySubstitution (theta2);
} }
} // namespace horus

View File

@ -11,6 +11,8 @@
#include "Horus.h" #include "Horus.h"
namespace horus {
class Parfactor : public TFactor<ProbFormula> class Parfactor : public TFactor<ProbFormula>
{ {
public: public:
@ -120,5 +122,7 @@ class Parfactor : public TFactor<ProbFormula>
typedef std::vector<Parfactor*> Parfactors; typedef std::vector<Parfactor*> Parfactors;
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_PARFACTOR_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_PARFACTOR_H_

View File

@ -7,6 +7,8 @@
#include "ParfactorList.h" #include "ParfactorList.h"
namespace horus {
ParfactorList::ParfactorList (const ParfactorList& pfList) ParfactorList::ParfactorList (const ParfactorList& pfList)
{ {
ParfactorList::const_iterator it = pfList.begin(); ParfactorList::const_iterator it = pfList.begin();
@ -644,3 +646,5 @@ ParfactorList::disjoint (
return (ts1 & ts2).empty(); return (ts1 & ts2).empty();
} }
} // namespace horus

View File

@ -6,6 +6,9 @@
#include "Parfactor.h" #include "Parfactor.h"
#include "ProbFormula.h" #include "ProbFormula.h"
namespace horus {
class Parfactor; class Parfactor;
@ -117,5 +120,7 @@ class ParfactorList
std::list<Parfactor*> pfList_; std::list<Parfactor*> pfList_;
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_PARFACTORLIST_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_PARFACTORLIST_H_

View File

@ -5,6 +5,9 @@
#include "ProbFormula.h" #include "ProbFormula.h"
namespace horus {
PrvGroup ProbFormula::freeGroup_ = 0; PrvGroup ProbFormula::freeGroup_ = 0;
@ -162,3 +165,5 @@ operator<< (std::ostream& os, const ObservedFormula& of)
return os; return os;
} }
} // namespace horus

View File

@ -9,6 +9,9 @@
#include "LiftedUtils.h" #include "LiftedUtils.h"
#include "Horus.h" #include "Horus.h"
namespace horus {
typedef unsigned long PrvGroup; typedef unsigned long PrvGroup;
class ProbFormula class ProbFormula
@ -111,5 +114,7 @@ class ObservedFormula
typedef std::vector<ObservedFormula> ObservedFormulas; typedef std::vector<ObservedFormula> ObservedFormulas;
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_PROBFORMULA_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_PROBFORMULA_H_

View File

@ -6,6 +6,8 @@
#include <ostream> #include <ostream>
namespace horus {
template <typename T, typename Compare = std::less<T>> template <typename T, typename Compare = std::less<T>>
class TinySet class TinySet
{ {
@ -402,5 +404,7 @@ TinySet<T,C>::consistent (void) const
return true; return true;
} }
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_TINYSET_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_TINYSET_H_

View File

@ -4,6 +4,8 @@
#include "BeliefProp.h" #include "BeliefProp.h"
namespace horus {
namespace Globals { namespace Globals {
bool logDomain = false; bool logDomain = false;
@ -14,7 +16,7 @@ LiftedSolverType liftedSolver = LiftedSolverType::LVE;
GroundSolverType groundSolver = GroundSolverType::VE; GroundSolverType groundSolver = GroundSolverType::VE;
}; }
@ -329,8 +331,7 @@ printDashedLine (std::ostream& os)
os << std::endl; os << std::endl;
} }
} // namespace Util
}
@ -426,5 +427,8 @@ pow (Params& v, double exp)
Globals::logDomain ? v *= exp : v ^= exp; Globals::logDomain ? v *= exp : v ^= exp;
} }
} } // namespace LogAware
} // namespace horus

View File

@ -16,12 +16,13 @@
#include "Horus.h" #include "Horus.h"
namespace horus {
namespace { namespace {
const double NEG_INF = -std::numeric_limits<double>::infinity(); const double NEG_INF = -std::numeric_limits<double>::infinity();
}; }
namespace Util { namespace Util {
@ -100,7 +101,7 @@ void printAsteriskLine (std::ostream& os = std::cout);
void printDashedLine (std::ostream& os = std::cout); void printDashedLine (std::ostream& os = std::cout);
}; } // namespace Util
@ -289,7 +290,7 @@ void pow (Params&, unsigned);
void pow (Params&, double); void pow (Params&, double);
}; } // namespace LogAware
@ -430,7 +431,9 @@ struct abs_diff_exp : public std::binary_function<T, T, T>
} }
}; };
} } // namespace FuncObject
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_UTIL_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_UTIL_H_

View File

@ -3,6 +3,8 @@
#include "Var.h" #include "Var.h"
namespace horus {
std::unordered_map<VarId, VarInfo> Var::varsInfo_; std::unordered_map<VarId, VarInfo> Var::varsInfo_;
@ -108,3 +110,5 @@ Var::clearVarsInfo (void)
varsInfo_.clear(); varsInfo_.clear();
} }
} // namespace horus

View File

@ -10,6 +10,8 @@
#include "Horus.h" #include "Horus.h"
namespace horus {
struct VarInfo struct VarInfo
{ {
VarInfo (std::string l, const States& sts) VarInfo (std::string l, const States& sts)
@ -105,5 +107,7 @@ Var::operator!= (const Var& var) const
return !(*this == var); return !(*this == var);
} }
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_VAR_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_VAR_H_

View File

@ -8,6 +8,8 @@
#include "Util.h" #include "Util.h"
namespace horus {
Params Params
VarElim::solveQuery (VarIds queryVids) VarElim::solveQuery (VarIds queryVids)
{ {
@ -198,3 +200,5 @@ VarElim::printActiveFactors (void)
} }
} }
} // namespace horus

View File

@ -9,6 +9,8 @@
#include "Horus.h" #include "Horus.h"
namespace horus {
class VarElim : public GroundSolver class VarElim : public GroundSolver
{ {
public: public:
@ -39,5 +41,7 @@ class VarElim : public GroundSolver
DISALLOW_COPY_AND_ASSIGN (VarElim); DISALLOW_COPY_AND_ASSIGN (VarElim);
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_VARELIM_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_VARELIM_H_

View File

@ -4,6 +4,7 @@
#include "WeightedBp.h" #include "WeightedBp.h"
namespace horus {
WeightedBp::~WeightedBp (void) WeightedBp::~WeightedBp (void)
{ {
@ -304,3 +305,5 @@ WeightedBp::printLinkInformation (void) const
} }
} }
} // namespace horus

View File

@ -6,6 +6,8 @@
#include "BeliefProp.h" #include "BeliefProp.h"
namespace horus {
class WeightedLink : public BpLink class WeightedLink : public BpLink
{ {
public: public:
@ -68,5 +70,7 @@ class WeightedBp : public BeliefProp
DISALLOW_COPY_AND_ASSIGN (WeightedBp); DISALLOW_COPY_AND_ASSIGN (WeightedBp);
}; };
} // namespace horus
#endif // YAP_PACKAGES_CLPBN_HORUS_WEIGHTEDBP_H_ #endif // YAP_PACKAGES_CLPBN_HORUS_WEIGHTEDBP_H_