aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
scheduleProject.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 Projection operator class used for scheduling inferences
24  *
25  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 
28 #ifndef GUM_SCHEDULE_PROJECT_H
29 #define GUM_SCHEDULE_PROJECT_H
30 
31 #include <string>
32 
33 #include <agrum/agrum.h>
34 
35 #include <agrum/tools/core/sequence.h>
36 #include <agrum/tools/core/set.h>
37 #include <agrum/tools/graphicalModels/inference/scheduler/scheduleMultiDim.h>
38 #include <agrum/tools/graphicalModels/inference/scheduler/scheduleOperation.h>
39 #include <agrum/tools/multidim/implementations/multiDimImplementation.h>
40 #include <agrum/tools/variables/discreteVariable.h>
41 
42 namespace gum {
43 
44  template < typename GUM_SCALAR >
45 
47  public:
48  // ############################################################################
49  /// @name Constructors / Destructors
50  // ############################################################################
51  /// @{
52 
53  /// default constructor
54  /** @warning table and del_vars are passed by copy */
56  const ScheduleMultiDim< GUM_SCALAR >& table,
57  const Set< const DiscreteVariable* >& del_vars,
59  const Set< const DiscreteVariable* >&));
60 
61  /// copy constructor
62  ScheduleProject(const ScheduleProject< GUM_SCALAR >&);
63 
64  /// virtual copy constructor: creates a clone of the operation
65  virtual ScheduleProject< GUM_SCALAR >* newFactory() const;
66 
67  /// destructor
68  virtual ~ScheduleProject();
69 
70  /// @}
71 
72  // ############################################################################
73  /// @name Operators
74  // ############################################################################
75  /// @{
76 
77  /// copy operator
78  ScheduleProject< GUM_SCALAR >& operator=(const ScheduleProject< GUM_SCALAR >&);
79 
80  /// operator ==
81  /** Two operations are identical if and only if they have the same
82  * arguments and their types are identical (combine, project, etc) */
83  bool operator==(const ScheduleOperation< GUM_SCALAR >&) const;
84 
85  /// operator !=
86  /** Two operations are identical if and only if they have the same
87  * arguments and their types are identical (combine, project, etc) */
88  bool operator!=(const ScheduleOperation< GUM_SCALAR >&) const;
89 
90  /// @}
91 
92  // ############################################################################
93  /// @name Accessors/Modifiers
94  // ############################################################################
95  /// @{
96 
97  /// executes the operation
98  void execute();
99 
100  /** @brief returns an estimation of the number of elementary operations
101  * needed to perform the ScheduleOperation */
102  float nbOperations() const;
103 
104  /// returns the memory consumption used during the operation
105  /** Actually, this function does not return a precise account of the memory
106  * used by the ScheduleOperation but a rough estimate based on the sizes
107  * of the tables involved in the operation.
108  * @return a pair of memory consumption: the first one is the maximum
109  * amount of memory used during the operation and the second one is the
110  * amount of memory still used at the end of the function ( the memory used
111  * by
112  * the resulting table ) */
113  std::pair< long, long > memoryUsage() const;
114 
115  /// returns the scheduleMultidim resulting from the execution of the
116  /// operation
117  const ScheduleMultiDim< GUM_SCALAR >& result() const;
118 
119  /// returns the set of multidims passed in argument to the operation
120  const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >& multiDimArgs() const;
121 
122  /// returns the set of multidims that should be the result of the operation
123  const Sequence< const ScheduleMultiDim< GUM_SCALAR >* >& multiDimResults() const;
124 
125  /// displays the content of the operation
126  std::string toString() const;
127 
128  /// @}
129 
130  private:
131  // the table to project
133 
134  // the set of variables that should be removed from the table
136 
137  /// the result of the operation
139 
140  /// the set of ScheduleMultidims passed in arguments
142 
143  /// the set of ScheduleMultidims resulting from the operation
145 
146  /// the projection operator
148  const Set< const DiscreteVariable* >&);
149  };
150 
151 } /* namespace gum */
152 
153 // always include the template implementation
154 #include <agrum/tools/graphicalModels/inference/scheduler/scheduleProject_tpl.h>
155 
156 #endif /* GUM_SCHEDULE_PROJECTION_H */
virtual ScheduleProject< GUM_SCALAR > * newFactory() const
virtual copy constructor: creates a clone of the operation
const ScheduleMultiDim< GUM_SCALAR > & result() const
returns the scheduleMultidim resulting from the execution of the operation
std::pair< long, long > memoryUsage() const
returns the memory consumption used during the operation
float nbOperations() const
returns an estimation of the number of elementary operations needed to perform the ScheduleOperation ...
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
ScheduleMultiDim< GUM_SCALAR > * _result_
the result of the operation
Sequence< const ScheduleMultiDim< GUM_SCALAR > *> * _results_
the set of ScheduleMultidims resulting from the operation
void execute()
executes the operation
const Sequence< const ScheduleMultiDim< GUM_SCALAR > *> & multiDimArgs() const
returns the set of multidims passed in argument to the operation
bool operator!=(const ScheduleOperation< GUM_SCALAR > &) const
operator !=
virtual ~ScheduleProject()
destructor
Sequence< const ScheduleMultiDim< GUM_SCALAR > *> * _args_
the set of ScheduleMultidims passed in arguments
std::string toString() const
displays the content of the operation
const Sequence< const ScheduleMultiDim< GUM_SCALAR > *> & multiDimResults() const
returns the set of multidims that should be the result of the operation
ScheduleProject(const ScheduleProject< GUM_SCALAR > &)
copy constructor
bool operator==(const ScheduleOperation< GUM_SCALAR > &) const
operator ==
ScheduleProject(const ScheduleMultiDim< GUM_SCALAR > &table, const Set< const DiscreteVariable * > &del_vars, MultiDimImplementation< GUM_SCALAR > *(*project)(const MultiDimImplementation< GUM_SCALAR > &, const Set< const DiscreteVariable * > &))
default constructor
ScheduleProject< GUM_SCALAR > & operator=(const ScheduleProject< GUM_SCALAR > &)
copy operator
ScheduleMultiDim< GUM_SCALAR > _table_
Set< const DiscreteVariable *> _del_vars_