Class PiecewiseConstantRateFunction
- java.lang.Object
-
- jsl.modeling.elements.variable.nhpp.PiecewiseRateFunction
-
- jsl.modeling.elements.variable.nhpp.PiecewiseConstantRateFunction
-
- All Implemented Interfaces:
CumulativeRateFunctionIfc,InvertibleCumulativeRateFunctionIfc,RateFunctionIfc
public class PiecewiseConstantRateFunction extends PiecewiseRateFunction
-
-
Field Summary
-
Fields inherited from class jsl.modeling.elements.variable.nhpp.PiecewiseRateFunction
myMaxRate, myMinRate, myRateSegments
-
-
Constructor Summary
Constructors Constructor Description 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 pairPiecewiseConstantRateFunction(double duration, double rate)Creates a PiecewiseConstantRateFunction given the first duration and rate pair, other pairs are added via addRateSegment()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddFirstSegment(double duration, double rate)voidaddRateSegment(double duration, double rate)Allows the construction of the piecewise rate function starting at time zero.booleancontains(double time)Returns true if the supplied time is within the time range of the rate functionintfindTimeInterval(double time)Searches for the interval that the supplied time falls within.double[]getDurations()Get the durations as an arraydouble[]getRates()Get the rates as an arrayvoidmultiplyRates(double factor)Multiplies each rate by the addFactor.PiecewiseConstantRateFunctionnewInstance()Returns a copy of the piecewise constance rate functionPiecewiseConstantRateFunctionnewInstance(double factor)Returns a copy of the piecewise constance rate function with each rate multiplied by the addFactor-
Methods inherited from class jsl.modeling.elements.variable.nhpp.PiecewiseRateFunction
findCumulativeRateInterval, getCumulativeRate, getCumulativeRateRangeLowerLimit, getCumulativeRateRangeUpperLimit, getInverseCumulativeRate, getMaximum, getMinimum, getNumberSegments, getRate, getRateSegment, getTimeRangeLowerLimit, getTimeRangeUpperLimit, toString
-
-
-
-
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 durationrate- 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 durationsrates- the rates
-
-
Method Detail
-
newInstance
public PiecewiseConstantRateFunction newInstance()
Returns a copy of the piecewise constance rate function- Specified by:
newInstancein classPiecewiseRateFunction- Returns:
- the piecewise constance rate function
-
newInstance
public PiecewiseConstantRateFunction newInstance(double factor)
Returns a copy of the piecewise constance rate function with each rate multiplied by the addFactor- Specified by:
newInstancein classPiecewiseRateFunction- 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:
addRateSegmentin classPiecewiseRateFunction- Parameters:
rate- must be > 0, and less than Double.POSITIVE_INFINITYduration- 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:
getRatesin classPiecewiseRateFunction- Returns:
- the rates as an array
-
getDurations
public double[] getDurations()
Get the durations as an array- Specified by:
getDurationsin classPiecewiseRateFunction- Returns:
- the durations as an array
-
contains
public final boolean contains(double time)
Description copied from interface:RateFunctionIfcReturns 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:
findTimeIntervalin classPiecewiseRateFunction- Parameters:
time- the time to look up- Returns:
- the index of the interval
-
-