aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
scheduleCombine.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /** @file
23  * @brief a Combination operator class used for scheduling inferences
24  *
25  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 #ifndef GUM_SCHEDULE_COMBINE_H
28 #define GUM_SCHEDULE_COMBINE_H
29 
30 #include <string>
31 
32 #include <agrum/agrum.h>
33 
34 #include <agrum/tools/core/sequence.h>
35 #include <agrum/tools/graphicalModels/inference/scheduler/scheduleMultiDim.h>
36 #include <agrum/tools/graphicalModels/inference/scheduler/scheduleOperation.h>
37 #include <agrum/tools/multidim/implementations/multiDimImplementation.h>
38 
39 namespace gum {
40 
41  template < typename GUM_SCALAR >
42 
44  public:
45  // ############################################################################
46  /// @name Constructors / Destructors
47  // ############################################################################
48  /// @{
49 
50  /// default constructor
51  /** @warning tables 1 and 2 are stored by copy into the ScheduleCombine.
52  * This is actually compulsory for the appropriate use of
53  * ScheduleCombination classes */
54  ScheduleCombine(const ScheduleMultiDim< GUM_SCALAR >& table1,
55  const ScheduleMultiDim< GUM_SCALAR >& table2,
59 
60  /// copy constructor
61  ScheduleCombine(const ScheduleCombine< GUM_SCALAR >&);
62 
63  /// virtual copy constructor: creates a clone of the operation
64  virtual ScheduleCombine< GUM_SCALAR >* newFactory() const;
65 
66  /// destructor
67  ~ScheduleCombine();
68 
69  /// @}
70 
71  // ############################################################################
72  /// @name Operators
73  // ############################################################################
74  /// @{
75 
76  /// copy operator
77  ScheduleCombine< GUM_SCALAR >& operator=(const ScheduleCombine< GUM_SCALAR >&);
78 
79  /// operator ==
80  /** Two operations are identical if and only if they have the same
81  * arguments and their types are identical (combine, project, etc) */
82  INLINE bool operator==(const ScheduleOperation< GUM_SCALAR >&) const;
83 
84  /// operator !=
85  /** Two operations are identical if and only if they have the same
86  * arguments and their types are identical (combine, project, etc) */
87  INLINE bool operator!=(const ScheduleOperation< GUM_SCALAR >&) const;
88 
89  /// @}
90 
91  // ############################################################################
92  /// @name Accessors/Modifiers
93  // ############################################################################
94  /// @{
95 
96  /// executes the operation
97  void execute();
98 
99  /** @brief returns an estimation of the number of elementary operations
100  * needed to perform the ScheduleOperation */
101  float nbOperations() const;
102 
103  /// returns the memory consumption used during the operation
104  /** Actually, this function does not return a precise account of the memory
105  * used by the ScheduleOperation but a rough estimate based on the sizes
106  * of the tables involved in the operation.
107  * @return a pair of memory consumption: the first one is the maximum
108  * amount of memory used during the operation and the second one is the
109  * amount of memory still used at the end of the function ( the memory used
110  * by
111  * the resulting table ) */
112  std::pair< long, long > memoryUsage() const;
113 
114  /// returns the scheduleMultidim resulting from the execution of the
115  /// operation
116  INLINE const ScheduleMultiDim< GUM_SCALAR >& result() const;
117 
118  /// returns the set of multidims passed in argument to the operation
119  const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >& multiDimArgs() const;
120 
121  /// returns the set of multidims that should be the result of the operation
122  const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >& multiDimResults() const;
123 
124  /// displays the content of the operation
125  std::string toString() const;
126 
127  /// @}
128 
129  private:
130  /// the first table to combine
132 
133  /// the second table to combine with
135 
136  /// the result of the operation
137  /** the result is allocated and deallocated by ScheduleCombine */
139 
140  /// the set of ScheduleMultidims passed in arguments
142 
143  /// the set of ScheduleMultidims resulting from the operation
145 
146  /// the function actually used to perform the combination
149  };
150 
151 } /* namespace gum */
152 
153 // always include the template implementation
154 #include <agrum/tools/graphicalModels/inference/scheduler/scheduleCombine_tpl.h>
155 
156 #endif /* GUM_SCHEDULE_COMBINE_H */
void execute()
executes the operation
std::string toString() const
displays the content of the operation
virtual ScheduleCombine< GUM_SCALAR > * newFactory() const
virtual copy constructor: creates a clone of the operation
ScheduleMultiDim< GUM_SCALAR > * _result_
the result of the operation
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
ScheduleCombine(const ScheduleMultiDim< GUM_SCALAR > &table1, const ScheduleMultiDim< GUM_SCALAR > &table2, MultiDimImplementation< GUM_SCALAR > *(*combine)(const MultiDimImplementation< GUM_SCALAR > &, const MultiDimImplementation< GUM_SCALAR > &))
default constructor
ScheduleMultiDim< GUM_SCALAR > _table2_
the second table to combine with
std::pair< long, long > memoryUsage() const
returns the memory consumption used during the operation
ScheduleCombine< GUM_SCALAR > & operator=(const ScheduleCombine< GUM_SCALAR > &)
copy operator
ScheduleCombine(const ScheduleCombine< GUM_SCALAR > &)
copy constructor
float nbOperations() const
returns an estimation of the number of elementary operations needed to perform the ScheduleOperation ...
~ScheduleCombine()
destructor
Sequence< const ScheduleMultiDim< GUM_SCALAR > *> * _args_
the set of ScheduleMultidims passed in arguments
const Sequence< const ScheduleMultiDim< GUM_SCALAR > *> & multiDimResults() const
returns the set of multidims that should be the result of the operation
INLINE const ScheduleMultiDim< GUM_SCALAR > & result() const
returns the scheduleMultidim resulting from the execution of the operation
const Sequence< const ScheduleMultiDim< GUM_SCALAR > *> & multiDimArgs() const
returns the set of multidims passed in argument to the operation
Sequence< const ScheduleMultiDim< GUM_SCALAR > *> * _results_
the set of ScheduleMultidims resulting from the operation
ScheduleMultiDim< GUM_SCALAR > _table1_
the first table to combine