27 #ifndef GUM_BAYESNET_FACTORY_H 28 #define GUM_BAYESNET_FACTORY_H 58 template <
typename GUM_SCALAR >
59 class BayesNetFactory :
public IBayesNetFactory {
121 const DiscreteVariable&
variable(const
std::
string& name) const;
138 const
std::
string& propValue) final;
247 const
std::vector<
float >& rawTable) final;
283 const
std::
string& modality) final;
350 void setVariable(const DiscreteVariable& var) final;
375 MultiDimAdressable* table,
376 bool redefineParents) final;
443 const
std::vector<
float >& rawTable);
453 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 461 #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.
Header of the IBayesNetFactory class.
void endParentsDeclaration() final
Tells the factory that we've finished declaring parents for some variable.
Class representing Bayesian networks.
Base class for discrete random variable.
Generic doubly linked lists.
gum is the global namespace for all aGrUM entities
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.
Implementation of the BayesNetFactory class.
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.