public class ContinuousDirector extends FixedPointDirector implements ContinuousStatefulDirector, ContinuousStepSizeController
A signal is a set of "events," each of which has a tag and value. The set of values includes a special element, called "absent", denoting the absence of a (normal) value. This director uses superdense time, where every event has a tag that is a member of the set RxN. R is a connected subset of the real numbers (giving "time", and approximated by instances of the Time class), and N is the natural numbers (giving an "index"). At a time t, a signal may have multiple values in sequence with tags (t, 0), (t, 1)... Its "initial value" is the value at tag (t, 0). It typically settles to a "final value" after a finite number of indices. If it fails to settle to a final value, the signal is said to have a "stuttering Zeno" condition, and time will not progress.
In our semantics, all signals are piecewise continuous. This means that the initial value, as a function of time, is continuous on the left, the final value, as a function of time, is continuous on the right, and the signal has exactly one value (meaning the initial value and the final value are the same) at all times except those on a discrete subset D.
A purely continuous signal has exactly one value at all times, meaning that the final value equals the initial value at all times. A purely discrete signal has initial value "absent" and final value "absent" at all times, and at a discrete subset of the times, it may have non-absent values. The only signal that is both purely continuous and purely discrete is the one that is absent at all tags.
A signal may be mostly continuous, but have multiple values at a discrete subset of times. These multiple values semantically represent discontinuities in a continuous signal that is not purely continuous.
The set of times where signals have more than one distinct value is a discrete subset D of the time line. These times are called "breakpoints" and are treated specially in the execution. Between these times, an ordinary differential equation (ODE) solver governs the execution. Initial values are always given by the ODE solver.
The parameters of this director are:
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 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.
This director is designed to work with any other director that implements the strict actor semantics. As long as the other director does not commit state changes except in postfire(), that director can be used within the model controlled by this director. If, in addition to implementing the strict actor semantics that other director also respects calls to fireAt(), then this director may be used within a model governed by that director.
This director is based on the CTDirector by Jie Liu and Haiyang Zheng, but it has a much simpler scheduler and a fixed-point semantics.
Red (hyzheng) |
Yellow (hyzheng) |
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected boolean |
_isInitializing
A local boolean variable indicating whether this director is in
initialization phase execution.
|
protected Time |
_iterationBeginTime
The current time at the start of the current integration step.
|
protected long |
_timeBase
The real starting time in term of system millisecond counts.
|
Parameter |
errorTolerance
Error tolerance for data values, used with variable step
size solvers to determine whether the current step size is accurate.
|
Parameter |
initStepSize
User's hint for the initial integration step size.
|
Parameter |
maxIterations
The maximum number of rounds that an
ODE solver can use to resolve the states of integrators.
|
Parameter |
maxStepSize
The maximum step size.
|
StringParameter |
ODESolver
The class name of the ODE solver used for integration.
|
_actorsAllowedToFire, _actorsFinishedFiring, _actorsFired, _index, _receivers, iterations, synchronizeToRealTime
_postfireReturns, _prefire
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
COMPLETED, NOT_READY, STOP_ITERATING
Constructor and Description |
---|
ContinuousDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name.
|
Modifier and Type | Method and Description |
---|---|
protected double |
_getCurrentStepSize()
Return the current step size.
|
protected ContinuousODESolver |
_getODESolver()
Return the ODE solver used to resolve states by the director.
|
protected void |
_initParameters()
Create and initialize all parameters to their default values.
|
protected ContinuousODESolver |
_instantiateODESolver(java.lang.String className)
Instantiate an ODESolver from its classname.
|
protected boolean |
_isDebugging()
Return true if debugging is turned on.
|
protected boolean |
_isIntermediateStep()
Return true if the solver is at the first or intermediate steps
of a multi-step solver.
|
protected void |
_reportDebugMessage(java.lang.String message)
Expose the debug method to the package.
|
void |
attributeChanged(Attribute attribute)
React to a change in an attribute.
|
java.lang.Object |
clone(Workspace workspace)
Clone the object into the specified workspace.
|
void |
fire()
Perform an integration step.
|
Time |
fireAt(Actor actor,
Time time,
int index)
Handle firing requests from the contained actors by registering
breakpoints.
|
double |
getCurrentStepSize()
Return the current integration step size.
|
double |
getErrorTolerance()
Return the local truncation error tolerance.
|
void |
initialize()
Initialize model after type resolution.
|
boolean |
isStepSizeAccurate()
Return true if all step size control actors agree that the current
step is accurate and if there are no breakpoints in the past.
|
boolean |
postfire()
If this director is not at the top level and the breakpoint table
is not empty, request a refiring at the first breakpoint or at
the local current time (iteration start time plus the step size),
whichever is less.
|
boolean |
prefire()
Initialize the fixed-point iteration by setting all receivers to
unknown, and return true if we have not passed the stop time.
|
void |
preinitialize()
Preinitialize the model for an execution.
|
double |
refinedStepSize()
Return the refined step size, which is the minimum of the
current step size and the suggested step size of all actors that
implement ContinuousStepSizeController and that also ensures
that we do not pass a breakpoint.
|
void |
resume()
Resume the actor at the specified time.
|
void |
rollBackToCommittedState()
Roll back all actors that implement ContinuousStatefulComponent
to committed state, and set local model time to the start
of the integration period.
|
void |
setModelTime(Time newTime)
Set a new value to the current time of the model.
|
java.lang.String[] |
suggestedModalModelDirectors()
Return an array of suggested ModalModel directors to use
with ContinuousDirector.
|
double |
suggestedStepSize()
Return the suggested step size for next integration.
|
boolean |
transferInputs(IOPort port)
Override the base class to do nothing.
|
boolean |
transferOutputs(IOPort port)
Override the base class to do nothing.
|
_areAllInputsKnown, _fireActor, _hasIterationConverged, _isReadyToFire, _receiverChanged, _resetAllReceivers, _sendAbsentToAllUnknownOutputsOf, _synchronizeToRealTime, getIndex, getModelNextIterationTime, implementsStrictActorSemantics, isFireFunctional, isStrict, newReceiver, setIndex
_setScheduler, addDebugListener, getScheduler, invalidateSchedule, isScheduleValid, removeDebugListener, resumeActor, setScheduler
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, addInitializable, createSchedule, defaultDependency, delayDependency, finish, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, initialize, invalidateResolvedTypes, isEmbedded, isStopRequested, iterate, mutexLockObject, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setTimeResolution, stop, stopFire, supportMultirateFiring, suspend, terminate, transferOutputs, wrapup
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, 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, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
public Parameter errorTolerance
public Parameter initStepSize
public Parameter maxIterations
public Parameter maxStepSize
public StringParameter ODESolver
protected boolean _isInitializing
protected Time _iterationBeginTime
protected long _timeBase
public ContinuousDirector(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 void attributeChanged(Attribute attribute) throws IllegalActionException
attributeChanged
in class Director
attribute
- The changed parameter.IllegalActionException
- If the new parameter value
is not valid.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class FixedPointDirector
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- Not thrown in this base classNamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void fire() throws IllegalActionException
If there is an enclosing ContinuousDirector, however, then this method simply performs the current round of execution of the enclosing director, using the step size of the enclosing director.
fire
in interface Executable
fire
in class FixedPointDirector
IllegalActionException
- If an actor throws it.public Time fireAt(Actor actor, Time time, int index) throws IllegalActionException
fireAt
in class Director
actor
- The actor that requests the firing.time
- The requested firing time.index
- The microstep.IllegalActionException
- If the time is earlier than
the current time.Director.fireAtCurrentTime(Actor)
,
Director.fireContainerAt(Time)
public final double getCurrentStepSize()
getCurrentStepSize
in interface ContinuousStatefulDirector
public final double getErrorTolerance()
getErrorTolerance
in interface ContinuousStatefulDirector
getErrorTolerance
in class Director
public void initialize() throws IllegalActionException
initialize
in interface Initializable
initialize
in class FixedPointDirector
IllegalActionException
- If the super class throws it.public boolean isStepSizeAccurate()
isStepSizeAccurate
in interface ContinuousStepSizeController
public boolean postfire() throws IllegalActionException
If the synchronizeToRealTime parameter is true, then this method will block execution until the real time catches up with current model time. The units for time are seconds.
postfire
in interface Executable
postfire
in class FixedPointDirector
IllegalActionException
- If the current model time exceeds
the stop time, or refiring can not be granted, or the super class throws it.public boolean prefire() throws IllegalActionException
prefire
in interface Executable
prefire
in class FixedPointDirector
IllegalActionException
- If thrown by the super class,
or if the model time of the environment is less than our current
model time.public void preinitialize() throws IllegalActionException
preinitialize
in interface Initializable
preinitialize
in class Director
IllegalActionException
- If the super class throws it, or
local variables cannot be initialized.public double refinedStepSize() throws IllegalActionException
refinedStepSize
in interface ContinuousStepSizeController
IllegalActionException
- If the scheduler throws it or the
refined step size is less than the time resolution.public void resume() throws IllegalActionException
resume
in class Director
IllegalActionException
- If the fireAt() request throws it.public void rollBackToCommittedState() throws IllegalActionException
rollBackToCommittedState
in interface ContinuousStatefulComponent
IllegalActionException
- If the rollback attempts to go
back further than the last committed time.public final void setModelTime(Time newTime) throws IllegalActionException
setModelTime
in class Director
newTime
- The new current simulation time.IllegalActionException
- If the time is in the past
relative to the time of local committed state.Director.getModelTime()
public java.lang.String[] suggestedModalModelDirectors()
suggestedModalModelDirectors
in class FixedPointDirector
Director.suggestedModalModelDirectors()
public double suggestedStepSize() throws IllegalActionException
suggestedStepSize
in interface ContinuousStepSizeController
IllegalActionException
- If an actor suggests an illegal step size.public boolean transferInputs(IOPort port) throws IllegalActionException
transferInputs
in class FixedPointDirector
port
- The port to transfer tokens from.IllegalActionException
- Not thrown in this base class.public boolean transferOutputs(IOPort port) throws IllegalActionException
transferOutputs
in class FixedPointDirector
port
- The port to transfer tokens from.IllegalActionException
- Not thrown in this base class.protected double _getCurrentStepSize()
protected final ContinuousODESolver _getODESolver()
protected void _initParameters()
protected final ContinuousODESolver _instantiateODESolver(java.lang.String className) throws IllegalActionException
className
- The solver's full class name.IllegalActionException
- If the solver can not be created.protected final boolean _isDebugging()
protected boolean _isIntermediateStep() throws IllegalActionException
IllegalActionException
- If the Time class throws it.protected void _reportDebugMessage(java.lang.String message)
message
- The message that is to be reported.