ptolemy.domains.hdf.kernel
Class HDFDirector

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.actor.Director
              extended by ptolemy.actor.sched.StaticSchedulingDirector
                  extended by ptolemy.domains.sdf.kernel.SDFDirector
                      extended by ptolemy.domains.hdf.kernel.HDFDirector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Executable, Initializable, PeriodicDirector, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class HDFDirector
extends SDFDirector

The Heterochronous Dataflow (HDF) domain is an extension of the Synchronous Dataflow (SDF) domain and implements the HDF model of computation [1]. In SDF, the set of port rates (called rate signatures) of an actor are constant. In HDF, however, rate signatures are allowed to change between iterations of the HDF schedule.

This director is often used with HDFFSMDirector. The HDFFSMDirector governs the execution of a modal model. The change of rate signatures can be modeled by state transitions of the modal model, in which each state refinement infers a set of rate signatures. Within each state, the HDF model behaves like an SDF model.

This director recomputes the schedules dynamically. To improve efficiency, this director uses a CachedSDFScheduler. A CachedSDFScheduler caches schedules labeled by their corresponding rate signatures, with the most recently used at the beginning of the queue. Therefore, when a state in HDF is revisited, the schedule identified by its rate signatures in the cache is used. We do not need to recompute the schedule.

The size of the cache in the CachedSDFScheduler is set by the scheduleCacheSize parameter of HDFDirector. The default value of this parameter is 100. If the cache is full, the least recently used schedule (at the end of the cache) is discarded.

References

  1. A. Girault, B. Lee, and E. A. Lee, `` Hierarchical Finite State Machines with Multiple Concurrency Models, '' April 13, 1998.

Since:
Ptolemy II 5.0
Version:
$Id: HDFDirector.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Ye Zhou. Contributor: Brian K. Vogel
See Also:
HDFFSMDirector, CachedSDFScheduler, Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (zhouye)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 Parameter scheduleCacheSize
          A parameter representing the size of the schedule cache to use.
 
Fields inherited from class ptolemy.domains.sdf.kernel.SDFDirector
_iterationCount, _periodicDirectorHelper, allowDisconnectedGraphs, allowRateChanges, constrainBufferSizes, iterations, period, synchronizeToRealTime, vectorizationFactor
 
Fields inherited from class ptolemy.actor.sched.StaticSchedulingDirector
_postfireReturns
 
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _currentTime, _finishRequested, _initializables, _stopRequested, timeResolution
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
HDFDirector()
          Construct a director in the default workspace with an empty string as its name.
HDFDirector(CompositeEntity container, java.lang.String name)
          Construct a director in the given container with the given name.
HDFDirector(Workspace workspace)
          Construct a director in the workspace with an empty name.
 
Method Summary
private  void _init()
          Initialize the object.
 void attributeChanged(Attribute attribute)
          If the attribute changed is the scheduleCacheSize parameter, construct the cache in the associated CachedSDFScheduler with the given cache size.
 boolean postfire()
          Send a request to the manager to get the HDF schedule if the schedule is not valid or this director is not at the top level.
 void preinitialize()
          Preinitialize the actors associated with this director.
 void setScheduler(Scheduler scheduler)
          Override the base class to ensure that the scheduler is an SDFScheduler and that its constrainBufferSizes parameter is set to false.
 
Methods inherited from class ptolemy.domains.sdf.kernel.SDFDirector
clone, createSchedule, fireAt, getModelNextIterationTime, initialize, newReceiver, periodValue, prefire, suggestedModalModelDirectors, supportMultirateFiring, transferInputs, transferOutputs
 
Methods inherited from class ptolemy.actor.sched.StaticSchedulingDirector
_setScheduler, addDebugListener, fire, getScheduler, invalidateSchedule, isScheduleValid, removeDebugListener
 
