|
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.stat.mperiods.SumMatrix
umontreal.iro.lecuyer.stat.mperiods.SumMatrixSW
public class SumMatrixSW
Extends SumMatrix
to add a sliding window. By using a circular buffer
to store the values, it can compute observations for all the periods or for a
subset of the periods.
When values are added to this matrix of sums using the add(int, int, double)
method,
the index of a real period needs to be specified. When obtaining a
value from this object, the index of a stored period (or simply a
period) is needed. If the number of considered periods is smaller than or
equal to the number of stored periods, these two index spaces match, no
information is lost, and this class behaves exactly as SumMatrix
.
This is the most common case.
However, if the number of real periods is greater than the number of stored
periods, some values are lost. Only the values from the last periods are
accessible at any time. For example, if a matrix of sums is defined to store
10 periods, values for the periods 0 to 9 are available until the
add(int, int, double)
method is required to add a value in the period 10 or greater.
After a value is added into the real period 10, values for the period 0 are
lost. The stored periods are shifted and stored periods 0 to 9 then
correspond to real periods 1 to 10. This facility allows, for example, to
compute a statistic for the last ten minutes, at any times during a
simulation.
Field Summary |
---|
Fields inherited from class umontreal.iro.lecuyer.stat.mperiods.SumMatrix |
---|
count, numPeriods, numStoredPeriods, numTypes |
Constructor Summary | |
---|---|
SumMatrixSW(int numTypes)
Constructs a new matrix of sums with sliding window for numTypes event types and a single period. |
|
SumMatrixSW(int numTypes,
int numPeriods)
Constructs a new matrix of sums with sliding window for numTypes event types and numPeriods periods. |
Method Summary | |
---|---|
void |
add(int type,
int realPeriod,
double x)
Adds a new observation x of type type in the real period realPeriod. |
void |
add(int type,
int realPeriod,
double x,
DoubleDoubleFunction fn)
Similar to int, double) , but applies
a function fn instead of just adding. |
int |
getFirstRealPeriod()
Returns the real period corresponding to stored period having index 0 when using the SumMatrix.getMeasure(int, int) method. |
int |
getNumRealPeriods()
Returns the number of real periods used by this matrix of sums. |
protected int |
getPeriod(int p)
Returns the period index corresponding to period p. |
void |
init()
Initializes this matrix of measures for a new simulation replication. |
protected void |
regroupPeriods(int x,
boolean onlyFirst)
Similar to SumMatrix.regroupPeriods(int) , but if onlyFirst is
false, do not sum the values in each group. |
void |
set(int type,
int realPeriod,
double x)
Sets the sum for event type in real period realPeriod for this matrix to x. |
void |
setFirstRealPeriod(int firstRealPeriod)
Sets the index of the first real period to firstRealPeriod. |
void |
setNumPeriods(int np)
Sets the number of periods to np. |
Methods inherited from class umontreal.iro.lecuyer.stat.mperiods.SumMatrix |
---|
clone, getMeasure, getNumMeasures, getNumPeriods, getNumStoredPeriods, regroupPeriods, setNumMeasures, toString |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SumMatrixSW(int numTypes)
numTypes
- the number of event types.
IllegalArgumentException
- if the number of types is negative.public SumMatrixSW(int numTypes, int numPeriods)
numTypes
- the number of event types.numPeriods
- the number of stored periods.
IllegalArgumentException
- if the number of types or periods is negative.Method Detail |
---|
public int getFirstRealPeriod()
SumMatrix.getMeasure(int, int)
method. If no period is currently lost, this
returns 0.
public void setFirstRealPeriod(int firstRealPeriod)
firstRealPeriod
- the new index of the first real period.
IllegalArgumentException
- if firstRealPeriod is negative.public int getNumRealPeriods()
add(int, int, double)
or set(int, int, double)
since the last call to init()
. In
contrast with the similar method SumMatrix.getNumStoredPeriods()
, the
returned value can be greater than SumMatrix.getNumPeriods()
.
public void add(int type, int realPeriod, double x)
getFirstRealPeriod()
, ...,
getFirstRealPeriod()
+ SumMatrix.getNumPeriods()
-
1], which we will call the current interval, a new value is added; the
corresponding measure is increased by x. If the period is at the
left of the current interval, an exception is thrown. Otherwise, the
window of observations slides and getFirstRealPeriod()
is
increased; some computed values are then lost.
add
in class SumMatrix
type
- the type of the new value.realPeriod
- the real period of the new value.x
- the value being added.
ArrayIndexOutOfBoundsException
- if type or realPeriod are negative, if
type is greater than or equal to the number of
supported types, or if realPeriod is smaller than
getFirstRealPeriod()
.public void add(int type, int realPeriod, double x, DoubleDoubleFunction fn)
SumMatrix
int, double)
, but applies
a function fn instead of just adding.
More specifically, if c is the original value in the matrix, and
x is the new value, this method adds the value f (c, x) at the given
position in the matrix.
add
in class SumMatrix
public void set(int type, int realPeriod, double x)
add(int, int, double)
method
except the measure is replaced by x instead of being incremented.
set
in class SumMatrix
type
- the type of the event.realPeriod
- the real period of the event.x
- the new value.
ArrayIndexOutOfBoundsException
- if type or realPeriod are negative, if
type is greater than or equal to the number of
supported types, or if realPeriod is smaller than
getFirstRealPeriod()
.public void init()
MeasureMatrix
init
in interface MeasureMatrix
init
in class SumMatrix
public void setNumPeriods(int np)
SumMatrix
SumMatrix.setNumMeasures(int)
,
added periods are initialized to 0 and the last periods are removed if
necessary.
setNumPeriods
in interface MeasureMatrix
setNumPeriods
in class SumMatrix
np
- the new number of periods.protected void regroupPeriods(int x, boolean onlyFirst)
SumMatrix
SumMatrix.regroupPeriods(int)
, but if onlyFirst is
false, do not sum the values in each group.
regroupPeriods with onlyFirst = false is internally used
by IntegralMeasureMatrix
.
regroupPeriods
in class SumMatrix
protected int getPeriod(int p)
SumMatrix
SumMatrixSW
to take
the sliding window into account.
getPeriod
in class SumMatrix
p
- the source period index.
|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |