diff --git a/packages/CLPBN/horus/BayesBall.cpp b/packages/CLPBN/horus/BayesBall.cpp index c196e3a21..108d241d5 100644 --- a/packages/CLPBN/horus/BayesBall.cpp +++ b/packages/CLPBN/horus/BayesBall.cpp @@ -14,7 +14,7 @@ FactorGraph* BayesBall::getMinimalFactorGraph (const VarIds& queryIds) { - assert (fg_.isFromBayesNetwork()); + assert (fg_.bayesianFactors()); Scheduling scheduling; for (size_t i = 0; i < queryIds.size(); i++) { assert (dag_.getNode (queryIds[i])); diff --git a/packages/CLPBN/horus/FactorGraph.cpp b/packages/CLPBN/horus/FactorGraph.cpp index 2987410b6..a0ac840c3 100644 --- a/packages/CLPBN/horus/FactorGraph.cpp +++ b/packages/CLPBN/horus/FactorGraph.cpp @@ -28,7 +28,7 @@ FactorGraph::FactorGraph (const FactorGraph& fg) addEdge (varNodes_[neighs[j]->getIndex()], facNode); } } - fromBayesNet_ = fg.isFromBayesNetwork(); + bayesFactors_ = fg.bayesianFactors(); } @@ -239,7 +239,7 @@ FactorGraph::isTree (void) const DAGraph& FactorGraph::getStructure (void) { - assert (fromBayesNet_); + assert (bayesFactors_); if (structure_.empty()) { for (size_t i = 0; i < varNodes_.size(); i++) { structure_.addNode (new DAGraphNode (varNodes_[i])); diff --git a/packages/CLPBN/horus/FactorGraph.h b/packages/CLPBN/horus/FactorGraph.h index 5346221b1..e1702f26b 100644 --- a/packages/CLPBN/horus/FactorGraph.h +++ b/packages/CLPBN/horus/FactorGraph.h @@ -65,7 +65,7 @@ class FacNode class FactorGraph { public: - FactorGraph (bool fbn = false) : fromBayesNet_(fbn) { } + FactorGraph (void) : bayesFactors_(false) { } FactorGraph (const FactorGraph&); @@ -74,8 +74,10 @@ class FactorGraph const VarNodes& varNodes (void) const { return varNodes_; } const FacNodes& facNodes (void) const { return facNodes_; } + + void setFactorsAsBayesian (void) { bayesFactors_ = true; } - bool isFromBayesNetwork (void) const { return fromBayesNet_ ; } + bool bayesianFactors (void) const { return bayesFactors_ ; } size_t nrVarNodes (void) const { return varNodes_.size(); } @@ -128,7 +130,7 @@ class FactorGraph FacNodes facNodes_; DAGraph structure_; - bool fromBayesNet_; + bool bayesFactors_; typedef unordered_map VarMap; VarMap varMap_; diff --git a/packages/CLPBN/horus/HorusYap.cpp b/packages/CLPBN/horus/HorusYap.cpp index c902a9165..082d2c884 100644 --- a/packages/CLPBN/horus/HorusYap.cpp +++ b/packages/CLPBN/horus/HorusYap.cpp @@ -219,8 +219,10 @@ int createGroundNetwork (void) { string factorsType ((char*) YAP_AtomName (YAP_AtomOfTerm (YAP_ARG1))); - bool fromBayesNet = factorsType == "bayes"; - FactorGraph* fg = new FactorGraph (fromBayesNet); + FactorGraph* fg = new FactorGraph(); + if (factorsType == "bayes") { + fg->setFactorsAsBayesian(); + } YAP_Term factorList = YAP_ARG2; while (factorList != YAP_TermNil()) { YAP_Term factor = YAP_HeadOfTerm (factorList); @@ -400,7 +402,7 @@ void runVeSolver ( results.reserve (tasks.size()); for (size_t i = 0; i < tasks.size(); i++) { FactorGraph* mfg = fg; - if (fg->isFromBayesNetwork()) { + if (fg->bayesianFactors()) { // mfg = BayesBall::getMinimalFactorGraph (*fg, tasks[i]); } // VarElimSolver solver (*mfg); @@ -410,7 +412,7 @@ void runVeSolver ( cout << endl; } results.push_back (solver.solveQuery (tasks[i])); - if (fg->isFromBayesNetwork()) { + if (fg->bayesianFactors()) { // delete mfg; } } @@ -429,7 +431,7 @@ void runBpSolver ( } Solver* solver = 0; FactorGraph* mfg = fg; - if (fg->isFromBayesNetwork()) { + if (fg->bayesianFactors()) { //mfg = BayesBall::getMinimalFactorGraph ( // *fg, VarIds (vids.begin(),vids.end())); } @@ -450,7 +452,7 @@ void runBpSolver ( for (size_t i = 0; i < tasks.size(); i++) { results.push_back (solver->solveQuery (tasks[i])); } - if (fg->isFromBayesNetwork()) { + if (fg->bayesianFactors()) { //delete mfg; } delete solver;