aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
multiDimCombineAndProject_tpl.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 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-2026 *
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
#pragma once
42
43
49
50
#include <
agrum/base/multidim/utils/operators/multiDimCombineAndProject.h
>
// to ease IDE parser
51
#ifndef DOXYGEN_SHOULD_SKIP_THIS
52
53
# include <
agrum/agrum.h
>
54
55
namespace
gum
{
56
57
// default constructor
58
template
<
class
TABLE >
59
MultiDimCombineAndProject< TABLE >::MultiDimCombineAndProject
() {
60
// for debugging purposes
61
GUM_CONSTRUCTOR(
MultiDimCombineAndProject
);
62
}
63
64
// copy constructor
65
template
<
class
TABLE >
66
MultiDimCombineAndProject< TABLE >::MultiDimCombineAndProject
(
67
const
MultiDimCombineAndProject< TABLE >
&) {
68
// for debugging purposes
69
GUM_CONS_CPY(
MultiDimCombineAndProject
);
70
}
71
72
// destructor
73
template
<
class
TABLE >
74
MultiDimCombineAndProject< TABLE >::~MultiDimCombineAndProject
() {
75
// for debugging purposes
76
GUM_DESTRUCTOR(
MultiDimCombineAndProject
);
77
}
78
79
// add to a given schedule the set of operations needed
80
template
<
class
TABLE >
81
Set< const IScheduleMultiDim* >
MultiDimCombineAndProject< TABLE >::schedule
(
82
Schedule
& schedule,
83
const
Set< const IScheduleMultiDim* >
& original_tables,
84
const
gum::VariableSet
& del_vars,
85
const
bool
is_result_persistent)
const
{
86
// compute the set of operations to perform and insert them into the schedule
87
auto
ops_res = operations(original_tables, del_vars,
false
);
88
for
(
const
auto
op: ops_res.first)
89
schedule.insertOperation(*op);
90
91
// get the results actually stored into the schedule
92
Set< const IScheduleMultiDim* >
result(ops_res.second.size());
93
if
(!is_result_persistent) {
94
for
(
const
auto
pot: ops_res.second)
95
result.insert(schedule.scheduleMultiDim(pot->id()));
96
}
else
{
97
for
(
const
auto
pot: ops_res.second) {
98
const
IScheduleMultiDim
* table = schedule.scheduleMultiDim(pot->id());
99
const
auto
creating_op = schedule.scheduleMultiDimCreator(table);
100
if
(creating_op !=
nullptr
) {
101
const_cast<
ScheduleOperator
*
>
(creating_op)->makeResultsPersistent(
true
);
102
}
103
result.insert(table);
104
}
105
}
106
107
// free memory
108
for
(
const
auto
op: ops_res.first)
109
delete
op;
110
111
return
result;
112
}
113
114
}
/* namespace gum */
115
116
#endif
/* DOXYGEN_SHOULD_SKIP_THIS */
agrum.h
gum::IScheduleMultiDim
The Table-agnostic base class of scheduleMultiDim.
Definition
IScheduleMultiDim.h:67
gum::MultiDimCombineAndProject
A generic interface to combine and project efficiently MultiDim tables.
Definition
multiDimCombineAndProject.h:69
gum::MultiDimCombineAndProject::~MultiDimCombineAndProject
virtual ~MultiDimCombineAndProject()
destructor
gum::MultiDimCombineAndProject::schedule
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
gum::MultiDimCombineAndProject::MultiDimCombineAndProject
MultiDimCombineAndProject()
default constructor
gum::ScheduleOperator
the base class for "low-level" operators used to schedule inferences
Definition
scheduleOperator.h:84
gum::Schedule
Class containing a schedule of operations to perform on multidims.
Definition
schedule.h:79
gum::Set
Representation of a set.
Definition
set.h:129
multiDimCombineAndProject.h
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::VariableSet
Set< const DiscreteVariable * > VariableSet
Definition
discreteVariable.h:192
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0