29 #ifndef GUM_BAYES_NET_FRAGMENT_H 30 #define GUM_BAYES_NET_FRAGMENT_H 32 #include <agrum/agrum.h> 34 #include <agrum/BN/IBayesNet.h> 35 #include <agrum/tools/graphs/parts/listeners/diGraphListener.h> 37 #include <agrum/BN/BayesNet.h> 71 template <
typename GUM_SCALAR >
110 virtual void whenArcAdded(
const void* src, NodeId from, NodeId to)
final;
116 virtual void whenArcDeleted(
const void* src, NodeId from, NodeId to)
final;
129 return cpt(idFromName(name));
144 return variable(idFromName(name));
184 return isInstalledNode(idFromName(name));
194 void installNode(
const std::string& name) { installNode(_bn_.idFromName(name)); }
211 void uninstallNode(
const std::string& name) { uninstallNode(idFromName(name)); }
225 installMarginal(_bn_.idFromName(name), pot);
240 void installCPT(NodeId id,
const Potential< GUM_SCALAR >& pot);
241 void installCPT(
const std::string& name,
const Potential< GUM_SCALAR >& pot) {
242 installCPT(_bn_.idFromName(name), pot);
253 void uninstallCPT(
const std::string& name) { uninstallCPT(idFromName(name)); }
263 return checkConsistency(idFromName(name));
295 void installCPT_(NodeId id,
const Potential< GUM_SCALAR >& pot);
305 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 311 #include <agrum/BN/BayesNetFragment_tpl.h> gum::BayesNet< GUM_SCALAR > toBN() const
create a brand new BayesNet from a fragment.
void uninstallArc_(NodeId from, NodeId to)
void installCPT(NodeId id, const Potential< GUM_SCALAR > &pot)
install a local cpt BY COPYfor a node into the fragment.
BayesNetFragment()=delete
void uninstallCPT_(NodeId id)
uninstall a local CPT.
INLINE void emplace(Args &&... args)
virtual void whenNodeDeleted(const void *src, NodeId id) final
the action to take when a node has just been removed from the graph
void installNode(const std::string &name)
check if a certain NodeId exists in the fragment
virtual NodeId nodeId(const DiscreteVariable &var) const final
Return id node from discrete var pointer.
void uninstallNode(NodeId id)
uninstall a node referenced by its nodeId
virtual const DiscreteVariable & variable(const std::string &name) const final
Returns the CPT of a variable.
void installCPT_(NodeId id, const Potential< GUM_SCALAR > &pot)
bool checkConsistency(const std::string &name) const
check if a certain NodeId exists in the fragment
virtual const DiscreteVariable & variable(NodeId id) const final
Returns a constant reference over a variabe given it's node id.
void installAscendants(NodeId id)
install a node and all its ascendants
virtual ~BayesNetFragment()
virtual void whenNodeAdded(const void *src, NodeId id) final
the action to take when a new node is inserted into the graph
BayesNetFragment(BayesNetFragment< GUM_SCALAR > &&fragment)=delete
void installMarginal(NodeId id, const Potential< GUM_SCALAR > &pot)
install a local marginal BY COPY for a node into the fragment.
const VariableNodeMap & variableNodeMap() const final
Returns a constant reference to the VariableNodeMap of this BN.
virtual void whenArcAdded(const void *src, NodeId from, NodeId to) final
the action to take when a new arc is inserted into the graph
bool checkConsistency(NodeId id) const
returns true if the nodeId's (local or not) cpt is consistent with its parents in the fragment ...
virtual const DiscreteVariable & variableFromName(const std::string &name) const final
Getter by name.
const IBayesNet< GUM_SCALAR > & _bn_
The referred BayesNet.
virtual NodeId idFromName(const std::string &name) const final
Getter by name.
Portion of a BN identified by the list of nodes and a BayesNet.
void installAscendants(const std::string &name)
check if a certain NodeId exists in the fragment
void installNode(NodeId id)
install a node referenced by its nodeId
void installArc_(NodeId from, NodeId to)
bool isInstalledNode(NodeId id) const
check if a certain NodeId exists in the fragment
const Potential< GUM_SCALAR > & cpt(NodeId varId) const final
Returns the CPT of a variable.
void installMarginal(const std::string &name, const Potential< GUM_SCALAR > &pot)
check if a certain NodeId exists in the fragment
bool checkConsistency() const
returns true if all nodes in the fragment are consistent
BayesNetFragment(const BayesNetFragment< GUM_SCALAR > &fragment)=delete
NodeProperty< const Potential< GUM_SCALAR > *> _localCPTs_
Mapping between the variable's id and their CPT specific to this Fragment.
bool isInstalledNode(const std::string &name) const
check if a certain NodeId exists in the fragment
void installCPT(const std::string &name, const Potential< GUM_SCALAR > &pot)
check if a certain NodeId exists in the fragment
void uninstallNode(const std::string &name)
check if a certain NodeId exists in the fragment
void uninstallCPT(const std::string &name)
check if a certain NodeId exists in the fragment
void uninstallCPT(NodeId id)
uninstall a local CPT.
virtual void whenArcDeleted(const void *src, NodeId from, NodeId to) final
the action to take when an arc has just been removed from the graph
BayesNetFragment(const IBayesNet< GUM_SCALAR > &bn)
const Potential< GUM_SCALAR > & cpt(const std::string &name) const
Returns the CPT of a variable.
virtual std::string toDot() const final
creates a dot representing the whole referred BN hilighting the fragment.