Methods inherited from class ptolemy.actor.Director
_description, _fireContainerAt, _isEmbedded, _isTopLevel, _transferInputs, _transferOutputs, addInitializable, defaultDependency, finish, fireAt, fireAtCurrentTime, getCausalityInterface, getCurrentTime, getErrorTolerance, getGlobalTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, isFireFunctional, isStopRequested, isStrict, iterate, preinitialize, removeInitializable, requestInitialization, setContainer, setCurrentTime, setModelTime, stop, stopFire, terminate, wrapup
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Executable
fire, isFireFunctional, isStrict, iterate, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, removeInitializable, wrapup
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
 

Field Detail

scheduleCacheSize

public Parameter scheduleCacheSize
A parameter representing the size of the schedule cache to use. If the value is less than or equal to zero, then schedules will never be discarded from the cache. The default value is 100.

Note that the number of schedules in an HDF model can be exponential in the number of actors. Setting the cache size to a very large value is therefore not recommended if the model contains a large number of HDF actors.

Constructor Detail

HDFDirector

public HDFDirector()
            throws IllegalActionException,
                   NameDuplicationException
Construct a director in the default workspace with an empty string as its name. The director is added to the list of objects in the workspace. Increment the version number of the workspace.

Throws:
IllegalActionException - If the name has a period in it, or the director is not compatible with the specified container.
NameDuplicationException - If the container already contains an entity with the specified name.

HDFDirector

public HDFDirector(Workspace workspace)
            throws IllegalActionException,
                   NameDuplicationException
Construct a director in the workspace with an empty name. The director is added to the list of objects in the workspace. Increment the version number of the workspace.

Parameters:
workspace - The workspace for this object.
Throws:
IllegalActionException - If the name has a period in it, or the director is not compatible with the specified container.
NameDuplicationException - If the container already contains an entity with the specified name.

HDFDirector

public HDFDirector(CompositeEntity container,
                   java.lang.String name)
            throws IllegalActionException,
                   NameDuplicationException
Construct a director in the given container with the given name. The container argument must not be null, or a NullPointerException will be thrown. If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace. The HDFDirector will have a default scheduler of type SDFScheduler.

Parameters:
container - Container of the director.
name - Name of this director.
Throws:
IllegalActionException - If the director is not compatible with the specified container. May be thrown in a derived class.
NameDuplicationException - If the container is not a CompositeActor and the name collides with an entity in the container.
Method Detail

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
If the attribute changed is the scheduleCacheSize parameter, construct the cache in the associated CachedSDFScheduler with the given cache size.

Overrides:
attributeChanged in class SDFDirector
Parameters:
attribute - The attribute that changed.
Throws:
IllegalActionException - If the super class throws it.

postfire

public boolean postfire()
                 throws IllegalActionException
Send a request to the manager to get the HDF schedule if the schedule is not valid or this director is not at the top level.

Specified by:
postfire in interface Executable
Overrides:
postfire in class SDFDirector
Returns:
True if the Director wants to be fired again in the future.
Throws:
IllegalActionException - If no schedule can be found, or if the super class method throws it.

preinitialize

public void preinitialize()
                   throws IllegalActionException
Preinitialize the actors associated with this director. The super class method will compute the schedule.

Specified by:
preinitialize in interface Initializable
Overrides:
preinitialize in class SDFDirector
Throws:
IllegalActionException - If the super class preinitialize throws it.

setScheduler

public void setScheduler(Scheduler scheduler)
                  throws IllegalActionException,
                         NameDuplicationException
Override the base class to ensure that the scheduler is an SDFScheduler and that its constrainBufferSizes parameter is set to false.

Overrides:
setScheduler in class StaticSchedulingDirector
Parameters:
scheduler - The scheduler that this director will use.
Throws:
IllegalActionException - If the scheduler is not an instance of SDFScheduler.
NameDuplicationException - Not thrown in this base class, but derived classes may throw it if the scheduler is not compatible.
See Also:
StaticSchedulingDirector.getScheduler()

_init

private void _init()
            throws IllegalActionException,
                   NameDuplicationException
Initialize the object. In this case, we give the HDFDirector a default scheduler of the class CachedSDFScheduler and a cacheSize parameter with default value 100.

Throws:
IllegalActionException
NameDuplicationException