aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
ICPTDisturber.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 /** @file
23  * @brief Interface-like class for disturbing Conditional Probability Tables.
24  *
25  * @author Pierre-Henri WUILLEMIN(@LIP6) and Ariele-Paolo MAESANO
26  */
27 
28 #ifndef GUM_I_CPT_DISTURBER_H
29 #define GUM_I_CPT_DISTURBER_H
30 
31 #include <agrum/BN/BayesNet.h>
32 #include <agrum/agrum.h>
33 #include <agrum/tools/multidim/potential.h>
34 
35 namespace gum {
36  /** @class ICPTDisturber
37  * @headerfile ICPTDisturber.h <agrum/BN/generator/ICPTDisturber.h>
38  * @brief Abstract class for Modifying Conditional Probability Tables.
39  * @ingroup bn_generator
40  *
41  * This abstract class is an implementation of the strategy pattern to
42  * help changing CPT generation policies for the BayesNetGenerator class.
43  */
44  template < typename GUM_SCALAR >
45  class ICPTDisturber {
46  public:
47  // ############################################################################
48  /// @name Constructors / Destructor
49  // ############################################################################
50  /// @{
51  /**
52  * Default constructor.
53  */
54  ICPTDisturber();
55 
56  /**
57  * Destructor.
58  */
59  virtual ~ICPTDisturber();
60  /// @}
61 
62  // ############################################################################
63  /// @name CPT disturbing methods
64  // ############################################################################
65  /**
66  * Generates a CPT using GUM_SCALAR.
67  * @param node The variable on the CPT owner.
68  * @param bayesNet the Bayesian network.
69  * @param src copy of the CPT before reduction.
70  * @param marg of the inference before reduction on the node varIdi.
71  */
72  virtual void disturbReducCPT(NodeId node,
73  BayesNet< GUM_SCALAR >& bayesNet,
74  Potential< GUM_SCALAR >& src,
75  Potential< GUM_SCALAR >& marg)
76  = 0;
77 
78  /**
79  * Disturb a CPT using GUM_SCALAR when inserting a new parent.
80  * @param node A reference on the CPT owner.
81  * @param bayesNet the Bayesian network.
82  * @param src copy of the CPT before augmentation.
83  * @param variation degree of variation from the initial probability.
84  */
85  virtual void disturbAugmCPT(NodeId node,
86  BayesNet< GUM_SCALAR >& bayesNet,
87  Potential< GUM_SCALAR >& src,
88  GUM_SCALAR variation)
89  = 0;
90  };
91 
92 
93 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
94  extern template class ICPTDisturber< double >;
95 #endif
96 
97 
98 } /* namespace gum */
99 
100 #include <agrum/BN/generator/ICPTDisturber_tpl.h>
101 #endif // GUM_I_CPT_DISTURBER_H
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643