Put the code inside a horus namespace
This commit is contained in:
parent
4267465f53
commit
6f83ceb6f5
@ -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
|
||||
|
||||
|
@ -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_
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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<VarId, BBNode*> varMap_;
|
||||
};
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_BAYESBALLGRAPH_H_
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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_
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "Util.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
void
|
||||
CTNode::mergeSubtree (CTNode* n, bool updateLevels)
|
||||
{
|
||||
@ -1186,3 +1188,5 @@ ConstraintTree::split (
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -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_
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "WeightedBp.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
bool CountingBp::fif_ = true;
|
||||
|
||||
|
||||
@ -427,3 +429,5 @@ CountingBp::printGroups (
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -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<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2));
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
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 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_
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "Horus.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
class EgNode;
|
||||
|
||||
typedef TinySet<EgNode*> 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_
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -9,6 +9,9 @@
|
||||
#include "Indexer.h"
|
||||
#include "Util.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
template <typename T>
|
||||
class TFactor
|
||||
{
|
||||
@ -363,5 +366,7 @@ class Factor : public TFactor<VarId>
|
||||
DISALLOW_ASSIGN (Factor);
|
||||
};
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_FACTOR_H_
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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_
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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_
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
typedef std::vector<unsigned> 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_
|
||||
|
||||
|
@ -14,6 +14,9 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
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_
|
||||
|
||||
|
@ -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] \
|
||||
[<OPTION>=<VALUE>]... <FILE> [<VAR>|<VAR>=<EVIDENCE>]... " ;
|
||||
@ -26,27 +27,27 @@ main (int argc, const char* argv[])
|
||||
{
|
||||
if (argc <= 1) {
|
||||
std::cerr << "Error: no probabilistic graphical model was given." ;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << USAGE << std::endl;
|
||||
std::cerr << std::endl << USAGE << std::endl;
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
int idx = readHorusFlags (argc, argv);
|
||||
FactorGraph fg;
|
||||
horus::FactorGraph fg;
|
||||
readFactorGraph (fg, argv[idx]);
|
||||
VarIds queryIds = readQueryAndEvidence (fg, argc, argv, idx + 1);
|
||||
if (FactorGraph::exportToLibDai()) {
|
||||
horus::VarIds queryIds
|
||||
= readQueryAndEvidence (fg, argc, argv, idx + 1);
|
||||
if (horus::FactorGraph::exportToLibDai()) {
|
||||
fg.exportToLibDai ("model.fg");
|
||||
}
|
||||
if (FactorGraph::exportToUai()) {
|
||||
if (horus::FactorGraph::exportToUai()) {
|
||||
fg.exportToUai ("model.uai");
|
||||
}
|
||||
if (FactorGraph::exportGraphViz()) {
|
||||
if (horus::FactorGraph::exportGraphViz()) {
|
||||
fg.exportToGraphViz ("model.dot");
|
||||
}
|
||||
if (FactorGraph::printFactorGraph()) {
|
||||
if (horus::FactorGraph::printFactorGraph()) {
|
||||
fg.print();
|
||||
}
|
||||
if (Globals::verbosity > 0) {
|
||||
if (horus::Globals::verbosity > 0) {
|
||||
std::cout << "factor graph contains " ;
|
||||
std::cout << fg.nrVarNodes() << " variables and " ;
|
||||
std::cout << fg.nrFacNodes() << " factors " << std::endl;
|
||||
@ -79,7 +80,7 @@ readHorusFlags (int argc, const char* argv[])
|
||||
std::cerr << USAGE << std::endl;
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
Util::setHorusFlag (leftArg, rightArg);
|
||||
horus::Util::setHorusFlag (leftArg, rightArg);
|
||||
}
|
||||
return i + 1;
|
||||
}
|
||||
@ -87,7 +88,7 @@ readHorusFlags (int argc, const char* argv[])
|
||||
|
||||
|
||||
void
|
||||
readFactorGraph (FactorGraph& fg, const char* s)
|
||||
readFactorGraph (horus::FactorGraph& fg, const char* s)
|
||||
{
|
||||
std::string fileName (s);
|
||||
std::string extension = fileName.substr (fileName.find_last_of ('.') + 1);
|
||||
@ -104,25 +105,25 @@ readFactorGraph (FactorGraph& fg, const char* s)
|
||||
|
||||
|
||||
|
||||
VarIds
|
||||
horus::VarIds
|
||||
readQueryAndEvidence (
|
||||
FactorGraph& fg,
|
||||
horus::FactorGraph& fg,
|
||||
int argc,
|
||||
const char* argv[],
|
||||
int start)
|
||||
{
|
||||
VarIds queryIds;
|
||||
horus::VarIds queryIds;
|
||||
for (int i = start; i < argc; i++) {
|
||||
const std::string& arg = argv[i];
|
||||
if (arg.find ('=') == std::string::npos) {
|
||||
if (Util::isInteger (arg) == false) {
|
||||
if (horus::Util::isInteger (arg) == false) {
|
||||
std::cerr << "Error: `" << arg << "' " ;
|
||||
std::cerr << "is not a variable id." ;
|
||||
std::cerr << std::endl;
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
VarId vid = Util::stringToUnsigned (arg);
|
||||
VarNode* queryVar = fg.getVarNode (vid);
|
||||
horus::VarId vid = horus::Util::stringToUnsigned (arg);
|
||||
horus::VarNode* queryVar = fg.getVarNode (vid);
|
||||
if (queryVar == false) {
|
||||
std::cerr << "Error: unknow variable with id " ;
|
||||
std::cerr << "`" << vid << "'." << std::endl;
|
||||
@ -138,13 +139,13 @@ readQueryAndEvidence (
|
||||
std::cerr << USAGE << std::endl;
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
if (Util::isInteger (leftArg) == false) {
|
||||
if (horus::Util::isInteger (leftArg) == false) {
|
||||
std::cerr << "Error: `" << leftArg << "' " ;
|
||||
std::cerr << "is not a variable id." << std::endl;
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
VarId vid = Util::stringToUnsigned (leftArg);
|
||||
VarNode* observedVar = fg.getVarNode (vid);
|
||||
horus::VarId vid = horus::Util::stringToUnsigned (leftArg);
|
||||
horus::VarNode* observedVar = fg.getVarNode (vid);
|
||||
if (observedVar == false) {
|
||||
std::cerr << "Error: unknow variable with id " ;
|
||||
std::cerr << "`" << vid << "'." << std::endl;
|
||||
@ -155,12 +156,12 @@ readQueryAndEvidence (
|
||||
std::cerr << USAGE << std::endl;
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
if (Util::isInteger (rightArg) == false) {
|
||||
if (horus::Util::isInteger (rightArg) == false) {
|
||||
std::cerr << "Error: `" << rightArg << "' " ;
|
||||
std::cerr << "is not a state index." << std::endl;
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
unsigned stateIdx = Util::stringToUnsigned (rightArg);
|
||||
unsigned stateIdx = horus::Util::stringToUnsigned (rightArg);
|
||||
if (observedVar->isValidState (stateIdx) == false) {
|
||||
std::cerr << "Error: `" << stateIdx << "' " ;
|
||||
std::cerr << "is not a valid state index for variable with id " ;
|
||||
@ -176,23 +177,25 @@ readQueryAndEvidence (
|
||||
|
||||
|
||||
void
|
||||
runSolver (const FactorGraph& fg, const VarIds& queryIds)
|
||||
runSolver (
|
||||
const horus::FactorGraph& fg,
|
||||
const horus::VarIds& queryIds)
|
||||
{
|
||||
GroundSolver* solver = 0;
|
||||
switch (Globals::groundSolver) {
|
||||
case GroundSolverType::VE:
|
||||
solver = new VarElim (fg);
|
||||
horus::GroundSolver* solver = 0;
|
||||
switch (horus::Globals::groundSolver) {
|
||||
case horus::GroundSolverType::VE:
|
||||
solver = new horus::VarElim (fg);
|
||||
break;
|
||||
case GroundSolverType::BP:
|
||||
solver = new BeliefProp (fg);
|
||||
case horus::GroundSolverType::BP:
|
||||
solver = new horus::BeliefProp (fg);
|
||||
break;
|
||||
case GroundSolverType::CBP:
|
||||
solver = new CountingBp (fg);
|
||||
case horus::GroundSolverType::CBP:
|
||||
solver = new horus::CountingBp (fg);
|
||||
break;
|
||||
default:
|
||||
assert (false);
|
||||
}
|
||||
if (Globals::verbosity > 0) {
|
||||
if (horus::Globals::verbosity > 0) {
|
||||
solver->printSolverFlags();
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "ElimGraph.h"
|
||||
#include "BayesBall.h"
|
||||
|
||||
namespace horus {
|
||||
|
||||
typedef std::pair<ParfactorList*, ObservedFormulas*> LiftedNetwork;
|
||||
|
||||
@ -581,3 +582,5 @@ init_predicates (void)
|
||||
freeGroundNetwork, 1);
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "Util.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
class Indexer
|
||||
{
|
||||
public:
|
||||
@ -361,5 +363,7 @@ operator<< (std::ostream &os, const MapIndexer& indexer)
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_INDEXER_H_
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "FactorGraph.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
LiftedBp::LiftedBp (const ParfactorList& parfactorList)
|
||||
: LiftedSolver (parfactorList)
|
||||
{
|
||||
@ -235,3 +237,5 @@ LiftedBp::getJointByConditioning (
|
||||
return prevBeliefs;
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "ParfactorList.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
class FactorGraph;
|
||||
class WeightedBp;
|
||||
|
||||
@ -43,5 +45,7 @@ class LiftedBp : public LiftedSolver
|
||||
DISALLOW_COPY_AND_ASSIGN (LiftedBp);
|
||||
};
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDBP_H_
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "Indexer.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
OrNode::~OrNode (void)
|
||||
{
|
||||
delete leftBranch_;
|
||||
@ -1316,3 +1318,5 @@ LiftedKc::printSolverFlags (void) const
|
||||
std::cout << ss.str() << std::endl;
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "ParfactorList.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
enum CircuitNodeType {
|
||||
OR_NODE,
|
||||
AND_NODE,
|
||||
@ -303,5 +305,7 @@ class LiftedKc : public LiftedSolver
|
||||
DISALLOW_COPY_AND_ASSIGN (LiftedKc);
|
||||
};
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDKC_H_
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "LiftedOperations.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
void
|
||||
LiftedOperations::shatterAgainstQuery (
|
||||
ParfactorList& pfList,
|
||||
@ -273,3 +275,5 @@ LiftedOperations::absorve (
|
||||
return absorvedPfs;
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
#include "ParfactorList.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
class LiftedOperations
|
||||
{
|
||||
public:
|
||||
@ -25,5 +28,7 @@ class LiftedOperations
|
||||
DISALLOW_COPY_AND_ASSIGN (LiftedOperations);
|
||||
};
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDOPERATIONS_H_
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "ParfactorList.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
class LiftedSolver
|
||||
{
|
||||
public:
|
||||
@ -23,5 +25,7 @@ class LiftedSolver
|
||||
DISALLOW_COPY_AND_ASSIGN (LiftedSolver);
|
||||
};
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDSOLVER_H_
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "LiftedUtils.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
namespace LiftedUtils {
|
||||
|
||||
std::unordered_map<std::string, unsigned> symbolDict;
|
||||
@ -130,3 +132,5 @@ operator<< (std::ostream& os, const Substitution& theta)
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "Util.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
class Symbol
|
||||
{
|
||||
public:
|
||||
@ -67,25 +69,28 @@ LogVar::valid (void) const
|
||||
return id_ != Util::maxUnsigned();
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
||||
namespace std {
|
||||
|
||||
template <> struct hash<Symbol> {
|
||||
size_t operator() (const Symbol& s) const {
|
||||
template <> struct hash<horus::Symbol> {
|
||||
size_t operator() (const horus::Symbol& s) const {
|
||||
return std::hash<unsigned>() (s);
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct hash<LogVar> {
|
||||
size_t operator() (const LogVar& X) const {
|
||||
template <> struct hash<horus::LogVar> {
|
||||
size_t operator() (const horus::LogVar& X) const {
|
||||
return std::hash<unsigned>() (X);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
typedef std::vector<Symbol> Symbols;
|
||||
typedef std::vector<Symbol> Tuple;
|
||||
typedef std::vector<Tuple> Tuples;
|
||||
@ -205,5 +210,7 @@ Substitution::nrReplacements (void) const
|
||||
return subs_.size();
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDUTILS_H_
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "Util.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
std::vector<LiftedOperator*>
|
||||
LiftedOperator::getValidOps (
|
||||
ParfactorList& pfList,
|
||||
@ -732,3 +734,5 @@ LiftedVe::getBestOperation (const Grounds& query)
|
||||
return bestOp;
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "ParfactorList.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
class LiftedOperator
|
||||
{
|
||||
public:
|
||||
@ -167,5 +169,7 @@ class LiftedVe : public LiftedSolver
|
||||
DISALLOW_COPY_AND_ASSIGN (LiftedVe);
|
||||
};
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDVE_H_
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "Indexer.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
bool
|
||||
Literal::isGround (ConstraintTree constr, LogVarSet ipgLogVars) const
|
||||
{
|
||||
@ -660,3 +662,5 @@ LiftedWCNF::printClauses (void) const
|
||||
Clause::printClauses (clauses_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "ParfactorList.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
class ConstraintTree;
|
||||
|
||||
enum LogVarType
|
||||
@ -241,5 +243,7 @@ class LiftedWCNF
|
||||
DISALLOW_COPY_AND_ASSIGN (LiftedWCNF);
|
||||
};
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_LIFTEDWCNF_H_
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "Horus.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
Parfactor::Parfactor (
|
||||
const ProbFormulas& formulas,
|
||||
const Params& params,
|
||||
@ -946,3 +948,5 @@ Parfactor::alignLogicalVars (Parfactor* g1, Parfactor* g2)
|
||||
g2->applySubstitution (theta2);
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "Horus.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
class Parfactor : public TFactor<ProbFormula>
|
||||
{
|
||||
public:
|
||||
@ -120,5 +122,7 @@ class Parfactor : public TFactor<ProbFormula>
|
||||
|
||||
typedef std::vector<Parfactor*> Parfactors;
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_PARFACTOR_H_
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "ParfactorList.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
ParfactorList::ParfactorList (const ParfactorList& pfList)
|
||||
{
|
||||
ParfactorList::const_iterator it = pfList.begin();
|
||||
@ -644,3 +646,5 @@ ParfactorList::disjoint (
|
||||
return (ts1 & ts2).empty();
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -6,6 +6,9 @@
|
||||
#include "Parfactor.h"
|
||||
#include "ProbFormula.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
class Parfactor;
|
||||
|
||||
|
||||
@ -117,5 +120,7 @@ class ParfactorList
|
||||
std::list<Parfactor*> pfList_;
|
||||
};
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_PARFACTORLIST_H_
|
||||
|
||||
|
@ -5,6 +5,9 @@
|
||||
#include "ProbFormula.h"
|
||||
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
PrvGroup ProbFormula::freeGroup_ = 0;
|
||||
|
||||
|
||||
@ -162,3 +165,5 @@ operator<< (std::ostream& os, const ObservedFormula& of)
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -9,6 +9,9 @@
|
||||
#include "LiftedUtils.h"
|
||||
#include "Horus.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
typedef unsigned long PrvGroup;
|
||||
|
||||
class ProbFormula
|
||||
@ -111,5 +114,7 @@ class ObservedFormula
|
||||
|
||||
typedef std::vector<ObservedFormula> ObservedFormulas;
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_PROBFORMULA_H_
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <ostream>
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
template <typename T, typename Compare = std::less<T>>
|
||||
class TinySet
|
||||
{
|
||||
@ -402,5 +404,7 @@ TinySet<T,C>::consistent (void) const
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_TINYSET_H_
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "BeliefProp.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
namespace Globals {
|
||||
|
||||
bool logDomain = false;
|
||||
@ -14,7 +16,7 @@ LiftedSolverType liftedSolver = LiftedSolverType::LVE;
|
||||
|
||||
GroundSolverType groundSolver = GroundSolverType::VE;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -329,8 +331,7 @@ printDashedLine (std::ostream& os)
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace Util
|
||||
|
||||
|
||||
|
||||
@ -426,5 +427,8 @@ pow (Params& v, double exp)
|
||||
Globals::logDomain ? v *= exp : v ^= exp;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LogAware
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
||||
|
@ -16,12 +16,13 @@
|
||||
|
||||
#include "Horus.h"
|
||||
|
||||
namespace horus {
|
||||
|
||||
namespace {
|
||||
|
||||
const double NEG_INF = -std::numeric_limits<double>::infinity();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
namespace Util {
|
||||
@ -100,7 +101,7 @@ void printAsteriskLine (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);
|
||||
|
||||
};
|
||||
} // 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_
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "Var.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
std::unordered_map<VarId, VarInfo> Var::varsInfo_;
|
||||
|
||||
|
||||
@ -108,3 +110,5 @@ Var::clearVarsInfo (void)
|
||||
varsInfo_.clear();
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "Horus.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
struct VarInfo
|
||||
{
|
||||
VarInfo (std::string l, const States& sts)
|
||||
@ -105,5 +107,7 @@ Var::operator!= (const Var& var) const
|
||||
return !(*this == var);
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_VAR_H_
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "Util.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
Params
|
||||
VarElim::solveQuery (VarIds queryVids)
|
||||
{
|
||||
@ -198,3 +200,5 @@ VarElim::printActiveFactors (void)
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "Horus.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
class VarElim : public GroundSolver
|
||||
{
|
||||
public:
|
||||
@ -39,5 +41,7 @@ class VarElim : public GroundSolver
|
||||
DISALLOW_COPY_AND_ASSIGN (VarElim);
|
||||
};
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_VARELIM_H_
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "WeightedBp.h"
|
||||
|
||||
namespace horus {
|
||||
|
||||
WeightedBp::~WeightedBp (void)
|
||||
{
|
||||
@ -304,3 +305,5 @@ WeightedBp::printLinkInformation (void) const
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace horus
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "BeliefProp.h"
|
||||
|
||||
|
||||
namespace horus {
|
||||
|
||||
class WeightedLink : public BpLink
|
||||
{
|
||||
public:
|
||||
@ -68,5 +70,7 @@ class WeightedBp : public BeliefProp
|
||||
DISALLOW_COPY_AND_ASSIGN (WeightedBp);
|
||||
};
|
||||
|
||||
} // namespace horus
|
||||
|
||||
#endif // YAP_PACKAGES_CLPBN_HORUS_WEIGHTEDBP_H_
|
||||
|
||||
|
Reference in New Issue
Block a user