ptolemy.domains.ct.kernel
Class CTScheduler

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.util.Attribute
          extended byptolemy.actor.sched.Scheduler
              extended byptolemy.domains.ct.kernel.CTScheduler
All Implemented Interfaces:
ptolemy.kernel.util.Changeable, java.lang.Cloneable, ptolemy.kernel.util.Debuggable, ptolemy.kernel.util.DebugListener, ptolemy.kernel.util.Derivable, ptolemy.kernel.util.ModelErrorHandler, ptolemy.kernel.util.MoMLExportable, ptolemy.kernel.util.Nameable, java.io.Serializable

public class CTScheduler
extends ptolemy.actor.sched.Scheduler

Static scheduler for the CT domain. A CT (sub)system can be mathematically represented as:

   
    dx/dt = f(x, u, t)
    y = g(x, u, t)
where x is the state of the system, u is the input, y is the output, f() is the state transition map and g() is the output map.

The system is built using actors. That is, all the functions, f() and g(), are built up by chains of actors. For higher order systems, x is a vector, built using more than one integrator. In general, actors that have the functionality of integration from their inputs to their outputs are called dynamic actors. Other actors are called arithmetic actors.

In order to interact with discrete domains, some actors in the CT domain are able to convert continuous waveforms to discrete events, and vice versa. An actor that has continuous input and discrete output is call an event generator; an actor that has discrete input and continuous output is called a waveform generator.

The interaction with some discrete domains requires that the CT simulation be able to remember its state and roll-back to the remembered state when needed. This in turn requires that all actors which have internal states should be able to remember and restore their states. These actors are called stateful actors.

In the continuous time simulation, time progresses in a discrete way. The distance between consecutive simulation time points is called the integration step size or step size, for short. Some actors need to be able to control the step sizes in the simulation. These actors are called step size control actors. Examples of step size control actors include integrators, which control the accuracy and speed of numerical ODE solutions, and some event generators, which detect events.

To help with scheduling, the actors are partitioned into several clusters: the arithmetic actors, the dynamic actors, the step size control actors, the sink actors, the stateful actors, the event generators, and the waveform generators. This scheduler uses the clustered information and the system topology, to provide the firing sequences for evaluating f() and g(). It also provides a firing order for all the dynamic actors. The firing sequence for evaluating f() is called the state transition schedule; the firing sequence for evaluating g() is called the output schedule; and the firing sequence for dynamic actors is called the dynamic actor schedule.

The state transition schedule is the actors in the f() function sorted in the topological order, such that, after the integrators emit their state x, a chain of firings according to the schedule evaluates the f() function and returns tokens corresponding to dx/dt to the integrators.

The output schedule is the actors in the g() function sorted in their topological order.

The dynamic actor schedule is a list of dynamic actors in their reverse topological order.

If there are loops of arithmetic actors or loops of integrators, then the (sub)system are not schedulable, and a NotSchedulableException will be thrown if schedules are requested.

Since:
Ptolemy II 0.2
Version:
$Id: CTScheduler.java,v 1.129 2004/04/13 19:05:09 cxh Exp $
Author:
Jie Liu
See Also:
Scheduler, Serialized Form
Accepted Rating:
Yellow (johnr)
Proposed Rating:
Green (liuj)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
ptolemy.kernel.util.NamedObj.ContainedObjectsIterator
 
Field Summary
static CTReceiver.SignalType CONTINUOUS
          These are syntactic sugar for signal types, which are defined in CTReceiver.
static CTReceiver.SignalType DISCRETE
          Signal type: DISCRETE.
static CTReceiver.SignalType UNKNOWN
          Signal type: UNKNOWN.
 
Fields inherited from class ptolemy.actor.sched.Scheduler
_DEFAULT_SCHEDULER_NAME
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
CTScheduler()
          Construct a CT scheduler in the default workspace with the default name "CTScheduler".
CTScheduler(ptolemy.actor.Director container, java.lang.String name)
          Construct a scheduler in the given container with the given name.
CTScheduler(ptolemy.kernel.util.Workspace workspace)
          Construct a CT scheduler in the given workspace with the name "CTScheduler".
 
