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 >
101 virtual void whenNodeAdded(
const void* src, NodeId id)
final;
112 virtual void whenArcAdded(
const void* src, NodeId from, NodeId to)
final;
118 virtual void whenArcDeleted(
const void* src, NodeId from, NodeId to)
final;
131 return cpt(idFromName(name));
146 return variable(idFromName(name));
187 return isInstalledNode(idFromName(name));
198 installNode(bn__.idFromName(name));
209 installAscendants(bn__.idFromName(name));
219 uninstallNode(idFromName(name));
234 const Potential< GUM_SCALAR >& pot) {
235 installMarginal(bn__.idFromName(name), pot);
250 void installCPT(NodeId id,
const Potential< GUM_SCALAR >& pot);
251 void installCPT(
const std::string& name,
const Potential< GUM_SCALAR >& pot) {
252 installCPT(bn__.idFromName(name), pot);
263 void uninstallCPT(
const std::string& name) { uninstallCPT(idFromName(name)); }
273 return checkConsistency(idFromName(name));
305 void installCPT_(NodeId id,
const Potential< GUM_SCALAR >& pot);
315 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 321 #include <agrum/BN/BayesNetFragment_tpl.h> gum::BayesNet< GUM_SCALAR > toBN() const
create a brand new BayesNet from a fragment.
const IBayesNet< GUM_SCALAR > & bn__
The referred BayesNet.
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.
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
NodeProperty< const Potential< GUM_SCALAR > *> localCPTs__
Mapping between the variable's id and their CPT specific to this Fragment.
bool checkConsistency() const
returns true if all nodes in the fragment are consistent
BayesNetFragment(const BayesNetFragment< GUM_SCALAR > &fragment)=delete
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.