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