55 template <
typename GUM_SCALAR >
57 for (
const auto node: i.
type().containerDag().nodes()) {
61 this->
dag_.addNodeWithId(attr.
id());
68 for (
const auto& arc: i.
type().containerDag().arcs()) {
70 this->
dag_.addArc(arc.tail(), arc.head());
77 template <
typename GUM_SCALAR >
84 template <
typename GUM_SCALAR >
90 template <
typename GUM_SCALAR >
95 template <
typename GUM_SCALAR >
107 template <
typename GUM_SCALAR >
109 return _get_(varId).cpf();
112 template <
typename GUM_SCALAR >
117 template <
typename GUM_SCALAR >
119 return _get_(
id).type().variable();
122 template <
typename GUM_SCALAR >
127 template <
typename GUM_SCALAR >
129 return _get_(name).id();
132 template <
typename GUM_SCALAR >
135 return _get_(name).type().variable();
138 template <
typename GUM_SCALAR >
144 template <
typename GUM_SCALAR >
152 template <
typename GUM_SCALAR >
155 for (
const auto node: this->
nodes()) {
163 template <
typename GUM_SCALAR >
165 std::string tab =
" ";
166 std::stringstream output;
167 output <<
"digraph \"";
168 output <<
_inst_->name() <<
"\" {" << std::endl;
170 for (
const auto node: this->
nodes()) {
175 output << tab <<
"\"" <<
variable(node).name() <<
"\" -> ";
176 output <<
"\"" <<
variable(chi).name() <<
"\";" << std::endl;
179 output << tab <<
"\"" <<
variable(node).name() <<
"\";" << std::endl;
183 output <<
"}" << std::endl;
DAG dag_
The DAG of this Directed Graphical Model.
virtual Size size() const final
Returns the number of variables in this Directed Graphical Model.
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
const NodeGraphPart & nodes() const final
Returns a constant reference to the dag of this Bayes Net.
Base class for discrete random variable.
IBayesNet< GUM_SCALAR > & operator=(const IBayesNet< GUM_SCALAR > &source)
Copy operator.
IBayesNet()
Default constructor.
Exception : node does not exist.
Exception : the element we looked for cannot be found.
Container used to map discrete variables with nodes.
This class decorates an PRMInstance<GUM_SCALAR> as an IBaseBayesNet.
NodeProperty< Size > _modalities_
const PRMClassElement< GUM_SCALAR > & _get_(NodeId id) const
Private getter with type checking in case the id is not a formal PRMAttribute<GUM_SCALAR>.
virtual ~InstanceBayesNet()
Destructor.
virtual const VariableNodeMap & variableNodeMap() const
See gum::IBaseBayesNet::variableNodeMap().
void _init_(const PRMInstance< GUM_SCALAR > &i)
InstanceBayesNet(const PRMInstance< GUM_SCALAR > &i)
Default constructor.
virtual const Tensor< GUM_SCALAR > & cpt(NodeId varId) const
See gum::IBaseBayesNet::cpt().
virtual std::string toDot() const
virtual NodeId nodeId(const DiscreteVariable &var) const
See gum::IBaseBayesNet::nodeId().
HashTable< const DiscreteVariable *, const PRMAttribute< GUM_SCALAR > * > _varNodeMap_
Mapping between DiscreteVariable and their NodeId.
virtual const DiscreteVariable & variableFromName(const std::string &name) const
See gum::IBaseBayesNet::variableFromName().
virtual NodeId idFromName(const std::string &name) const
See gum::IBaseBayesNet::idFromName().
virtual const DiscreteVariable & variable(NodeId id) const
See gum::IBaseBayesNet::variable().
const NodeProperty< Size > & modalities() const
See gum::IBaseBayesNet::cpt().
InstanceBayesNet & operator=(const InstanceBayesNet &from)
Copy operator.
const PRMInstance< GUM_SCALAR > * _inst_
The PRMClassElementContainer decorated by this.
PRMAttribute is a member of a Class in a PRM.
virtual PRMType & type()=0
See gum::PRMClassElement::type().
Abstract class representing an element of PRM class.
NodeId id() const
Returns the NodeId of this element in it's class DAG.
An PRMInstance is a Bayesian network fragment defined by a Class and used in a PRMSystem.
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
PRMAttribute< GUM_SCALAR > & get(NodeId id)
Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
#define GUM_ERROR(type, msg)
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
Headers of InstanceBayesNet.
namespace for all probabilistic relational models entities
gum is the global namespace for all aGrUM entities