Package ca.uqac.lif.cep.fsm
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 ClassesModifier and TypeClassDescriptionstatic classRepresents a transition in the Moore machineNested classes/interfaces inherited from class ca.uqac.lif.cep.SynchronousProcessor
ca.uqac.lif.cep.SynchronousProcessor.InputPushable, ca.uqac.lif.cep.SynchronousProcessor.OutputPullableNested classes/interfaces inherited from class ca.uqac.lif.cep.Processor
ca.uqac.lif.cep.Processor.InternalProcessorState -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe current state the machine is inprotected Set<ca.uqac.lif.cep.functions.ContextAssignment> The initial assignments given to each variableprotected intThe initial state of the machineA map storing the last event position for each stateA map storing the last loopless pathAssociates output symbols to the states of the machineprotected Map<Integer, List<MooreMachine.Transition>> A map from a state to the list of transitions from that stateFields inherited from class ca.uqac.lif.cep.SynchronousProcessor
m_inputPushables, m_outputPullables, m_tempQueueFields 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInitialAssignment(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.addTransition(int source, MooreMachine.Transition t) Adds a transition to the machineprotected voidassignToContext(ca.uqac.lif.cep.functions.ContextAssignment asg) protected booleanduplicate(boolean with_state) protected booleanfire(MooreMachine.Transition t, Object[] inputs, Object[] outputs) Fires a transition and updates the machine's stategetState()voidreset()Methods inherited from class ca.uqac.lif.cep.SynchronousProcessor
getPullableOutput, getPushableInputMethods 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
-
Field Details
-
m_relation
A map from a state to the list of transitions from that state -
m_outputSymbols
Associates output symbols to the states of the machine -
m_currentState
protected int m_currentStateThe current state the machine is in -
m_initialState
protected int m_initialStateThe initial state of the machine -
m_lastOccurrences
A map storing the last event position for each state -
m_looplessPath
A map storing the last loopless path -
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:
resetin classca.uqac.lif.cep.Processor
-
addSymbols
Associates output symbols (i.e. event) to a state of the Moore machine- Parameters:
state- The statesymbols- 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
Associates an output symbol (i.e. event) to a state of the Moore machine- Parameters:
state- The statesymbol- 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
Adds a transition to the machine- Parameters:
source- The source statet- 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:
computein classca.uqac.lif.cep.SynchronousProcessor- Throws:
ca.uqac.lif.cep.ProcessorException
-
fire
Fires a transition and updates the machine's state- Parameters:
t- The transition to fireinputs- The inputs that caused the transition to fireoutputs- Any output symbol associated with the destination state,nullotherwise- Returns:
trueif an output symbol is produced,falseotherwise
-
duplicate
- Specified by:
duplicatein interfaceca.uqac.lif.cep.Duplicable- Specified by:
duplicatein classca.uqac.lif.cep.Processor
-
getState
- Specified by:
getStatein interfaceca.uqac.lif.cep.Stateful
-