Class MooreMachine

java.lang.Object
ca.uqac.lif.cep.Processor
ca.uqac.lif.cep.SynchronousProcessor
ca.uqac.lif.cep.fsm.MooreMachine
All Implemented Interfaces:
ca.uqac.lif.cep.Contextualizable, ca.uqac.lif.cep.Duplicable, ca.uqac.lif.cep.DuplicableProcessor, ca.uqac.lif.cep.Stateful

public class MooreMachine extends ca.uqac.lif.cep.SynchronousProcessor implements ca.uqac.lif.cep.Stateful
A finite-state automaton with output symbols associated to its states. Its input arity is not fixed to 1, i.e. it can read events from multiple traces at once. (Although, theoretically, this can be reduced to the unary case, so this is not a genuine generalization.)

A "classical" finite-state automaton is a particular case of Moore machine where one simply ignores any output symbols. In that context, accepting and rejecting states can simply be associated to two different, arbitrary symbols (e.g. true and false).

Author:
Sylvain Hallé
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Represents a transition in the Moore machine

    Nested classes/interfaces inherited from class ca.uqac.lif.cep.SynchronousProcessor

    ca.uqac.lif.cep.SynchronousProcessor.InputPushable, ca.uqac.lif.cep.SynchronousProcessor.OutputPullable

    Nested classes/interfaces inherited from class ca.uqac.lif.cep.Processor

    ca.uqac.lif.cep.Processor.InternalProcessorState
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    The current state the machine is in
    protected Set<ca.uqac.lif.cep.functions.ContextAssignment>
    The initial assignments given to each variable
    protected int
    The initial state of the machine
    protected Map<Integer,Integer>
    A map storing the last event position for each state
    protected List<Integer>
    A map storing the last loopless path
    protected Map<Integer,ca.uqac.lif.cep.functions.Function[]>
    Associates output symbols to the states of the machine
    A map from a state to the list of transitions from that state

    Fields inherited from class ca.uqac.lif.cep.SynchronousProcessor

    m_inputPushables, m_outputPullables, m_tempQueue

    Fields inherited from class ca.uqac.lif.cep.Processor

    m_context, m_hasBeenNotifiedOfEndOfTrace, m_inputArity, m_inputPullables, m_inputQueues, m_notifiedEndOfTraceDownstream, m_outputArity, m_outputPushables, m_outputQueues, MAX_PULL_RETRIES, s_versionString
  • Constructor Summary

    Constructors
    Constructor
    Description
    MooreMachine(int in_arity, int out_arity)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addInitialAssignment(ca.uqac.lif.cep.functions.ContextAssignment asg)
     
    addSymbol(int state, ca.uqac.lif.cep.functions.Function symbol)
    Associates an output symbol (i.e.
    addSymbols(int state, ca.uqac.lif.cep.functions.Function... symbols)
    Associates output symbols (i.e.
    Adds a transition to the machine
    protected void
    assignToContext(ca.uqac.lif.cep.functions.ContextAssignment asg)
     
    protected boolean
    compute(Object[] inputs, Queue<Object[]> outputs)
     
    duplicate(boolean with_state)
     
    protected boolean
    fire(MooreMachine.Transition t, Object[] inputs, Object[] outputs)
    Fires a transition and updates the machine's state
     
    void
     

    Methods inherited from class ca.uqac.lif.cep.SynchronousProcessor

    getPullableOutput, getPushableInput

    Methods inherited from class ca.uqac.lif.cep.Processor

    allNotifiedEndOfTrace, allNull, copyInputQueue, copyOutputQueue, duplicate, duplicateInto, equals, getAt, getContext, getContext, getEmptyQueue, getId, getInputArity, getInputQueue, getInputType, getInputTypesFor, getOutputArity, getOutputQueue, getOutputType, getPullableInput, getPullableOutput, getPushableInput, getPushableOutput, hashCode, leftShift, newContext, onEndOfTrace, or, or, or, printState, readState, rightShift, setContext, setContext, setPullableInput, setPushableOutput, start, startAll, stop, stopAll

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • m_relation

      protected Map<Integer,List<MooreMachine.Transition>> m_relation
      A map from a state to the list of transitions from that state
    • m_outputSymbols

      protected Map<Integer,ca.uqac.lif.cep.functions.Function[]> m_outputSymbols
      Associates output symbols to the states of the machine
    • m_currentState

      protected int m_currentState
      The current state the machine is in
    • m_initialState

      protected int m_initialState
      The initial state of the machine
    • m_lastOccurrences

      protected Map<Integer,Integer> m_lastOccurrences
      A map storing the last event position for each state
    • m_looplessPath

      protected List<Integer> m_looplessPath
      A map storing the last loopless path
    • m_initialAssignments

      protected Set<ca.uqac.lif.cep.functions.ContextAssignment> m_initialAssignments
      The initial assignments given to each variable
  • Constructor Details

    • MooreMachine

      public MooreMachine(int in_arity, int out_arity)
  • Method Details

    • addInitialAssignment

      public void addInitialAssignment(ca.uqac.lif.cep.functions.ContextAssignment asg)
    • assignToContext

      protected void assignToContext(ca.uqac.lif.cep.functions.ContextAssignment asg)
    • reset

      public void reset()
      Overrides:
      reset in class ca.uqac.lif.cep.Processor
    • addSymbols

      public MooreMachine addSymbols(int state, ca.uqac.lif.cep.functions.Function... symbols)
      Associates output symbols (i.e. event) to a state of the Moore machine
      Parameters:
      state - The state
      symbols - The symbols to associate. This will be the output event produced whenever the machine takes a transition ending in that state. There should be as many symbols as the output arity of the machine
      Returns:
      A reference to the current Moore machine
    • addSymbol

      public MooreMachine addSymbol(int state, ca.uqac.lif.cep.functions.Function symbol)
      Associates an output symbol (i.e. event) to a state of the Moore machine
      Parameters:
      state - The state
      symbol - The symbol to associate. This will be the output event produced whenever the machine takes a transition ending in that state. There should be as many symbols as the output arity of the machine. Therefore this method should only be called on a Moore machine of output arity 1.
      Returns:
      A reference to the current Moore machine
    • addTransition

      public MooreMachine addTransition(int source, MooreMachine.Transition t)
      Adds a transition to the machine
      Parameters:
      source - The source state
      t - The transition to add
      Returns:
      A reference to the current Moore machine
    • compute

      protected boolean compute(Object[] inputs, Queue<Object[]> outputs) throws ca.uqac.lif.cep.ProcessorException
      Specified by:
      compute in class ca.uqac.lif.cep.SynchronousProcessor
      Throws:
      ca.uqac.lif.cep.ProcessorException
    • fire

      protected boolean fire(MooreMachine.Transition t, Object[] inputs, Object[] outputs)
      Fires a transition and updates the machine's state
      Parameters:
      t - The transition to fire
      inputs - The inputs that caused the transition to fire
      outputs - Any output symbol associated with the destination state, null otherwise
      Returns:
      true if an output symbol is produced, false otherwise
    • duplicate

      public MooreMachine duplicate(boolean with_state)
      Specified by:
      duplicate in interface ca.uqac.lif.cep.Duplicable
      Specified by:
      duplicate in class ca.uqac.lif.cep.Processor
    • getState

      public Object getState()
      Specified by:
      getState in interface ca.uqac.lif.cep.Stateful