aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
schedulerBasic.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 scheduler that executes any available operation (chosen aribtrarily)
24  *
25  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 
28 #ifndef GUM_SCHEDULER_BASIC_H
29 #define GUM_SCHEDULER_BASIC_H
30 
31 #include <agrum/tools/graphicalModels/inference/scheduler/scheduler.h>
32 
33 namespace gum {
34 
35  template < typename GUM_SCALAR >
36  class SchedulerBasic: public Scheduler< GUM_SCALAR > {
37  public:
38  // ############################################################################
39  /// @name Constructors / Destructors
40  // ############################################################################
41  /// @{
42 
43  /// default constructor
45 
46  /// copy constructor
47  SchedulerBasic(const SchedulerBasic< GUM_SCALAR >&);
48 
49  /// destructor
50  virtual ~SchedulerBasic();
51 
52  /// virtual constructor
53  /** @return a new fresh SchedulerBasic */
54  SchedulerBasic< GUM_SCALAR >* newFactory() const;
55 
56  /// @}
57 
58  // ############################################################################
59  /// @name Accessors/Modifiers
60  // ############################################################################
61  /// @{
62 
63  /// execute all the operations of a given schedule
64  /** @return a Boolean indicating whether all the schedule was performed */
65  bool execute(Schedule< GUM_SCALAR >&);
66 
67  /// execute only k operations of a given schedule (default k = 1)
68  /** If there are fewer than k operations in the schedule, then all those
69  * operations are performed
70  * @return a Boolean indicating whether the k operations (or all the
71  * operations of the schedule) were performed */
72  bool execute(Schedule< GUM_SCALAR >&, Size k);
73 
74  /** @brief returns an estimation of the number of elementary operations
75  * needed
76  * to perform a given schedule */
77  float nbOperations(const Schedule< GUM_SCALAR >&) const;
78 
79  /** @brief returns an estimation of the number of elementary operations
80  *needed
81  * to perform the k first ScheduleOperations of a given schedule
82  *
83  * If there are fewer than k operations in the schedule, then all those
84  * operations are taken into account */
85  float nbOperations(const Schedule< GUM_SCALAR >&, Size k) const;
86 
87  /// returns the memory consumption used during the execution of a schedule
88  /** Actually, this function does not return a precise account of the memory
89  * used to perform the schedule but a rough estimate based on the sizes
90  * of the tables involved in the schedule.
91  * @return a pair of memory consumption: the first one is the maximum
92  * amount of memory used during the execution of the Schedule and the second
93  * one is the amount of memory still used at the end of the execution of
94  * the schedule */
95  std::pair< long, long > memoryUsage(const Schedule< GUM_SCALAR >&) const;
96 
97  /** @brief returns the memory consumption used during the execution of the
98  * k first ScheduleOperations of a given schedule
99  *
100  * Actually, this function does not return a precise account of the memory
101  * used to perform the schedule but a rough estimate based on the sizes
102  * of the tables involved in the schedule.
103  * If there are fewer than k operations in the schedule, then all those
104  * operations are taken into account.
105  * @return a pair of memory consumption: the first one is the maximum
106  * amount of memory used during the execution of the Schedule and the second
107  * one is the amount of memory still used at the end of the execution of
108  * k first operations of the schedule */
109  std::pair< long, long > memoryUsage(const Schedule< GUM_SCALAR >&, Size k) const;
110 
111  /// @}
112  };
113 
114 } /* namespace gum */
115 
116 // always include the template implementation
117 #include <agrum/tools/graphicalModels/inference/scheduler/schedulerBasic_tpl.h>
118 
119 #endif /* GUM_SCHEDULER_BASIC_H */
SchedulerBasic(const SchedulerBasic< GUM_SCALAR > &)
copy constructor
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
std::pair< long, long > memoryUsage(const Schedule< GUM_SCALAR > &) const
returns the memory consumption used during the execution of a schedule
SchedulerBasic< GUM_SCALAR > * newFactory() const
virtual constructor
std::pair< long, long > memoryUsage(const Schedule< GUM_SCALAR > &, Size k) const
returns the memory consumption used during the execution of the k first ScheduleOperations of a given...
bool execute(Schedule< GUM_SCALAR > &)
execute all the operations of a given schedule
SchedulerBasic()
default constructor
virtual ~SchedulerBasic()
destructor
bool execute(Schedule< GUM_SCALAR > &, Size k)
execute only k operations of a given schedule (default k = 1)
float nbOperations(const Schedule< GUM_SCALAR > &) const
returns an estimation of the number of elementary operations needed to perform a given schedule ...
float nbOperations(const Schedule< GUM_SCALAR > &, Size k) const
returns an estimation of the number of elementary operations needed to perform the k first ScheduleOp...