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 void
addFirstSegment(double duration, double rate)
void
addRateSegment(double duration, double rate)
Allows the construction of the piecewise rate function starting at time zero.boolean
contains(double time)
Returns true if the supplied time is within the time range of the rate functionint
findTimeInterval(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 arrayvoid
multiplyRates(double factor)
Multiplies each rate by the addFactor.PiecewiseConstantRateFunction
newInstance()
Returns a copy of the piecewise constance rate functionPiecewiseConstantRateFunction
newInstance(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:
newInstance
in 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:
newInstance
in 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:
addRateSegment
in 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:
getRates
in classPiecewiseRateFunction
- Returns:
- the rates as an array
-
getDurations
public double[] getDurations()
Get the durations as an array- Specified by:
getDurations
in classPiecewiseRateFunction
- 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 classPiecewiseRateFunction
- Parameters:
time
- the time to look up- Returns:
- the index of the interval
-
-