![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
A factory class to ease BayesNet construction. More...
#include <agrum/BN/BayesNetFactory.h>
Public Types | |
| enum class | factory_state : char { NONE , NETWORK , VARIABLE , PARENTS , RAW_CPT , FACT_CPT , FACT_ENTRY } |
| The enumeration of states in which the factory can be in. More... | |
Public Member Functions | |
Constructor & destructor. | |
| BayesNetFactory (BayesNet< GUM_SCALAR > *bn) | |
| Use this constructor if you want to use an already created BayesNet. | |
| BayesNetFactory (const BayesNetFactory< GUM_SCALAR > &source) | |
| Copy constructor. | |
| virtual | ~BayesNetFactory () |
| Destructor. | |
Getter and setters. | |
| BayesNet< GUM_SCALAR > * | bayesNet () |
| Returns the BayesNet created by this factory. | |
| const DiscreteVariable & | varInBN (NodeId id) final |
| short-cut accessor for a DiscreveVariable in the BN | |
| factory_state | state () const final |
| Returns the current state of the factory. | |
| NodeId | variableId (const std::string &name) const final |
| Returns the NodeId of a variable given it's name. | |
| const DiscreteVariable & | variable (const std::string &name) const |
| Returns a constant reference on a variable given it's name. | |
| Size | cptDomainSize (NodeId n) const final |
| Returns the domainSize of the cpt for the node n. | |
Network declaration methods (NONE -> NETWORK) | |
| void | startNetworkDeclaration () final |
| Tells the factory that we're in a network declaration. | |
| void | variableType (const VarType &type) |
| Tells the factory the current variable's type. | |
| void | addNetworkProperty (const std::string &propName, const std::string &propValue) final |
| Tells the factory to add a property to the current network. | |
| void | endNetworkDeclaration () final |
| Tells the factory that we're out of a network declaration. | |
Variable declaration methods (NONE -> VARIABLE) | |
| void | startVariableDeclaration () final |
| Tells the factory that we're in a variable declaration. | |
| void | variableName (const std::string &name) final |
| Tells the factory the current variable's name. | |
| void | variableDescription (const std::string &desc) final |
| Tells the factory the current variable's description. | |
| void | addModality (const std::string &name) final |
| Adds a modality to the current labelized variable. | |
| void | addMin (const long &min) |
| Adds the min value of the current range variable. | |
| void | addMax (const long &max) |
| Adds the max value of the current range variable. | |
| void | addTick (const GUM_SCALAR &tick) |
| Adds a tick to the current Discretized variable. | |
| void | setVariableCPTImplementation (MultiDimAdressable *adressable) final |
| Defines the implementation to use for var's Tensor. | |
| NodeId | endVariableDeclaration () final |
| Tells the factory that we're out of a variable declaration. | |
Parents declaration methods (NONE -> PARENTS) | |
| void | startParentsDeclaration (const std::string &var) final |
| Tells the factory that we're declaring parents for some variable. | |
| void | addParent (const std::string &var) final |
| Tells the factory for which variable we're declaring parents. | |
| void | endParentsDeclaration () final |
| Tells the factory that we've finished declaring parents for some variable. | |
Raw Probability table declaration methods (NONE -> RAW_CPT) | |
| void | startRawProbabilityDeclaration (const std::string &var) final |
| Tells the factory that we're declaring a conditional probability table for some variable. | |
| void | rawConditionalTable (const std::vector< std::string > &variables, const std::vector< float > &rawTable) final |
| Fills the variable's table with the values in rawTable. | |
| void | rawConditionalTable (const std::vector< float > &rawTable) final |
| Fills the variable's table with the values in rawTable. | |
| void | endRawProbabilityDeclaration () final |
| Tells the factory that we finished declaring a conditional probability table. | |
Factorized probability table declaration methods | |
| void | startFactorizedProbabilityDeclaration (const std::string &var) final |
| Tells the factory that we're starting a factorized declaration. | |
| void | startFactorizedEntry () final |
| Tells the factory that we start an entry of a factorized conditional probability table. | |
| void | endFactorizedEntry () final |
| Tells the factory that we end an entry of a factorized conditional probability table. | |
| 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. | |
| void | setVariableValuesUnchecked (const std::vector< float > &values) final |
| Gives the values of the variable with respect to precedent parents modality. | |
| void | setVariableValues (const std::vector< float > &values) final |
| same than below with gum::OperationNotAllowed exception if value's size not OK. | |
| void | endFactorizedProbabilityDeclaration () final |
| Tells the factory that we finished declaring a conditional probability table. | |
Delegated CPT definitions methods | |
(NONE, NETWORK) | |
| void | setVariable (const DiscreteVariable &var) final |
| Define a variable. | |
| void | setVariableCPT (const std::string &varName, MultiDimAdressable *table, bool redefineParents) final |
| Define a variable's CPT. | |
verbosity control | |
| void | setVerbose () |
| void | resetVerbose () |
| bool | isVerbose () |
Private Member Functions | |
| BayesNetFactory< GUM_SCALAR > & | operator= (const BayesNetFactory< GUM_SCALAR > &source)=delete |
| Copy operator is illegal, use only copy constructor. | |
| void | _illegalStateError_ (const std::string &s) |
| Raise an OperationNotAllowed with the message "Illegal state.". | |
| void | _checkVariableName_ (const std::string &name) const |
| Check if a variable with the given name exists, if not raise an NotFound exception. | |
| 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. | |
| void | _checkModalityInBag_ (const std::string &mod) |
| Check if in stringBag there is no other modality with the same name. | |
| void | _setCPTAndParents_ (const DiscreteVariable &var, Tensor< GUM_SCALAR > *table) |
| Sub method of setVariableCPT() which redefine the BayesNet's DAG with respect to table. | |
| void | _resetParts_ () |
| Reset the different parts used to constructed the BayesNet. | |
| void | _fillProbaWithValuesTable_ (const std::vector< std::string > &variables, const std::vector< float > &rawTable) |
| Fill a tensor from a raw CPT. | |
| void | _fillProbaWithValuesTable_ (const std::vector< float > &rawTable) |
| Fill a tensor from a raw CPT.(using the canonical order of vars). | |
| bool | _increment_ (std::vector< gum::Idx > &modCounter, List< const DiscreteVariable * > &varList) const |
| Increment a modality counter for the fillProbaWithValuesTable method. | |
Private Attributes | |
| std::vector< factory_state > | _states_ |
| State stack. | |
| BayesNet< GUM_SCALAR > * | _bn_ |
| The constructed BayesNet. | |
| HashTable< std::string, NodeId > | _varNameMap_ |
| Mapping between a declared variable's name and it's node id. | |
| bool | _verbose_ |
Current constructed BayesNet's parts. | |
| bool | _foo_flag_ |
| Depending on the context this flag is used for some VERY important reasons. | |
| bool | _bar_flag_ |
| Depending on the context this flag is used for some VERY important reasons. | |
| std::vector< std::string > | _stringBag_ |
| Just to keep track of strings between two start/end calls. | |
| Instantiation * | _parents_ |
| Used when a factorized CPT is built. | |
| MultiDimImplementation< GUM_SCALAR > * | _impl_ |
| Implementation of variable between two startVariableDeclaration/endVariableDeclaration calls. | |
A factory class to ease BayesNet construction.
A BayesNetFactory will never create a BayesNet and works on only one BayesNet.
The only exception of this behaviour is when you create a copy of the factory, it will create a copy of it's BayesNet. This is useful if you want to create two BayesNet sharing a common base.
However be very careful because the copy will not delete it's BayesNet.
Each method will raise an OperationNotAllowed if you call it when the factory is not in a valid state for that call. The error message is "Illegal state.".
Definition at line 81 of file BayesNetFactory.h.
|
stronginherited |
The enumeration of states in which the factory can be in.
Every documentation section's name indicates from which state you can call it's methods, and in which state it places the factory.
There is an exception for the delegated CPT definition methods which do not change the state of the factory.
| Enumerator | |
|---|---|
| NONE | |
| NETWORK | |
| VARIABLE | |
| PARENTS | |
| RAW_CPT | |
| FACT_CPT | |
| FACT_ENTRY | |
Definition at line 79 of file IBayesNetFactory.h.
|
explicit |
Use this constructor if you want to use an already created BayesNet.
| bn | A pointer over the BayesNet filled by this factory. |
| DuplicateElement | Raised if two variables in bn share the same name. |
Definition at line 60 of file BayesNetFactory_tpl.h.
References BayesNetFactory(), _bn_, _impl_, _parents_, _states_, _varNameMap_, GUM_ERROR, gum::IBayesNetFactory::NONE, and gum::IBayesNetFactory::resetVerbose().
Referenced by BayesNetFactory(), BayesNetFactory(), ~BayesNetFactory(), and operator=().
| INLINE gum::BayesNetFactory< GUM_SCALAR >::BayesNetFactory | ( | const BayesNetFactory< GUM_SCALAR > & | source | ) |
Copy constructor.
The copy will have an exact copy of the constructed BayesNet in source.
| OperationNotAllowed | Raised if the state of source is not NONE or NETWORK. |
Definition at line 79 of file BayesNetFactory_tpl.h.
References BayesNetFactory(), _bn_, _impl_, _parents_, _states_, GUM_ERROR, gum::IBayesNetFactory::NONE, and state().
|
virtual |
Destructor.
To prevent strange behaviour you should always destroy a BayesNetFactory when it's state equals NONE.
| FatalError | Raised if the state of the factory prevents it to die peacefully. |
Definition at line 93 of file BayesNetFactory_tpl.h.
References BayesNetFactory(), _impl_, and _parents_.
|
private |
Check if in stringBag there is no other modality with the same name.
Definition at line 917 of file BayesNetFactory_tpl.h.
References _stringBag_, and GUM_ERROR.
Referenced by addModality().
|
private |
Check if var exists and if mod is one of it's modality, if not raise an NotFound exception.
Definition at line 903 of file BayesNetFactory_tpl.h.
References _bn_, _checkVariableName_(), _varNameMap_, gum::DiscreteVariable::domainSize(), GUM_ERROR, and gum::DiscreteVariable::label().
Referenced by setParentModality().
|
private |
Check if a variable with the given name exists, if not raise an NotFound exception.
Definition at line 896 of file BayesNetFactory_tpl.h.
References _varNameMap_, and GUM_ERROR.
Referenced by _checkVariableModality_(), _setCPTAndParents_(), addParent(), setParentModality(), setVariable(), setVariableCPT(), startFactorizedProbabilityDeclaration(), startParentsDeclaration(), and startRawProbabilityDeclaration().
|
private |
Fill a tensor from a raw CPT.(using the canonical order of vars).
Definition at line 546 of file BayesNetFactory_tpl.h.
References _bn_, _stringBag_, _varNameMap_, gum::Instantiation::end(), gum::Instantiation::incNotVar(), gum::Instantiation::incVar(), gum::Instantiation::setFirstNotVar(), gum::Instantiation::setFirstVar(), and gum::Instantiation::unsetEnd().
|
private |
Fill a tensor from a raw CPT.
Definition at line 503 of file BayesNetFactory_tpl.h.
References _bn_, _increment_(), _stringBag_, _varNameMap_, gum::Instantiation::chgVal(), gum::List< Val >::pushBack(), and gum::List< Val >::size().
Referenced by rawConditionalTable(), and rawConditionalTable().
|
private |
Raise an OperationNotAllowed with the message "Illegal state.".
Definition at line 844 of file BayesNetFactory_tpl.h.
References gum::IBayesNetFactory::FACT_CPT, gum::IBayesNetFactory::FACT_ENTRY, GUM_ERROR, gum::IBayesNetFactory::NETWORK, gum::IBayesNetFactory::NONE, gum::IBayesNetFactory::PARENTS, gum::IBayesNetFactory::RAW_CPT, state(), and gum::IBayesNetFactory::VARIABLE.
Referenced by addMax(), addMin(), addModality(), addParent(), addTick(), endFactorizedEntry(), endFactorizedProbabilityDeclaration(), endNetworkDeclaration(), endParentsDeclaration(), endRawProbabilityDeclaration(), endVariableDeclaration(), rawConditionalTable(), rawConditionalTable(), setParentModality(), setVariable(), setVariableCPT(), setVariableCPTImplementation(), setVariableValues(), setVariableValuesUnchecked(), startFactorizedEntry(), startFactorizedProbabilityDeclaration(), startNetworkDeclaration(), startParentsDeclaration(), startRawProbabilityDeclaration(), startVariableDeclaration(), variableDescription(), variableName(), and variableType().
|
private |
Increment a modality counter for the fillProbaWithValuesTable method.
Definition at line 569 of file BayesNetFactory_tpl.h.
References gum::List< Val >::size().
Referenced by _fillProbaWithValuesTable_().
|
private |
Reset the different parts used to constructed the BayesNet.
Definition at line 944 of file BayesNetFactory_tpl.h.
References _bar_flag_, _foo_flag_, and _stringBag_.
Referenced by endFactorizedProbabilityDeclaration(), endParentsDeclaration(), endRawProbabilityDeclaration(), and endVariableDeclaration().
|
private |
Sub method of setVariableCPT() which redefine the BayesNet's DAG with respect to table.
Definition at line 926 of file BayesNetFactory_tpl.h.
References _bn_, _checkVariableName_(), _varNameMap_, and gum::Variable::name().
Referenced by setVariableCPT().
|
virtual |
Adds the max value of the current range variable.
Implements gum::IBayesNetFactory.
Definition at line 272 of file BayesNetFactory_tpl.h.
References _illegalStateError_(), _stringBag_, state(), and gum::IBayesNetFactory::VARIABLE.
|
virtual |
Adds the min value of the current range variable.
Implements gum::IBayesNetFactory.
Definition at line 260 of file BayesNetFactory_tpl.h.
References _illegalStateError_(), _stringBag_, state(), and gum::IBayesNetFactory::VARIABLE.
|
finalvirtual |
Adds a modality to the current labelized variable.
Implements gum::IBayesNetFactory.
Definition at line 247 of file BayesNetFactory_tpl.h.
References _checkModalityInBag_(), _illegalStateError_(), _stringBag_, state(), and gum::IBayesNetFactory::VARIABLE.
Referenced by gum::prm::PRMSystem< double >::getArrayType().
|
finalvirtual |
Tells the factory to add a property to the current network.
Implements gum::IBayesNetFactory.
Definition at line 166 of file BayesNetFactory_tpl.h.
References _bn_.
Referenced by gum::prm::PRMSystem< GUM_SCALAR >::groundedBN().
|
finalvirtual |
Tells the factory for which variable we're declaring parents.
| var | The parent's name. |
| NotFound | Raised if var does not exists. |
Implements gum::IBayesNetFactory.
Definition at line 433 of file BayesNetFactory_tpl.h.
References _checkVariableName_(), _illegalStateError_(), _stringBag_, gum::IBayesNetFactory::PARENTS, and state().
Referenced by gum::prm::PRMSystem< GUM_SCALAR >::_groundRef_().
| INLINE void gum::BayesNetFactory< GUM_SCALAR >::addTick | ( | const GUM_SCALAR & | tick | ) |
Adds a tick to the current Discretized variable.
Definition at line 284 of file BayesNetFactory_tpl.h.
References _illegalStateError_(), _stringBag_, state(), and gum::IBayesNetFactory::VARIABLE.
| INLINE BayesNet< GUM_SCALAR > * gum::BayesNetFactory< GUM_SCALAR >::bayesNet | ( | ) |
Returns the BayesNet created by this factory.
| OperationNotAllowed | Raise if the state of the factory is different than NONE. |
Definition at line 111 of file BayesNetFactory_tpl.h.
References _bn_.
|
finalvirtual |
Returns the domainSize of the cpt for the node n.
Implements gum::IBayesNetFactory.
Definition at line 150 of file BayesNetFactory_tpl.h.
References _bn_.
|
finalvirtual |
Tells the factory that we end an entry of a factorized conditional probability table.
Implements gum::IBayesNetFactory.
Definition at line 640 of file BayesNetFactory_tpl.h.
References _illegalStateError_(), _parents_, _states_, gum::IBayesNetFactory::FACT_ENTRY, and state().
|
finalvirtual |
Tells the factory that we finished declaring a conditional probability table.
Implements gum::IBayesNetFactory.
Definition at line 759 of file BayesNetFactory_tpl.h.
References _illegalStateError_(), _resetParts_(), _states_, gum::IBayesNetFactory::FACT_CPT, and state().
|
finalvirtual |
Tells the factory that we're out of a network declaration.
Implements gum::IBayesNetFactory.
Definition at line 173 of file BayesNetFactory_tpl.h.
References _illegalStateError_(), _states_, gum::IBayesNetFactory::NETWORK, and state().
Referenced by gum::prm::PRMSystem< GUM_SCALAR >::groundedBN().
|
finalvirtual |
Tells the factory that we've finished declaring parents for some variable.
Implements gum::IBayesNetFactory.
Definition at line 447 of file BayesNetFactory_tpl.h.
References _bn_, _illegalStateError_(), _resetParts_(), _states_, _stringBag_, _varNameMap_, gum::IBayesNetFactory::PARENTS, and state().
|
finalvirtual |
Tells the factory that we finished declaring a conditional probability table.
Implements gum::IBayesNetFactory.
Definition at line 603 of file BayesNetFactory_tpl.h.
References _illegalStateError_(), _resetParts_(), _states_, gum::IBayesNetFactory::RAW_CPT, and state().
|
finalvirtual |
Tells the factory that we're out of a variable declaration.
| gum::OperationNotAllowed | Raised if the variable isn't defined (or / not enough defined). |
Implements gum::IBayesNetFactory.
Definition at line 324 of file BayesNetFactory_tpl.h.
References _bar_flag_, _bn_, _foo_flag_, _illegalStateError_(), _impl_, _resetParts_(), _states_, _stringBag_, _varNameMap_, GUM_ERROR, gum::Variable::name(), state(), and gum::IBayesNetFactory::VARIABLE.
|
inlineinherited |
|
privatedelete |
Copy operator is illegal, use only copy constructor.
References BayesNetFactory().
|
finalvirtual |
Fills the variable's table with the values in rawTable.
use the canonical ordering for the variables (e.g. see BIF format) ...
| rawTable | The raw table. |
Implements gum::IBayesNetFactory.
Definition at line 537 of file BayesNetFactory_tpl.h.
References _fillProbaWithValuesTable_(), _illegalStateError_(), gum::IBayesNetFactory::RAW_CPT, and state().
|
finalvirtual |
Fills the variable's table with the values in rawTable.
Parse the parents in the same order in variables
Given a sequence [var, p_1, p_2, ...,p_n-1, p_n] of parents, modalities are parsed in the given order (if all p_i are binary):
* [0, 0, ..., 0, 0], * [0, 0, ..., 0, 1], * [0, 0, ..., 1, 0], * [0, 0, ..., 1, 1], * ..., * [1, 1, ..., 1, 0], * [1, 1, ..., 1, 1]. *
| variables | the vector giving the order of parents |
| rawTable | The raw table. |
Implements gum::IBayesNetFactory.
Definition at line 492 of file BayesNetFactory_tpl.h.
References _fillProbaWithValuesTable_(), _illegalStateError_(), gum::IBayesNetFactory::RAW_CPT, and state().
|
inlineinherited |
Definition at line 99 of file IBayesNetFactory.h.
References _verbose_.
Referenced by gum::BayesNetFactory< GUM_SCALAR >::BayesNetFactory().
|
finalvirtual |
Tells the factory on which modality we want to instantiate one of variable's parent.
Implements gum::IBayesNetFactory.
Definition at line 653 of file BayesNetFactory_tpl.h.
References _bn_, _checkVariableModality_(), _checkVariableName_(), _illegalStateError_(), _parents_, _varNameMap_, gum::IBayesNetFactory::FACT_ENTRY, and state().
|
finalvirtual |
Define a variable.
You can only call this method is the factory is in the NONE or NETWORK state.
The variable is added by copy.
| var | The pointer over a DiscreteVariable used to define a new variable in the built BayesNet. |
| DuplicateElement | Raised if a variable with the same name already exists. |
| OperationNotAllowed | Raised if redefineParents == false and if table is not a valid CPT for var in the current state of the BayesNet. |
Implements gum::IBayesNetFactory.
Definition at line 780 of file BayesNetFactory_tpl.h.
References _bn_, _checkVariableName_(), _illegalStateError_(), _varNameMap_, GUM_ERROR, gum::Variable::name(), gum::IBayesNetFactory::NONE, and state().
|
finalvirtual |
Define a variable's CPT.
You can only call this method if the factory is in the NONE or NETWORK state.
Be careful that table is given to the built BayesNet, so it will be deleted with it, and you should not directly access it after you call this method.
When the redefineParents flag is set to true the constructed BayesNet's DAG is changed to fit with table's definition.
| varName | The name of the concerned variable. |
| table | A pointer over the CPT used for var. |
| redefineParents | If true redefine var's parents to match table's variables set. |
| NotFound | Raised if no variable matches var. |
| OperationNotAllowed | Raised if redefineParents == false and if table is not a valid CPT for var in the current state of the BayesNet. |
Implements gum::IBayesNetFactory.
Definition at line 813 of file BayesNetFactory_tpl.h.
References _bn_, _checkVariableName_(), _illegalStateError_(), _setCPTAndParents_(), _varNameMap_, GUM_ERROR, gum::IBayesNetFactory::NONE, and state().
|
finalvirtual |
Defines the implementation to use for var's Tensor.
| NotFound | Raised if no variable matches var. |
| OperationNotAllowed | Raised if impl is not empty. |
| OperationNotAllowed | If an implementation is already defined for the current variable. |
Implements gum::IBayesNetFactory.
Definition at line 304 of file BayesNetFactory_tpl.h.
References _illegalStateError_(), _impl_, GUM_ERROR, state(), and gum::IBayesNetFactory::VARIABLE.
Referenced by gum::prm::PRMSystem< double >::begin().
|
finalvirtual |
same than below with gum::OperationNotAllowed exception if value's size not OK.
Implements gum::IBayesNetFactory.
Definition at line 740 of file BayesNetFactory_tpl.h.
References _bn_, _illegalStateError_(), _stringBag_, _varNameMap_, gum::IBayesNetFactory::FACT_ENTRY, GUM_ERROR, setVariableValuesUnchecked(), and state().
|
finalvirtual |
Gives the values of the variable with respect to precedent parents modality.
If some parents have no modality set, then we apply values for all instantiations of that parent.
This means you can declare a default value for the table by doing
as for rawProba, if value's size is different than the number of modalities of the current variable, we don't use the supplementary values and we fill by 0 the missing values.
Implements gum::IBayesNetFactory.
Definition at line 692 of file BayesNetFactory_tpl.h.
References _bn_, _illegalStateError_(), _parents_, _stringBag_, _varNameMap_, gum::Instantiation::end(), gum::IBayesNetFactory::FACT_ENTRY, gum::Instantiation::incIn(), gum::Instantiation::incOut(), gum::Variable::name(), gum::Instantiation::setFirst(), gum::Instantiation::setFirstIn(), gum::Instantiation::setFirstOut(), gum::Instantiation::setVals(), state(), and gum::Instantiation::val().
Referenced by setVariableValues().
|
inlineinherited |
|
finalvirtual |
Tells the factory that we start an entry of a factorized conditional probability table.
Implements gum::IBayesNetFactory.
Definition at line 628 of file BayesNetFactory_tpl.h.
References _illegalStateError_(), _parents_, _states_, gum::IBayesNetFactory::FACT_CPT, gum::IBayesNetFactory::FACT_ENTRY, and state().
|
finalvirtual |
Tells the factory that we're starting a factorized declaration.
Implements gum::IBayesNetFactory.
Definition at line 615 of file BayesNetFactory_tpl.h.
References _checkVariableName_(), _illegalStateError_(), _states_, _stringBag_, gum::IBayesNetFactory::FACT_CPT, gum::IBayesNetFactory::NONE, and state().
|
finalvirtual |
Tells the factory that we're in a network declaration.
Implements gum::IBayesNetFactory.
Definition at line 156 of file BayesNetFactory_tpl.h.
References _illegalStateError_(), _states_, gum::IBayesNetFactory::NETWORK, gum::IBayesNetFactory::NONE, and state().
Referenced by gum::prm::PRMSystem< GUM_SCALAR >::groundedBN().
|
finalvirtual |
Tells the factory that we're declaring parents for some variable.
| var | The concerned variable's name. |
| NotFound | Raised if var does not exists. |
Implements gum::IBayesNetFactory.
Definition at line 419 of file BayesNetFactory_tpl.h.
References _checkVariableName_(), _illegalStateError_(), _states_, _stringBag_, gum::IBayesNetFactory::NONE, gum::IBayesNetFactory::PARENTS, and state().
Referenced by gum::prm::PRMSystem< GUM_SCALAR >::_groundRef_().
|
finalvirtual |
Tells the factory that we're declaring a conditional probability table for some variable.
| var | The concerned variable's name. |
Implements gum::IBayesNetFactory.
Definition at line 470 of file BayesNetFactory_tpl.h.
References _checkVariableName_(), _illegalStateError_(), _states_, _stringBag_, gum::IBayesNetFactory::NONE, gum::IBayesNetFactory::RAW_CPT, and state().
|
finalvirtual |
Tells the factory that we're in a variable declaration.
Implements gum::IBayesNetFactory.
Definition at line 184 of file BayesNetFactory_tpl.h.
References _illegalStateError_(), _states_, _stringBag_, gum::IBayesNetFactory::NONE, state(), and gum::IBayesNetFactory::VARIABLE.
Referenced by gum::prm::PRMSystem< GUM_SCALAR >::_groundAgg_().
|
finalvirtual |
Returns the current state of the factory.
Implements gum::IBayesNetFactory.
Definition at line 122 of file BayesNetFactory_tpl.h.
References _states_.
Referenced by BayesNetFactory(), _illegalStateError_(), addMax(), addMin(), addModality(), addParent(), addTick(), endFactorizedEntry(), endFactorizedProbabilityDeclaration(), endNetworkDeclaration(), endParentsDeclaration(), endRawProbabilityDeclaration(), endVariableDeclaration(), rawConditionalTable(), rawConditionalTable(), setParentModality(), setVariable(), setVariableCPT(), setVariableCPTImplementation(), setVariableValues(), setVariableValuesUnchecked(), startFactorizedEntry(), startFactorizedProbabilityDeclaration(), startNetworkDeclaration(), startParentsDeclaration(), startRawProbabilityDeclaration(), startVariableDeclaration(), variableDescription(), variableName(), and variableType().
| INLINE const DiscreteVariable & gum::BayesNetFactory< GUM_SCALAR >::variable | ( | const std::string & | name | ) | const |
Returns a constant reference on a variable given it's name.
| NotFound | Raised if no variable matches the name. |
Definition at line 140 of file BayesNetFactory_tpl.h.
References _bn_, GUM_ERROR, and variableId().
Referenced by gum::prm::PRMSystem< double >::_groundAgg_(), and gum::prm::PRMSystem< double >::_groundTensor_().
|
finalvirtual |
Tells the factory the current variable's description.
Implements gum::IBayesNetFactory.
Definition at line 210 of file BayesNetFactory_tpl.h.
References _bar_flag_, _illegalStateError_(), _stringBag_, state(), and gum::IBayesNetFactory::VARIABLE.
|
finalvirtual |
Returns the NodeId of a variable given it's name.
| NotFound | Raised if no variable matches the name. |
Implements gum::IBayesNetFactory.
Definition at line 130 of file BayesNetFactory_tpl.h.
References _varNameMap_, and GUM_ERROR.
Referenced by variable().
|
finalvirtual |
Tells the factory the current variable's name.
| DuplicateElement | Raised if a variable with the same name already exist. |
Implements gum::IBayesNetFactory.
Definition at line 197 of file BayesNetFactory_tpl.h.
References _foo_flag_, _illegalStateError_(), _stringBag_, _varNameMap_, GUM_ERROR, state(), and gum::IBayesNetFactory::VARIABLE.
Referenced by gum::prm::PRMSystem< GUM_SCALAR >::_groundAgg_().
|
virtual |
Tells the factory the current variable's type.
Implements gum::IBayesNetFactory.
Definition at line 225 of file BayesNetFactory_tpl.h.
References _illegalStateError_(), _stringBag_, gum::CONTINUOUS, gum::DISCRETIZED, GUM_ERROR, gum::INTEGER, gum::LABELIZED, gum::RANGE, state(), and gum::IBayesNetFactory::VARIABLE.
|
finalvirtual |
short-cut accessor for a DiscreveVariable in the BN
Implements gum::IBayesNetFactory.
Definition at line 116 of file BayesNetFactory_tpl.h.
References _bn_.
|
private |
Depending on the context this flag is used for some VERY important reasons.
Definition at line 424 of file BayesNetFactory.h.
Referenced by _resetParts_(), endVariableDeclaration(), and variableDescription().
|
private |
The constructed BayesNet.
Definition at line 442 of file BayesNetFactory.h.
Referenced by BayesNetFactory(), BayesNetFactory(), _checkVariableModality_(), _fillProbaWithValuesTable_(), _fillProbaWithValuesTable_(), _setCPTAndParents_(), addNetworkProperty(), bayesNet(), cptDomainSize(), endParentsDeclaration(), endVariableDeclaration(), setParentModality(), setVariable(), setVariableCPT(), setVariableValues(), setVariableValuesUnchecked(), variable(), and varInBN().
|
private |
Depending on the context this flag is used for some VERY important reasons.
Definition at line 420 of file BayesNetFactory.h.
Referenced by _resetParts_(), endVariableDeclaration(), and variableName().
|
private |
Implementation of variable between two startVariableDeclaration/endVariableDeclaration calls.
Definition at line 434 of file BayesNetFactory.h.
Referenced by BayesNetFactory(), BayesNetFactory(), ~BayesNetFactory(), endVariableDeclaration(), and setVariableCPTImplementation().
|
private |
Used when a factorized CPT is built.
Definition at line 430 of file BayesNetFactory.h.
Referenced by BayesNetFactory(), BayesNetFactory(), ~BayesNetFactory(), endFactorizedEntry(), setParentModality(), setVariableValuesUnchecked(), and startFactorizedEntry().
|
private |
State stack.
Definition at line 439 of file BayesNetFactory.h.
Referenced by BayesNetFactory(), BayesNetFactory(), endFactorizedEntry(), endFactorizedProbabilityDeclaration(), endNetworkDeclaration(), endParentsDeclaration(), endRawProbabilityDeclaration(), endVariableDeclaration(), startFactorizedEntry(), startFactorizedProbabilityDeclaration(), startNetworkDeclaration(), startParentsDeclaration(), startRawProbabilityDeclaration(), startVariableDeclaration(), and state().
|
private |
Just to keep track of strings between two start/end calls.
Definition at line 427 of file BayesNetFactory.h.
Referenced by _checkModalityInBag_(), _fillProbaWithValuesTable_(), _fillProbaWithValuesTable_(), _resetParts_(), addMax(), addMin(), addModality(), addParent(), addTick(), endParentsDeclaration(), endVariableDeclaration(), setVariableValues(), setVariableValuesUnchecked(), startFactorizedProbabilityDeclaration(), startParentsDeclaration(), startRawProbabilityDeclaration(), startVariableDeclaration(), variableDescription(), variableName(), and variableType().
|
private |
Mapping between a declared variable's name and it's node id.
Definition at line 445 of file BayesNetFactory.h.
Referenced by BayesNetFactory(), _checkVariableModality_(), _checkVariableName_(), _fillProbaWithValuesTable_(), _fillProbaWithValuesTable_(), _setCPTAndParents_(), endParentsDeclaration(), endVariableDeclaration(), setParentModality(), setVariable(), setVariableCPT(), setVariableValues(), setVariableValuesUnchecked(), variableId(), and variableName().
|
privateinherited |
Definition at line 149 of file IBayesNetFactory.h.
Referenced by IBayesNetFactory(), isVerbose(), resetVerbose(), and setVerbose().