aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
multiDimNoisyAND.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 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 class for NoisyAND-net implementation as multiDim
25  *
26  * @author Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
27  */
28 #ifndef GUM_MULTI_DIM_NOISY_AND_H
29 #define GUM_MULTI_DIM_NOISY_AND_H
30 
31 #include <agrum/tools/multidim/ICIModels/multiDimICIModel.h>
32 
33 namespace gum {
34 
35  // clang-format off
36  /**
37  * @class MultiDimNoisyAND
38  * @headerfile multiDimNoisyAND.h <agrum/tools/multidim/ICIModels/multiDimNoisyAND.h>
39  * @ingroup multidim_group
40  *
41  * @brief Noisy AND representation
42  *
43  * Noisy-AND as described for instance in (ECAI-14, 2000, Galan and Diez)
44  *
45  * @warning
46  * - The first variable is assumed to be the NOISY-AND. The latter are
47  * the causes.
48  * - This code give probabilities for BINARY VARIABLES (other values are
49  * assumed to be of probability 0). But for optimization reason, we will
50  * never check if it is the case.
51  */
52  // clang-format on
53  template < typename GUM_SCALAR >
55  public:
56  // ============================================================================
57  /// @name Constructors / Destructors
58  // ============================================================================
59  /// @{
60 
61  /**
62  * Default constructor.
63  * @throw gum::InvalidArgument if external_weight is null.
64  */
65  MultiDimNoisyAND(GUM_SCALAR external_weight,
66  GUM_SCALAR default_weight = (GUM_SCALAR)1.0);
67 
68  MultiDimNoisyAND(const MultiDimNoisyAND< GUM_SCALAR >& from);
69 
70  /**
71  * Copy constructor using a bijection to swap variables from source.
72  *
73  * @param bij First variables are new variables, seconds are in from.
74  * @param from the copied instance
75  */
77  const Bijection< const DiscreteVariable*, const DiscreteVariable* >& bij,
78  const MultiDimNoisyAND< GUM_SCALAR >& from);
79 
80  /**
81  * Destructor.
82  */
83  virtual ~MultiDimNoisyAND();
84 
85  /// @}
86 
87  /**
88  * This method creates a clone of this object, withouth its content
89  * (including variable), you must use this method if you want to ensure
90  * that the generated object has the same type than the object containing
91  * the called newFactory()
92  *
93  * For example :
94  * @code
95  * MultiDimArray<double> y;
96  * MultiDimContainer<double>* x = y.newFactory();
97  * @endcode
98  *
99  * Then x is a MultiDimArray<double>*.
100  *
101  * @warning you must desallocate by yourself the memory
102  * @return an empty clone of this object with the same type
103  */
104  virtual MultiDimContainer< GUM_SCALAR >* newFactory() const;
105 
106  // ============================================================================
107  /// @name Accessors / Modifiers
108  // ============================================================================
109  /// @{
110 
111  public:
112  virtual GUM_SCALAR get(const Instantiation& i) const;
113 
114  std::string toString() const;
115 
116  /**
117  * @brief Returns the real name of the multiDimArray.
118  *
119  * In aGrUM, all the types of multi-dimensional arrays/functionals have a
120  * name that describes what they are in reality. For instance, a table
121  * stored in extension is a "MultiDimArray", one that stores only non zero
122  * elements is a "MultiDimSparseArray", and so on. These names are unique
123  * for each type of implementation and is used by the system to determine
124  * which is the best functions to use, say, when we wish to use operators
125  * such as operator+ on two MultiDimImplementations.
126  */
127  virtual const std::string& name() const;
128 
129  /// @}
130  };
131 
132 
133 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
134  extern template class MultiDimNoisyAND< double >;
135 #endif
136 
137  /// For friendly displaying the content of the array.
138  template < typename GUM_SCALAR >
140  const MultiDimNoisyAND< GUM_SCALAR >& ag);
141 
142 } /* namespace gum */
143 
144 #include <agrum/tools/multidim/ICIModels/multiDimNoisyAND_tpl.h>
145 
146 #endif /* GUM_MULTI_DIM_NOISY_AND_H */
MultiDimNoisyAND(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bij, const MultiDimNoisyAND< GUM_SCALAR > &from)
Copy constructor using a bijection to swap variables from source.
virtual const std::string & name() const
Returns the real name of the multiDimArray.
MultiDimNoisyAND(GUM_SCALAR external_weight, GUM_SCALAR default_weight=(GUM_SCALAR) 1.0)
Default constructor.
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
virtual GUM_SCALAR get(const Instantiation &i) const
Returns the real name of the multiDimArray.
virtual ~MultiDimNoisyAND()
Destructor.
Noisy AND representation.
virtual MultiDimContainer< GUM_SCALAR > * newFactory() const
This method creates a clone of this object, withouth its content (including variable), you must use this method if you want to ensure that the generated object has the same type than the object containing the called newFactory()
std::ostream & operator<<(std::ostream &s, const MultiDimNoisyAND< GUM_SCALAR > &ag)
For friendly displaying the content of the array.
MultiDimNoisyAND(const MultiDimNoisyAND< GUM_SCALAR > &from)
Default constructor.
std::string toString() const
Returns the real name of the multiDimArray.