Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## umontreal.iro.lecuyer.stat.mperiods
Class IntegralMeasureMatrix<M extends MeasureMatrix>

    java.lang.Object
      umontreal.iro.lecuyer.stat.mperiods.IntegralMeasureMatrix<M>

All Implemented Interfaces:
  Cloneable, MeasureMatrix

Direct Known Subclasses:
  IntegralMeasureMatrixSW, NonStationaryMeasureMatrix

    public class IntegralMeasureMatrix<M extends MeasureMatrix>

extends Object
implements MeasureMatrix, Cloneable

Computes per-period values for a matrix of measures with a single period. Some matrices of measures only support a single period. For example, when using an `Accumulate` object to compute an integral over simulation time, per-period measures cannot be computed directly. This class can be used to transform a matrix of measures with a single period computing integrals into a multiple-periods matrix.

Let fi(t) be an integral (or a sum) for measure i, computed by the underlying single-period matrix over the simulation time, from 0 to t. Often, fi(t) is a discrete function such as a sum or the integral of a piecewise-constant function, but the function can also be continuous. If `newRecord()` is called at simulation time tp, the value of (tp) = (f0(tp), f1(tp),…) is computed and recorded. At time t0 where `init()` is called, a record is automatically added with the values in the matrices of measures. At the end of the simulation, if `newRecord()` was called P times, we have P + 1 recorded values of (tp), for p = 0,…, P. This permits the computation of P vectors of integrals, each corresponding to a period. The integrals for period `p`, i.e., during the interval [tp, tp+1), are computed by (tp+1) - (tp).

Constructor Summary
`IntegralMeasureMatrix(M mat, int numPeriods)` Constructs a new matrix of measures for computing integrals on multiple periods.

Method Summary
`IntegralMeasureMatrix<M>` | `clone()`
`protected SumMatrix` | `createSumMatrix(int nm, int np)` This methods creates and returns the internal sum matrix, and is overridden in `IntegralMeasureMatrixSW` to create an instance of `SumMatrixSW` instead.
`double` | `getMeasure(int i, int p)` Returns the measure `i` for period `p`.
`M` | `getMeasureMatrix()` Returns the associated single-period matrix of measures.
`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` | `getNumStoredRecords()` Returns the current number of records of (t) available for this matrix of measures.
`protected int` | `getPeriod()` Returns the period, in `mpc`, the new record needs to be added in.
`double` | `getSum(int i, int r)` Returns fi(tr), the measure `i` of the associated measure matrix at the simulation time tr.
`SumMatrix` | `getSumMatrix()` Returns the internal sum matrix for which each period p contains the value of (tp).
`void` | `init()` Initializes this matrix of measures for a new simulation replication.
`void` | `newRecord()` Records the current values of (t).
`void` | `regroupPeriods(int x)` Increases the length of stored periods by regrouping them.
`void` | `setMeasureMatrix(M mat)` Sets the associated matrix of measures to `mat`.
`void` | `setNumMeasures(int nm)` Sets the number of measures to `nm`.
`void` | `setNumPeriods(int numPeriods)` Sets the number of periods of this matrix to `np`.
`String` | `toString()`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### IntegralMeasureMatrix

    public IntegralMeasureMatrix(M mat,
                                 int numPeriods)

  Constructs a new matrix of measures for computing integrals on multiple periods. The wrapped matrix of measures is given by `mat`, and the integral is computed for `numPeriods`. The object will be able to record `numPeriods+1` values of (t). The number of measures or periods of `mat` should not be changed after it is associated with this object.

  Parameters:
    `mat` - the single-period matrix of measures.
    `numPeriods` - the required number of periods.
  Throws:
    `NullPointerException` - if `mat` is `null`.
    `IllegalArgumentException` - if a multiple-periods matrix of measures is given, or if `numPeriods` is smaller than 1.

Method Detail

### createSumMatrix

    protected SumMatrix createSumMatrix(int nm,
                                        int np)

  This methods creates and returns the internal sum matrix, and is overridden in `IntegralMeasureMatrixSW` to create an instance of `SumMatrixSW` instead.

  Parameters:
    `nm` - the number of measures.
    `np` - the number of periods.

