56 template < GUM_Numeric GUM_SCALAR >
58 for (
const auto node: i.
type().containerDag().nodes()) {
62 this->
dag_.addNodeWithId(attr.
id());
67 for (
const auto& arc: i.
type().containerDag().arcs()) {
69 this->
dag_.addArc(arc.tail(), arc.head());
76 template < GUM_Numeric GUM_SCALAR >
83 template < GUM_Numeric GUM_SCALAR >
89 template < GUM_Numeric GUM_SCALAR >
94 template < GUM_Numeric GUM_SCALAR >
106 template < GUM_Numeric GUM_SCALAR >
108 return _get_(varId).cpf();
111 template < GUM_Numeric GUM_SCALAR >
116 template < GUM_Numeric GUM_SCALAR >
118 return _get_(
id).type().variable();
121 template < GUM_Numeric GUM_SCALAR >
126 template < GUM_Numeric GUM_SCALAR >
128 return _get_(name).id();
131 template < GUM_Numeric GUM_SCALAR >
134 return _get_(name).type().variable();
137 template < GUM_Numeric GUM_SCALAR >
142 template < GUM_Numeric GUM_SCALAR >
149 template < GUM_Numeric GUM_SCALAR >
152 for (
const auto node: this->
nodes()) {
160 template < GUM_Numeric GUM_SCALAR >
162 std::string tab =
" ";
163 std::stringstream output;
164 output << std::format(
"digraph \"{}\" {{\n",
_inst_->name());
166 for (
const auto node: this->
nodes()) {
171 output << std::format(
"{}\"{}\" -> \"{}\";\n",
177 output << std::format(
"{}\"{}\";\n", tab,
variable(node).name());
DAG dag_
The DAG of this Directed Graphical Model.
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 named copy of the internal DAG: each node id is assigned the name of the corresponding vari...
Base class for discrete random variable.
IBayesNet()
Default constructor.
IBayesNet< GUM_SCALAR > & operator=(const IBayesNet< GUM_SCALAR > &source)
Copy operator.
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.
std::string toDot() const override
NodeProperty< Size > _modalities_
InstanceBayesNet(const PRMInstance< GUM_SCALAR > &i)
Default constructor.
void _init_(const PRMInstance< GUM_SCALAR > &i)
const VariableNodeMap & variableNodeMap() const override
See gum::IBaseBayesNet::variableNodeMap().
~InstanceBayesNet() override
Destructor.
const NodeProperty< Size > & modalities() const
See gum::IBaseBayesNet::cpt().
const DiscreteVariable & variable(NodeId id) const override
See gum::IBaseBayesNet::variable().
HashTable< const DiscreteVariable *, const PRMAttribute< GUM_SCALAR > * > _varNodeMap_
Mapping between DiscreteVariable and their NodeId.
const Tensor< GUM_SCALAR > & cpt(NodeId varId) const override
See gum::IBaseBayesNet::cpt().
const PRMClassElement< GUM_SCALAR > & _get_(NodeId id) const
Private getter with type checking in case the id is not a formal PRMAttribute<GUM_SCALAR>.
const DiscreteVariable & variableFromName(std::string_view name) const override
See gum::IBaseBayesNet::variableFromName().
InstanceBayesNet & operator=(const InstanceBayesNet &from)
Copy operator.
NodeId idFromName(std::string_view name) const override
See gum::IBaseBayesNet::idFromName().
NodeId nodeId(const DiscreteVariable &var) const override
See gum::IBaseBayesNet::nodeId().
const PRMInstance< GUM_SCALAR > * _inst_
The PRMClassElementContainer decorated by this.
PRMAttribute is a member of a Class in a PRM.
PRMType & type() override=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.
bool exists(NodeId id) const
Returns true if id matches an PRMAttribute<GUM_SCALAR> in this PRMInstance<GUM_SCALAR>.
PRMAttribute< GUM_SCALAR > & get(NodeId id)
Getter on an PRMAttribute<GUM_SCALAR> of this PRMInstance<GUM_SCALAR>.
PRMClass< GUM_SCALAR > & type()
Returns the type of this instance.
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