Class PiecewiseRateFunction

    • Field Detail

      • myRateSegments

        protected java.util.List<RateSegmentIfc> myRateSegments
      • myMaxRate

        protected double myMaxRate
      • myMinRate

        protected double myMinRate
    • Constructor Detail

      • PiecewiseRateFunction

        public PiecewiseRateFunction()
    • Method Detail

      • addRateSegment

        public abstract void addRateSegment​(double duration,
                                            double rate)
        Adds a rate segment to the function
        Parameters:
        duration - the duration
        rate - the rate
      • findTimeInterval

        public abstract 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)
        Parameters:
        time - the time to look for
        Returns:
        the index of the interval
      • newInstance

        public abstract PiecewiseRateFunction newInstance()
        Returns a copy of the piecewise rate function
        Returns:
        a copy of the piecewise rate function
      • newInstance

        public abstract PiecewiseRateFunction newInstance​(double factor)
        Returns a copy of the piecewise rate function with each rate multiplied by the addFactor
        Parameters:
        factor - rate multiplied by the addFactor
        Returns:
        a copy of the piecewise
      • getRates

        public abstract double[] getRates()
        Get the rates as an array
        Returns:
        the rates as an array
      • getDurations

        public abstract double[] getDurations()
        Get the durations as an array
        Returns:
        the durations as an array
      • getTimeRangeLowerLimit

        public final double getTimeRangeLowerLimit()
        Description copied from interface: RateFunctionIfc
        The function's lower limit on the time range
        Specified by:
        getTimeRangeLowerLimit in interface RateFunctionIfc
        Returns:
        The function's lower limit on the time range
      • getTimeRangeUpperLimit

        public final double getTimeRangeUpperLimit()
        Description copied from interface: RateFunctionIfc
        The function's upper limit on the time range
        Specified by:
        getTimeRangeUpperLimit in interface RateFunctionIfc
        Returns:
        The function's upper limit on the time range
      • getRate

        public final double getRate​(double time)
        Returns the rate for the supplied time
        Specified by:
        getRate in interface RateFunctionIfc
        Parameters:
        time - the time to evaluate
        Returns:
        the rate for the supplied time
      • getCumulativeRate

        public final double getCumulativeRate​(double time)
        Returns the value of the cumulative rate function at the supplied time
        Specified by:
        getCumulativeRate in interface CumulativeRateFunctionIfc
        Parameters:
        time - the time to evaluate
        Returns:
        the value of the cumulative rate function
      • getInverseCumulativeRate

        public final double getInverseCumulativeRate​(double rate)
        Returns the value of the inverse cumulative rate function at the supplied rate The value returned is interpreted as a time
        Specified by:
        getInverseCumulativeRate in interface InvertibleCumulativeRateFunctionIfc
        Parameters:
        rate - the rate
        Returns:
        the value of the inverse cumulative rate function
      • findCumulativeRateInterval

        public int findCumulativeRateInterval​(double cumRate)
        Searches for the interval that the supplied cumulative rate 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)
        Parameters:
        cumRate - the rate
        Returns:
        the interval that the supplied cumulative rate
      • getRateSegment

        public RateSegmentIfc getRateSegment​(int k)
        Returns the rate segment at index k Interval indexing starts at index 0 (i.e. 0 is the first interval, silly Java zero based indexing)
        Parameters:
        k - the index
        Returns:
        the rate segment at index k
      • getNumberSegments

        public int getNumberSegments()
        Returns the number of segments
        Returns:
        the number of segments
      • getMaximum

        public final double getMaximum()
        Description copied from interface: RateFunctionIfc
        Gets the maximum value of the rate function over its time horizon
        Specified by:
        getMaximum in interface RateFunctionIfc
        Returns:
        Gets the maximum value of the rate function over its time horizon
      • getMinimum

        public final double getMinimum()
        Description copied from interface: RateFunctionIfc
        Gets the minimum value of the rate function over its time horizon
        Specified by:
        getMinimum in interface RateFunctionIfc
        Returns:
        Gets the minimum value of the rate function over its time horizon
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object