### getMeasureMatrix

    public M getMeasureMatrix()

  Returns the associated single-period matrix of measures.

  Returns:
    the associated single-period matrix of measures.

### setMeasureMatrix

    public void setMeasureMatrix(M mat)

  Sets the associated matrix of measures to `mat`. This should only be called before or after `init()`.

  Parameters:
    `mat` - the new matrix of measures.
  Throws:
    `NullPointerException` - if `mat` is `null`.
    `IllegalArgumentException` - if the given matrix has multiple periods.

### getSumMatrix

    public SumMatrix getSumMatrix()

  Returns the internal sum matrix for which each period p contains the value of (tp). The number of measures of this matrix is `getNumMeasures()` while the number of periods is one more than `getNumPeriods()`.

  Returns:
    the internal matrix of sums.

### getNumStoredRecords

    public int getNumStoredRecords()

  Returns the current number of records of (t) available for this matrix of measures.

  Returns:
    the current number of records.

### newRecord

    public void newRecord()

  Records the current values of (t). This increases the number of stored records, and an `IllegalStateException` is thrown if no additional record can be stored.

### getPeriod

    protected int getPeriod()

  Returns the period, in `mpc`, the new record needs to be added in. This returns `mpc.``getNumStoredPeriods()`.

  Returns:
    the period used by `newRecord()`.

### init

    public void init()

  Description copied from interface: `MeasureMatrix`
  Initializes this matrix of measures for a new simulation replication. This resets the measured values to 0, or initializes the probes used to compute them.

  Specified by:
    `init` in interface `MeasureMatrix`

### getNumMeasures

    public int getNumMeasures()

  Description copied from interface: `MeasureMatrix`
  Returns the number of measures calculated by the implementation of this interface.

  Specified by:
    `getNumMeasures` in interface `MeasureMatrix`
  Returns:
    the number of computed values.

### setNumMeasures

    public void setNumMeasures(int nm)

  Description copied from interface: `MeasureMatrix`
  Sets the number of measures to `nm`. If this method is supported, it can limit the maximal or minimal accepted number of measures.

  Specified by:
    `setNumMeasures` in interface `MeasureMatrix`
  Parameters:
    `nm` - the new number of measures.

### getNumPeriods

    public int getNumPeriods()

  Description copied from interface: `MeasureMatrix`
  Returns the number of periods stored into this matrix of measures.

  Specified by:
    `getNumPeriods` in interface `MeasureMatrix`
  Returns:
    the number of stored periods.

### setNumPeriods

    public void setNumPeriods(int numPeriods)

  Description copied from interface: `MeasureMatrix`
  Sets the number of periods of this matrix to `np`. If this method is supported, it can limit the maximal or minimal accepted number of periods.

  Specified by:
    `setNumPeriods` in interface `MeasureMatrix`
  Parameters:
    `numPeriods` - the new number of periods.

### getSum

    public double getSum(int i,
                         int r)

  Returns fi(tr), the measure `i` of the associated measure matrix at the simulation time tr.

  Parameters:
    `i` - the measure index.
    `r` - the record index.
  Returns:
    the value of the measure.
  Throws:
    `IndexOutOfBoundsException` - if `i` or `r` are out of bounds.

### getMeasure

    public double getMeasure(int i,
                             int p)

  Returns the measure `i` for period `p`. This corresponds to fi(tp+1) - fi(tp) where tp is the simulation time of the stored record p.

  Specified by:
    `getMeasure` in interface `MeasureMatrix`
  Parameters:
    `i` - the index of the measure.
    `p` - the period of the measure.
  Returns:
    the corresponding value.
  Throws:
    `IndexOutOfBoundsException` - if `i` or `p` are negative or greater than or equal to the number of measures or the number of periods, respectively.

### regroupPeriods

    public void regroupPeriods(int x)

  Description copied from interface: `MeasureMatrix`
  Increases the length of stored periods by regrouping them. If this method is supported, for `p = 0`, ..., `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.

  Specified by:
    `regroupPeriods` in interface `MeasureMatrix`
  Parameters:
    `x` - the number of periods per group.

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### clone

    public IntegralMeasureMatrix<M> clone()

  Overrides:
    `clone` in class `Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

To submit a bug or ask questions, send an e-mail to Richard Simard.