aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
multiDimCombination.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_COMBINATION_H
49#define GUM_MULTI_DIM_COMBINATION_H
50
51#include <utility>
52#include <vector>
53
54#include <agrum/agrum.h>
55
57
58namespace gum {
59
119 template < class TABLE >
121#ifndef DOXYGEN_SHOULD_SKIP_THIS
122 // class to get the types of the TABLE's values using metaprogramming
123 template < typename T >
124 struct TableType {
125 using value_type = T;
126 };
127
128 template < template < typename, typename... > class CONTAINER, typename T, typename... Args >
129 struct TableType< CONTAINER< T, Args... > > {
130 using value_type = T;
131 };
132#endif // DOXYGEN_SHOULD_SKIP_THIS
133
134 public:
136 using value_type = typename TableType< TABLE >::value_type;
137
138 // =========================================================================
140 // =========================================================================
142
145
148
151
159
161 // =========================================================================
163 // =========================================================================
165
176 virtual TABLE* execute(const Set< const TABLE* >& set) const = 0;
177 virtual void execute(TABLE& container, const Set< const TABLE* >& set) const = 0;
178
180
184 virtual std::pair< std::vector< ScheduleOperator* >, const IScheduleMultiDim* >
185 operations(const std::vector< const IScheduleMultiDim* >& set,
186 const bool is_result_persistent = false) const
187 = 0;
188 virtual std::pair< std::vector< ScheduleOperator* >, const IScheduleMultiDim* >
190 const bool is_result_persistent = false) const
191 = 0;
192
194
200 const bool is_result_persistent = false) const;
202 const std::vector< const IScheduleMultiDim* >& set,
203 const bool is_result_persistent = false) const;
204
206 virtual void setCombinationFunction(TABLE (*combine)(const TABLE&, const TABLE&)) = 0;
207
209 virtual TABLE (*combinationFunction())(const TABLE&, const TABLE&) = 0;
210
215 virtual double nbOperations(const Set< const TABLE* >& set) const = 0;
216 virtual double nbOperations(const Set< const Sequence< const DiscreteVariable* >* >& set) const
217 = 0;
218
231 virtual std::pair< double, double > memoryUsage(const Set< const TABLE* >& set) const = 0;
232 virtual std::pair< double, double >
233 memoryUsage(const Set< const Sequence< const DiscreteVariable* >* >& set) const = 0;
234
235 private:
238
240 };
241
242} /* namespace gum */
243
244// always include the template implementation
246
247#endif /* GUM_MULTI_DIM_COMBINATION_H */
The Table-agnostic base class of scheduleMultiDim.
virtual TABLE(*)(const TABLE &, const TABLE &) combinationFunction()
returns the combination function currently used by the combinator
MultiDimCombination< TABLE > & operator=(const MultiDimCombination< TABLE > &)
forbid copy operators
MultiDimCombination(const MultiDimCombination< TABLE > &)
copy constructor
virtual std::pair< std::vector< ScheduleOperator * >, const IScheduleMultiDim * > operations(const std::vector< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const =0
returns the set of operations to perform as well as the result of the combination
virtual TABLE * execute(const Set< const TABLE * > &set) const =0
creates and returns the result of the combination of the tables within set
virtual std::pair< double, double > memoryUsage(const Set< const Sequence< const DiscreteVariable * > * > &set) const =0
returns the combination function currently used by the combinator
virtual ~MultiDimCombination()
destructor
virtual double nbOperations(const Set< const TABLE * > &set) const =0
returns a rough estimate of the number of operations that will be performed to compute the combinatio...
virtual void setCombinationFunction(TABLE(*combine)(const TABLE &, const TABLE &))=0
changes the function used for combining two TABLES
virtual MultiDimCombination< TABLE > * clone() const =0
virtual constructor
virtual double nbOperations(const Set< const Sequence< const DiscreteVariable * > * > &set) const =0
returns the combination function currently used by the combinator
MultiDimCombination()
default constructor
const IScheduleMultiDim * schedule(Schedule &schedule, const Set< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const
add to a given schedule the set of operations needed to perform the combination
const IScheduleMultiDim * schedule(Schedule &schedule, const std::vector< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const
returns the combination function currently used by the combinator
virtual std::pair< double, double > memoryUsage(const Set< const TABLE * > &set) const =0
Returns the memory consumption used during the combination.
virtual std::pair< std::vector< ScheduleOperator * >, const IScheduleMultiDim * > operations(const Set< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const =0
returns the combination function currently used by the combinator
virtual void execute(TABLE &container, const Set< const TABLE * > &set) const =0
returns the combination function currently used by the combinator
typename TableType< TABLE >::value_type value_type
the type of the values contained into TABLE
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 class to combine efficiently several MultiDim tables.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Class containing a schedule of operations to perform on multidims.