Bayesian Belief NetworkΒΆ
Creating a Bayesian Belief Network (BBN) is easy. Favor the factory methods instance
when creating all
objects related to a BBN. The instance
methods create a shared pointer
to the real underlying object.
The use of shared pointers
will prevent memory leaks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include "Variable.h"
#include "BbnNode.h"
#include "Bbn.h"
using namespace com::ooc::bbn;
int main(int argc, char *argv[]) {
// create vector of nodes
std::vector<graph::_bbnNode> nodes{
graph::BbnNode::instance(graph::Variable::instance("0", "a", {"on", "off"}), {0.5, 0.5}),
graph::BbnNode::instance(graph::Variable::instance("1", "b", {"on", "off"}), {0.5, 0.5, 0.5, 0.5})
};
// create vector of edges
std::vector<graph::_edge> edges{
graph::Edge::instance("0", "1", graph::EdgeType::DIRECTED)
};
// create bbn
auto bbn = graph::Bbn::instance(nodes, edges);
return 0;
}
|