30 #ifndef GUM_BAYES_NET_H 31 #define GUM_BAYES_NET_H 44 template <
typename GUM_SCALAR >
77 template <
typename GUM_SCALAR >
111 explicit BayesNet(std::string name);
194 NodeId add(
const std::string& name,
unsigned int nbrmod);
330 const std::string& old_label,
331 const std::string& new_label);
337 const std::string& old_label,
338 const std::string& new_label) {
394 void addArc(
const std::string& tail,
const std::string& head);
416 void eraseArc(
const std::string& tail,
const std::string& head) {
449 void reverseArc(
const std::string& tail,
const std::string& head) {
481 GUM_SCALAR external_weight);
501 GUM_SCALAR external_weight,
504 GUM_SCALAR external_weight,
507 GUM_SCALAR external_weight,
522 GUM_SCALAR external_weight,
546 GUM_SCALAR external_weight,
621 const std::string& head,
622 GUM_SCALAR causalWeight) {
671 template <
typename GUM_SCALAR >
672 std::ostream& operator<<(std::ostream& output, const BayesNet< GUM_SCALAR >& bn);
675 #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 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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.