|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.util.Attribute
ptolemy.actor.Director
ptolemy.actor.sched.StaticSchedulingDirector
ptolemy.domains.ct.kernel.CTDirector
This is the abstract base class for directors in the CT domain.
A CTDirector has a CTScheduler which provides the schedules for firing the actors in different phases of execution.
A CTDirector may have more than one ODE solvers. In each iteration, one of the ODE solvers is taking charge of solving the ODEs. This solver is called the current ODE solver.
The continuous time (CT) domain is a timed domain. There is a global notion of time that all the actors are aware of. Time is maintained by the director. The method getCurrentTime() returns the current notion of time. Time can be set by the setCurrentTime() method, but this method should not the called by the actors. Time can only be set by directors or their ODE solvers.
This base class maintains a list of parameters that may be used by
ODE solvers and actors. These parameters are:
startTime: The start time of the
simulation. This parameter is effective only if the director
is at the top level. Default value is 0.0.
stopTime: The stop time of the simulation.
This parameter is effective only if the director
is at the top level. Default value is Double.MAX_VALUE.
initStepSize: The suggested integration step size
by the user. This will be the step size for fixed step
size ODE solvers if there is no breakpoint. However, it is just
a hint otherwise. Default value is 0.1
minStepSize: The minimum step
size that the user wants to use in the simulation. Default value is 1e-5.
maxStepSize: The maximum step
size the user wants to use in the simulation. Usually used to control
the simulation speed. Default value is 1.0.
maxIterations:
Used only in implicit ODE solvers. This is the maximum number of
iterations for finding the fixed point at one time point.
Default value is 20.
errorTolerance: This is the local truncation
error tolerance, used for controlling the integration accuracy
in variable step size ODE solvers. If the local truncation error
at some step size control actors are greater than this tolerance, then the
integration step is considered to have failed, and should be restarted with
a reduced step size. Default value 1e-4.
valueResolution:
This is used to control the convergence of fixed point iterations.
If in two successive iterations the differences of the state variables
is less than this resolution, then the fixed point is considered to have
reached.
Default value is 1e-6.
timeResolution: The minimum resolution
of time. If two time values differ less than this value,
they are considered equivalent. Default value is 1e-10.
This director also maintains a breakpoint table to record all predictable breakpoints that are greater than the current time. The breakpoints are sorted in their chronological order in the table. Breakpoints at the same time (controlled by the time resolution parameter) are considered to be one. A breakpoint can be inserted into the table by calling the fireAt() method. The fireAt method may be requested by the director, which inserts the start time and stop time of the execution. In this case, the first parameter actor is null. The fireAt method may also be requested by the actors and the requests are handled differently depending on the second parameter time. If the time is the current time, and if the actors are discrete actors, the actors are added into a refireActor list and will be fired in the current iteration. Otherwise, the time will be inserted into the breakpoint table.
Director,
Serialized Form
| Green (chf) |
| Green (liuj) |
| Nested Class Summary |
| Nested classes inherited from class ptolemy.kernel.util.NamedObj |
NamedObj.ContainedObjectsIterator |
| Field Summary | |
protected boolean |
_postfireReturns
This flag will be set to false if any actor returns false to postfire() during the fire() phase of the director. |
protected java.util.LinkedList |
_refireActors
A list of actors that requested to refire at the current time. |
Parameter |
errorTolerance
ODE solving error tolerance, only effective in variable step size methods. |
Parameter |
initStepSize
User's hint for the initial integration step size. |
Parameter |
maxIterations
The maximum number of iterations in looking for a fixed-point. |
Parameter |
maxStepSize
User's guide for the maximum integration step size. |
Parameter |
minStepSize
User's guide for the minimum integration step size. |
Parameter |
startTime
Starting time of the simulation. |
Parameter |
stopTime
Stop time of the simulation. |
Parameter |
synchronizeToRealTime
Indicate whether the execution will synchronize to real time. |
Parameter |
timeResolution
The resolution in comparing time. |
Parameter |
valueResolution
Value resolution in looking for a fixed-point. |
| Fields inherited from class ptolemy.actor.Director |
_currentTime, _stopRequested |
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
| Fields inherited from interface ptolemy.actor.Executable |
COMPLETED, NOT_READY, STOP_ITERATING |
| Constructor Summary | |
CTDirector()
Construct a director in the default workspace with an empty string as its name. |
|
CTDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name. |
|
CTDirector(Workspace workspace)
Construct a director in the workspace with an empty name. |
|
| Method Summary | |
protected boolean |
_areTimesCloseEnough(double firstTime,
double secondTime)
Return true if the difference of the two given times is less than the time resolution of the director. |
protected void |
_initParameters()
Create and initialize all parameters to their default values. |
protected ODESolver |
_instantiateODESolver(java.lang.String className)
Instantiate an ODESolver from its classname. |
protected void |
_setBreakpointIteration(boolean breakpoint)
Set to indicate that this is an iteration just after a breakpoint. |
protected void |
_setCurrentODESolver(ODESolver solver)
Set the current ODE Solver to be the argument. |
protected void |
_setDiscretePhase(boolean discrete)
Set the current phase of execution as a discrete phase. |
protected void |
_setIterationBeginTime(double time)
Set the iteration begin time. |
protected boolean |
_writeAccessRequired()
Returns false always, indicating that this director does not need to modify the topology during one iteration. |
void |
attributeChanged(Attribute attribute)
React to a change in an attribute. |
abstract boolean |
canBeInsideDirector()
Return true if the director can be an inside director, i.e. |
abstract boolean |
canBeTopLevelDirector()
Return true if the director can be a top-level director. |
void |
fireAt(Actor actor,
double time)
Handle the firing request from the containing actors. |
TotallyOrderedSet |
getBreakPoints()
Return the breakpoint table. |
ODESolver |
getCurrentODESolver()
Return the current ODE solver. |
double |
getCurrentStepSize()
Return the current integration step size. |
double |
getErrorTolerance()
Return the local truncation error tolerance, used by variable step size solvers. |
double |
getInitialStepSize()
Return the initial step size. |
double |
getIterationBeginTime()
Return the begin time of the current iteration. |
int |
getMaxIterations()
Return the maximum number of iterations in fixed point calculation. |
double |
getMaxStepSize()
Return the maximum step size used in variable step size ODE solvers. |
double |
getMinStepSize()
Return the minimum step size used in variable step size ODE solvers. |
double |
getNextIterationTime()
Return the current iteration begin time plus the current step size. |
double |
getStartTime()
Return the start time parameter value. |
double |
getStopTime()
Return the stop time. |
double |
getSuggestedNextStepSize()
Return the suggested next step size. |
double |
getValueResolution()
Return the value resolution, used for testing if an implicit method has reached the fixed point. |
void |
initialize()
Initialization after type resolution. |
boolean |
isBreakpointIteration()
Return true if this is the first iteration after a breakpoint. |
boolean |
isDiscretePhase()
Return true if this is the discrete phase execution. |
boolean |
isPrefireComplete(Actor actor)
Return true if the actor has been prefired in the current iteration. |
Receiver |
newReceiver()
Return a new CTReceiver. |
void |
prefireClear()
Clear the set of actors that have been prefired. |
void |
preinitialize()
Prepare for an execution. |
void |
produceOutput()
Fire all the actors in the output schedule. |
void |
setCurrentStepSize(double stepsize)
Set the current step size. |
void |
setCurrentTime(double newTime)
Set a new value to the current time of the model, where the new time can be earlier than the current time to support rollback. |
void |
setPrefireComplete(Actor actor)
Mark the specified actor as having been prefired in the current iteration. |
void |
setSuggestedNextStepSize(double stepsize)
Set the suggested next step size. |
void |
updateContinuousStates()
Call postfire() on all actors in the continuous part of the model. |
| Methods inherited from class ptolemy.actor.sched.StaticSchedulingDirector |
_setScheduler, addDebugListener, fire, getScheduler, invalidateSchedule, isScheduleValid, postfire, prefire, removeDebugListener, setScheduler, setScheduleValid |
| Methods inherited from class ptolemy.actor.Director |
_description, _isEmbedded, _isTopLevel, domainPolymorphicTransferInputs, domainPolymorphicTransferOutputs, fireAtCurrentTime, getCurrentTime, getTimeResolution, initialize, invalidateResolvedTypes, iterate, needWriteAccess, requestInitialization, setContainer, setTimeResolution, stop, stopFire, terminate, transferInputs, transferOutputs, wrapup |
| Methods inherited from class ptolemy.kernel.util.Attribute |
_getContainedObject, _propagateExistence, clone, getContainer, setName |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public Parameter errorTolerance
public Parameter initStepSize
public Parameter maxIterations
public Parameter maxStepSize
public Parameter minStepSize
public Parameter startTime
public Parameter stopTime
public Parameter synchronizeToRealTime
public Parameter timeResolution
public Parameter valueResolution
protected boolean _postfireReturns
protected java.util.LinkedList _refireActors
| Constructor Detail |
public CTDirector()
public CTDirector(Workspace workspace)
workspace - The workspace of this object.public CTDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container - The container.name - Name of this director.
IllegalActionException - If the director is not compatible
with the specified container. May be thrown by a derived class.
NameDuplicationException - If the name collides with
a property in the container.| Method Detail |
public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged in class NamedObjattribute - The changed parameter.
IllegalActionException - If the parameter set is not valid.public abstract boolean canBeInsideDirector()
public abstract boolean canBeTopLevelDirector()
public void fireAt(Actor actor, double time) throws IllegalActionException
From this director's point of view, it is irrelevant which actor requests the breakpoint. All actors will be executed at every breakpoint.
If the actor is null, it indicates the time for the start or the stop of an execution. Otherwise, it is the actor that requests the firing.
In CT domain, the signals may be piecewise continuous. They may generate discontinuities at some time points. In order to generate the discontinuities, the actors request to be fired at some time as many times as necessary, and each time they produce some outputs. The CT director does not deal with discontinuity but only handle the requests from the actors it contains. For example, the ContinuousClock actor fires twice at each offset.
actor - The actor that requested the firing or null that
indicates the time of the start or stop of an execution.time - The requested firing time.
IllegalActionException - If the time is earlier than
the current time.public final TotallyOrderedSet getBreakPoints()
public final ODESolver getCurrentODESolver()
public final double getCurrentStepSize()
public final double getErrorTolerance()
public final double getInitialStepSize()
public final double getIterationBeginTime()
public final int getMaxIterations()
public final double getMaxStepSize()
public final double getMinStepSize()
public double getNextIterationTime()
getNextIterationTime in class Directorpublic final double getStartTime()
public final double getStopTime()
public final double getSuggestedNextStepSize()
public final double getValueResolution()
public void initialize()
throws IllegalActionException
initialize in interface Executableinitialize in class DirectorIllegalActionException - If the super class throws it.public final boolean isBreakpointIteration()
public final boolean isDiscretePhase()
public boolean isPrefireComplete(Actor actor)
actor - The actor about which we are asking.
setPrefireComplete(Actor)public Receiver newReceiver()
newReceiver in class Directorpublic void prefireClear()
public void preinitialize()
throws IllegalActionException
preinitialize in interface Executablepreinitialize in class DirectorIllegalActionException - If the director has no
container, the director does not fit this level of hierarchy,
or there is no scheduler.
public void produceOutput()
throws IllegalActionException
IllegalActionException - If an actor in the output
schedule throws it.public void setCurrentStepSize(double stepsize)
stepsize - The step size to be set.public void setCurrentTime(double newTime)
setCurrentTime in class DirectornewTime - The new current simulation time.public void setPrefireComplete(Actor actor)
actor - The actor about which we are asking.isPrefireComplete(Actor)public void setSuggestedNextStepSize(double stepsize)
stepsize - The suggested next step size.
public void updateContinuousStates()
throws IllegalActionException
IllegalActionException - If any of the actors
throws it.
protected boolean _areTimesCloseEnough(double firstTime,
double secondTime)
firstTime - The first time.secondTime - The second time.
protected void _initParameters()
protected ODESolver _instantiateODESolver(java.lang.String className) throws IllegalActionException
className - The solver's full class name.
IllegalActionException - If the solver is unable to be
created.protected void _setBreakpointIteration(boolean breakpoint)
breakpoint - True if this is a breakpoint iteration.protected void _setCurrentODESolver(ODESolver solver) throws IllegalActionException
solver - The solver to set.
IllegalActionException - Not thrown in this base class.
It may be thrown by the derived classes if the solver is not
appropriate.protected void _setDiscretePhase(boolean discrete)
discrete - True if this is the discrete phase.protected void _setIterationBeginTime(double time)
time - The iteration begin time.protected boolean _writeAccessRequired()
_writeAccessRequired in class Director
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||