aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
IBayesNetFactory.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Header of the IBayesNetFactory class.
25  *
26  * @author Lionel TORTI and Pierre-Henri WUILLEMIN(@LIP6)
27  */
28 #ifndef GUM_INTERFACE_BAYESNET_FACTORY_H
29 #define GUM_INTERFACE_BAYESNET_FACTORY_H
30 
31 #include <string>
32 #include <vector>
33 
34 #include <agrum/tools/graphicalModels/variableNodeMap.h>
35 #include <agrum/tools/multidim/implementations/multiDimAdressable.h>
36 #include <agrum/tools/variables/labelizedVariable.h>
37 
38 namespace gum {
39  /**
40  * @class IBayesNetFactory
41  * @headerfile IBayesNetFactory.h <agrum/BN/IBayesNetFactory.h>
42  * @ingroup bn_group
43  *
44  * IBayesNetFactory is the non-template interface for @ref BayesNetFactory :
45  * many ways to build a BN do not depend on the specification of the
46  * GUM_SCALAR template argument (for instance for BN readers).
47  */
49  public:
50  /**
51  * @brief The enumeration of states in which the factory can be in.
52  *
53  * Every documentation section's name indicates from which state you can
54  * call it's methods, and in which state it places the factory.
55  *
56  * There is an exception for the delegated CPT definition methods which do
57  * not change the state of the factory.
58  */
59  enum class factory_state : char
60  {
61  NONE,
62  NETWORK,
63  VARIABLE,
64  PARENTS,
65  RAW_CPT,
66  FACT_CPT,
68  };
69 
71  // just to make some compilers happy
72  virtual ~IBayesNetFactory(){};
73 
74  /**
75  * @name verbosity control
76  * @{
77  */
78  void setVerbose() { _verbose_ = true; };
79 
80  void resetVerbose() { _verbose_ = false; };
81 
82  bool isVerbose() { return _verbose_; };
83 
84  /**
85  * @}
86  */
87 
88  /// @{
89  /// @brief Please @see BayesNetFactory<GUM_SCALAR> for documentation.
90  virtual const DiscreteVariable& varInBN(NodeId id) = 0;
91  virtual factory_state state() const = 0;
92  virtual NodeId variableId(const std::string& name) const = 0;
93  virtual Size cptDomainSize(NodeId n) const = 0;
94 
95  virtual void startNetworkDeclaration() = 0;
96  virtual void addNetworkProperty(const std::string& propName, const std::string& propValue) = 0;
97  virtual void endNetworkDeclaration() = 0;
98  virtual void startVariableDeclaration() = 0;
99  virtual void variableName(const std::string& name) = 0;
100  virtual void variableDescription(const std::string& desc) = 0;
101  virtual void variableType(const VarType& type) = 0;
102  virtual void addModality(const std::string& name) = 0;
103  virtual void addMin(const long& min) = 0;
104  virtual void addMax(const long& max) = 0;
105  virtual void setVariableCPTImplementation(MultiDimAdressable* impl) = 0;
106  virtual NodeId endVariableDeclaration() = 0;
107  virtual void startParentsDeclaration(const std::string& var) = 0;
108  virtual void addParent(const std::string& var) = 0;
109  virtual void endParentsDeclaration() = 0;
110  virtual void startRawProbabilityDeclaration(const std::string& var) = 0;
111  virtual void rawConditionalTable(const std::vector< std::string >& variables,
112  const std::vector< float >& rawTable)
113  = 0;
114  virtual void rawConditionalTable(const std::vector< float >& rawTable) = 0;
115  virtual void endRawProbabilityDeclaration() = 0;
116  virtual void startFactorizedProbabilityDeclaration(const std::string& var) = 0;
117  virtual void startFactorizedEntry() = 0;
118  virtual void endFactorizedEntry() = 0;
119  virtual void setParentModality(const std::string& parent, const std::string& modality) = 0;
120  virtual void setVariableValuesUnchecked(const std::vector< float >& values) = 0;
121  virtual void setVariableValues(const std::vector< float >& values) = 0;
122  virtual void endFactorizedProbabilityDeclaration() = 0;
123  virtual void setVariable(const DiscreteVariable& var) = 0;
124  virtual void
125  setVariableCPT(const std::string& varName, MultiDimAdressable* table, bool redefineParents)
126  = 0;
127  /// @}
128 
129  private:
130  bool _verbose_;
131  };
132 } /* namespace gum */
133 
134 #endif // GUM_ASBTRACT_BAYESNET_FACTORY_H
virtual void addNetworkProperty(const std::string &propName, const std::string &propValue)=0
Please.
virtual void variableName(const std::string &name)=0
Please.
IBayesNetFactory is the non-template interface for BayesNetFactory : many ways to build a BN do not d...
virtual void startNetworkDeclaration()=0
Please.
virtual void endNetworkDeclaration()=0
Please.
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
virtual void endFactorizedEntry()=0
Please.
virtual void setVariableCPT(const std::string &varName, MultiDimAdressable *table, bool redefineParents)=0
Please.
virtual void setVariableValuesUnchecked(const std::vector< float > &values)=0
Please.
virtual void startParentsDeclaration(const std::string &var)=0
Please.
virtual void rawConditionalTable(const std::vector< float > &rawTable)=0
Please.
virtual void addMax(const long &max)=0
Please.
virtual void endParentsDeclaration()=0
Please.
factory_state
The enumeration of states in which the factory can be in.
virtual void addModality(const std::string &name)=0
Please.
virtual NodeId variableId(const std::string &name) const =0
Please.
virtual void variableType(const VarType &type)=0
Please.
virtual void setVariableValues(const std::vector< float > &values)=0
Please.
virtual void variableDescription(const std::string &desc)=0
Please.
virtual void addMin(const long &min)=0
Please.
virtual void startFactorizedProbabilityDeclaration(const std::string &var)=0
Please.
virtual void endRawProbabilityDeclaration()=0
Please.
virtual void endFactorizedProbabilityDeclaration()=0
Please.
virtual Size cptDomainSize(NodeId n) const =0
Please.
virtual void setParentModality(const std::string &parent, const std::string &modality)=0
Please.
virtual const DiscreteVariable & varInBN(NodeId id)=0
Please.
virtual void rawConditionalTable(const std::vector< std::string > &variables, const std::vector< float > &rawTable)=0
Please.
virtual void startVariableDeclaration()=0
Please.
virtual NodeId endVariableDeclaration()=0
Please.
virtual void setVariableCPTImplementation(MultiDimAdressable *impl)=0
Please.
virtual void addParent(const std::string &var)=0
Please.
virtual factory_state state() const =0
Please.
virtual void startFactorizedEntry()=0
Please.
virtual void setVariable(const DiscreteVariable &var)=0
Please.
virtual void startRawProbabilityDeclaration(const std::string &var)=0
Please.