aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
multiDimCombinationDefault.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_DEFAULT_H
49#define GUM_MULTI_DIM_COMBINATION_DEFAULT_H
50
51#include <agrum/agrum.h>
52
54
55namespace gum {
56
57 // clang-format off
120 // clang-format on
121
122 template < class TABLE >
123 class MultiDimCombinationDefault final: public MultiDimCombination< TABLE > {
124 public:
125 // ========================================================================
127 // ========================================================================
129
137 MultiDimCombinationDefault(TABLE (*combine)(const TABLE&, const TABLE&));
138
141
144
152
154 // ========================================================================
156 // ========================================================================
158
169 TABLE* execute(const Set< const TABLE* >& set) const final;
170 void execute(TABLE& container, const Set< const TABLE* >& set) const final;
171
173
177 std::pair< std::vector< ScheduleOperator* >, const IScheduleMultiDim* >
178 operations(const std::vector< const IScheduleMultiDim* >& set,
179 const bool is_result_persistent = false) const final;
180 std::pair< std::vector< ScheduleOperator* >, const IScheduleMultiDim* >
181 operations(const Set< const IScheduleMultiDim* >& set,
182 const bool is_result_persistent = false) const final;
183
185 using MultiDimCombination< TABLE >::schedule;
186
188 void setCombinationFunction(TABLE (*combine)(const TABLE&, const TABLE&)) final;
189
191 TABLE (*combinationFunction())(const TABLE&, const TABLE&) final;
192
197 double nbOperations(const Set< const TABLE* >& set) const final;
198 double nbOperations(const Set< const Sequence< const DiscreteVariable* >* >& set) const final;
199
211 std::pair< double, double > memoryUsage(const Set< const TABLE* >& set) const final;
212 std::pair< double, double >
213 memoryUsage(const Set< const Sequence< const DiscreteVariable* >* >& set) const final;
214
216
217 private:
219 TABLE (*_combine_)(const TABLE& t1, const TABLE& t2);
220
225 double _combinedSize_(const IScheduleMultiDim& table1, const IScheduleMultiDim& table2) const;
226
228 void _freeData_(std::vector< const IScheduleMultiDim* >& tables,
229 std::vector< ScheduleOperator* >& operations) const;
230 };
231
232} /* namespace gum */
233
234// always include the template implementation
235#include <agrum/base/multidim/utils/operators/multiDimCombinationDefault_tpl.h>
236
237#endif /* GUM_MULTI_DIM_COMBINATION_DEFAULT_H */
Base class for discrete random variable.
The Table-agnostic base class of scheduleMultiDim.
std::pair< std::vector< ScheduleOperator * >, const IScheduleMultiDim * > operations(const std::vector< const IScheduleMultiDim * > &set, const bool is_result_persistent=false) const final
returns the set of operations to perform to make the combination
TABLE(* _combine_)(const TABLE &t1, const TABLE &t2)
The function used to combine two tables.
TABLE(*)(const TABLE &, const TABLE &) combinationFunction()
Returns the combination function currently used by the combinator.
MultiDimCombinationDefault(const MultiDimCombinationDefault< TABLE > &)
Copy constructor.
MultiDimCombinationDefault(TABLE(*combine)(const TABLE &, const TABLE &))
Default constructor.
TABLE * execute(const Set< const TABLE * > &set) const final
Creates and returns the result of the combination of the tables within set.
virtual ~MultiDimCombinationDefault()
Destructor.
void _freeData_(std::vector< const IScheduleMultiDim * > &tables, std::vector< ScheduleOperator * > &operations) const
free the scheduling memory
double nbOperations(const Set< const TABLE * > &set) const final
returns a rough estimate of the number of operations that will be performed to compute the combinatio...
virtual MultiDimCombinationDefault< TABLE > * clone() const
virtual constructor
double _combinedSize_(const IScheduleMultiDim &table1, const IScheduleMultiDim &table2) const
returns the domain size of the Cartesian product of the union of all the variables in seq1 and seq2.
void execute(TABLE &container, const Set< const TABLE * > &set) const final
Returns the combination function currently used by the combinator.
void setCombinationFunction(TABLE(*combine)(const TABLE &, const TABLE &)) final
Changes the function used for combining two TABLES.
std::pair< double, double > memoryUsage(const Set< const TABLE * > &set) const final
Returns the additional memory consumption used during the combination.
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
the base class for "low-level" operators used to schedule inferences
The generic class for storing (ordered) sequences of objects.
Definition sequence.h:972
Representation of a set.
Definition set.h:131
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
STL namespace.