Clean ups

This commit is contained in:
Tiago Gomes 2013-02-16 16:17:14 +00:00
parent d0f5d0f9ab
commit 0852c4fe22
4 changed files with 24 additions and 24 deletions

View File

@ -38,22 +38,22 @@ BayesBall::getMinimalFactorGraph (const VarIds& queryIds)
BBNode* n = sch.node;
n->setAsVisited();
if (n->hasEvidence() == false && sch.visitedFromChild) {
if (n->isMarkedOnTop() == false) {
n->markOnTop();
if (n->isMarkedAbove() == false) {
n->markAbove();
scheduleParents (n, scheduling);
}
if (n->isMarkedOnBottom() == false) {
n->markOnBottom();
if (n->isMarkedBelow() == false) {
n->markBelow();
scheduleChilds (n, scheduling);
}
}
if (sch.visitedFromParent) {
if (n->hasEvidence() && n->isMarkedOnTop() == false) {
n->markOnTop();
if (n->hasEvidence() && n->isMarkedAbove() == false) {
n->markAbove();
scheduleParents (n, scheduling);
}
if (n->hasEvidence() == false && n->isMarkedOnBottom() == false) {
n->markOnBottom();
if (n->hasEvidence() == false && n->isMarkedBelow() == false) {
n->markBelow();
scheduleChilds (n, scheduling);
}
}
@ -74,7 +74,7 @@ BayesBall::constructGraph (FactorGraph* fg) const
for (size_t i = 0; i < facNodes.size(); i++) {
const BBNode* n = dag_.getNode (
facNodes[i]->factor().argument (0));
if (n->isMarkedOnTop()) {
if (n->isMarkedAbove()) {
fg->addFactor (facNodes[i]->factor());
} else if (n->hasEvidence() && n->isVisited()) {
VarIds varIds = { facNodes[i]->factor().argument (0) };

View File

@ -9,6 +9,7 @@
#include "BayesBallGraph.h"
#include "Horus.h"
namespace Horus {
struct ScheduleInfo {
@ -39,9 +40,8 @@ class BayesBall {
void scheduleChilds (const BBNode* n, Scheduling& sch) const;
FactorGraph& fg_;
BayesBallGraph& dag_;
FactorGraph& fg_;
BayesBallGraph& dag_;
};

View File

@ -7,12 +7,13 @@
#include "Var.h"
#include "Horus.h"
namespace Horus {
class BBNode : public Var {
public:
BBNode (Var* v) : Var (v), visited_(false),
markedOnTop_(false), markedOnBottom_(false) { }
markedAbove_(false), markedBelow_(false) { }
const std::vector<BBNode*>& childs (void) const { return childs_; }
@ -30,20 +31,20 @@ class BBNode : public Var {
void setAsVisited (void) { visited_ = true; }
bool isMarkedOnTop (void) const { return markedOnTop_; }
bool isMarkedAbove (void) const { return markedAbove_; }
void markOnTop (void) { markedOnTop_ = true; }
void markAbove (void) { markedAbove_ = true; }
bool isMarkedOnBottom (void) const { return markedOnBottom_; }
bool isMarkedBelow (void) const { return markedBelow_; }
void markOnBottom (void) { markedOnBottom_ = true; }
void markBelow (void) { markedBelow_ = true; }
void clear (void) { visited_ = markedOnTop_ = markedOnBottom_ = false; }
void clear (void) { visited_ = markedAbove_ = markedBelow_ = false; }
private:
bool visited_;
bool markedOnTop_;
bool markedOnBottom_;
bool markedAbove_;
bool markedBelow_;
std::vector<BBNode*> childs_;
std::vector<BBNode*> parents_;
@ -71,9 +72,8 @@ class BayesBallGraph {
void exportToGraphViz (const char*);
private:
std::vector<BBNode*> nodes_;
std::unordered_map<VarId, BBNode*> varMap_;
std::vector<BBNode*> nodes_;
std::unordered_map<VarId, BBNode*> varMap_;
};
} // namespace Horus

View File

@ -78,7 +78,7 @@ class CTNode {
void updateChildLevels (CTNode*, unsigned);
Symbol symbol_;
CTChilds childs_;
CTChilds childs_;
unsigned level_;
DISALLOW_ASSIGN (CTNode);