55 template <
typename GUM_SCALAR >
63 this->
dag_.addNodeWithId(elt.
id());
73 this->
dag_.addArc(arc.tail(), arc.head());
80 template <
typename GUM_SCALAR >
87 template <
typename GUM_SCALAR >
93 template <
typename GUM_SCALAR >
98 template <
typename GUM_SCALAR >
110 template <
typename GUM_SCALAR >
112 return _get_(varId).cpf();
115 template <
typename GUM_SCALAR >
120 template <
typename GUM_SCALAR >
122 return _get_(
id).type().variable();
125 template <
typename GUM_SCALAR >
130 template <
typename GUM_SCALAR >
132 return _get_(name).id();
135 template <
typename GUM_SCALAR >
138 return _get_(name).type().variable();
141 template <
typename GUM_SCALAR >
144 if (this->
dag_.exists(
id)) {
151 template <
typename GUM_SCALAR >
159 template <
typename GUM_SCALAR >
162 for (
const auto node: this->
nodes()) {
170 template <
typename GUM_SCALAR >
172 std::string tab =
" ";
173 std::stringstream output;
174 output <<
"digraph \"";
175 output <<
_class_->name() <<
"\" {" << std::endl;
177 for (
const auto node: this->
nodes()) {
179 for (
const auto chi: this->
children(node)) {
180 output << tab <<
"\"" <<
variable(node).name() <<
"\" -> ";
181 output <<
"\"" <<
variable(chi).name() <<
"\";" << std::endl;
184 output << tab <<
"\"" <<
variable(node).name() <<
"\";" << std::endl;
188 output <<
"}" << std::endl;
Headers of ClassBayesNet<GUM_SCALAR>.
const ArcSet & arcs() const
returns the set of arcs stored within the ArcGraphPart
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.
Exception : fatal (unknown ?) error.
IBayesNet< GUM_SCALAR > & operator=(const IBayesNet< GUM_SCALAR > &source)
Copy operator.
IBayesNet()
Default constructor.
Exception : node does not exist.
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
Exception : the element we looked for cannot be found.
Container used to map discrete variables with nodes.
This class decorates a gum::prm::Class<GUM_SCALAR> has an IBaseBayesNet.
virtual ~ClassBayesNet()
Destructor.
virtual const DiscreteVariable & variableFromName(const std::string &name) const
See gum::IBaseBayesNet::variableFromName().
virtual NodeId nodeId(const DiscreteVariable &var) const
See gum::IBaseBayesNet::nodeId().
const PRMClassElement< GUM_SCALAR > & _get_(NodeId id) const
Private getter with type checking in case the id is not a formal PRMAttribute.
virtual const Tensor< GUM_SCALAR > & cpt(NodeId varId) const
Returns the CPT of a node in this ClassBayesNet<GUM_SCALAR>.
ClassBayesNet(const PRMClass< GUM_SCALAR > &c)
Default constructor.
NodeProperty< Size > _modalities_
HashTable< const DiscreteVariable *, const PRMClassElement< GUM_SCALAR > * > _varNodeMap_
Mapping between DiscreteVariable and their NodeId.
virtual std::string toDot() const
virtual const VariableNodeMap & variableNodeMap() const
See gum::IBaseBayesNet::variableNodeMap().
const NodeProperty< Size > & modalities() const
See gum::IBaseBayesNet::modalities().
virtual NodeId idFromName(const std::string &name) const
See gum::IBaseBayesNet::idFromName().
void _init_(const PRMClass< GUM_SCALAR > &c)
const PRMClass< GUM_SCALAR > * _class_
The PRMClassElementContainer decorated by this.
virtual const DiscreteVariable & variable(NodeId id) const
See gum::IBaseBayesNet::variable().
ClassBayesNet< GUM_SCALAR > & operator=(const ClassBayesNet< GUM_SCALAR > &from)
Copy operator.
virtual const DAG & containerDag() const
Returns the gum::DAG of this PRMClassElementContainer.
Abstract class representing an element of PRM class.
static INLINE bool isAggregate(const PRMClassElement< GUM_SCALAR > &elt)
Return true if obj is of type PRMAggregate.
NodeId id() const
Returns the NodeId of this element in it's class DAG.
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.
static INLINE bool isAttribute(const PRMClassElement< GUM_SCALAR > &elt)
Returns true if obj_ptr is of type PRMAttribute.
A PRMClass is an object of a PRM representing a fragment of a Bayesian network which can be instantia...
PRMClassElement< GUM_SCALAR > & get(NodeId id)
See gum::prm::PRMClassElementContainer<GUM_SCALAR>::get(NodeId).
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
aGrUM's inline/outline selection
namespace for all probabilistic relational models entities
gum is the global namespace for all aGrUM entities