35 template <
typename GUM_SCALAR >
38 for (
const auto node : i.
type().containerDag().nodes()) {
42 this->_dag.addNodeWithId(attr.
id());
49 for (
const auto& arc : i.
type().containerDag().arcs()) {
51 this->_dag.addArc(arc.tail(), arc.head());
58 template <
typename GUM_SCALAR >
67 template <
typename GUM_SCALAR >
75 template <
typename GUM_SCALAR >
80 template <
typename GUM_SCALAR >
92 template <
typename GUM_SCALAR >
95 return __get(varId).cpf();
98 template <
typename GUM_SCALAR >
104 template <
typename GUM_SCALAR >
107 return __get(
id).type().variable();
110 template <
typename GUM_SCALAR >
116 template <
typename GUM_SCALAR >
119 return __get(name).id();
122 template <
typename GUM_SCALAR >
125 const std::string& name)
const {
126 return __get(name).type().variable();
129 template <
typename GUM_SCALAR >
135 template <
typename GUM_SCALAR >
145 template <
typename GUM_SCALAR >
149 for (
const auto node : this->
nodes()) {
157 template <
typename GUM_SCALAR >
159 std::string tab =
" ";
160 std::stringstream output;
161 output <<
"digraph \"";
162 output <<
__inst->name() <<
"\" {" << std::endl;
164 for (
const auto node : this->
nodes()) {
168 for (
const auto chi : children) {
169 output << tab <<
"\"" <<
variable(node).
name() <<
"\" -> ";
170 output <<
"\"" <<
variable(chi).
name() <<
"\";" << std::endl;
173 output << tab <<
"\"" <<
variable(node).
name() <<
"\";" << std::endl;
177 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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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)