Method Summary
protected  ptolemy.actor.sched.Schedule _getSchedule()
          Return the CTSchedule.
 boolean isContinuous(ptolemy.actor.Actor actor)
          Return true if the specified actor is in the continuous cluster of the model.
 boolean isDiscrete(ptolemy.actor.Actor actor)
          Return true if the specified actor is in the discrete cluster of the model.
 java.util.List predecessorList(ptolemy.actor.Actor actor)
          Return the predecessors of the given actor in the topology within this opaque composite actor.
 java.lang.String signalTypeToString(CTReceiver.SignalType signalType)
          Return the SignalType as a String
 java.util.List successorList(ptolemy.actor.Actor actor)
          Return the successive actors of the given actor in the topology.
 java.lang.String toString()
          Return all the scheduling information in a String.
 
Methods inherited from class ptolemy.actor.sched.Scheduler
clone, getSchedule, isValid, setContainer, setValid
 
Methods inherited from class ptolemy.kernel.util.Attribute
_getContainedObject, _propagateExistence, getContainer, setName
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTINUOUS

public static final CTReceiver.SignalType CONTINUOUS
These are syntactic sugar for signal types, which are defined in CTReceiver. Signal type: CONTINUOUS.


DISCRETE

public static final CTReceiver.SignalType DISCRETE
Signal type: DISCRETE.


UNKNOWN

public static final CTReceiver.SignalType UNKNOWN
Signal type: UNKNOWN.

Constructor Detail

CTScheduler

public CTScheduler()
Construct a CT scheduler in the default workspace with the default name "CTScheduler". There is no director containing this scheduler. To attach this scheduler to a CTDirector, call setScheduler() on the CTDirector.


CTScheduler

public CTScheduler(ptolemy.kernel.util.Workspace workspace)
Construct a CT scheduler in the given workspace with the name "CTScheduler". There is no director containing this scheduler. To attach this scheduler to a CTDirector, call setScheduler() on the CTDirector.

Parameters:
workspace - The workspace.

CTScheduler

public CTScheduler(ptolemy.actor.Director container,
                   java.lang.String name)
            throws ptolemy.kernel.util.IllegalActionException,
                   ptolemy.kernel.util.NameDuplicationException
Construct a scheduler in the given container with the given name. The container argument must not be null, or a NullPointerException will be thrown. This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.

Parameters:
container - The container.
name - The name of this attribute.
Throws:
ptolemy.kernel.util.IllegalActionException - If the attribute is not of an acceptable class for the container, or if the name contains a period.
ptolemy.kernel.util.NameDuplicationException - If the name coincides with an attribute already in the container.
Method Detail

isContinuous

public boolean isContinuous(ptolemy.actor.Actor actor)
                     throws ptolemy.kernel.util.IllegalActionException
Return true if the specified actor is in the continuous cluster of the model.

Parameters:
actor - The specified actor.
Returns:
True if the actor is a continuous actor.
Throws:
ptolemy.kernel.util.IllegalActionException - If this method is called before initialization, where the schedule is computed.

isDiscrete

public boolean isDiscrete(ptolemy.actor.Actor actor)
                   throws ptolemy.kernel.util.IllegalActionException
Return true if the specified actor is in the discrete cluster of the model.

Parameters:
actor - The specified actor.
Returns:
True if the actor is a discrete actor.
Throws:
ptolemy.kernel.util.IllegalActionException - If this method is called before initialization, where the schedule is computed.

predecessorList

public java.util.List predecessorList(ptolemy.actor.Actor actor)
Return the predecessors of the given actor in the topology within this opaque composite actor. If the argument is null, returns null. If the actor is a source, returns an empty list.

Parameters:
actor - The specified actor.
Returns:
The list of predecessors, unordered.

signalTypeToString

public java.lang.String signalTypeToString(CTReceiver.SignalType signalType)
Return the SignalType as a String


successorList

public java.util.List successorList(ptolemy.actor.Actor actor)
Return the successive actors of the given actor in the topology. If the argument is null, returns null. If the actor is a sink, returns an empty list.

Parameters:
actor - The specified actor. If the actor is null, returns null.
Returns:
The enumerations of predecessors.

toString

public java.lang.String toString()
Return all the scheduling information in a String.

Returns:
All the schedules.

_getSchedule

protected ptolemy.actor.sched.Schedule _getSchedule()
                                             throws ptolemy.actor.sched.NotSchedulableException,
                                                    ptolemy.kernel.util.IllegalActionException
Return the CTSchedule. Caching of the schedule is done in the director class, so this method does not test for the validation of the schedule.

Throws:
ptolemy.actor.sched.NotSchedulableException
ptolemy.kernel.util.IllegalActionException