aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::Schedule< GUM_SCALAR > Class Template Reference

Class containing a schedule of operations to perform on multidims. More...

#include <schedule.h>

+ Collaboration diagram for gum::Schedule< GUM_SCALAR >:

Public Member Functions

Constructors / Destructors
 Schedule ()
 default constructor (construct an empty sequence) More...
 
 Schedule (const Schedule< GUM_SCALAR > &)
 copy constructor More...
 
 ~Schedule ()
 destructor More...
 
Operators
Schedule< GUM_SCALAR > & operator= (const Schedule< GUM_SCALAR > &)
 copy operator More...
 
Accessors/Modifiers
NodeId insert (const ScheduleOperation< GUM_SCALAR > &)
 inserts an operation to be scheduled More...
 
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 More...
 
void forceAfter (NodeId op_to_force, NodeId op_before)
 inserts an operation to be scheduled More...
 
void forceAfter (const ScheduleOperation< GUM_SCALAR > &op_to_force, const Set< const ScheduleOperation< GUM_SCALAR > * > &ops_before)
 adds a constraint indicating that an operation cannot be performed before a set of operations More...
 
void forceAfter (NodeId op_to_force, const NodeSet &ops_before)
 inserts an operation to be scheduled More...
 
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 More...
 
void forceBefore (NodeId op_to_force, NodeId op_after)
 inserts an operation to be scheduled More...
 
void forceBefore (const ScheduleOperation< GUM_SCALAR > &op_to_force, const Set< const ScheduleOperation< GUM_SCALAR > * > &ops_after)
 adds a constraint indicating that an operation must be performed before a set of operations More...
 
void forceBefore (NodeId op_to_force, const NodeSet &ops_after)
 inserts an operation to be scheduled More...
 
const DAGscheduling_dag () const
 returns a DAG indicating in which order the operations can be performed More...
 
const ScheduleOperation< GUM_SCALAR > & operation (NodeId) const
 returns the scheduleOperation corresponding to an id in the DAG More...
 
NodeId nodeId (const ScheduleOperation< GUM_SCALAR > &) const
 returns the id of the node corresponding to a given ScheduleOperation More...
 
const NodeProperty< const ScheduleOperation< GUM_SCALAR > *> & operations () const
 resturns the association between operations anf nodeIds More...
 
const NodeSetoperationsInvolving (const ScheduleMultiDim< GUM_SCALAR > &table) const
 returns the set of operations involving a given multidim table More...
 
const NodeSetoperationsInvolving (MultiDimId table_id) const
 inserts an operation to be scheduled More...
 
const NodeSetavailableOperations () const
 returns the set of ScheduleOperations that can be executed at once More...
 
void execute (NodeId)
 executes a given operation (if this one is available) More...
 
void execute (const ScheduleOperation< GUM_SCALAR > &)
 inserts an operation to be scheduled More...
 
float nbOperations (NodeId) const
 returns an estimation of the number of elementary operations needed to perform a given ScheduleOperation More...
 
float nbOperations (ScheduleOperation< GUM_SCALAR > &) const
 inserts an operation to be scheduled More...
 
std::pair< long, long > memoryUsage (NodeId) const
 returns the memory consumption used during the execution of an operation More...
 
std::pair< long, long > memoryUsage (ScheduleOperation< GUM_SCALAR > &) const
 inserts an operation to be scheduled More...
 

Public Types

using OperationId = Idx
 to identify correctly the ids that correspond to ScheduleOperation ids More...
 
using MultiDimId = Idx
 to identify correctly the ids that correspond to ScheduleMultiDim ids More...
 

Detailed Description

template<typename GUM_SCALAR>
class gum::Schedule< GUM_SCALAR >

Class containing a schedule of operations to perform on multidims.

A Schedule class contains a set of operations to be scheduled. It is able to indicate which operations can currently be performed (because all their arguments have already been computed). In addition, it is possible to insert new operations into the schedule (at a specific place) and to remove some operations.

Warning
In the Schedule class does not guarantee that the schedule can always be performed, i.e., that there always exists a sequence in which all the operations of the schedule can be performed. It is up to the user to check this (function schedulePossible () may help here).

Definition at line 67 of file schedule.h.

Member Typedef Documentation

◆ MultiDimId

template<typename GUM_SCALAR >
using gum::Schedule< GUM_SCALAR >::MultiDimId = Idx

to identify correctly the ids that correspond to ScheduleMultiDim ids

Definition at line 73 of file schedule.h.

◆ OperationId

template<typename GUM_SCALAR >
using gum::Schedule< GUM_SCALAR >::OperationId = Idx

to identify correctly the ids that correspond to ScheduleOperation ids

Definition at line 70 of file schedule.h.

Constructor & Destructor Documentation

◆ Schedule() [1/2]

template<typename GUM_SCALAR >
gum::Schedule< GUM_SCALAR >::Schedule ( )

default constructor (construct an empty sequence)

◆ Schedule() [2/2]

template<typename GUM_SCALAR >
gum::Schedule< GUM_SCALAR >::Schedule ( const Schedule< GUM_SCALAR > &  )

