aGrUM  0.14.2
schedule.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
25 #ifndef GUM_SCHEDULE_H
26 #define GUM_SCHEDULE_H
27 
28 #include <utility>
29 
30 #include <agrum/agrum.h>
31 
32 #include <agrum/core/hashTable.h>
33 #include <agrum/core/set.h>
34 #include <agrum/graphs/DAG.h>
36 
43 
44 namespace gum {
45 
64  template < typename GUM_SCALAR >
65  class Schedule {
66  public:
68  using OperationId = Idx;
69 
71  using MultiDimId = Idx;
72 
73  // ############################################################################
75  // ############################################################################
77 
79  Schedule();
80 
83 
85  ~Schedule();
86 
88 
89  // ############################################################################
91  // ############################################################################
92 
94 
97 
99 
100  // ############################################################################
102  // ############################################################################
104 
106 
110 
114  void forceAfter(const ScheduleOperation< GUM_SCALAR >& op_to_force,
115  const ScheduleOperation< GUM_SCALAR >& op_before);
116  void forceAfter(NodeId op_to_force, NodeId op_before);
117 
121  void
122  forceAfter(const ScheduleOperation< GUM_SCALAR >& op_to_force,
123  const Set< const ScheduleOperation< GUM_SCALAR >* >& ops_before);
124  void forceAfter(NodeId op_to_force, const NodeSet& ops_before);
125 
128  void forceBefore(const ScheduleOperation< GUM_SCALAR >& op_to_force,
129  const ScheduleOperation< GUM_SCALAR >& op_after);
130  void forceBefore(NodeId op_to_force, NodeId op_after);
131 
134  void
135  forceBefore(const ScheduleOperation< GUM_SCALAR >& op_to_force,
136  const Set< const ScheduleOperation< GUM_SCALAR >* >& ops_after);
137  void forceBefore(NodeId op_to_force, const NodeSet& ops_after);
138 
140 
142  const DAG& scheduling_dag() const;
143 
145 
148 
150 
153 
156  operations() const;
157 
159  const NodeSet&
161  const NodeSet& operationsInvolving(MultiDimId table_id) const;
162 
164 
166  const NodeSet& availableOperations() const;
167 
169 
176  void execute(NodeId);
178 
182  float nbOperations(NodeId) const;
184 
186 
195  std::pair< long, long > memoryUsage(NodeId) const;
196  std::pair< long, long > memoryUsage(ScheduleOperation< GUM_SCALAR >&) const;
197 
199 
200  private:
202 
205  mutable DAG __dag;
206 
209 
212 
216 
218 
226 
229 
232 
235  void __updateWrongParents() const;
236  };
237 
238 } /* namespace gum */
239 
240 // always include the template implementation
242 
243 #endif /* GUM_SCHEDULE_H */
NodeSet __operations_available
the set of operations that can be executed at once
Definition: schedule.h:228
an operator used by scheduling inferences to store tables into cliques
a MultiDimImplementation Wrapper used for scheduling inferences
void execute(NodeId)
executes a given operation (if this one is available)
an operator used by scheduled inferences to store tables into separators
a Combination operator class used for scheduling inferences
NodeProperty< ScheduleOperation< GUM_SCALAR > *> __node2operation
a hashtable assigning to each node of the DAG an operation
Definition: schedule.h:208
Sets of elements (i.e.
DAG __dag
the DAG of the operations to perform
Definition: schedule.h:205
Idx MultiDimId
to identify correctly the ids that correspond to ScheduleMultiDim ids
Definition: schedule.h:71
NodeId nodeId(const ScheduleOperation< GUM_SCALAR > &) const
returns the id of the node corresponding to a given ScheduleOperation
NodeSet __operations_with_wrong_parents
a list of operations whose parents are not properly set
Definition: schedule.h:225
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
void forceAfter(const ScheduleOperation< GUM_SCALAR > &op_to_force, const ScheduleOperation< GUM_SCALAR > &op_before)
adds a constraint indicating that an operation cannot be performed before another one ...
The class for generic Hash Tables.
Definition: hashTable.h:676
NodeId insert(const ScheduleOperation< GUM_SCALAR > &)
inserts an operation to be scheduled
const NodeSet & operationsInvolving(const ScheduleMultiDim< GUM_SCALAR > &table) const
returns the set of operations involving a given multidim table
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:162
const DAG & scheduling_dag() const
returns a DAG indicating in which order the operations can be performed
const NodeSet & availableOperations() const
returns the set of ScheduleOperations that can be executed at once
~Schedule()
destructor
Schedule< GUM_SCALAR > & operator=(const Schedule< GUM_SCALAR > &)
copy operator
Class containing a schedule of operations to perform on multidims.
the base operation class used to schedule inferences
std::pair< long, long > memoryUsage(NodeId) const
returns the memory consumption used during the execution of an operation
a MultiDim Delete operator class used for scheduling inferences
void forceBefore(const ScheduleOperation< GUM_SCALAR > &op_to_force, const ScheduleOperation< GUM_SCALAR > &op_after)
adds a constraint indicating that an operation must be performed before another one ...
Idx OperationId
to identify correctly the ids that correspond to ScheduleOperation ids
Definition: schedule.h:68
const ScheduleOperation< GUM_SCALAR > & operation(NodeId) const
returns the scheduleOperation corresponding to an id in the DAG
Schedule()
default constructor (construct an empty sequence)
Class containing a schedule of operations to perform on multidims.
Definition: schedule.h:65
Size Idx
Type for indexes.
Definition: types.h:50
a Projection operator class used for scheduling inferences
HashTable< OperationId, NodeId > __operation2node
a hashtable assigning to each operation id a node id in the DAG
Definition: schedule.h:211
void __updateWrongParents() const
updates the set of parents for the nodes whoses parents are not correct yet and update accordingly th...
HashTable< MultiDimId, NodeId > __created_multidims
a hashtable assigning to each ScheduleMultiDim resulting from a computation the MultiDimOperation nod...
Definition: schedule.h:215
Base class for dag.
Definition: DAG.h:99
Class hash tables iterators.
float nbOperations(NodeId) const
returns an estimation of the number of elementary operations needed to perform a given ScheduleOperat...
Size NodeId
Type for node ids.
Definition: graphElements.h:97
Base classes for directed acyclic graphs.
const NodeProperty< const ScheduleOperation< GUM_SCALAR > *> & operations() const
resturns the association between operations anf nodeIds
HashTable< MultiDimId, NodeSet *> __multidim2operations
for each multidim, store the set of operations involving it
Definition: schedule.h:231
some utils for topology : NodeId, Edge, Arc and consorts ...