30 #ifndef GUM_BAYESNET_FACTORY_H 31 #define GUM_BAYESNET_FACTORY_H 61 template <
typename GUM_SCALAR >
62 class BayesNetFactory :
public IBayesNetFactory {
124 const DiscreteVariable&
variable(const
std::
string& name) const;
141 const
std::
string& propValue) final;
250 const
std::vector<
float >& rawTable) final;
286 const
std::
string& modality) final;
353 void setVariable(const DiscreteVariable& var) final;
378 MultiDimAdressable* table,
379 bool redefineParents) final;
446 const
std::vector<
float >& rawTable);
456 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 464 #endif // GUM_BAYESNET_FACTORY_H aGrUM's Potential is a multi-dimensional array with tensor operators.
Class representing a Bayesian Network.
void endRawProbabilityDeclaration() final
Tells the factory that we finished declaring a conditional probability table.
void variableName(const std::string &name) final
Tells the factory the current variable's name.
void endFactorizedEntry() final
Tells the factory that we end an entry of a factorized conditional probability table.
void setVariableCPTImplementation(MultiDimAdressable *adressable) final
Defines the implementation to use for var's Potential.
void startFactorizedEntry() final
Tells the factory that we start an entry of a factorized conditional probability table.
BayesNetFactory(BayesNet< GUM_SCALAR > *bn)
Use this constructor if you want to use an already created BayesNet.
void addParent(const std::string &var) final
Tells the factory for which variable we're declaring parents.
void setVariable(const DiscreteVariable &var) final
Define a variable.
BayesNet< GUM_SCALAR > * bayesNet()
Returns the BayesNet created by this factory.
factory_state state() const final
Returns the current state of the factory.
void addNetworkProperty(const std::string &propName, const std::string &propValue) final
Tells the factory to add a property to the current network.
void startParentsDeclaration(const std::string &var) final
Tells the factory that we're declaring parents for some variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void endParentsDeclaration() final
Tells the factory that we've finished declaring parents for some variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Base class for discrete random variable.
Generic doubly linked lists.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The class for generic Hash Tables.
void __fillProbaWithValuesTable(const std::vector< std::string > &variables, const std::vector< float > &rawTable)
Fill a potential from a raw CPT.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __illegalStateError(const std::string &s)
Raise an OperationNotAllowed with the message "Illegal state.".
void startFactorizedProbabilityDeclaration(const std::string &var) final
Tells the factory that we're starting a factorized declaration.
NodeId variableId(const std::string &name) const final
Returns the NodeId of a variable given it's name.
void startNetworkDeclaration() final
Tells the factory that we're in a network declaration.
HashTable< std::string, NodeId > __varNameMap
Mapping between a declared variable's name and it's node id.
void startVariableDeclaration() final
Tells the factory that we're in a variable declaration.
factory_state
The enumeration of states in which the factory can be in.
BayesNet< GUM_SCALAR > * __bn
The constructed BayesNet.
Idx __checkVariableModality(const std::string &name, const std::string &mod)
Check if var exists and if mod is one of it's modality, if not raise an NotFound exception.
NodeId endVariableDeclaration() final
Tells the factory that we're out of a variable declaration.
std::vector< factory_state > __states
State stack.
Size cptDomainSize(NodeId n) const final
Returns the domainSize of the cpt for the node n.
void startRawProbabilityDeclaration(const std::string &var) final
Tells the factory that we're declaring a conditional probability table for some variable.
std::vector< std::string > __stringBag
Just to keep track of strings between two start/end calls.
const DiscreteVariable & varInBN(NodeId id) final
short-cut accessor for a DiscreveVariable in the BN
void setVariableValuesUnchecked(const std::vector< float > &values) final
Gives the values of the variable with respect to precedent parents modality.
Class for assigning/browsing values to tuples of discrete variables.
void setVariableCPT(const std::string &varName, MultiDimAdressable *table, bool redefineParents) final
Define a variable's CPT.
void endFactorizedProbabilityDeclaration() final
Tells the factory that we finished declaring a conditional probability table.
bool __foo_flag
Depending on the context this flag is used for some VERY important reasons.
Instantiation * __parents
Used when a factorized CPT is built.
void variableDescription(const std::string &desc) final
Tells the factory the current variable's description.
void __checkVariableName(const std::string &name)
Check if a variable with the given name exists, if not raise an NotFound exception.
void rawConditionalTable(const std::vector< std::string > &variables, const std::vector< float > &rawTable) final
Fills the variable's table with the values in rawTable.
<agrum/multidim/multiDimImplementation.h>
Size Idx
Type for indexes.
void endNetworkDeclaration() final
Tells the factory that we're out of a network declaration.
const DiscreteVariable & variable(const std::string &name) const
Returns a constant reference on a variable given it's name.
void __checkModalityInBag(const std::string &mod)
Check if in __stringBag there is no other modality with the same name.
void addModality(const std::string &name) final
Adds a modality to the current variable.
bool __increment(std::vector< gum::Idx > &modCounter, List< const DiscreteVariable * > &varList)
Increment a modality counter for the __fillProbaWithValuesTable method.
bool __bar_flag
Depending on the context this flag is used for some VERY important reasons.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
MultiDimImplementation< GUM_SCALAR > * __impl
Implementation of variable between two startVariableDeclaration/endVariableDeclaration calls...
void __setCPTAndParents(const DiscreteVariable &var, Potential< GUM_SCALAR > *table)
Sub method of setVariableCPT() which redefine the BayesNet's DAG with respect to table.
Size NodeId
Type for node ids.
void setVariableValues(const std::vector< float > &values) final
same than below with gum::OperationNotAllowed exception if value's size not OK.
void __resetParts()
Reset the different parts used to constructed the BayesNet.
A factory class to ease BayesNet construction.
virtual ~BayesNetFactory()
Destructor.
void setParentModality(const std::string &parent, const std::string &modality) final
Tells the factory on which modality we want to instantiate one of variable's parent.