This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/CLPBN/clpbn/bp/BayesNode.h

62 lines
1.8 KiB
C
Raw Normal View History

2011-12-12 15:29:51 +00:00
#ifndef HORUS_BAYESNODE_H
#define HORUS_BAYESNODE_H
#include <vector>
2011-12-12 15:29:51 +00:00
#include "VarNode.h"
#include "Distribution.h"
2012-03-22 11:33:24 +00:00
#include "Horus.h"
using namespace std;
2011-12-12 15:29:51 +00:00
class BayesNode : public VarNode
{
public:
2011-12-12 15:29:51 +00:00
BayesNode (const VarNode& v) : VarNode (v) {}
BayesNode (VarId, unsigned, int, Distribution*);
BayesNode (VarId, unsigned, int, const BnNodeSet&, Distribution*);
2011-12-12 15:29:51 +00:00
void setParents (const BnNodeSet&);
void addChild (BayesNode*);
2011-12-12 15:29:51 +00:00
void setDistribution (Distribution*);
Distribution* getDistribution (void);
2012-03-22 11:33:24 +00:00
const Params& getParameters (void);
Params getRow (int) const;
bool isRoot (void);
bool isLeaf (void);
bool hasNeighbors (void) const;
int getCptSize (void);
int getIndexOfParent (const BayesNode*) const;
2012-03-22 11:33:24 +00:00
string cptEntryToString (int, const vector<unsigned>&) const;
2011-12-12 15:29:51 +00:00
const BnNodeSet& getParents (void) const { return parents_; }
const BnNodeSet& getChilds (void) const { return childs_; }
unsigned getRowSize (void) const
{
2011-12-12 15:29:51 +00:00
return dist_->params.size() / nrStates();
}
2012-03-22 11:33:24 +00:00
double getProbability (int row, unsigned col)
{
int idx = (row * getRowSize()) + col;
return dist_->params[idx];
}
private:
DISALLOW_COPY_AND_ASSIGN (BayesNode);
2011-12-12 15:29:51 +00:00
States getDomainHeaders (void) const;
friend ostream& operator << (ostream&, const BayesNode&);
BnNodeSet parents_;
BnNodeSet childs_;
Distribution* dist_;
};
ostream& operator << (ostream&, const BayesNode&);
2011-12-12 15:29:51 +00:00
#endif // HORUS_BAYESNODE_H