Class PiecewiseRateFunction
- java.lang.Object
-
- jsl.modeling.elements.variable.nhpp.PiecewiseRateFunction
-
- All Implemented Interfaces:
CumulativeRateFunctionIfc
,InvertibleCumulativeRateFunctionIfc
,RateFunctionIfc
- Direct Known Subclasses:
PiecewiseConstantRateFunction
,PiecewiseLinearRateFunction
public abstract class PiecewiseRateFunction extends java.lang.Object implements InvertibleCumulativeRateFunctionIfc
-
-
Field Summary
Fields Modifier and Type Field Description protected double
myMaxRate
protected double
myMinRate
protected java.util.List<RateSegmentIfc>
myRateSegments
-
Constructor Summary
Constructors Constructor Description PiecewiseRateFunction()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
addRateSegment(double duration, double rate)
Adds a rate segment to the functionint
findCumulativeRateInterval(double cumRate)
Searches for the interval that the supplied cumulative rate falls within.abstract int
findTimeInterval(double time)
Searches for the interval that the supplied time falls within.double
getCumulativeRate(double time)
Returns the value of the cumulative rate function at the supplied timedouble
getCumulativeRateRangeLowerLimit()
The function's lower limit on the cumulative rate rangedouble
getCumulativeRateRangeUpperLimit()
The function's upper limit on the cumulative rate rangeabstract double[]
getDurations()
Get the durations as an arraydouble
getInverseCumulativeRate(double rate)
Returns the value of the inverse cumulative rate function at the supplied rate The value returned is interpreted as a timedouble
getMaximum()
Gets the maximum value of the rate function over its time horizondouble
getMinimum()
Gets the minimum value of the rate function over its time horizonint
getNumberSegments()
Returns the number of segmentsdouble
getRate(double time)
Returns the rate for the supplied timeabstract double[]
getRates()
Get the rates as an arrayRateSegmentIfc
getRateSegment(int k)
Returns the rate segment at index k Interval indexing starts at index 0 (i.e.double
getTimeRangeLowerLimit()
The function's lower limit on the time rangedouble
getTimeRangeUpperLimit()
The function's upper limit on the time rangeabstract PiecewiseRateFunction
newInstance()
Returns a copy of the piecewise rate functionabstract PiecewiseRateFunction
newInstance(double factor)
Returns a copy of the piecewise rate function with each rate multiplied by the addFactorjava.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jsl.modeling.elements.variable.nhpp.RateFunctionIfc
contains
-
-
-
-
Field Detail
-
myRateSegments
protected java.util.List<RateSegmentIfc> myRateSegments
-
myMaxRate
protected double myMaxRate
-
myMinRate
protected double myMinRate
-
-
Method Detail
-
addRateSegment
public abstract void addRateSegment(double duration, double rate)
Adds a rate segment to the function- Parameters:
duration
- the durationrate
- 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 interfaceRateFunctionIfc
- 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 interfaceRateFunctionIfc
- Returns:
- The function's upper limit on the time range
-
getCumulativeRateRangeLowerLimit
public final double getCumulativeRateRangeLowerLimit()
Description copied from interface:CumulativeRateFunctionIfc
The function's lower limit on the cumulative rate range- Specified by:
getCumulativeRateRangeLowerLimit
in interfaceCumulativeRateFunctionIfc
- Returns:
- The function's lower limit on the cumulative rate range
-
getCumulativeRateRangeUpperLimit
public final double getCumulativeRateRangeUpperLimit()
Description copied from interface:CumulativeRateFunctionIfc
The function's upper limit on the cumulative rate range- Specified by:
getCumulativeRateRangeUpperLimit
in interfaceCumulativeRateFunctionIfc
- Returns:
- The function's upper limit on the cumulative rate range
-
getRate
public final double getRate(double time)
Returns the rate for the supplied time- Specified by:
getRate
in interfaceRateFunctionIfc
- 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 interfaceCumulativeRateFunctionIfc
- 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 interfaceInvertibleCumulativeRateFunctionIfc
- 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 interfaceRateFunctionIfc
- 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 interfaceRateFunctionIfc
- Returns:
- Gets the minimum value of the rate function over its time horizon
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-