copy constructor

◆ ~Schedule()

template<typename GUM_SCALAR >
gum::Schedule< GUM_SCALAR >::~Schedule ( )

destructor

Member Function Documentation

◆ _updateWrongParents_()

template<typename GUM_SCALAR >
void gum::Schedule< GUM_SCALAR >::_updateWrongParents_ ( ) const
private

updates the set of parents for the nodes whoses parents are not correct yet and update accordingly the available operations

◆ availableOperations()

template<typename GUM_SCALAR >
const NodeSet& gum::Schedule< GUM_SCALAR >::availableOperations ( ) const

returns the set of ScheduleOperations that can be executed at once

The scheduleOperations that can be executed at once are those that have no parent or whose parents have already been executed.

◆ execute() [1/2]

template<typename GUM_SCALAR >
void gum::Schedule< GUM_SCALAR >::execute ( NodeId  )

executes a given operation (if this one is available)

Note that, whenever an operation is performed, the list of available operations is updated and the operation itslef is removed from the schedule

Exceptions
OperationNotAllowedexception is thrown if the operation cannot be executed yet because some of its arguments have not already been computed
NotFoundexception is thrown if the operation cannot be found

◆ execute() [2/2]

template<typename GUM_SCALAR >
void gum::Schedule< GUM_SCALAR >::execute ( const ScheduleOperation< GUM_SCALAR > &  )

inserts an operation to be scheduled

The Schedule class is able to determined by itself when the operation should be performed.

Warning
operations are inserted by copy

◆ forceAfter() [1/4]

template<typename GUM_SCALAR >
void gum::Schedule< GUM_SCALAR >::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

◆ forceAfter() [2/4]

template<typename GUM_SCALAR >
void gum::Schedule< GUM_SCALAR >::forceAfter ( NodeId  op_to_force,
NodeId  op_before 
)

inserts an operation to be scheduled

The Schedule class is able to determined by itself when the operation should be performed.

Warning
operations are inserted by copy

◆ forceAfter() [3/4]

template<typename GUM_SCALAR >
void gum::Schedule< GUM_SCALAR >::forceAfter ( const ScheduleOperation< GUM_SCALAR > &  op_to_force,
const Set< const ScheduleOperation< GUM_SCALAR > * > &  ops_before 
)

adds a constraint indicating that an operation cannot be performed before a set of operations

◆ forceAfter() [4/4]

template<typename GUM_SCALAR >
void gum::Schedule< GUM_SCALAR >::forceAfter ( NodeId  op_to_force,
const NodeSet ops_before 
)

inserts an operation to be scheduled

The Schedule class is able to determined by itself when the operation should be performed.

Warning
operations are inserted by copy

◆ forceBefore() [1/4]

template<typename GUM_SCALAR >
void gum::Schedule< GUM_SCALAR >::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

◆ forceBefore() [2/4]

template<typename GUM_SCALAR >
void gum::Schedule< GUM_SCALAR >::forceBefore ( NodeId  op_to_force,
NodeId  op_after 
)

inserts an operation to be scheduled

The Schedule class is able to determined by itself when the operation should be performed.

Warning
operations are inserted by copy

◆ forceBefore() [3/4]

template<typename GUM_SCALAR >
void gum::Schedule< GUM_SCALAR >::forceBefore ( const ScheduleOperation< GUM_SCALAR > &  op_to_force,
const Set< const ScheduleOperation< GUM_SCALAR > * > &  ops_after 
)

adds a constraint indicating that an operation must be performed before a set of operations

◆ forceBefore() [4/4]

template<typename GUM_SCALAR >
void gum::Schedule< GUM_SCALAR >::forceBefore ( NodeId  op_to_force,
const NodeSet ops_after 
)

inserts an operation to be scheduled

The Schedule class is able to determined by itself when the operation should be performed.

Warning
operations are inserted by copy

◆ insert()

template<typename GUM_SCALAR >
NodeId gum::Schedule< GUM_SCALAR >::insert ( const ScheduleOperation< GUM_SCALAR > &  )

inserts an operation to be scheduled

The Schedule class is able to determined by itself when the operation should be performed.

Warning
operations are inserted by copy

◆ memoryUsage() [1/2]

template<typename GUM_SCALAR >
std::pair< long, long > gum::Schedule< GUM_SCALAR >::memoryUsage ( NodeId  ) const

returns the memory consumption used during the execution of an operation

Actually, this function does not return a precise account of the memory used by the scheduleOperation but a rough estimate based on the sizes of the tables involved in the operation.

Returns
a pair of memory consumption: the first one is the maximum amount of memory used during the ScheduleOperation and the second one is the amount of memory still used at the end of the operation ( the memory used by the resulting table )

◆ memoryUsage() [2/2]

template<typename GUM_SCALAR >
std::pair< long, long > gum::Schedule< GUM_SCALAR >::memoryUsage ( ScheduleOperation< GUM_SCALAR > &  ) const

inserts an operation to be scheduled

The Schedule class is able to determined by itself when the operation should be performed.

