aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
multiDimCombineAndProjectDefault.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_DEFAULT_H
49#define GUM_MULTI_DIM_COMBINE_AND_PROJECT_DEFAULT_H
50
52
53namespace gum {
54
55 // clang-format off
63 // clang-format on
64
65 template < class TABLE >
67 public:
69
70 // ========================================================================
72 // ========================================================================
74
76 MultiDimCombineAndProjectDefault(TABLE (*combine)(const TABLE&, const TABLE&),
77 TABLE (*project)(const TABLE&, const gum::VariableSet&));
78
81
84
92
94 // ========================================================================
96 // ========================================================================
98
110 const gum::VariableSet& del_vars) final;
111
112
116 std::pair< std::vector< ScheduleOperator* >, Set< const IScheduleMultiDim* > >
118 const gum::VariableSet& del_vars,
119 const bool is_result_persistent = false) const final;
120 std::pair< std::vector< ScheduleOperator* >, Set< const IScheduleMultiDim* > >
121 operations(const std::vector< const IScheduleMultiDim* >& original_tables,
122 const gum::VariableSet& del_vars,
123 const bool is_result_persistent = false) const final;
124
128 using MultiDimCombineAndProject< TABLE >::schedule;
129
131 void setCombinationFunction(TABLE (*combine)(const TABLE&, const TABLE&)) final;
132
147 void setCombinationClass(const MultiDimCombination< TABLE >& comb_class) final;
148
150 TABLE (*combinationFunction())(const TABLE&, const TABLE&) final;
151
153 void setProjectionFunction(TABLE (*proj)(const TABLE&, const gum::VariableSet&)) final;
154
161 void setProjectionClass(const MultiDimProjection< TABLE >& proj_class) final;
162
164 TABLE (*projectionFunction())(const TABLE&, const gum::VariableSet&) final;
165
170 double nbOperations(const Set< const TABLE* >& set,
171 const gum::VariableSet& del_vars) const final;
172
177 double nbOperations(const Set< const Sequence< const DiscreteVariable* >* >& set,
178 const gum::VariableSet& del_vars) const final;
179
193 std::pair< double, double > memoryUsage(const Set< const TABLE* >& set,
194 const gum::VariableSet& del_vars) const final;
195
209 std::pair< double, double >
210 memoryUsage(const Set< const Sequence< const DiscreteVariable* >* >& set,
211 const gum::VariableSet& del_vars) const final;
212
214
215 private:
218
221
222
224 void _freeData_(std::vector< const IScheduleMultiDim* >& tables,
225 std::vector< ScheduleOperator* >& operations) const;
226 };
227
228} /* namespace gum */
229
230// always include the template implementation
231#include <agrum/base/multidim/utils/operators/multiDimCombineAndProjectDefault_tpl.h>
232
233#endif /* GUM_MULTI_DIM_COMBINE_AND_PROJECT_DEFAULT_H */
Base class for discrete random variable.
The Table-agnostic base class of scheduleMultiDim.
A generic interface to combine efficiently several MultiDim tables.
void _freeData_(std::vector< const IScheduleMultiDim * > &tables, std::vector< ScheduleOperator * > &operations) const
free the scheduling memory
MultiDimCombination< TABLE > * _combination_
the class used for the combinations
Set< const TABLE * > execute(const Set< const TABLE * > &set, const gum::VariableSet &del_vars) final
creates and returns the result of the projection over the variables not in del_vars of the combinatio...
MultiDimCombineAndProjectDefault(const MultiDimCombineAndProjectDefault< TABLE > &)
Copy constructor.
std::pair< double, double > memoryUsage(const Set< const TABLE * > &set, const gum::VariableSet &del_vars) const final
returns the memory consumption used during the combinations and projections
void setCombinationFunction(TABLE(*combine)(const TABLE &, const TABLE &)) final
changes the function used for combining two TABLES
typename MultiDimCombineAndProject< TABLE >::value_type value_type
MultiDimCombineAndProjectDefault(TABLE(*combine)(const TABLE &, const TABLE &), TABLE(*project)(const TABLE &, const gum::VariableSet &))
Default constructor.
MultiDimProjection< TABLE > * _projection_
the class used for the projections
void setProjectionClass(const MultiDimProjection< TABLE > &proj_class) final
Changes the class that performs the projections.
virtual ~MultiDimCombineAndProjectDefault()
Destructor.
TABLE(*)(const TABLE &, const TABLE &) combinationFunction()
Returns the current combination function.
TABLE(*)(const TABLE &, const gum::VariableSet &) projectionFunction()
returns the current projection function
void setCombinationClass(const MultiDimCombination< TABLE > &comb_class) final
changes the class that performs the combinations
void setProjectionFunction(TABLE(*proj)(const TABLE &, const gum::VariableSet &)) final
Changes the function used for projecting TABLES.
virtual MultiDimCombineAndProjectDefault< TABLE > * clone() const
virtual constructor
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 final
returns the set of operations to perform to make all the combinations and projections
double nbOperations(const Set< const TABLE * > &set, const gum::VariableSet &del_vars) const final
returns a rough estimate of the number of operations that will be performed to compute the combinatio...
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
typename TableType< TABLE >::value_type value_type
the type of the values contained into TABLE
MultiDimCombineAndProject()
default constructor
A generic class to project efficiently a MultiDim table over a subset of its variables.
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
Set< const DiscreteVariable * > VariableSet
STL namespace.