Class PiecewiseLinearRateFunction

    • Constructor Detail

      • PiecewiseLinearRateFunction

        public PiecewiseLinearRateFunction​(double duration,
                                           double secondRate)
        Constructs a PiecewiseLinearRateFunction with the first rate specified for time zero as zero
        Parameters:
        duration - The duration until the second rate
        secondRate - The rate after the supplied duration
      • PiecewiseLinearRateFunction

        public PiecewiseLinearRateFunction​(double firstRate,
                                           double duration,
                                           double secondRate)
        Constructs a PiecewiseLinearRateFunction with the first rate specified for time zero
        Parameters:
        firstRate - The rate at time zero
        duration - The duration until the second rate
        secondRate - The rate after the supplied duration
      • PiecewiseLinearRateFunction

        public PiecewiseLinearRateFunction​(double[] durations,
                                           double[] rates)
        Uses the segments represented by the rate, duration pairs The rate array must be larger than the duration array, not null, and have at least 2 rates. Any rates rate[0] beginning rate of segment 0, duration[0] duration of segment 0 i >=1 rate[i] ending rate of segment i-1, beginning rate of segment i, duration[i] duration of segment i
        Parameters:
        durations - the durations
        rates - the rates
    • Method Detail

      • addFirstSegment

        protected final void addFirstSegment​(double firstRate,
                                             double duration,
                                             double secondRate)
      • newInstance

        public PiecewiseLinearRateFunction newInstance​(double factor)
        Returns a copy of the piecewise linear rate function with each rate multiplied by the addFactor
        Specified by:
        newInstance in class PiecewiseRateFunction
        Parameters:
        factor - the addFactor to multiply
        Returns:
        a copy of the piecewise linear rate function
      • addRateSegment

        public final void addRateSegment​(double duration,
                                         double rate)
        Allows the construction of the piecewise linear rate function The user supplies the knot points on the piecewise linear function by supplying the rate at the end of the supplied duration via consecutive calls to addRateSegment().
        Specified by:
        addRateSegment in class PiecewiseRateFunction
        Parameters:
        duration - must be > 0 and less than Double.POSITIVE_INFINITY
        rate - must be >= 0, and less than Double.POSITIVE_INFINITY
      • 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:
        an int representing the interval