Class PlateauFinder

  • All Implemented Interfaces:
    ca.uqac.lif.azrael.Printable, ca.uqac.lif.azrael.Readable, ca.uqac.lif.cep.Contextualizable, ca.uqac.lif.cep.Duplicable, ca.uqac.lif.cep.DuplicableProcessor

    public class PlateauFinder
    extends WindowProcessor
    Finds a plateau in a data stream. A plateau is found when all values in a window lie in an interval of a predetermined width. By default, the interval is of width 5 and the window is of width 5.

    The plateau finder outputs a non-zero event only for the first event of the plateau (this has to be delayed by the width of the window). It outputs zero for all other events of the plateau. Moreover, new plateau will only be looked for only once a value lies outside the current interval. For example, in the following sequence:

    Event #12345678
    Value123212108
    An output event will be emitted after reading event #5 (there are five consecutive values all within an interval of 5), indicating that event 1 is the start of a plateau, but a zero event will be produced for all other events, as they are the continuation of the current plateau.
    • Nested Class Summary

      • 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 double m_lastPlateauFound
      The value of the last plateau found.
      protected boolean m_plateauFound
      Whether an output event has been sent for the current plateau
      protected float m_range
      The range all values should lie in
      protected boolean m_relative
      Whether the height of the plateau should be relative to that of the last plateau (true), or absolute (false)
      • 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_eventTracker, m_hasBeenNotifiedOfEndOfTrace, m_inputArity, m_inputCount, m_inputPullables, m_inputQueues, m_notifiedEndOfTraceDownstream, m_outputArity, m_outputCount, m_outputPushables, m_outputQueues, MAX_PULL_RETRIES, s_versionString
    • Constructor Summary

      Constructors 
      Constructor Description
      PlateauFinder()
      Instantiates a plateau finder with default settings
      PlateauFinder​(int width)
      Instantiates a plateau finder with default settings
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean compute​(java.lang.Object[] inputs, java.util.Queue<java.lang.Object[]> outputs)  
      java.lang.Float computeOutputValue()  
      PlateauFinder duplicate​(boolean with_state)  
      void reset()  
      PlateauFinder setPlateauRange​(int range)
      Sets the range all values should lie in to be considered in the same plateau
      PlateauFinder setRelative​(boolean relative)
      Sets whether the height of the plateau should be relative to that of the last plateau (true), or absolute (false)
      • Methods inherited from class ca.uqac.lif.cep.SynchronousProcessor

        getPullableOutput, getPushableInput, setEventTracker
      • Methods inherited from class ca.uqac.lif.cep.Processor

        allNotifiedEndOfTrace, allNull, associateTo, associateToInput, associateToOutput, copyInputQueue, copyOutputQueue, duplicate, duplicateInto, equals, getAt, getContext, getContext, getEmptyQueue, getEventTracker, getId, getInputArity, getInputCount, getInputQueue, getInputType, getInputTypesFor, getLeaves, getLeaves, getOutputArity, getOutputCount, getOutputQueue, getOutputType, getPullableInput, getPullableOutput, getPushableInput, getPushableOutput, hashCode, leftShift, newContext, onEndOfTrace, or, or, print, printState, read, 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 Detail

      • m_range

        protected float m_range
        The range all values should lie in
      • m_plateauFound

        protected boolean m_plateauFound
        Whether an output event has been sent for the current plateau
      • m_relative

        protected boolean m_relative
        Whether the height of the plateau should be relative to that of the last plateau (true), or absolute (false)
      • m_lastPlateauFound

        protected double m_lastPlateauFound
        The value of the last plateau found. Remembering this value is necessary if the finder is set to "relative" mode
        See Also:
        setRelative(boolean)
    • Constructor Detail

      • PlateauFinder

        public PlateauFinder​(int width)
        Instantiates a plateau finder with default settings
        Parameters:
        width - The width of the window
      • PlateauFinder

        public PlateauFinder()
        Instantiates a plateau finder with default settings
    • Method Detail

      • setRelative

        public PlateauFinder setRelative​(boolean relative)
        Sets whether the height of the plateau should be relative to that of the last plateau (true), or absolute (false)
        Parameters:
        relative - See above
        Returns:
        A reference to the current plateau finder
      • setPlateauRange

        public PlateauFinder setPlateauRange​(int range)
        Sets the range all values should lie in to be considered in the same plateau
        Parameters:
        range - The range
        Returns:
        A reference to the current plateau finder
      • compute

        protected boolean compute​(java.lang.Object[] inputs,
                                  java.util.Queue<java.lang.Object[]> outputs)
        Specified by:
        compute in class ca.uqac.lif.cep.SynchronousProcessor
      • duplicate

        public PlateauFinder duplicate​(boolean with_state)
        Specified by:
        duplicate in interface ca.uqac.lif.cep.Duplicable
        Specified by:
        duplicate in class ca.uqac.lif.cep.Processor