Class 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)
    • 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 interface Executable
        Overrides:
        fire in class FSMActor
        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.
      • 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 class FSMActor
        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.