Class PiecewiseConstantRateFunction

    • Constructor Detail

      • PiecewiseConstantRateFunction

        public PiecewiseConstantRateFunction​(double duration,
                                             double rate)
        Creates a PiecewiseConstantRateFunction given the first duration and rate pair, other pairs are added via addRateSegment()
        Parameters:
        duration - the first duration
        rate - the first rate
      • PiecewiseConstantRateFunction

        public PiecewiseConstantRateFunction​(double[] durations,
                                             double[] rates)
        Adds the segments represented by the duration, rate pairs The arrays must be the same length, not null, and have at least 1 pair
        Parameters:
        durations - the durations
        rates - the rates
    • Method Detail

      • newInstance

        public PiecewiseConstantRateFunction newInstance​(double factor)
        Returns a copy of the piecewise constance rate function with each rate multiplied by the addFactor
        Specified by:
        newInstance in class PiecewiseRateFunction
        Parameters:
        factor - multiplied by the addFactor
        Returns:
        the piecewise constance rate function
      • addFirstSegment

        protected final void addFirstSegment​(double duration,
                                             double rate)
      • addRateSegment

        public final void addRateSegment​(double duration,
                                         double rate)
        Allows the construction of the piecewise rate function starting at time zero. The user supplies the arrival rate and the duration for that arrival rate, by consecutive calls to addRateSegment().
        Specified by:
        addRateSegment in class PiecewiseRateFunction
        Parameters:
        rate - must be > 0, and less than Double.POSITIVE_INFINITY
        duration - must be > 0
      • multiplyRates

        public void multiplyRates​(double factor)
        Multiplies each rate by the addFactor. Changes each rate segment in this function
        Parameters:
        factor - the addFactor to multiply
      • getRates

        public double[] getRates()
        Get the rates as an array
        Specified by:
        getRates in class PiecewiseRateFunction
        Returns:
        the rates as an array
      • getDurations

        public double[] getDurations()
        Get the durations as an array
        Specified by:
        getDurations in class PiecewiseRateFunction
        Returns:
        the durations as an array
      • contains

        public final boolean contains​(double time)
        Description copied from interface: RateFunctionIfc
        Returns true if the supplied time is within the time range of the rate function
        Parameters:
        time - the time to evaluate
        Returns:
        true if the supplied time is within the time range
      • findTimeInterval

        public final int findTimeInterval​(double time)
        Searches for the interval that the supplied time falls within. Returns -1 if no interval is found Interval indexing starts at index 0 (i.e. 0 is the first interval, silly Java zero based indexing)
        Specified by:
        findTimeInterval in class PiecewiseRateFunction
        Parameters:
        time - the time to look up
        Returns:
        the index of the interval