aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
scheduleProjection.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_SCHEDULE_PROJECTION_H
49#define GUM_SCHEDULE_PROJECTION_H
50
51#include <memory>
52#include <string>
53
54#include <agrum/agrum.h>
55
58
59namespace gum {
60
61
102 template < typename TABLE >
104 public:
105 // ############################################################################
107 // ############################################################################
109
111
124 const gum::VariableSet& del_vars,
125 TABLE (*project)(const TABLE&, const gum::VariableSet&),
126 const bool is_result_persistent = false);
127
130
133
136
138
141
143
144
145 // ############################################################################
147 // ############################################################################
149
151 ScheduleProjection< TABLE >& operator=(const ScheduleProjection< TABLE >&);
152
154 ScheduleProjection< TABLE >& operator=(ScheduleProjection< TABLE >&&);
155
157
162 bool operator==(const ScheduleOperator&) const final;
163
165
170 bool operator!=(const ScheduleOperator&) const final;
171
173
178 virtual bool operator==(const ScheduleProjection< TABLE >&) const;
179
181
186 virtual bool operator!=(const ScheduleProjection< TABLE >&) const;
187
189
190
191 // ############################################################################
193 // ############################################################################
195
203 bool hasSameArguments(const ScheduleOperator&) const final;
204
212 bool hasSameArguments(const ScheduleProjection< TABLE >&) const;
213
221 bool hasSimilarArguments(const ScheduleOperator&) const final;
222
230 bool hasSimilarArguments(const ScheduleProjection< TABLE >&) const;
231
233 bool isSameOperator(const ScheduleOperator&) const final;
234
236 bool isSameOperator(const ScheduleProjection< TABLE >&) const;
237
239 const ScheduleMultiDim< TABLE >& arg() const;
240
242 const Sequence< const IScheduleMultiDim* >& args() const final;
243
245 const ScheduleMultiDim< TABLE >& result() const;
246
248 const Sequence< const IScheduleMultiDim* >& results() const final;
249
251
257 void updateArgs(const Sequence< const IScheduleMultiDim* >& new_args) final;
258
260 bool isExecuted() const final;
261
263
265 void execute() final;
266
268 void undo() final;
269
272 double nbOperations() const final;
273
275
282 std::pair< double, double > memoryUsage() const final;
283
285 std::string toString() const final;
286
288 void setProjectionFunction(TABLE (*project)(const TABLE&, const gum::VariableSet&));
289
291
292 private:
294 const ScheduleMultiDim< TABLE >* _arg_{nullptr};
295
297
300
303
305
310
313
315 TABLE (*_project_)(const TABLE&, const gum::VariableSet&);
316 };
317
318} /* namespace gum */
319
320// always include the template implementation
322
323#endif /* GUM_SCHEDULE_PROJECTION_H */
The Table-agnostic base class of scheduleMultiDim.
a Wrapper for multi-dimensional tables used for scheduling inferences
ScheduleOperator(const ScheduleOperatorType type, const bool imply_deletion, const bool are_results_persistent)
default constructor
std::pair< double, double > memoryUsage() const final
returns the memory consumption used during the execution of the operator
ScheduleProjection(const ScheduleMultiDim< TABLE > &table, const gum::VariableSet &del_vars, TABLE(*project)(const TABLE &, const gum::VariableSet &), const bool is_result_persistent=false)
default constructor
gum::VariableSet _del_vars_
the set of variables that should be removed from the arg table
ScheduleProjection(ScheduleProjection< TABLE > &&from)
move constructor
bool isSameOperator(const ScheduleOperator &) const final
checks whether two ScheduleOperator perform the same projection
void updateArgs(const Sequence< const IScheduleMultiDim * > &new_args) final
modifies the arguments of the operator
void execute() final
executes the operator
Sequence< const IScheduleMultiDim * > _args_
the sequence of arguments passed to the operator
double nbOperations() const final
returns an estimation of the number of elementary operations needed to perform the ScheduleOperator
bool isExecuted() const final
indicates whether the operator has been executed
const ScheduleMultiDim< TABLE > * _arg_
the argument to be projected
const ScheduleMultiDim< TABLE > & arg() const
returns the argument of the projection
bool hasSameArguments(const ScheduleOperator &) const final
checks whether two ScheduleProjection have the same parameters (same variables, including the set of ...
void setProjectionFunction(TABLE(*project)(const TABLE &, const gum::VariableSet &))
use a new projection function
Sequence< const IScheduleMultiDim * > _results_
the sequence of ScheduleMultidim output by the operator
const Sequence< const IScheduleMultiDim * > & results() const final
returns the sequence of ScheduleMultidim output by the operator
void undo() final
undo a previous execution, if any
bool hasSimilarArguments(const ScheduleOperator &) const final
checks whether two ScheduleProjection have similar parameters (same variables, including the set of v...
ScheduleProjection< TABLE > * clone() const final
virtual copy constructor
ScheduleProjection(const ScheduleProjection< TABLE > &from)
copy constructor
TABLE(* _project_)(const TABLE &, const gum::VariableSet &)
the projection operator
std::string toString() const final
displays the content of the operator
const ScheduleMultiDim< TABLE > & result() const
returns the result of the projection
ScheduleMultiDim< TABLE > * _result_
the result of the projection
const Sequence< const IScheduleMultiDim * > & args() const final
returns the sequence of arguments passed to the operator
The generic class for storing (ordered) sequences of objects.
Definition sequence.h:972
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Set< const DiscreteVariable * > VariableSet
STL namespace.
a Wrapper for multi-dimensional tables used for scheduling inferences
the base class for "low-level" operators used to schedule inferences
a Projection operator class used for scheduling inferences