aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
multiDimCombineAndProject.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  *
25  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 
28 #ifndef GUM_MULTI_DIM_COMBINE_AND_PROJECT_H
29 #define GUM_MULTI_DIM_COMBINE_AND_PROJECT_H
30 
31 #include <utility>
32 
33 #include <agrum/tools/core/sequence.h>
34 #include <agrum/tools/core/set.h>
35 #include <agrum/tools/variables/discreteVariable.h>
36 
37 namespace gum {
38 
39  // clang-format off
40  /**
41  * @class MultiDimCombineAndProject
42  * @headerfile multiDimCombineAndProject.h <agrum/tools/multidim/operators/multiDimCombineAndProject.h>
43  * @ingroup multidim_op_group
44  *
45  * @brief A generic interface to combine and project efficiently MultiDim tables.
46  */
47  // clang-format on
48  template < typename GUM_SCALAR, template < typename > class TABLE >
50  public:
51  // ========================================================================
52  /// @name Constructors / Destructors
53  // ========================================================================
54  /// @{
55 
56  /// default constructor
58 
59  /// copy constructor
61 
62  /// destructor
63  virtual ~MultiDimCombineAndProject();
64 
65  /**
66  * @brief virtual constructor
67  *
68  * @return a new fresh MultiDimCombineAndProject with the same combination
69  * and projection functions.
70  */
71  virtual MultiDimCombineAndProject< GUM_SCALAR, TABLE >* newFactory() const = 0;
72 
73  /// @}
74  // ========================================================================
75  /// @name Accessors/Modifiers
76  // ========================================================================
77  /// @{
78 
79  /**
80  * @brief creates and returns the result of the projection over the
81  * variables not in del_vars of the combination of the tables within set
82  *
83  * @return a new freshly created TABLE which is the result of the
84  * projection of the combination of all the TABLES passed in argument
85  *
86  * @throws InvalidArgumentsNumber exception is thrown if the set passed in
87  * argument contains less than two elements
88  */
89  virtual Set< const TABLE< GUM_SCALAR >* >
91  Set< const DiscreteVariable* > del_vars)
92  = 0;
93 
94  /// changes the function used for combining two TABLES
95  virtual void setCombineFunction(TABLE< GUM_SCALAR >* (*combine)(const TABLE< GUM_SCALAR >&,
96  const TABLE< GUM_SCALAR >&))
97  = 0;
98 
99  /// returns the current combination function
100  virtual TABLE< GUM_SCALAR >* (*combineFunction())(const TABLE< GUM_SCALAR >&,
101  const TABLE< GUM_SCALAR >&)
102  = 0;
103 
104  /// changes the function used for projecting TABLES
105  virtual void
106  setProjectFunction(TABLE< GUM_SCALAR >* (*proj)(const TABLE< GUM_SCALAR >&,
107  const Set< const DiscreteVariable* >&))
108  = 0;
109 
110  /// returns the current projection function
111  virtual TABLE< GUM_SCALAR >* (*projectFunction())(const TABLE< GUM_SCALAR >&,
112  const Set< const DiscreteVariable* >&)
113  = 0;
114 
115  /**
116  * @brief returns a rough estimate of the number of operations that will be
117  * performed to compute the combination.
118  */
119  virtual float nbOperations(const Set< const TABLE< GUM_SCALAR >* >& set,
120  const Set< const DiscreteVariable* >& del_vars) const = 0;
121  virtual std::pair< long, long >
122  memoryUsage(const Set< const Sequence< const DiscreteVariable* >* >& set,
123  Set< const DiscreteVariable* > del_vars) const = 0;
124 
125  /// @}
126 
127  private:
128  /// forbid copy operators
131  };
132 
133 } /* namespace gum */
134 
135 // always include the template implementation
136 #include <agrum/tools/multidim/utils/operators/multiDimCombineAndProject_tpl.h>
137 
138 #endif /* GUM_MULTI_DIM_COMBINE_AND_PROJECT_H */
virtual std::pair< long, long > memoryUsage(const Set< const Sequence< const DiscreteVariable * > * > &set, Set< const DiscreteVariable * > del_vars) const =0
creates and returns the result of the projection over the variables not in del_vars of the combinatio...
virtual void setProjectFunction(TABLE< GUM_SCALAR > *(*proj)(const TABLE< GUM_SCALAR > &, const Set< const DiscreteVariable * > &))=0
changes the function used for projecting TABLES
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
A generic interface to combine and project efficiently MultiDim tables.
virtual void setCombineFunction(TABLE< GUM_SCALAR > *(*combine)(const TABLE< GUM_SCALAR > &, const TABLE< GUM_SCALAR > &))=0
changes the function used for combining two TABLES
MultiDimCombineAndProject(const MultiDimCombineAndProject< GUM_SCALAR, TABLE > &)
copy constructor
virtual Set< const TABLE< GUM_SCALAR > *> combineAndProject(Set< const TABLE< GUM_SCALAR > * > set, Set< const DiscreteVariable * > del_vars)=0
creates and returns the result of the projection over the variables not in del_vars of the combinatio...
MultiDimCombineAndProject< GUM_SCALAR, TABLE > & operator=(const MultiDimCombineAndProject< GUM_SCALAR, TABLE > &)
forbid copy operators
virtual ~MultiDimCombineAndProject()
destructor
virtual MultiDimCombineAndProject< GUM_SCALAR, TABLE > * newFactory() const =0
virtual constructor
MultiDimCombineAndProject()
default constructor
virtual float nbOperations(const Set< const TABLE< GUM_SCALAR > * > &set, const Set< const DiscreteVariable * > &del_vars) const =0
returns a rough estimate of the number of operations that will be performed to compute the combinatio...