32 template <
typename GUM_SCALAR >
35 for (
const auto node : i.
type().containerDag().nodes()) {
39 this->_dag.addNodeWithId(attr.
id());
46 for (
const auto& arc : i.
type().containerDag().arcs()) {
48 this->_dag.addArc(arc.tail(), arc.head());
55 template <
typename GUM_SCALAR >
64 template <
typename GUM_SCALAR >
72 template <
typename GUM_SCALAR >
77 template <
typename GUM_SCALAR >
89 template <
typename GUM_SCALAR >
92 return __get(varId).cpf();
95 template <
typename GUM_SCALAR >
101 template <
typename GUM_SCALAR >
104 return __get(
id).type().variable();
107 template <
typename GUM_SCALAR >
113 template <
typename GUM_SCALAR >
116 return __get(name).id();
119 template <
typename GUM_SCALAR >
122 const std::string& name)
const {
123 return __get(name).type().variable();
126 template <
typename GUM_SCALAR >
132 template <
typename GUM_SCALAR >
142 template <
typename GUM_SCALAR >
146 for (
const auto node : this->
nodes()) {
154 template <
typename GUM_SCALAR >
156 std::string tab =
" ";
157 std::stringstream output;
158 output <<
"digraph \"";
159 output <<
__inst->name() <<
"\" {" << std::endl;
161 for (
const auto node : this->
nodes()) {
165 for (
const auto chi : children) {
166 output << tab <<
"\"" <<
variable(node).
name() <<
"\" -> ";
167 output <<
"\"" <<
variable(chi).
name() <<
"\";" << std::endl;
170 output << tab <<
"\"" <<
variable(node).
name() <<
"\";" << std::endl;
174 output <<
"}" << std::endl;
aGrUM's Potential is a multi-dimensional array with tensor operators.
virtual NodeId idFromName(const std::string &name) const
See gum::IBaseBayesNet::idFromName().
virtual const Potential< GUM_SCALAR > & cpt(NodeId varId) const
See gum::IBaseBayesNet::cpt().
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
virtual const VariableNodeMap & variableNodeMap() const
See gum::IBaseBayesNet::variableNodeMap().
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
virtual const DiscreteVariable & variable(NodeId id) const
See gum::IBaseBayesNet::variable().
PRMAttribute< GUM_SCALAR > & get(NodeId id)
Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
virtual PRMType & type()=0
See gum::PRMClassElement::type().
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
const PRMClassElement< GUM_SCALAR > & __get(NodeId id) const
Private getter with type checking in case the id is not a formal PRMAttribute<GUM_SCALAR>.
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
Container used to map discrete variables with nodes.
const NodeProperty< Size > & modalities() const
See gum::IBaseBayesNet::cpt().
virtual std::string toDot() const
Abstract class representing an element of PRM class.
IBayesNet< GUM_SCALAR > & operator=(const IBayesNet< GUM_SCALAR > &source)
Copy operator.
InstanceBayesNet(const PRMInstance< GUM_SCALAR > &i)
Default constructor.
Base class for discrete random variable.
virtual const DiscreteVariable & variableFromName(const std::string &name) const
See gum::IBaseBayesNet::variableFromName().
Class representing the minimal interface for Bayesian Network.
gum is the global namespace for all aGrUM entities
HashTable< const DiscreteVariable *, const PRMAttribute< GUM_SCALAR > *> __varNodeMap
Mapping between DiscreteVariable and their NodeId.
The class for generic Hash Tables.
NodeProperty< Size > __modalities
const PRMInstance< GUM_SCALAR > * __inst
The PRMClassElementContainer decorated by this.
Size size() const
Returns the number of variables in this Directed Graphical Model.
virtual NodeId nodeId(const DiscreteVariable &var) const
See gum::IBaseBayesNet::nodeId().
const NodeGraphPart & nodes() const
Returns a constant reference to the dag of this Bayes Net.
InstanceBayesNet & operator=(const InstanceBayesNet &from)
Copy operator.
Headers of InstanceBayesNet.
virtual ~InstanceBayesNet()
Destructor.
NodeId id() const
Returns the NodeId of this element in it's class DAG.
void __init(const PRMInstance< GUM_SCALAR > &i)
This class decorates an PRMInstance<GUM_SCALAR> as an IBaseBayesNet.
PRMAttribute is a member of a Class in a PRM.
const std::string & name() const
returns the name of the variable
Size NodeId
Type for node ids.
#define GUM_ERROR(type, msg)