28 #ifndef GUM_BAYES_NET_H 29 #define GUM_BAYES_NET_H 42 template <
typename GUM_SCALAR >
75 template <
typename GUM_SCALAR >
109 explicit BayesNet(std::string name);
192 NodeId add(
const std::string& name,
unsigned int nbrmod);
328 const std::string& old_label,
329 const std::string& new_label);
335 const std::string& old_label,
336 const std::string& new_label) {
389 void addArc(
const std::string& tail,
const std::string& head) {
413 void eraseArc(
const std::string& tail,
const std::string& head) {
446 void reverseArc(
const std::string& tail,
const std::string& head) {
478 GUM_SCALAR external_weight);
498 GUM_SCALAR external_weight,
501 GUM_SCALAR external_weight,
504 GUM_SCALAR external_weight,
519 GUM_SCALAR external_weight,
543 GUM_SCALAR external_weight,
618 const std::string& head,
619 GUM_SCALAR causalWeight) {
668 template <
typename GUM_SCALAR >
669 std::ostream& operator<<(std::ostream& output, const BayesNet< GUM_SCALAR >& bn);
672 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS void addArc(NodeId tail, NodeId head)
Add an arc in the BN, and update arc.head's CPT.
aGrUM's Potential is a multi-dimensional array with tensor operators.
Class representing a Bayesian Network.
void changeVariableName(const std::string &name, const std::string &new_name)
Changes a variable's name.
NodeId addCOUNT(const DiscreteVariable &var, Idx value=1)
Others aggregators.
NodeId addNoisyOR(const DiscreteVariable &var, GUM_SCALAR external_weight)
Add a variable, it's associate node and a gum::noisyOR implementation.
void changeVariableName(NodeId id, const std::string &new_name)
Changes a variable's name in the gum::BayesNet.
const DiscreteVariable & variable(NodeId id) const final
Returns a gum::DiscreteVariable given its gum::NodeId in the gum::BayesNet.
void addArc(const std::string &tail, const std::string &head)
Add an arc in the BN, and update arc.head's CPT.
void reverseArc(const std::string &tail, const std::string &head)
Reverses an arc while preserving the same joint distribution.
NodeId add(const DiscreteVariable &var)
Add a variable to the gum::BayesNet.
VariableNodeMap __varMap
the map between variable and id
NodeId addAMPLITUDE(const DiscreteVariable &var)
Others aggregators.
Container used to map discrete variables with nodes.
BayesNet()
Default constructor.
void erase(const std::string &name)
Removes a variable from the gum::BayesNet.
Template implementation of BN/BayesNet.h class.
Class representing Bayesian networks.
NodeId addLogit(const DiscreteVariable &var, GUM_SCALAR external_weight, NodeId id)
Add a variable, its associate node and a Logit implementation.
NodeId addAND(const DiscreteVariable &var)
Add a variable, it's associate node and an AND implementation.
void generateCPT(NodeId node) const
randomly generate CPT for a given node in a given structure
Base class for discrete random variable.
Class representing the minimal interface for Bayesian Network.
gum is the global namespace for all aGrUM entities
NodeId addFORALL(const DiscreteVariable &var, Idx value=1)
Others aggregators.
static BayesNet< GUM_SCALAR > fastPrototype(const std::string &dotlike, Size domainSize=2)
Create a bn with a dotlike syntax : 'a->b->c;b->d;'.
void eraseArc(const std::string &tail, const std::string &head)
Removes an arc in the BN, and update head's CTP.
The class for generic Hash Tables.
void addWeightedArc(NodeId tail, NodeId head, GUM_SCALAR causalWeight)
Add an arc in the BN, and update arc.head's CPT.
NodeId addNoisyORNet(const DiscreteVariable &var, GUM_SCALAR external_weight)
Add a variable, it's associate node and a gum::noisyOR implementation.
void beginTopologyTransformation()
When inserting/removing arcs, node CPTs change their dimension with a cost in time.
const DiscreteVariable & variableFromName(const std::string &name) const final
Returns a variable given its name in the gum::BayesNet.
void _unsafeChangePotential(NodeId id, Potential< GUM_SCALAR > *newPot)
change the CPT associated to nodeId to newPot delete the old CPT associated to nodeId.
Header of the Potential class.
const VariableNodeMap & variableNodeMap() const final
Returns a map between variables and nodes of this gum::BayesNet.
NodeId addNoisyAND(const DiscreteVariable &var, GUM_SCALAR external_weight, NodeId id)
Add a variable, its associate node and a noisyAND implementation.
The base class for all directed edgesThis class is used as a basis for manipulating all directed edge...
NodeId addOR(const DiscreteVariable &var)
Add a variable, it's associate node and an OR implementation.
void generateCPT(const std::string &name) const
NodeProperty< Potential< GUM_SCALAR > *> __probaMap
Mapping between the variable's id and their CPT.
void generateCPTs() const
randomly generates CPTs for a given structure
NodeId addEXISTS(const DiscreteVariable &var, Idx value=1)
Others aggregators.
const Potential< GUM_SCALAR > & cpt(NodeId varId) const final
Returns the CPT of a variable.
void addWeightedArc(const std::string &tail, const std::string &head, GUM_SCALAR causalWeight)
Add an arc in the BN, and update arc.head's CPT.
void changeVariableLabel(NodeId id, const std::string &old_label, const std::string &new_label)
Changes a variable's label in the gum::BayesNet.
NodeId addMAX(const DiscreteVariable &var)
Others aggregators.
void __copyPotentials(const BayesNet< GUM_SCALAR > &source)
copy of potentials from a BN to another, using names of vars as ref.
NodeId nodeId(const DiscreteVariable &var) const final
Returns a variable's id in the gum::BayesNet.
~BayesNet() final
Destructor.
void endTopologyTransformation()
terminates a sequence of insertions/deletions of arcs by adjusting all CPTs dimensions.
<agrum/multidim/multiDimImplementation.h>
Size Idx
Type for indexes.
void changePotential(NodeId id, Potential< GUM_SCALAR > *newPot)
change the CPT associated to nodeId to newPot delete the old CPT associated to nodeId.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
void changeVariableLabel(const std::string &name, const std::string &old_label, const std::string &new_label)
Changes a variable's name.
NodeId addMEDIAN(const DiscreteVariable &var)
Others aggregators.
NodeId addNoisyORCompound(const DiscreteVariable &var, GUM_SCALAR external_weight)
Add a variable, it's associate node and a gum::noisyOR implementation.
NodeId idFromName(const std::string &name) const final
Returns a variable's id given its name in the gum::BayesNet.
const DiscreteVariable & variable(const std::string &name) const
Returns a gum::DiscreteVariable given its gum::NodeId in the gum::BayesNet.
void __clearPotentials()
clear all potentials
void erase(NodeId varId)
Remove a variable from the gum::BayesNet.
Class hash tables iterators.
Size NodeId
Type for node ids.
NodeId addMIN(const DiscreteVariable &var)
Others aggregators.
A factory class to ease BayesNet construction.
void reverseArc(NodeId tail, NodeId head)
Reverses an arc while preserving the same joint distribution.
void eraseArc(const Arc &arc)
Removes an arc in the BN, and update head's CTP.