|
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
public class SumMatrix
This matrix of measures can be used to compute sums of values, or the number
of occurrences of events. It supports several types of observations on
several simulation periods. This class supports every optional operation
specified by the MeasureMatrix
interface.
Field Summary | |
---|---|
protected double[] |
count
Array containing the sums, in row major order. |
protected int |
numPeriods
Number of periods. |
protected int |
numStoredPeriods
Number of stored periods. |
protected int |
numTypes
Number of types of events. |
Constructor Summary | |
---|---|
SumMatrix(int numTypes)
Constructs a new matrix of sums for numTypes event types and a single period. |
|
SumMatrix(int numTypes,
int numPeriods)
Constructs a new matrix of sums for numTypes event types and numPeriods periods. |
Method Summary | |
---|---|
void |
add(int type,
int period,
double x)
Adds a new observation x of type type in the period period. |
void |
add(int type,
int period,
double x,
DoubleDoubleFunction fn)
Similar to int, double) , but applies
a function fn instead of just adding. |
SumMatrix |
clone()
|
double |
getMeasure(int i,
int p)
Returns the measure corresponding to the index i and period p. |
int |
getNumMeasures()
Returns the number of measures calculated by the implementation of this interface. |
int |
getNumPeriods()
Returns the number of periods stored into this matrix of measures. |
int |
getNumStoredPeriods()
Returns the total number of periods stored in 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. |
void |
regroupPeriods(int x)
Increases the length of stored periods by regrouping them. |
protected void |
regroupPeriods(int x,
boolean onlyFirst)
Similar to regroupPeriods(int) , but if onlyFirst is
false, do not sum the values in each group. |
void |
set(int type,
int period,
double x)
Sets the sum for event type in period period for this matrix to x. |
void |
setNumMeasures(int nm)
Sets the number of measures to nm. |
void |
setNumPeriods(int np)
Sets the number of periods to np. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int numTypes
protected int numPeriods
protected int numStoredPeriods
protected double[] count
Constructor Detail |
---|
public SumMatrix(int numTypes)
numTypes
- the number of event types.
IllegalArgumentException
- if the number of types is negative.public SumMatrix(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 getNumStoredPeriods()
add(int, int, double)
or set(int, int, double)
since the last call to init()
. If
add(int, int, double)
or set(int, int, double)
were not called since the last
initialization, this returns 0. The returned value cannot be larger than
the number of stored periods (getNumPeriods()
).
public void add(int type, int period, double x)
type
- the type of the new value.period
- the period of the new value.x
- the value being added.
ArrayIndexOutOfBoundsException
- if type or period are negative, if
type is greater than or equal to the number of
supported types, or if period is greater than or
equal to the number of supported periods.public void add(int type, int period, double x, DoubleDoubleFunction fn)
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.
public void set(int type, int period, double x)
add(int, int, double)
method except
the measure is replaced by x instead of being incremented.
type
- the type of the event.period
- the period of the event.x
- the new value.
ArrayIndexOutOfBoundsException
- if type or period are negative, if
type is greater than or equal to the number of
supported types, or if period is greater than or
equal to the number of supported periods.public void init()
MeasureMatrix
init
in interface MeasureMatrix
public int getNumMeasures()
MeasureMatrix
getNumMeasures
in interface MeasureMatrix
public void setNumMeasures(int nm)
getNumMeasures()
, new measures are added and initialized to 0. If
nm is smaller than getNumMeasures()
, the last
getNumMeasures()
- nm measures are removed. Otherwise,
nothing happens.
setNumMeasures
in interface MeasureMatrix
nm
- the new number of measures.
IllegalArgumentException
- if the given number is negative.public int getNumPeriods()
MeasureMatrix
getNumPeriods
in interface MeasureMatrix
public void setNumPeriods(int np)
setNumMeasures(int)
,
added periods are initialized to 0 and the last periods are removed if
necessary.
setNumPeriods
in interface MeasureMatrix
np
- the new number of periods.
IllegalArgumentException
- if the given number is negative.public double getMeasure(int i, int p)
MeasureMatrix
getMeasure
in interface MeasureMatrix
i
- the index of the measure.p
- the period of the measure.
public String toString()
toString
in class Object
public void regroupPeriods(int x)
MeasureMatrix
MeasureMatrix.getNumPeriods()
/x -
1, it sums the values for periods xp, ...,xp+x-1,
and stores the results in period p whose length will be
x times the length of original periods. If the number of periods
is not a multiple of x, an additional period is used to contain
the remaining sums of values. The unused periods are zeroed for future
use. This method can be useful for memory management when using batch
means to estimate steady-state performance measures.
regroupPeriods
in interface MeasureMatrix
x
- the number of periods per group.protected void regroupPeriods(int x, boolean onlyFirst)
regroupPeriods(int)
, but if onlyFirst is
false, do not sum the values in each group.
regroupPeriods with onlyFirst = false is internally used
by IntegralMeasureMatrix
.
public SumMatrix clone()
clone
in class Object
protected int getPeriod(int p)
SumMatrixSW
to take
the sliding window into account.
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 |