aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
multiDimCombineAndProject.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
47
48#ifndef GUM_MULTI_DIM_COMBINE_AND_PROJECT_H
49#define GUM_MULTI_DIM_COMBINE_AND_PROJECT_H
50
51#include <utility>
52
55
56namespace gum {
57
58 // clang-format off
66 // clang-format on
67
68 template < class TABLE >
70#ifndef DOXYGEN_SHOULD_SKIP_THIS
71 // class to get the types of the TABLE's values using metaprogramming
72 template < typename T >
73 struct TableType {
74 using value_type = T;
75 };
76
77 template < template < typename, typename... > class CONTAINER, typename T, typename... Args >
78 struct TableType< CONTAINER< T, Args... > > {
79 using value_type = T;
80 };
81#endif // DOXYGEN_SHOULD_SKIP_THIS
82
83 public:
85 using value_type = typename TableType< TABLE >::value_type;
86
87 // ========================================================================
89 // ========================================================================
91
94
97
100
108
110 // ========================================================================
112 // ========================================================================
114
126 const gum::VariableSet& del_vars)
127 = 0;
128
132 virtual std::pair< std::vector< ScheduleOperator* >, Set< const IScheduleMultiDim* > >
134 const gum::VariableSet& del_vars,
135 const bool is_result_persistent = false) const
136 = 0;
137 virtual std::pair< std::vector< ScheduleOperator* >, Set< const IScheduleMultiDim* > >
138 operations(const std::vector< const IScheduleMultiDim* >& original_tables,
139 const gum::VariableSet& del_vars,
140 const bool is_result_persistent = false) const
141 = 0;
142
147 const Set< const IScheduleMultiDim* >& original_tables,
148 const gum::VariableSet& del_vars,
149 const bool is_result_persistent = false) const;
150
152 virtual void setCombinationFunction(TABLE (*combine)(const TABLE&, const TABLE&)) = 0;
153
168 virtual void setCombinationClass(const MultiDimCombination< TABLE >& comb_class) = 0;
169
171 virtual TABLE (*combinationFunction())(const TABLE&, const TABLE&) = 0;
172
174 virtual void setProjectionFunction(TABLE (*proj)(const TABLE&, const gum::VariableSet&)) = 0;
175
177 virtual TABLE (*projectionFunction())(const TABLE&, const gum::VariableSet&) = 0;
178
185 virtual void setProjectionClass(const MultiDimProjection< TABLE >& proj_class) = 0;
186
191 virtual double nbOperations(const Set< const TABLE* >& set,
192 const gum::VariableSet& del_vars) const
193 = 0;
194
199 virtual double nbOperations(const Set< const Sequence< const DiscreteVariable* >* >& set,
200 const gum::VariableSet& del_vars) const
201 = 0;
202
216 virtual std::pair< double, double > memoryUsage(const Set< const TABLE* >& set,
217 const gum::VariableSet& del_vars) const
218 = 0;
219
233 virtual std::pair< double, double >
235 const gum::VariableSet& del_vars) const
236 = 0;
237
239
240 private:
243 };
244
245} /* namespace gum */
246
247// always include the template implementation
249
250#endif /* GUM_MULTI_DIM_COMBINE_AND_PROJECT_H */
A generic interface to combine efficiently several MultiDim tables.
MultiDimCombineAndProject< TABLE > & operator=(const MultiDimCombineAndProject< TABLE > &)
forbid copy operators
virtual TABLE(*)(const TABLE &, const TABLE &) combinationFunction()
returns the current combination function
virtual TABLE(*)(const TABLE &, const gum::VariableSet &) projectionFunction()
returns the current projection function
virtual ~MultiDimCombineAndProject()
destructor
Set< const IScheduleMultiDim * > schedule(Schedule &schedule, const Set< const IScheduleMultiDim * > &original_tables, const gum::VariableSet &del_vars, const bool is_result_persistent=false) const
add to a given schedule the set of operations needed to perform all the combinations and projections
virtual std::pair< double, double > memoryUsage(const Set< const Sequence< const DiscreteVariable * > * > &set, const gum::VariableSet &del_vars) const =0
returns the memory consumption used during the combinations and projections
virtual void setProjectionClass(const MultiDimProjection< TABLE > &proj_class)=0
Changes the class that performs the projections.
virtual std::pair< double, double > memoryUsage(const Set< const TABLE * > &set, const gum::VariableSet &del_vars) const =0
returns the memory consumption used during the combinations and projections
virtual MultiDimCombineAndProject< TABLE > * clone() const =0
virtual constructor
typename TableType< TABLE >::value_type value_type
the type of the values contained into TABLE
MultiDimCombineAndProject()
default constructor
virtual double nbOperations(const Set< const TABLE * > &set, const gum::VariableSet &del_vars) const =0
returns a rough estimate of the number of operations that will be performed to compute the combinatio...
virtual std::pair< std::vector< ScheduleOperator * >, Set< const IScheduleMultiDim * > > operations(const std::vector< const IScheduleMultiDim * > &original_tables, const gum::VariableSet &del_vars, const bool is_result_persistent=false) const =0
returns the current combination function
virtual void setCombinationFunction(TABLE(*combine)(const TABLE &, const TABLE &))=0
changes the function used for combining two TABLES
virtual std::pair< std::vector< ScheduleOperator * >, Set< const IScheduleMultiDim * > > operations(const Set< const IScheduleMultiDim * > &original_tables, const gum::VariableSet &del_vars, const bool is_result_persistent=false) const =0
returns the set of operations to perform to make all the combinations and projections
virtual Set< const TABLE * > execute(const Set< const TABLE * > &set, const gum::VariableSet &del_vars)=0
creates and returns the result of the projection over the variables not in del_vars of the combinatio...
MultiDimCombineAndProject(const MultiDimCombineAndProject< TABLE > &)
copy constructor
virtual void setProjectionFunction(TABLE(*proj)(const TABLE &, const gum::VariableSet &))=0
changes the function used for projecting TABLES
virtual void setCombinationClass(const MultiDimCombination< TABLE > &comb_class)=0
f
virtual double nbOperations(const Set< const Sequence< const DiscreteVariable * > * > &set, const gum::VariableSet &del_vars) const =0
returns a rough estimate of the number of operations that will be performed to compute the combinatio...
A generic class to project efficiently a MultiDim table over a subset of its variables.
Class containing a schedule of operations to perform on multidims.
Definition schedule.h:80
The generic class for storing (ordered) sequences of objects.
Definition sequence.h:972
Representation of a set.
Definition set.h:131
A generic interface to combine and project efficiently MultiDim tables.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Set< const DiscreteVariable * > VariableSet