|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectumontreal.iro.lecuyer.randvar.RandomVariateGen
umontreal.iro.lecuyer.contactcenters.MultiPeriodGen
public class MultiPeriodGen
Represents a random variate generator for non-stationary distributions with constant parameters during each period. When a new random variate is required, a random variate generator corresponding to the appropriate period is selected and a value is drawn from this generator.
This generator supports caching by using internal
RandomVariateGenWithCache
instances for each period. If a single
cache was used, the generator could recover a value whose distribution does
not correspond with the current period. Caching is disabled by default, and
can be enabled by using the setCaching(boolean)
method.
Field Summary |
---|
Fields inherited from class umontreal.iro.lecuyer.randvar.RandomVariateGen |
---|
dist, stream |
Constructor Summary | |
---|---|
MultiPeriodGen(PeriodChangeEvent pce,
RandomVariateGen gen)
Constructs a new multi-period random variate generator with period-change event pce, and random variate generator gen for every period. |
|
MultiPeriodGen(PeriodChangeEvent pce,
RandomVariateGen[] gens)
Constructs a new multi-period random variate generator with period-change event pce, and the per-period random variate generators gens. |
Method Summary | |
---|---|
void |
clearCache()
Clears the values cached by this generator. |
static MultiPeriodGen |
createConstant(PeriodChangeEvent pce,
double[] values)
Constructs and returns a multiple-periods random variate generator using the constant distribution with value values[p] for period p as defined by pce. |
static MultiPeriodGen |
createExponential(PeriodChangeEvent pce,
RandomStream stream,
double[] lambdas)
Constructs and returns a multiple-periods random variate generator using the exponential distribution with rate lambdas[p] for period p as defined by pce. |
static MultiPeriodGen |
createGamma(PeriodChangeEvent pce,
RandomStream stream,
double[] alphas,
double[] lambdas)
Constructs and returns a multiple-periods random variate generator using the gamma distribution with parameters alphas[p] and lambdas[p] for period p as defined by pce. |
DoubleArrayList[] |
getCachedValues()
Returns an array of array lists containing the values cached by each period-specific generator. |
int[] |
getCacheIndices()
Returns an array containing the cache indices of each per-period generator. |
Distribution |
getDistribution()
Returns the distribution used during the current period. |
RandomVariateGen |
getGenerator(int p)
Returns the random variate generator corresponding to the period p. |
RandomVariateGen[] |
getGenerators()
Returns the random variate generators associated with this object. |
RandomVariateGenWithCache[] |
getGeneratorsWithCache()
Returns the random variate generators with cache used by this object. |
RandomVariateGenWithCache |
getGeneratorWithCache(int p)
Returns the random variate generator with cache corresponding to the period p. |
double |
getMean(int p)
Returns the mean for period p. |
static double |
getMean(RandomVariateGen rvg)
Returns the mean of the distribution for a random variate generator, taking the shift into account. |
double |
getMult()
Returns the multiplier applied to each generated random variate. |
PeriodChangeEvent |
getPeriodChangeEvent()
Returns the period-change event associated with this object. |
TimeUnit |
getSourceTimeUnit()
Returns the time unit in which the values coming from the probability distribution are expressed. |
RandomStream |
getStream()
Returns the random stream used during the current period. |
TimeUnit |
getTargetTimeUnit()
Returns the time unit in which the values returned by nextDouble()
must be expressed. |
double |
getVariance(int p)
Returns the variance for the period p. |
void |
init()
Initializes the generator at the beginning of the simulation. |
void |
initCache()
Resets the cache of this generator, if caching is enabled. |
boolean |
isCaching()
Determines if this multiple-periods generator is caching the generated values, using internal RandomVariateGenWithCache objects. |
void |
nextArrayOfDouble(double[] v,
int start,
int n)
|
double |
nextDouble()
|
double |
nextDouble(Contact contact)
Ignores the given contact and calls nextDouble() . |
void |
setCachedValues(DoubleArrayList[] values)
Sets the array list containing the cached values to values[g] for each period-specific generator g. |
void |
setCacheIndices(int[] ind)
Sets the array of cache indices to ind. |
void |
setCaching(boolean caching)
Sets the status of the caching for this generator. |
void |
setGenerator(int p,
RandomVariateGen gen)
Sets the random variate generator for period p to gen. |
void |
setGenerators(RandomVariateGen[] gens)
Sets the per-period random variate generators to gens. |
void |
setMult(double mult)
Sets the multiplier applied to each generated random variate to mult. |
void |
setSourceTimeUnit(TimeUnit unit)
Sets the source time unit to unit. |
void |
setTargetTimeUnit(TimeUnit unit)
Sets the target time unit to unit. |
Methods inherited from class umontreal.iro.lecuyer.randvar.RandomVariateGen |
---|
setStream, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MultiPeriodGen(PeriodChangeEvent pce, RandomVariateGen gen)
pce
- the period-change event.gen
- one random variate generator for every period.
NullPointerException
- if any argument is null.public MultiPeriodGen(PeriodChangeEvent pce, RandomVariateGen[] gens)
pce
- the period change event.gens
- one random variate generator for each period.
NullPointerException
- if any argument is null.
IllegalArgumentException
- if the length of gens does not correspond to the
number of periods.Method Detail |
---|
public boolean isCaching()
RandomVariateGenWithCache
objects. By
default, caching is disabled for better memory utilization.
public void setCaching(boolean caching)
caching
- the new status of the caching.public PeriodChangeEvent getPeriodChangeEvent()
public RandomVariateGen[] getGenerators()
public RandomVariateGenWithCache[] getGeneratorsWithCache()
IllegalStateException
.
IllegalStateException
- if caching is disabled.public void setGenerators(RandomVariateGen[] gens)
gens
- the array containing the new random variate generators.
IllegalArgumentException
- if the length of gens is invalid.
NullPointerException
- if any argument is null.public RandomVariateGen getGenerator(int p)
p
- index of the period.
ArrayIndexOutOfBoundsException
- if p is out of bounds.public RandomVariateGenWithCache getGeneratorWithCache(int p)
IllegalStateException
.
p
- index of the period.
ArrayIndexOutOfBoundsException
- if p is out of bounds.
IllegalStateException
- if caching is disabled.public void setGenerator(int p, RandomVariateGen gen)
p
- the period index.gen
- the new random variate generator.
ArrayIndexOutOfBoundsException
- if p is out of bounds.public void initCache()
nextDouble()
, until the cache is
exhausted. When there is no more cached value, random variates are
computed as usual.
public void clearCache()
public int[] getCacheIndices()
IllegalStateException
- if caching is disabled.public void setCacheIndices(int[] ind)
ind
- the new array of cache indices.
NullPointerException
- if ind is null.
IllegalArgumentException
- if ind has incorrect size.
IllegalStateException
- if caching is disabled.public DoubleArrayList[] getCachedValues()
public void setCachedValues(DoubleArrayList[] values)
values
- the array list of cached values.
NullPointerException
- if values is null.public TimeUnit getSourceTimeUnit()
public void setSourceTimeUnit(TimeUnit unit)
unit
- the source time unit.getSourceTimeUnit()
public TimeUnit getTargetTimeUnit()
nextDouble()
must be expressed. If the target unit is null, no conversion of
the generated values is performed. By default, this returns null.
public void setTargetTimeUnit(TimeUnit unit)
unit
- the target time unit.getTargetTimeUnit()
public static double getMean(RandomVariateGen rvg)
Distribution.getMean()
on the distribution associated with the generator.
If rvg is an instance of
RandomVariateGenWithShift
or
RandomVariateGenIntWithShift
, it then
subtracts the associated shift.
rvg
- the random variate generator.
public double getMean(int p)
p
- the index of the period.
public double getVariance(int p)
p
- the index of the period.
public double getMult()
public void setMult(double mult)
mult
- the new multiplier.public double nextDouble()
nextDouble
in class RandomVariateGen
public void nextArrayOfDouble(double[] v, int start, int n)
nextArrayOfDouble
in class RandomVariateGen
public RandomStream getStream()
getStream
in class RandomVariateGen
public Distribution getDistribution()
getDistribution
in class RandomVariateGen
public double nextDouble(Contact contact)
nextDouble()
.
nextDouble
in interface ValueGenerator
contact
- the contact being concerned.
public void init()
ValueGenerator
init
in interface Initializable
init
in interface ValueGenerator
public static MultiPeriodGen createConstant(PeriodChangeEvent pce, double[] values)
pce
- the period-change event.values
- the values of the constant.
IllegalArgumentException
- if the length of array is less than the number of periods.public static MultiPeriodGen createExponential(PeriodChangeEvent pce, RandomStream stream, double[] lambdas)
pce
- the period-change event.stream
- the random stream.lambdas
- the rates for the exponential variates.
IllegalArgumentException
- if the length of array is less than the number of periods.public static MultiPeriodGen createGamma(PeriodChangeEvent pce, RandomStream stream, double[] alphas, double[] lambdas)
pce
- the period-change event.stream
- the random stream.alphas
- the alpha parameters for the gamma variates.lambdas
- the lambda parameters for the gamma variates.
IllegalArgumentException
- if the length of the arrays is less than the number of
periods, or the two arrays have different lengths.
|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |