Class HybridModalDirector
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.actor.Director
-
- ptolemy.domains.modal.kernel.FSMDirector
-
- ptolemy.domains.continuous.kernel.HybridModalDirector
-
- All Implemented Interfaces:
java.lang.Cloneable
,ContinuousStatefulComponent
,ContinuousStepSizeController
,Executable
,Initializable
,QuasiTransparentDirector
,SuperdenseTimeDirector
,ExplicitChangeContext
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class HybridModalDirector extends FSMDirector implements ContinuousStatefulComponent, ContinuousStepSizeController
An HybridModalDirector governs the execution of the discrete dynamics of a hybrid system model. It extends ModalDirector by implementing the ContinuousStatefulComponent and ContinuousStepSizeController interfaces by delegating the function of those interfaces to the currently active state refinement.Note that when a multi-step solver is used, the guards on the transitions are only evaluated when either the step size is zero or the multi-step solver has just completed its last step. The guards are not evaluated during intermediate steps.
This director is based on HSFSMDirector by Xiaojun Liu and Haiyang Zheng.
- Since:
- Ptolemy II 5.2
- Version:
- $Id$
- Author:
- Edward A. Lee, Haiyang Zheng
- Pt.AcceptedRating:
- Red (liuxj)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
-
Fields inherited from class ptolemy.domains.modal.kernel.FSMDirector
_currentLocalReceiverMap, _indexOffset, _localReceiverMaps, controllerName
-
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _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
Constructors Constructor Description HybridModalDirector(CompositeEntity container, java.lang.String name)
Construct a director in the given container with the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ContinuousDirector
_enclosingContinuousDirector()
Return the enclosing continuous director, or null if there is none.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
fire()
Fire the model model for one iteration.double
getErrorTolerance()
Return error tolerance used for detecting enabled transitions.ParseTreeEvaluator
getParseTreeEvaluator()
Return the parse tree evaluator used to evaluate guard expressions.boolean
isStepSizeAccurate()
Return true if all actors that were fired in the current iteration report that the step size is accurate and if no transition is enabled.boolean
postfire()
Override the base class so that if there is no enabled transition then we record for each comparison operation in each guard expression the distance between the current value of the variable being compared and the threshold.boolean
prefire()
Override the base class to set current time to match that of the enclosing executive director, if there is one, regardless of whether that time is in the future or past.double
refinedStepSize()
Return the minimum of the step sizes suggested by any actors that were fired in the current iteration.void
rollBackToCommittedState()
Roll back to committed state.double
suggestedStepSize()
Return the minimum of the step sizes suggested by any actors that were fired in current iteration.-
Methods inherited from class ptolemy.domains.modal.kernel.FSMDirector
_buildLocalReceiverMaps, _currentLocalReceivers, _getLastChosenTransition, _getStateRefinementsToPostfire, _getTransitionRefinementsToPostfire, _readInputs, _readOutputsFromRefinement, _setCurrentConnectionMap, _setCurrentState, _transferOutputs, attributeChanged, defaultDependency, fireAt, getContext, getController, getIndex, getModelNextIterationTime, getModifiedVariables, handleModelError, implementsStrictActorSemantics, initialize, invalidateSchedule, isStrict, newReceiver, preinitialize, resetOutputReceivers, setContainer, setIndex, transferInputs
-
Methods inherited from class ptolemy.actor.Director
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, addInitializable, createSchedule, delayDependency, elapsedTimeSinceStart, finish, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, initialize, invalidateResolvedTypes, isEmbedded, isFireFunctional, isStopRequested, iterate, mutexLockObject, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, resume, resumeActor, scheduleContainedActors, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, stop, stopFire, suggestedModalModelDirectors, supportMultirateFiring, suspend, terminate, transferOutputs, transferOutputs, 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, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, 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, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, 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.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Constructor Detail
-
HybridModalDirector
public HybridModalDirector(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.- Parameters:
container
- Container of this director.name
- Name of this director.- Throws:
IllegalActionException
- If the name has a period in it, or the director is not compatible with the specified container.NameDuplicationException
- If the container is not a CompositeActor and the name collides with an entity in the container.
-
-
Method Detail
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace. This calls the base class and then sets the attribute public members to refer to the attributes of the new actor.- Overrides:
clone
in classFSMDirector
- Parameters:
workspace
- The workspace for the new actor.- Returns:
- A new FSMActor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Fire the model model for one iteration. Override the base class to avoid firing the controller during intermediate stages of a multi-step solver.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classFSMDirector
- Throws:
IllegalActionException
- If there is more than one transition enabled and nondeterminism is not permitted, or there is no controller, or it is thrown by any choice action.
-
getErrorTolerance
public final double getErrorTolerance()
Return error tolerance used for detecting enabled transitions. If there is an enclosing continuous director, then get the error tolerance from that director. Otherwise, return 1e-4.- Returns:
- The error tolerance used for detecting enabled transitions.
-
getParseTreeEvaluator
public ParseTreeEvaluator getParseTreeEvaluator()
Return the parse tree evaluator used to evaluate guard expressions. In this class, an instance ofParseTreeEvaluatorForGuardExpression
is returned. The parse tree evaluator is set to construction mode.- Overrides:
getParseTreeEvaluator
in classFSMDirector
- Returns:
- ParseTreeEvaluator used to evaluate guard expressions.
-
isStepSizeAccurate
public boolean isStepSizeAccurate()
Return true if all actors that were fired in the current iteration report that the step size is accurate and if no transition is enabled.- Specified by:
isStepSizeAccurate
in interfaceContinuousStepSizeController
- Returns:
- True if the current step is accurate.
-
postfire
public boolean postfire() throws IllegalActionException
Override the base class so that if there is no enabled transition then we record for each comparison operation in each guard expression the distance between the current value of the variable being compared and the threshold.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classFSMDirector
- Returns:
- True if the mode controller wishes to be scheduled for another iteration.
- Throws:
IllegalActionException
- If thrown by any commit action or there is no controller.
-
prefire
public boolean prefire() throws IllegalActionException
Override the base class to set current time to match that of the enclosing executive director, if there is one, regardless of whether that time is in the future or past. The superclass sets current time only if the local time is less than the environment time. Initialize the firing of the director by resetting all receivers to unknown.- Specified by:
prefire
in interfaceExecutable
- Overrides:
prefire
in classFSMDirector
- Returns:
- Whatever the superclass returns.
- Throws:
IllegalActionException
- If thrown by the superclass.
-
refinedStepSize
public double refinedStepSize() throws IllegalActionException
Return the minimum of the step sizes suggested by any actors that were fired in the current iteration.- Specified by:
refinedStepSize
in interfaceContinuousStepSizeController
- Returns:
- The suggested refined step size.
- Throws:
IllegalActionException
- If the step size cannot be further refined.
-
rollBackToCommittedState
public void rollBackToCommittedState() throws IllegalActionException
Roll back to committed state. This will roll back any actors that were fired in the current iteration.- Specified by:
rollBackToCommittedState
in interfaceContinuousStatefulComponent
- Throws:
IllegalActionException
- If the rollback attempts to go back further than the last committed time.
-
suggestedStepSize
public double suggestedStepSize() throws IllegalActionException
Return the minimum of the step sizes suggested by any actors that were fired in current iteration.- Specified by:
suggestedStepSize
in interfaceContinuousStepSizeController
- Returns:
- The suggested next step size.
- Throws:
IllegalActionException
- If an actor requests an illegal step size.
-
_enclosingContinuousDirector
protected ContinuousDirector _enclosingContinuousDirector()
Return the enclosing continuous director, or null if there is none. The enclosing continuous director is a director above this in the hierarchy, possibly separated by composite actors with other foreign directors.- Returns:
- The enclosing ContinuousDirector, or null if there is none.
-
-