|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
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
public abstract class CTDirector
Abstract base class for directors in the CT domain. A CTDirector has a CTScheduler which provides static schedules for firing the actors in different phases of execution in one iteration.
A CTDirector may have more than one ODE solver. In each phase of execution, one ODE solver takes charge of solving the behavior of a model. 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 getModelTime() returns the current notion of model time. Time can be set by the setModelTime() method, but this method should not the called by the actors. Time can only be set by directors or their ODE solvers. Because ODE solvers can change time in their fire() methods, we need to record the beginning time of an iteration to support roll back. The _setIterationBeginTime() method is just designed for this purpose. It is called in the prefire() method of each iteration to store the beginning time, and the getIterationBeginTime() returns the lastest stored time.
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. The 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. The default value is Infinity, which
results in execution that does not stop on its own.
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. The default value is 0.1
minStepSize
: The minimum step
size that users want to use in the simulation. The default value is 1e-5.
maxStepSize
: The maximum step
size that users want to use in the simulation. Usually used to control
the simulation speed. The 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.
The 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. The default value is 1e-4.
valueResolution
:
This is used to control the convergence of fixed point iterations.
If in two successive iterations the difference of the state variables
is less than this resolution, then the fixed point is considered to have
reached. The default value is 1e-6.
This director maintains a breakpoint table to record all predictable breakpoints that are greater than or equal to the current time. The breakpoints are sorted in their chronological order. Breakpoints at the same time are considered to be identical, and the breakpoint table does not contain duplicate time points. 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 stop time of the execution. The fireAt method may also be requested by actors and the requested firing time will be inserted into the breakpoint table.
Green (hyzheng) |
Green (hyzheng) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
private TotallyOrderedSet |
_breakpoints
|
private ODESolver |
_currentSolver
|
private double |
_currentStepSize
|
private boolean |
_discretePhase
|
private double |
_errorTolerance
|
private CTExecutionPhase |
_executionPhase
|
private double |
_initStepSize
|
private Time |
_iterationBeginTime
|
private int |
_maxIterations
|
private double |
_maxStepSize
|
private double |
_minStepSize
|
private java.util.Set |
_prefiredActors
|
private Time |
_startTime
|
private double |
_startTimeValue
|
private Time |
_stopTime
|
private double |
_stopTimeValue
|
private double |
_suggestedNextStepSize
|
protected long |
_timeBase
The real starting time in term of system millisecond counts. |
private double |
_valueResolution
|
Parameter |
errorTolerance
Error tolerance for local truncation error control, 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
Indicator whether the execution will synchronize to real time. |
Parameter |
valueResolution
Value resolution in looking for a fixed-point state resolution. |
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 | |
---|---|
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 | |
---|---|
private void |
_initializeLocalVariables()
|
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 |
_setCurrentODESolver(ODESolver solver)
Set the current ODE solver to be the given ODE solver. |
protected void |
_setDiscretePhase(boolean discrete)
Set the current phase of execution as a discrete phase. |
protected void |
_setExecutionPhase(CTExecutionPhase phase)
Set the execution phase to the given phase. |
protected void |
_setIterationBeginTime(Time time)
Set the iteration begin time. |
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. |
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace. |
Dependency |
delayDependency(double delay)
Return a boolean dependency representing a model-time delay of the specified amount. |
abstract void |
fire()
Override the fire() method of the super class. |
Time |
fireAt(Actor actor,
Time time)
Handle firing requests from the contained actors. |
TotallyOrderedSet |
getBreakPoints()
Return the breakpoint table. |
ODESolver |
getCurrentODESolver()
Return the current ODE solver used to resolve states by the director. |
double |
getCurrentStepSize()
Return the current integration step size. |
double |
getErrorTolerance()
Return the local truncation error tolerance, used by variable step size solvers. |
CTExecutionPhase |
getExecutionPhase()
Get the current execution phase of this director. |
double |
getInitialStepSize()
Return the initial step size. |
Time |
getIterationBeginTime()
Return the begin time of the current iteration. |
int |
getMaxIterations()
Return the maximum number of iterations in a 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. |
Time |
getModelNextIterationTime()
Return the current iteration begin time plus the current step size. |
Time |
getModelStartTime()
Return the start time. |
Time |
getModelStopTime()
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()
Initialize model after type resolution. |
boolean |
isDiscretePhase()
Return true if this is the discrete phase of execution. |
Receiver |
newReceiver()
Return a new CTReceiver. |
boolean |
postfire()
If the stop() method has not been called and all the actors return true at postfire, return true. |
void |
prefireClear()
Clear the set of actors that have been prefired. |
boolean |
prefireDynamicActors()
Invoke prefire() on all DYNAMIC_ACTORS, such as integrators, and emit their current states. |
void |
preinitialize()
Preinitialize the model for an execution. |
void |
setCurrentStepSize(double stepSize)
Set the current step size. |
void |
setSuggestedNextStepSize(double stepsize)
Set the suggested next step size. |
java.lang.String[] |
suggestedModalModelDirectors()
Return an array of suggested ModalModel directors to use with CTDirector. |
Methods inherited from class ptolemy.actor.sched.StaticSchedulingDirector |
---|
_setScheduler, addDebugListener, getScheduler, invalidateSchedule, isScheduleValid, prefire, removeDebugListener, setScheduler |
Methods inherited from class ptolemy.kernel.util.Attribute |
---|
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ptolemy.actor.TimedDirector |
---|
getModelTime, getTimeResolution |
Methods inherited from interface ptolemy.domains.ct.kernel.CTGeneralDirector |
---|
getExecutiveCTGeneralDirector, getODESolverClassName |
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 valueResolution
protected long _timeBase
private TotallyOrderedSet _breakpoints
private ODESolver _currentSolver
private double _currentStepSize
private boolean _discretePhase
private double _errorTolerance
private CTExecutionPhase _executionPhase
private double _initStepSize
private Time _iterationBeginTime
private int _maxIterations
private double _maxStepSize
private double _minStepSize
private java.util.Set _prefiredActors
private Time _startTime
private double _startTimeValue
private Time _stopTime
private double _stopTimeValue
private double _suggestedNextStepSize
private double _valueResolution
Constructor Detail |
---|
public CTDirector()
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.public CTDirector(Workspace workspace)
workspace
- The workspace of this object.Method Detail |
---|
public void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class Director
attribute
- The changed parameter.
IllegalActionException
- If the new parameter value
is not valid.public abstract boolean canBeInsideDirector()
public abstract boolean canBeTopLevelDirector()
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class StaticSchedulingDirector
workspace
- The workspace for the cloned object.
java.lang.CloneNotSupportedException
- Not thrown in this base classNamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public Dependency delayDependency(double delay)
delayDependency
in interface TimedDirector
delay
- A non-negative delay.
public abstract void fire() throws IllegalActionException
fire
in interface Executable
fire
in class StaticSchedulingDirector
IllegalActionException
- If any actor executed by this
actor return false in prefire.public Time fireAt(Actor actor, Time time) throws IllegalActionException
actor
- The actor that requests the firing.time
- The requested firing time.
IllegalActionException
- If the time is earlier than
the current time, or the breakpoint table is null.Director.fireAtCurrentTime(Actor)
public final TotallyOrderedSet getBreakPoints()
public final ODESolver getCurrentODESolver()
public double getCurrentStepSize()
getCurrentStepSize
in interface CTGeneralDirector
setCurrentStepSize(double)
public double getErrorTolerance()
getErrorTolerance
in interface CTGeneralDirector
getErrorTolerance
in class Director
public CTExecutionPhase getExecutionPhase()
getExecutionPhase
in interface CTGeneralDirector
public final double getInitialStepSize()
public Time getIterationBeginTime()
getIterationBeginTime
in interface CTGeneralDirector
public final int getMaxIterations()
public final double getMaxStepSize()
public final double getMinStepSize()
public Time getModelNextIterationTime()
getModelNextIterationTime
in class Director
Director.getModelTime()
public final Time getModelStartTime()
getModelStartTime
in class Director
public final Time getModelStopTime()
getModelStopTime
in class Director
public final double getSuggestedNextStepSize()
setSuggestedNextStepSize(double)
public final double getValueResolution()
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class Director
IllegalActionException
- If the super class throws it.public boolean isDiscretePhase()
isDiscretePhase
in interface CTGeneralDirector
public Receiver newReceiver()
newReceiver
in class Director
public boolean postfire() throws IllegalActionException
postfire
in interface Executable
postfire
in class StaticSchedulingDirector
IllegalActionException
- If refiring can not be granted.public void prefireClear()
public boolean prefireDynamicActors() throws IllegalActionException
IllegalActionException
- If scheduler throws it, or dynamic
actors throw it in their prefire() method, or they can not be prefired.public void preinitialize() throws IllegalActionException
Note, however, time does not have a meaning when actors are preinitialized. So actors must not use a notion of time in their preinitialize() methods.
preinitialize
in interface Initializable
preinitialize
in class Director
IllegalActionException
- If this director has no
container, or this director does not fit this level of hierarchy,
or there is no scheduler.public void setCurrentStepSize(double stepSize)
stepSize
- The step size to be set.getCurrentStepSize()
public void setSuggestedNextStepSize(double stepsize)
stepsize
- The suggested next step size.getSuggestedNextStepSize()
public java.lang.String[] suggestedModalModelDirectors()
suggestedModalModelDirectors
in class Director
Director.suggestedModalModelDirectors()
protected void _initParameters()
protected final ODESolver _instantiateODESolver(java.lang.String className) throws IllegalActionException
className
- The solver's full class name.
IllegalActionException
- If the solver can not be created.protected final 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 final void _setDiscretePhase(boolean discrete)
discrete
- True if this is the discrete phase.protected final void _setExecutionPhase(CTExecutionPhase phase)
phase
- The current phase of the CT director.protected final void _setIterationBeginTime(Time time)
time
- The iteration begin time.private void _initializeLocalVariables() throws IllegalActionException
IllegalActionException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |