From 6f83ceb6f5c32d2848de10ceb0134b6f39788946 Mon Sep 17 00:00:00 2001 From: Tiago Gomes Date: Thu, 7 Feb 2013 23:53:13 +0000 Subject: [PATCH] Put the code inside a horus namespace --- packages/CLPBN/horus/BayesBall.cpp | 4 ++ packages/CLPBN/horus/BayesBall.h | 3 + packages/CLPBN/horus/BayesBallGraph.cpp | 4 ++ packages/CLPBN/horus/BayesBallGraph.h | 4 ++ packages/CLPBN/horus/BeliefProp.cpp | 4 ++ packages/CLPBN/horus/BeliefProp.h | 4 ++ packages/CLPBN/horus/ConstraintTree.cpp | 4 ++ packages/CLPBN/horus/ConstraintTree.h | 4 ++ packages/CLPBN/horus/CountingBp.cpp | 4 ++ packages/CLPBN/horus/CountingBp.h | 14 ++++- packages/CLPBN/horus/ElimGraph.cpp | 5 ++ packages/CLPBN/horus/ElimGraph.h | 4 ++ packages/CLPBN/horus/Factor.cpp | 4 ++ packages/CLPBN/horus/Factor.h | 5 ++ packages/CLPBN/horus/FactorGraph.cpp | 4 ++ packages/CLPBN/horus/FactorGraph.h | 4 ++ packages/CLPBN/horus/GroundSolver.cpp | 4 ++ packages/CLPBN/horus/GroundSolver.h | 4 ++ packages/CLPBN/horus/Histogram.cpp | 4 ++ packages/CLPBN/horus/Histogram.h | 4 ++ packages/CLPBN/horus/Horus.h | 9 ++- packages/CLPBN/horus/HorusCli.cpp | 73 ++++++++++++----------- packages/CLPBN/horus/HorusYap.cpp | 3 + packages/CLPBN/horus/Indexer.h | 4 ++ packages/CLPBN/horus/LiftedBp.cpp | 4 ++ packages/CLPBN/horus/LiftedBp.h | 4 ++ packages/CLPBN/horus/LiftedKc.cpp | 4 ++ packages/CLPBN/horus/LiftedKc.h | 4 ++ packages/CLPBN/horus/LiftedOperations.cpp | 4 ++ packages/CLPBN/horus/LiftedOperations.h | 5 ++ packages/CLPBN/horus/LiftedSolver.h | 4 ++ packages/CLPBN/horus/LiftedUtils.cpp | 4 ++ packages/CLPBN/horus/LiftedUtils.h | 17 ++++-- packages/CLPBN/horus/LiftedVe.cpp | 4 ++ packages/CLPBN/horus/LiftedVe.h | 4 ++ packages/CLPBN/horus/LiftedWCNF.cpp | 4 ++ packages/CLPBN/horus/LiftedWCNF.h | 4 ++ packages/CLPBN/horus/Parfactor.cpp | 4 ++ packages/CLPBN/horus/Parfactor.h | 4 ++ packages/CLPBN/horus/ParfactorList.cpp | 4 ++ packages/CLPBN/horus/ParfactorList.h | 5 ++ packages/CLPBN/horus/ProbFormula.cpp | 5 ++ packages/CLPBN/horus/ProbFormula.h | 5 ++ packages/CLPBN/horus/TinySet.h | 4 ++ packages/CLPBN/horus/Util.cpp | 12 ++-- packages/CLPBN/horus/Util.h | 11 ++-- packages/CLPBN/horus/Var.cpp | 4 ++ packages/CLPBN/horus/Var.h | 4 ++ packages/CLPBN/horus/VarElim.cpp | 4 ++ packages/CLPBN/horus/VarElim.h | 4 ++ packages/CLPBN/horus/WeightedBp.cpp | 3 + packages/CLPBN/horus/WeightedBp.h | 4 ++ 52 files changed, 270 insertions(+), 53 deletions(-) diff --git a/packages/CLPBN/horus/BayesBall.cpp b/packages/CLPBN/horus/BayesBall.cpp index 01da5edc0..be3abc309 100644 --- a/packages/CLPBN/horus/BayesBall.cpp +++ b/packages/CLPBN/horus/BayesBall.cpp @@ -3,6 +3,8 @@ #include "BayesBall.h" +namespace horus { + BayesBall::BayesBall (FactorGraph& fg) : fg_(fg) , dag_(fg.getStructure()) { @@ -93,3 +95,5 @@ BayesBall::constructGraph (FactorGraph* fg) const } } +} // namespace horus + diff --git a/packages/CLPBN/horus/BayesBall.h b/packages/CLPBN/horus/BayesBall.h index b8101231e..367bfe67d 100644 --- a/packages/CLPBN/horus/BayesBall.h +++ b/packages/CLPBN/horus/BayesBall.h @@ -9,6 +9,7 @@ #include "BayesBallGraph.h" #include "Horus.h" +namespace horus { struct ScheduleInfo { @@ -69,5 +70,7 @@ BayesBall::scheduleChilds (const BBNode* n, Scheduling& sch) const } } +} // namespace horus + #endif // YAP_PACKAGES_CLPBN_HORUS_BAYESBALL_H_ diff --git a/packages/CLPBN/horus/BayesBallGraph.cpp b/packages/CLPBN/horus/BayesBallGraph.cpp index 18b93b86f..c4500076a 100644 --- a/packages/CLPBN/horus/BayesBallGraph.cpp +++ b/packages/CLPBN/horus/BayesBallGraph.cpp @@ -8,6 +8,8 @@ #include "Util.h" +namespace horus { + void BayesBallGraph::addNode (BBNode* n) { @@ -103,3 +105,5 @@ BayesBallGraph::exportToGraphViz (const char* fileName) out.close(); } +} // namespace horus + diff --git a/packages/CLPBN/horus/BayesBallGraph.h b/packages/CLPBN/horus/BayesBallGraph.h index e6c82467c..abc434a87 100644 --- a/packages/CLPBN/horus/BayesBallGraph.h +++ b/packages/CLPBN/horus/BayesBallGraph.h @@ -7,6 +7,8 @@ #include "Var.h" #include "Horus.h" +namespace horus { + class BBNode : public Var { public: @@ -76,5 +78,7 @@ class BayesBallGraph std::unordered_map varMap_; }; +} // namespace horus + #endif // YAP_PACKAGES_CLPBN_HORUS_BAYESBALLGRAPH_H_ diff --git a/packages/CLPBN/horus/BeliefProp.cpp b/packages/CLPBN/horus/BeliefProp.cpp index 2b4aa6a6d..d170840e6 100644 --- a/packages/CLPBN/horus/BeliefProp.cpp +++ b/packages/CLPBN/horus/BeliefProp.cpp @@ -9,6 +9,8 @@ #include "Horus.h" +namespace horus { + BpLink::BpLink (FacNode* fn, VarNode* vn) { fac_ = fn; @@ -570,3 +572,5 @@ BeliefProp::printLinkInformation (void) const } } +} // namespace horus + diff --git a/packages/CLPBN/horus/BeliefProp.h b/packages/CLPBN/horus/BeliefProp.h index 77783069f..385966985 100644 --- a/packages/CLPBN/horus/BeliefProp.h +++ b/packages/CLPBN/horus/BeliefProp.h @@ -9,6 +9,8 @@ #include "FactorGraph.h" +namespace horus { + enum MsgSchedule { SEQ_FIXED, SEQ_RANDOM, @@ -168,5 +170,7 @@ BeliefProp::ninf (const FacNode* fac) const return facsI_[fac->getIndex()]; } +} // namespace horus + #endif // YAP_PACKAGES_CLPBN_HORUS_BELIEFPROP_H_ diff --git a/packages/CLPBN/horus/ConstraintTree.cpp b/packages/CLPBN/horus/ConstraintTree.cpp index fa4797add..f7f8cb88c 100644 --- a/packages/CLPBN/horus/ConstraintTree.cpp +++ b/packages/CLPBN/horus/ConstraintTree.cpp @@ -7,6 +7,8 @@ #include "Util.h" +namespace horus { + void CTNode::mergeSubtree (CTNode* n, bool updateLevels) { @@ -1186,3 +1188,5 @@ ConstraintTree::split ( } } +} // namespace horus + diff --git a/packages/CLPBN/horus/ConstraintTree.h b/packages/CLPBN/horus/ConstraintTree.h index c2970aeff..42700f9df 100644 --- a/packages/CLPBN/horus/ConstraintTree.h +++ b/packages/CLPBN/horus/ConstraintTree.h @@ -12,6 +12,8 @@ #include "LiftedUtils.h" +namespace horus { + class CTNode; class ConstraintTree; @@ -242,5 +244,7 @@ ConstraintTree::nrLogVars (void) const assert (LogVarSet (logVars_) == logVarSet_); } +} // namespace horus + #endif // YAP_PACKAGES_CLPBN_HORUS_CONSTRAINTTREE_H_ diff --git a/packages/CLPBN/horus/CountingBp.cpp b/packages/CLPBN/horus/CountingBp.cpp index 88064a2ec..84a5c8f20 100644 --- a/packages/CLPBN/horus/CountingBp.cpp +++ b/packages/CLPBN/horus/CountingBp.cpp @@ -7,6 +7,8 @@ #include "WeightedBp.h" +namespace horus { + bool CountingBp::fif_ = true; @@ -427,3 +429,5 @@ CountingBp::printGroups ( } } +} // namespace horus + diff --git a/packages/CLPBN/horus/CountingBp.h b/packages/CLPBN/horus/CountingBp.h index 64da217f0..6a2aa9456 100644 --- a/packages/CLPBN/horus/CountingBp.h +++ b/packages/CLPBN/horus/CountingBp.h @@ -9,6 +9,8 @@ #include "Horus.h" +namespace horus { + class VarCluster; class FacCluster; class WeightedBp; @@ -36,6 +38,8 @@ inline size_t hash_combine (size_t seed, const T& v) return seed ^ (std::hash()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2)); } +} // namespace horus + namespace std { @@ -43,7 +47,7 @@ template struct hash> { size_t operator() (const std::pair& p) const { - return hash_combine (std::hash()(p.first), p.second); + return horus::hash_combine (std::hash()(p.first), p.second); } }; @@ -55,15 +59,17 @@ template struct hash> typename std::vector::const_iterator first = vec.begin(); typename std::vector::const_iterator last = vec.end(); for (; first != last; ++first) { - h = hash_combine (h, *first); + h = horus::hash_combine (h, *first); } return h; } }; -} +} // namespace std +namespace horus { + class VarCluster { public: @@ -214,5 +220,7 @@ CountingBp::setColor (const FacNode* fn, Color c) facColors_[fn->getIndex()] = c; } +} // namespace horus + #endif // YAP_PACKAGES_CLPBN_HORUS_COUNTINGBP_H_ diff --git a/packages/CLPBN/horus/ElimGraph.cpp b/packages/CLPBN/horus/ElimGraph.cpp index 2f637d85e..a6adb2546 100644 --- a/packages/CLPBN/horus/ElimGraph.cpp +++ b/packages/CLPBN/horus/ElimGraph.cpp @@ -3,6 +3,9 @@ #include "ElimGraph.h" + +namespace horus { + ElimHeuristic ElimGraph::elimHeuristic_ = MIN_NEIGHBORS; @@ -238,3 +241,5 @@ ElimGraph::connectAllNeighbors (const EgNode* n) } } +} // namespace horus + diff --git a/packages/CLPBN/horus/ElimGraph.h b/packages/CLPBN/horus/ElimGraph.h index 1c97205fd..a5a1c40da 100644 --- a/packages/CLPBN/horus/ElimGraph.h +++ b/packages/CLPBN/horus/ElimGraph.h @@ -11,6 +11,8 @@ #include "Horus.h" +namespace horus { + class EgNode; typedef TinySet EGNeighs; @@ -171,5 +173,7 @@ ElimGraph::neighbors (EgNode* n1, EgNode* n2) const return n1->isNeighbor (n2); } +} // namespace horus + #endif // YAP_PACKAGES_CLPBN_HORUS_ELIMGRAPH_H_ diff --git a/packages/CLPBN/horus/Factor.cpp b/packages/CLPBN/horus/Factor.cpp index 381ad74a7..8626c1d56 100644 --- a/packages/CLPBN/horus/Factor.cpp +++ b/packages/CLPBN/horus/Factor.cpp @@ -8,6 +8,8 @@ #include "Var.h" +namespace horus { + Factor::Factor (const Factor& g) { clone (g); @@ -233,3 +235,5 @@ Factor::clone (const Factor& g) distId_ = g.distId(); } +} // namespace horus + diff --git a/packages/CLPBN/horus/Factor.h b/packages/CLPBN/horus/Factor.h index 5d81e5ac1..23c1e0465 100644 --- a/packages/CLPBN/horus/Factor.h +++ b/packages/CLPBN/horus/Factor.h @@ -9,6 +9,9 @@ #include "Indexer.h" #include "Util.h" + +namespace horus { + template class TFactor { @@ -363,5 +366,7 @@ class Factor : public TFactor DISALLOW_ASSIGN (Factor); }; +} // namespace horus + #endif // YAP_PACKAGES_CLPBN_HORUS_FACTOR_H_ diff --git a/packages/CLPBN/horus/FactorGraph.cpp b/packages/CLPBN/horus/FactorGraph.cpp index 7ab9a305e..201be12a9 100644 --- a/packages/CLPBN/horus/FactorGraph.cpp +++ b/packages/CLPBN/horus/FactorGraph.cpp @@ -8,6 +8,8 @@ #include "Util.h" +namespace horus { + bool FactorGraph::exportLd_ = false; bool FactorGraph::exportUai_ = false; bool FactorGraph::exportGv_ = false; @@ -480,3 +482,5 @@ FactorGraph::containsCycle ( return false; // no cycle detected in this component } +} // namespace horus + diff --git a/packages/CLPBN/horus/FactorGraph.h b/packages/CLPBN/horus/FactorGraph.h index f829ecd1e..5a2a38256 100644 --- a/packages/CLPBN/horus/FactorGraph.h +++ b/packages/CLPBN/horus/FactorGraph.h @@ -10,6 +10,9 @@ #include "BayesBallGraph.h" #include "Horus.h" + +namespace horus { + class FacNode; @@ -179,6 +182,7 @@ struct sortByVarId } }; +} // namespace horus #endif // YAP_PACKAGES_CLPBN_HORUS_FACTORGRAPH_H_ diff --git a/packages/CLPBN/horus/GroundSolver.cpp b/packages/CLPBN/horus/GroundSolver.cpp index e7538fc33..562193762 100644 --- a/packages/CLPBN/horus/GroundSolver.cpp +++ b/packages/CLPBN/horus/GroundSolver.cpp @@ -11,6 +11,8 @@ #include "Util.h" +namespace horus { + void GroundSolver::printAnswer (const VarIds& vids) { @@ -112,3 +114,5 @@ GroundSolver::getJointByConditioning ( return prevBeliefs; } +} // namespace horus + diff --git a/packages/CLPBN/horus/GroundSolver.h b/packages/CLPBN/horus/GroundSolver.h index dfccb3eb1..23ae27afc 100644 --- a/packages/CLPBN/horus/GroundSolver.h +++ b/packages/CLPBN/horus/GroundSolver.h @@ -5,6 +5,8 @@ #include "Horus.h" +namespace horus { + class GroundSolver { public: @@ -30,5 +32,7 @@ class GroundSolver DISALLOW_COPY_AND_ASSIGN (GroundSolver); }; +} // namespace horus + #endif // YAP_PACKAGES_CLPBN_HORUS_GROUNDSOLVER_H_ diff --git a/packages/CLPBN/horus/Histogram.cpp b/packages/CLPBN/horus/Histogram.cpp index 23540a68c..021414825 100644 --- a/packages/CLPBN/horus/Histogram.cpp +++ b/packages/CLPBN/horus/Histogram.cpp @@ -7,6 +7,8 @@ #include "Util.h" +namespace horus { + HistogramSet::HistogramSet (unsigned size, unsigned range) { size_ = size; @@ -145,3 +147,5 @@ operator<< (std::ostream& os, const HistogramSet& hs) return os; } +} // namespace horus + diff --git a/packages/CLPBN/horus/Histogram.h b/packages/CLPBN/horus/Histogram.h index 2129fcdbb..1c8761c00 100644 --- a/packages/CLPBN/horus/Histogram.h +++ b/packages/CLPBN/horus/Histogram.h @@ -9,6 +9,8 @@ typedef std::vector Histogram; +namespace horus { + class HistogramSet { public: @@ -44,5 +46,7 @@ class HistogramSet DISALLOW_COPY_AND_ASSIGN (HistogramSet); }; +} // namespace horus + #endif // YAP_PACKAGES_CLPBN_HORUS_HISTOGRAM_H_ diff --git a/packages/CLPBN/horus/Horus.h b/packages/CLPBN/horus/Horus.h index 5ddb118b4..b1c23467f 100644 --- a/packages/CLPBN/horus/Horus.h +++ b/packages/CLPBN/horus/Horus.h @@ -14,6 +14,9 @@ #include #include + +namespace horus { + class Var; class Factor; class VarNode; @@ -57,7 +60,7 @@ extern unsigned verbosity; extern LiftedSolverType liftedSolver; extern GroundSolverType groundSolver; -}; +} namespace Constants { @@ -70,7 +73,9 @@ const int NO_EVIDENCE = -1; // number of digits to show when printing a parameter const unsigned PRECISION = 6; -}; +} + +} // namespace horus #endif // YAP_PACKAGES_CLPBN_HORUS_HORUS_H_ diff --git a/packages/CLPBN/horus/HorusCli.cpp b/packages/CLPBN/horus/HorusCli.cpp index 7b3312071..ecf425c0b 100644 --- a/packages/CLPBN/horus/HorusCli.cpp +++ b/packages/CLPBN/horus/HorusCli.cpp @@ -11,11 +11,12 @@ 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] \ [