Warning
operations are inserted by copy

◆ nbOperations() [1/2]

template<typename GUM_SCALAR >
float gum::Schedule< GUM_SCALAR >::nbOperations ( NodeId  ) const

returns an estimation of the number of elementary operations needed to perform a given ScheduleOperation

◆ nbOperations() [2/2]

template<typename GUM_SCALAR >
float gum::Schedule< GUM_SCALAR >::nbOperations ( ScheduleOperation< GUM_SCALAR > &  ) const

inserts an operation to be scheduled

The Schedule class is able to determined by itself when the operation should be performed.

Warning
operations are inserted by copy

◆ nodeId()

template<typename GUM_SCALAR >
NodeId gum::Schedule< GUM_SCALAR >::nodeId ( const ScheduleOperation< GUM_SCALAR > &  ) const

returns the id of the node corresponding to a given ScheduleOperation

Exceptions
NotFoundexception is raised the operation does not belong to the Schedule

◆ operation()

template<typename GUM_SCALAR >
const ScheduleOperation< GUM_SCALAR >& gum::Schedule< GUM_SCALAR >::operation ( NodeId  ) const

returns the scheduleOperation corresponding to an id in the DAG

Exceptions
NotFoundexception is raised if the DAG does not contain the id

◆ operations()

template<typename GUM_SCALAR >
const NodeProperty< const ScheduleOperation< GUM_SCALAR >* >& gum::Schedule< GUM_SCALAR >::operations ( ) const

resturns the association between operations anf nodeIds

◆ operationsInvolving() [1/2]

template<typename GUM_SCALAR >
const NodeSet& gum::Schedule< GUM_SCALAR >::operationsInvolving ( const ScheduleMultiDim< GUM_SCALAR > &  table) const

returns the set of operations involving a given multidim table

◆ operationsInvolving() [2/2]

template<typename GUM_SCALAR >
const NodeSet& gum::Schedule< GUM_SCALAR >::operationsInvolving ( MultiDimId  table_id) const

inserts an operation to be scheduled

The Schedule class is able to determined by itself when the operation should be performed.

Warning
operations are inserted by copy

◆ operator=()

template<typename GUM_SCALAR >
Schedule< GUM_SCALAR >& gum::Schedule< GUM_SCALAR >::operator= ( const Schedule< GUM_SCALAR > &  )

copy operator

◆ scheduling_dag()

template<typename GUM_SCALAR >
const DAG& gum::Schedule< GUM_SCALAR >::scheduling_dag ( ) const

returns a DAG indicating in which order the operations can be performed

In this DAG, each node corresponds to an operation and an operation can be performed only if its ancestors have all been performed.

Member Data Documentation

◆ _created_multidims_

template<typename GUM_SCALAR >
HashTable< MultiDimId, NodeId > gum::Schedule< GUM_SCALAR >::_created_multidims_
private

a hashtable assigning to each ScheduleMultiDim resulting from a computation the MultiDimOperation node id that created it

Definition at line 213 of file schedule.h.

◆ _dag_

template<typename GUM_SCALAR >
DAG gum::Schedule< GUM_SCALAR >::_dag_
mutableprivate

the DAG of the operations to perform

Operations can be scheduled as a DAG: nodes without parents can be executed directly. The other nodes need their parents to be executed to get all their arguments constructed.

Definition at line 203 of file schedule.h.

◆ _multidim2operations_

template<typename GUM_SCALAR >
HashTable< MultiDimId, NodeSet* > gum::Schedule< GUM_SCALAR >::_multidim2operations_
private

for each multidim, store the set of operations involving it

Definition at line 229 of file schedule.h.

◆ _node2operation_

template<typename GUM_SCALAR >
NodeProperty< ScheduleOperation< GUM_SCALAR >* > gum::Schedule< GUM_SCALAR >::_node2operation_
private

a hashtable assigning to each node of the DAG an operation

Definition at line 206 of file schedule.h.

◆ _operation2node_

template<typename GUM_SCALAR >
HashTable< OperationId, NodeId > gum::Schedule< GUM_SCALAR >::_operation2node_
private

a hashtable assigning to each operation id a node id in the DAG

Definition at line 209 of file schedule.h.

◆ _operations_available_

template<typename GUM_SCALAR >
NodeSet gum::Schedule< GUM_SCALAR >::_operations_available_
mutableprivate

the set of operations that can be executed at once

Definition at line 226 of file schedule.h.

◆ _operations_with_wrong_parents_

template<typename GUM_SCALAR >
NodeSet gum::Schedule< GUM_SCALAR >::_operations_with_wrong_parents_
mutableprivate

a list of operations whose parents are not properly set

when entering operations to be performed in a "wrong" order, it may happen that the parents of some operations in the DAG are not properly set (the parents being inserted after the child). We keep a list of such nodes and, whenever we wish to perform the schedule or get its DAG, we compute the correct set of parents of the operations of this list and, when this is done, we remove them from the list. As such, when the list is empty, the schedule can be performed.

Definition at line 223 of file schedule.h.


The documentation for this class was generated from the following file: