aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
scheduleBinaryCombination.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#ifndef GUM_SCHEDULE_BINARY_COMBINATION_H
48#define GUM_SCHEDULE_BINARY_COMBINATION_H
49
50#include <memory>
51#include <string>
52
53#include <agrum/agrum.h>
54
57
58namespace gum {
59
101 template < typename TABLE1, typename TABLE2, typename TABLE_RES >
103 public:
104 // ############################################################################
106 // ############################################################################
108
110
120 const ScheduleMultiDim< TABLE2 >& table2,
121 TABLE_RES (*combine)(const TABLE1&, const TABLE2&),
122 const bool is_result_persistent = false);
123
126
129
132
134
137
139
140
141 // ############################################################################
143 // ############################################################################
145
147 ScheduleBinaryCombination< TABLE1, TABLE2, TABLE_RES >&
148 operator=(const ScheduleBinaryCombination< TABLE1, TABLE2, TABLE_RES >&);
149
151 ScheduleBinaryCombination< TABLE1, TABLE2, TABLE_RES >&
152 operator=(ScheduleBinaryCombination< TABLE1, TABLE2, TABLE_RES >&&);
153
155
159 bool operator==(const ScheduleOperator&) const final;
160
162
166 bool operator!=(const ScheduleOperator&) const final;
167
169
173 bool operator==(const ScheduleBinaryCombination< TABLE1, TABLE2, TABLE_RES >&) const;
174
176
180 bool operator!=(const ScheduleBinaryCombination< TABLE1, TABLE2, TABLE_RES >&) const;
181
183
184
185 // ############################################################################
187 // ############################################################################
189
196 bool hasSameArguments(const ScheduleOperator&) const final;
197
204 bool hasSameArguments(const ScheduleBinaryCombination< TABLE1, TABLE2, TABLE_RES >&) const;
205
208 bool hasSimilarArguments(const ScheduleOperator&) const final;
209
212 bool hasSimilarArguments(const ScheduleBinaryCombination< TABLE1, TABLE2, TABLE_RES >&) const;
213
215 bool isSameOperator(const ScheduleOperator&) const final;
216
218 bool isSameOperator(const ScheduleBinaryCombination< TABLE1, TABLE2, TABLE_RES >&) const;
219
221 const ScheduleMultiDim< TABLE1 >& arg1() const;
222
224 const ScheduleMultiDim< TABLE2 >& arg2() const;
225
227 const Sequence< const IScheduleMultiDim* >& args() const final;
228
230
233 const ScheduleMultiDim< TABLE_RES >& result() const;
234
236
242 const Sequence< const IScheduleMultiDim* >& results() const final;
243
245
251 void updateArgs(const Sequence< const IScheduleMultiDim* >& new_args) final;
252
254 bool isExecuted() const final;
255
257
259 void execute() final;
260
262 void undo() final;
263
266 double nbOperations() const final;
267
269
276 std::pair< double, double > memoryUsage() const final;
277
279 std::string toString() const final;
280
282 void setCombinationFunction(TABLE_RES (*combine)(const TABLE1&, const TABLE2&));
283
285
286
287 private:
289 const ScheduleMultiDim< TABLE1 >* _arg1_{nullptr};
290
293
295
298
301
303
308
310 TABLE_RES (*_combine_)(const TABLE1&, const TABLE2&);
311 };
312
313} /* namespace gum */
314
315// always include the template implementation
317
318#endif /* GUM_SCHEDULE_BINARY_COMBINATION_H */
The Table-agnostic base class of scheduleMultiDim.
const Sequence< const IScheduleMultiDim * > & args() const final
returns the sequence of arguments passed to the operator
ScheduleBinaryCombination(ScheduleBinaryCombination< TABLE1, TABLE2, TABLE_RES > &&from)
move constructor
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
ScheduleBinaryCombination(const ScheduleMultiDim< TABLE1 > &table1, const ScheduleMultiDim< TABLE2 > &table2, TABLE_RES(*combine)(const TABLE1 &, const TABLE2 &), const bool is_result_persistent=false)
default constructor
bool isExecuted() const final
indicates whether the operator has been executed
const ScheduleMultiDim< TABLE1 > & arg1() const
returns the first argument of the combination
void setCombinationFunction(TABLE_RES(*combine)(const TABLE1 &, const TABLE2 &))
use a new combination function
bool hasSimilarArguments(const ScheduleOperator &) const final
checks whether two ScheduleCombination have similar parameters (same variables)
std::pair< double, double > memoryUsage() const final
returns the memory consumption used during the execution of the operator
void undo() final
undo a previous execution, if any
void execute() final
executes the operator
ScheduleMultiDim< TABLE_RES > * _result_
the result of the combination
ScheduleBinaryCombination< TABLE1, TABLE2, TABLE_RES > * clone() const final
virtual copy constructor
const ScheduleMultiDim< TABLE2 > * _arg2_
the second argument of the combination
bool isSameOperator(const ScheduleOperator &) const final
checks whether two ScheduleOperator perform the same set of operations
const ScheduleMultiDim< TABLE2 > & arg2() const
returns the first argument of the combination
std::string toString() const final
displays the content of the operator
Sequence< const IScheduleMultiDim * > _results_
the sequence of ScheduleMultidim output by the operator
TABLE_RES(* _combine_)(const TABLE1 &, const TABLE2 &)
the function actually used to perform the combination
bool hasSameArguments(const ScheduleOperator &) const final
checks whether two ScheduleCombination have the same parameters (same variables and same content)
const ScheduleMultiDim< TABLE1 > * _arg1_
the first argument of the combination
void updateArgs(const Sequence< const IScheduleMultiDim * > &new_args) final
modifies the arguments of the operator
ScheduleBinaryCombination(const ScheduleBinaryCombination< TABLE1, TABLE2, TABLE_RES > &from)
copy constructor
const ScheduleMultiDim< TABLE_RES > & result() const
returns the result of the combination
const Sequence< const IScheduleMultiDim * > & results() const final
returns the ScheduleMultidim resulting from the operator
ScheduleOperator(const ScheduleOperatorType type, const bool imply_deletion, const bool are_results_persistent)
default constructor
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
STL namespace.
a binary combination operator class used for scheduling inferences
a Wrapper for multi-dimensional tables used for scheduling inferences
the base class for "low-level" operators used to schedule inferences