Class InterfaceAutomaton
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity
-
- ptolemy.kernel.CompositeEntity
-
- ptolemy.domains.modal.kernel.FSMActor
-
- ptolemy.domains.modal.kernel.ia.InterfaceAutomaton
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,Initializable
,TypedActor
,ExplicitChangeContext
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class InterfaceAutomaton extends FSMActor
This class models an Interface Automaton. Interface automata is an automata model defined by de Alfaro and Henzinger in the paper "Interface Automata". An InterfaceAutomaton contains a set of states and InterfaceAutomatonTransitions. There are three kinds transitions: input transition, output transition, and internal transitions. The input and output transitions correspond to input and output ports, respectively. The internal transition correspond to a parameter in this InterfaceAutomaton. The parameter is added automatically when the internal transition is added.When an InterfaceAutomaton is fired, the outgoing transitions of the current state are examined. An IllegalActionException is thrown if there is more than one enabled transition. If there is exactly one enabled transition then it is taken.
An InterfaceAutomaton enters its initial state during initialization. The name of the initial state is specified by the initialStateName string attribute.
- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Yuhong Xiong, Xiaojun Liu and Edward A. Lee
- See Also:
State
,InterfaceAutomatonTransition
- Pt.AcceptedRating:
- Yellow (kienhuis)
- Pt.ProposedRating:
- Yellow (liuxj)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.domains.modal.kernel.FSMActor
FSMActor.PortScope
-
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
-
-
Field Summary
-
Fields inherited from class ptolemy.domains.modal.kernel.FSMActor
_currentState, _disabledRefinements, _initializables, _inputTokenMap, _lastChosenTransition, _lastChosenTransitions, _lastTakenTransitions, _stateRefinementsToPostfire, _stopRequested, errorCause, errorClass, errorMessage, finalStateNames, initialStateName, probability, resetOnEachRun, seed, stateDependentCausality, timeout
-
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
-
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 InterfaceAutomaton()
Construct an InterfaceAutomaton in the default workspace with an empty string as its name.InterfaceAutomaton(CompositeEntity container, java.lang.String name)
Create an InterfaceAutomaton in the specified container with the specified name.InterfaceAutomaton(Workspace workspace)
Construct an InterfaceAutomaton in the specified workspace with an empty string as its name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_addRelation(ComponentRelation relation)
Add an InterfaceAutomatonTransition to this InterfaceAutomaton.void
addPorts()
Add instances of TypedIOPort that correspond to input and output transitions, if these port do not exist.void
combineInternalTransitions()
Combine each chain of internal transitions into one transition.InterfaceAutomaton
compose(InterfaceAutomaton automaton)
Return a new InterfaceAutomaton that is the composition of the specified InterfaceAutomaton and this one.InterfaceAutomaton
compose(InterfaceAutomaton automaton, boolean considerTransient)
Return a new InterfaceAutomaton that is the composition of the specified InterfaceAutomaton and this one.java.util.Set
computeAlternatingSimulation(InterfaceAutomaton subAutomaton)
Return the unique maximal alternating simulation from the specified automaton to this automaton.java.util.Set
deadlockStates()
Return the deadlock states in a Set.java.util.Set
epsilonClosure(State state)
Return the epsilon-closure of the specified state.java.util.Set
externallyEnabledDestinations(State sourceState, java.lang.String transitionLabel)
Return the set of externally enabled destination states.java.util.Set
externallyEnabledInputTransitionLabels(State state)
Return the labels for the set of externally enabled input transitions for the specified state.java.util.Set
externallyEnabledOutputTransitionLabels(State state)
Return the labels for the set of externally enabled output transitions for the specified state.void
fire()
Choose the enabled transition among the outgoing transitions of the current state.java.lang.String
getInfo()
Return a high-level description of this automaton.java.util.Set
inputNameSet()
Return the names of the input ports as a Set.java.util.Set
internalTransitionNameSet()
Return the names of the internal transitions as a Set.boolean
isClosed()
Return true if this automaton does not have any input and output; false otherwise.boolean
isEmpty()
Return true if this automaton is empty; false otherwise.ComponentRelation
newRelation(java.lang.String name)
Create a new instance of InterfaceAutomatonTransition with the specified name in this actor, and return it.java.util.Set
outputNameSet()
Return the names of the output ports as a Set.void
project(InterfaceAutomaton automaton)
Project this automaton into the specified one.static java.util.Set
reacheableAlternatingSimulation(java.util.Set alternatingSimulation, InterfaceAutomaton superAutomaton, InterfaceAutomaton subAutomaton)
Return the reacheable state pairs in the specified alternating simulation.void
renameTransitionLabels(java.util.Map nameMap)
Rename the labels on some transitions.-
Methods inherited from class ptolemy.domains.modal.kernel.FSMActor
_addEntity, _areAllImmediateTransitionsDisabled, _chooseTransitions, _destinationState, _getChannelForIdentifier, _getPortForIdentifier, _getStateRefinementsToPostfire, _getTransitionRefinementsToPostfire, _init, _initializeRefinements, _isRefinementOutput, _isSafeToClear, _readInputs, _schedule, _setCurrentConnectionMap, _setTimeForRefinement, addChosenTransition, addInitializable, attributeChanged, clone, createReceivers, currentState, enabledTransitions, exportSubmodel, foundUnknown, getCausalityInterface, getContext, getDirector, getExecutiveDirector, getInitialState, getLastChosenTransition, getLastChosenTransitions, getLastTakenTransitions, getManager, getModifiedVariables, getPortScope, handleModelError, hasInput, hasInput, initialize, inputPortList, isBackwardTypeInferenceEnabled, isFireFunctional, isOpaque, isStrict, iterate, newPort, newReceiver, outputPortList, postfire, prefire, preinitialize, readInputs, readOutputsFromRefinement, removeInitializable, reset, setLastChosenTransition, setNewIteration, setSupportMultirate, stop, stopFire, terminate, typeConstraints, wasTransitionTaken, wrapup
-
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _containedDecorators, _deepOpaqueEntityList, _description, _exportMoMLContents, _finishedAddEntity, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepEntityList, deepGetEntities, deepNamedObjList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyAllCompositeTransparentAndOpaqueEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, setContainer, statistics, uniqueName
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _removePort, connectedPortList, connectedPorts, connectionsChanged, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, 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.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Constructor Detail
-
InterfaceAutomaton
public InterfaceAutomaton()
Construct an InterfaceAutomaton in the default workspace with an empty string as its name. Add the actor to the workspace directory. Increment the version number of the workspace.
-
InterfaceAutomaton
public InterfaceAutomaton(Workspace workspace)
Construct an InterfaceAutomaton in the specified workspace with an empty string as its name. The name can be changed later with setName(). If the workspace argument is null, then use the default workspace. Add the actor to the workspace directory. Increment the version number of the workspace.- Parameters:
workspace
- The workspace that will list the actor.
-
InterfaceAutomaton
public InterfaceAutomaton(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Create an InterfaceAutomaton in the specified container with the specified name. The name must be unique within the container or an exception is thrown. The container argument must not be null, or a NullPointerException will be thrown.- Parameters:
container
- The container.name
- The name of this automaton within the container.- Throws:
IllegalActionException
- If the entity cannot be contained by the proposed container.NameDuplicationException
- If the name coincides with an entity already in the container.
-
-
Method Detail
-
addPorts
public void addPorts()
Add instances of TypedIOPort that correspond to input and output transitions, if these port do not exist. If the ports corresponding to some transitions already exist, do nothing with respect to those transitions.
-
combineInternalTransitions
public void combineInternalTransitions()
Combine each chain of internal transitions into one transition. This method iterates through all the states. If a state has just one incoming and one outgoing internal transitions, and it is not the initial state, it is removed and the two transitions are combined into one. The label on the new transition is formed by <incomingLabel><NAME_CONNECTOR><outgoingLabel>.
-
compose
public InterfaceAutomaton compose(InterfaceAutomaton automaton) throws IllegalActionException
Return a new InterfaceAutomaton that is the composition of the specified InterfaceAutomaton and this one.- Parameters:
automaton
- An InterfaceAutomaton to compose with this one.- Returns:
- An InterfaceAutomaton that is the composition.
- Throws:
IllegalActionException
- If this automaton is not composable with the argument.
-
compose
public InterfaceAutomaton compose(InterfaceAutomaton automaton, boolean considerTransient) throws IllegalActionException
Return a new InterfaceAutomaton that is the composition of the specified InterfaceAutomaton and this one.- Parameters:
automaton
- An InterfaceAutomaton to compose with this one.considerTransient
- True to indicate that transient states should be treated differently; false to indicate that transient states are treated as regular ones.- Returns:
- An InterfaceAutomaton that is the composition.
- Throws:
IllegalActionException
- If this automaton is not composable with the argument.
-
computeAlternatingSimulation
public java.util.Set computeAlternatingSimulation(InterfaceAutomaton subAutomaton) throws IllegalActionException
Return the unique maximal alternating simulation from the specified automaton to this automaton. Alternating simulation is a binary relation defined in the interface automata paper. If P and Q are two interface automata, and Vp and Vq are their states, an alternating simulation is a subset of Vp x Vq that satisfies the conditions described in the paper. This method computes such a subset. If this subset is not empty, we say that there is an alternating simulation from Q to P. In this class, we call the automaton P the super automaton, and Q the sub automaton.This method returns a set of instances of StatePair. The first state in each pair is in the super automaton, and the second state is in the sub automaton.
- Parameters:
subAutomaton
- An interface automaton.- Returns:
- A set representing the alternating simulation.
- Throws:
IllegalActionException
- If this automaton or the specified one is not consistent. For example, missing ports.- See Also:
StatePair
-
deadlockStates
public java.util.Set deadlockStates() throws IllegalActionException
Return the deadlock states in a Set. A state is a deadlock state if it does not have any outgoing transitions.- Returns:
- A Set of deadlock states.
- Throws:
IllegalActionException
- If this automaton is not closed.
-
epsilonClosure
public java.util.Set epsilonClosure(State state)
Return the epsilon-closure of the specified state. Epsilon-closure is defined in Definition 11 of the interface automaton paper. It is the set of states that can be reached from the specified state by taking only internal transitions.- Parameters:
state
- The state from which the epsilon-closure is computed.- Returns:
- A set of instances of State.
-
externallyEnabledDestinations
public java.util.Set externallyEnabledDestinations(State sourceState, java.lang.String transitionLabel)
Return the set of externally enabled destination states. This set is defined in Definition 13 of the interface automaton paper. The caller should ensure that the specified transition label is for an externally enabled input or output transition. This method assumes this is true without checking.- Parameters:
sourceState
- The source state from which the externally enabled destinations are computed.transitionLabel
- The label for an externally enabled transition.- Returns:
- A set of instances of State.
-
externallyEnabledInputTransitionLabels
public java.util.Set externallyEnabledInputTransitionLabels(State state)
Return the labels for the set of externally enabled input transitions for the specified state. This set is defined in Definition 12 of the interface automaton paper.- Parameters:
state
- The state for which the externally enabled input transitions are computed.- Returns:
- A set of string.
-
externallyEnabledOutputTransitionLabels
public java.util.Set externallyEnabledOutputTransitionLabels(State state)
Return the labels for the set of externally enabled output transitions for the specified state. This set is defined in Definition 12 of the interface automaton paper.- Parameters:
state
- The state for which the externally enabled output transitions are computed.- Returns:
- A set of string.
-
fire
public void fire() throws IllegalActionException
Choose the enabled transition among the outgoing transitions of the current state. Throw an exception if there is more than one transition enabled.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classFSMActor
- Throws:
IllegalActionException
- If there is more than one transition enabled.
-
getInfo
public java.lang.String getInfo()
Return a high-level description of this automaton. The returned String has the format:(full name of automaton): (number of states) states (number of transitions) transitions (number of input names) input names (number of output names) output names (number of internal transition names) internal transition names Input Names: (list of input names) Output Names: (list of output names) Internal Transition Names: (list of internal transition names)
- Returns:
- A high-level description of this automaton.
-
inputNameSet
public java.util.Set inputNameSet()
Return the names of the input ports as a Set.- Returns:
- A Set containing all the input port names.
-
internalTransitionNameSet
public java.util.Set internalTransitionNameSet()
Return the names of the internal transitions as a Set.- Returns:
- A Set containing all the internal transition names.
-
isClosed
public boolean isClosed()
Return true if this automaton does not have any input and output; false otherwise.- Returns:
- True if this automaton does not have any input and output.
-
isEmpty
public boolean isEmpty()
Return true if this automaton is empty; false otherwise.- Returns:
- true if this automaton is empty; false otherwise.
-
newRelation
public ComponentRelation newRelation(java.lang.String name) throws IllegalActionException, NameDuplicationException
Create a new instance of InterfaceAutomatonTransition with the specified name in this actor, and return it. This method is write-synchronized on the workspace.- Overrides:
newRelation
in classFSMActor
- Parameters:
name
- The name of the new transition.- Returns:
- An InterfaceAutomatonTransition with the given name.
- Throws:
IllegalActionException
- If the name argument is null.NameDuplicationException
- If name collides with that of a transition already in this actor.
-
outputNameSet
public java.util.Set outputNameSet()
Return the names of the output ports as a Set.- Returns:
- A Set containing all the output port names.
-
project
public void project(InterfaceAutomaton automaton) throws IllegalActionException
Project this automaton into the specified one. More specifically, this method converts the input and output transitions of this automaton that do not overlap with the specified one to internal transitions, and remove the corresponding ports.- Parameters:
automaton
- The interface automaton to which this automaton will be projected.- Throws:
IllegalActionException
- If this or the specified automaton is not consistent. For example, missing ports.
-
reacheableAlternatingSimulation
public static java.util.Set reacheableAlternatingSimulation(java.util.Set alternatingSimulation, InterfaceAutomaton superAutomaton, InterfaceAutomaton subAutomaton) throws IllegalActionException
Return the reacheable state pairs in the specified alternating simulation. A state pair is reacheable if they can be reached from the initial states of their corresponding automata through the same input or output transitions, or internal transitions. The internal transitions in the two automata that are taken to reach a state pair do not have to be the same.- Parameters:
alternatingSimulation
- A set of instances of StatePair.superAutomaton
- The automaton that contains the first state in the state pairs in alternatingSimulation.subAutomaton
- The automaton that contains the second state in the state pairs in alternatingSimulation.- Returns:
- A set of instances of StatePair that only contain the reacheable state pairs in alternatingSimulation.
- Throws:
IllegalActionException
- If thrown by getInitialState().
-
renameTransitionLabels
public void renameTransitionLabels(java.util.Map nameMap) throws IllegalActionException, NameDuplicationException
Rename the labels on some transitions. The argument is a Map specifying which transition labels should be renamed. The keys of the Map are the old label names, and the values are the new label names. Neither the keys nor the values should include the ending character "?", "!", or ";" that indicate the type of the transition. And this method does not change the type.For input and output transitions, this method also renames the ports associated with the renamed transitions, if these ports are created already. This is done regardless of whether there are instances of transitions that correspond to the ports. For internal transitions, this method renames the parameter associated with the renamed transition.
- Parameters:
nameMap
- A map between the old and the new label names.- Throws:
IllegalActionException
- If the new name is not legal.NameDuplicationException
- If the requested name change will cause name collision.
-
_addRelation
protected void _addRelation(ComponentRelation relation) throws IllegalActionException, NameDuplicationException
Add an InterfaceAutomatonTransition to this InterfaceAutomaton. This method should not be used directly. Call the setContainer() method of the transition instead. This method does not set the container of the transition to refer to this container. This method is not synchronized on the workspace, so the caller should be.- Overrides:
_addRelation
in classFSMActor
- Parameters:
relation
- The InterfaceAutomatonTransition to contain.- Throws:
IllegalActionException
- If the transition has no name, or is not an instance of Transition.NameDuplicationException
- If the name collides with a name already on the contained transitions list.
-
-