SSJ  3.3.1
Stochastic Simulation in Java
Classes | Public Member Functions | Protected Attributes | List of all members
MatrixOfStatProbes< E extends StatProbe > Class Template Reference

Represents a matrix of statistical probes that can be managed simultaneously. More...

Inheritance diagram for MatrixOfStatProbes< E extends StatProbe >:
[legend]
Collaboration diagram for MatrixOfStatProbes< E extends StatProbe >:
[legend]

Public Member Functions

 MatrixOfStatProbes (int numRows, int numColumns)
 Constructs a new unnamed matrix of statistical probes with numRows rows, and numColumns columns, and filled with null references. More...
 
 MatrixOfStatProbes (String name, int numRows, int numColumns)
 Constructs a new matrix of statistical probes with name name, numRows rows, and numColumns columns, and filled with null references. More...
 
String getName ()
 Returns the global name of this matrix of statistical probes. More...
 
void setName (String name)
 Sets the global name of this matrix to name. More...
 
int rows ()
 Returns the number of rows in this matrix. More...
 
int columns ()
 Returns the number of columns in this matrix. More...
 
void setRows (int newRows)
 Sets the number of rows of this matrix of statistical probes to newRows, adding or removing cells as necessary. More...
 
void setColumns (int newColumns)
 Similar to setRows(int), for setting the number of columns. More...
 
get (int r, int c)
 Returns the statistical probe corresponding to the row r and column c. More...
 
void set (int r, int c, E probe)
 Sets the statistical probe corresponding to the row r and column c to probe. More...
 
void init ()
 Initializes this matrix of statistical probes by calling StatProbe.init on each element.
 
void sum (DoubleMatrix2D m)
 For each probe in the matrix, computes the sum by calling umontreal.ssj.stat.StatProbe.sum, and stores it into the given matrix m. More...
 
void average (DoubleMatrix2D m)
 For each statistical probe in the matrix, computes the average by calling umontreal.ssj.stat.StatProbe.average, and stores it into the given matrix m. More...
 
boolean isCollecting ()
 Determines if this matrix of statistical probes is collecting values. More...
 
void setCollecting (boolean c)
 Sets the status of the statistical collecting mechanism to c. More...
 
boolean isBroadcasting ()
 Determines if this matrix of statistical probes is broadcasting values to registered observers. More...
 
void setBroadcasting (boolean b)
 Sets the status of the observation broadcasting mechanism to b. More...
 
void addMatrixOfObservationListener (MatrixOfObservationListener l)
 Adds the observation listener l to the list of observers of this matrix of statistical probes. More...
 
void removeMatrixOfObservationListener (MatrixOfObservationListener l)
 Removes the observation listener l from the list of observers of this matrix of statistical probes. More...
 
void clearMatrixOfObservationListeners ()
 Removes all observation listeners from the list of observers of this matrix of statistical probes.
 
void notifyListeners (DoubleMatrix2D x)
 Notifies the observation x to all registered observers if broadcasting is ON. More...
 
List< E > viewRow (int r)
 Returns a list representing a view on row r of this matrix of statistical probe. More...
 
List< E > viewColumn (int c)
 Returns a list representing a view on column c of this matrix of statistical probe. More...
 
String rowReport (int r)
 Formats a report for the row r of the statistical probe matrix. More...
 
String columnReport (int c)
 Formats a report for the column c of the statistical probe matrix. More...
 
MatrixOfStatProbes< E > clone ()
 Clones this object. More...
 
Iterator< E > iterator ()
 

Protected Attributes

boolean collect = true
 
boolean broadcast = false
 
String name
 

Detailed Description

Represents a matrix of statistical probes that can be managed simultaneously.

Each element of this matrix is a umontreal.ssj.stat.StatProbe instance which can be obtained and manipulated. Alternatively, several methods are provided to manipulate all probes in the matrix simultaneously.

Each matrix of probes can have a global name describing the contents of its elements, and local names for each cell. For example, a matrix of statistical probes for the waiting times can have the global name "<tt>Waiting times</tt>" while the first cell has local name "<tt>type 1, period 1</tt>".

Facilities are provided to fill matrices of sums, averages, etc. obtained from the individual statistical probes. DoubleMatrix2D is used instead of 2D arrays because it more efficiently stores the values, and it supports computations on the elements.

Constructor & Destructor Documentation

◆ MatrixOfStatProbes() [1/2]

MatrixOfStatProbes ( int  numRows,
int  numColumns 
)

Constructs a new unnamed matrix of statistical probes with numRows rows, and numColumns columns, and filled with null references.

Parameters
numRowsthe number of rows in the matrix.
numColumnsthe number of columns in the matrix.
Exceptions
NegativeArraySizeExceptionif numRows or numColumns are negative.

◆ MatrixOfStatProbes() [2/2]

MatrixOfStatProbes ( String  name,
int  numRows,
int  numColumns 
)

Constructs a new matrix of statistical probes with name name, numRows rows, and numColumns columns, and filled with null references.

Parameters
namethe global name of the matrix.
numRowsthe number of rows in the matrix.
numColumnsthe number of columns in the matrix.
Exceptions
NegativeArraySizeExceptionif numRows or numColumns are negative.

Member Function Documentation

◆ addMatrixOfObservationListener()

void addMatrixOfObservationListener ( MatrixOfObservationListener  l)

Adds the observation listener l to the list of observers of this matrix of statistical probes.

Parameters
lthe new observation listener.
Exceptions
NullPointerExceptionif l is null.

◆ average()

void average ( DoubleMatrix2D  m)

For each statistical probe in the matrix, computes the average by calling umontreal.ssj.stat.StatProbe.average, and stores it into the given matrix m.

Parameters
mthe matrix to be filled with averages.
Exceptions
NullPointerExceptionif m is null.
IllegalArgumentExceptionif m.rows() does not correspond to rows, or m.columns() does not correspond to columns.

◆ clone()

MatrixOfStatProbes<E> clone ( )

Clones this object.

This makes a shallow copy of this matrix, i.e., this does not clone all the probes in the matrix.

◆ columnReport()

String columnReport ( int  c)

Formats a report for the column c of the statistical probe matrix.

The returned string is constructed by getting a view of column c and using StatProbe.report on this list.

Parameters
cthe column being reported.
Returns
the report formatted as a string.

◆ columns()

int columns ( )

Returns the number of columns in this matrix.

Returns
the total number of columns.

◆ get()

E get ( int  r,
int  c 
)

Returns the statistical probe corresponding to the row r and column c.

Parameters
rthe row to look at.
cthe column to look at.
Returns
the corresponding statistical probe.
Exceptions
ArrayIndexOutOfBoundsExceptionif r or c are negative, if r is greater than or equal to rows, or if c is greater than or equal to columns.

◆ getName()

String getName ( )

Returns the global name of this matrix of statistical probes.

Returns
the global name of the matrix.

◆ isBroadcasting()

boolean isBroadcasting ( )

Determines if this matrix of statistical probes is broadcasting values to registered observers.

The default is false.

Returns
the status of broadcasting.

◆ isCollecting()

boolean isCollecting ( )

Determines if this matrix of statistical probes is collecting values.

The default is true.

Returns
the status of statistical collecting.

◆ notifyListeners()

void notifyListeners ( DoubleMatrix2D  x)

Notifies the observation x to all registered observers if broadcasting is ON.

Otherwise, does nothing.

◆ removeMatrixOfObservationListener()

void removeMatrixOfObservationListener ( MatrixOfObservationListener  l)

Removes the observation listener l from the list of observers of this matrix of statistical probes.

Parameters
lthe observation listener to be deleted.

◆ rowReport()

String rowReport ( int  r)

Formats a report for the row r of the statistical probe matrix.

The returned string is constructed by getting a view of row r and using StatProbe.report on this list.

Parameters
rthe row being reported.
Returns
the report formatted as a string.

◆ rows()

int rows ( )

Returns the number of rows in this matrix.

Returns
the total number of rows.

◆ set()

void set ( int  r,
int  c,
probe 
)

Sets the statistical probe corresponding to the row r and column c to probe.

Parameters
rthe row to modify.
cthe column to modify.
probet he new probe.
Exceptions
ArrayIndexOutOfBoundsExceptionif r or c are negative, if r is greater than or equal to rows, or if c is greater than or equal to columns.

◆ setBroadcasting()

void setBroadcasting ( boolean  b)

Sets the status of the observation broadcasting mechanism to b.

A true value turns broadcasting ON, a false value turns it OFF.

Parameters
bthe status of broadcasting.

◆ setCollecting()

void setCollecting ( boolean  c)

Sets the status of the statistical collecting mechanism to c.

A true value turns statistical collecting ON, a false value turns it OFF.

Parameters
cthe status of statistical collecting.

◆ setColumns()

void setColumns ( int  newColumns)

Similar to setRows(int), for setting the number of columns.

Parameters
newColumnsthe new number of columns of the matrix.
Exceptions
IllegalArgumentExceptionif an error occurs during construction of statistical probes.
NegativeArraySizeExceptionif newolumns is negative.

◆ setName()

void setName ( String  name)

Sets the global name of this matrix to name.

Parameters
namethe new global name of the matrix.

◆ setRows()

void setRows ( int  newRows)

Sets the number of rows of this matrix of statistical probes to newRows, adding or removing cells as necessary.

If newRows is negative, a NegativeArraySizeException is thrown. Otherwise, if newRows is equal to rows, nothing happens. If the number of rows is reduced, the last rows - newRows rows of statistical probes are lost. If the number of rows is increased, the new elements of the matrix are set to null.

Parameters
newRowsthe new number of rows of the matrix.
Exceptions
IllegalArgumentExceptionif an error occurs during construction of statistical probes.
NegativeArraySizeExceptionif newRows is negative.

◆ sum()

void sum ( DoubleMatrix2D  m)

For each probe in the matrix, computes the sum by calling umontreal.ssj.stat.StatProbe.sum, and stores it into the given matrix m.

Parameters
mthe matrix to be filled with sums.
Exceptions
NullPointerExceptionif m is null.
IllegalArgumentExceptionif m.rows() does not correspond to rows, or m.columns() does not correspond to columns.

◆ viewColumn()

List<E> viewColumn ( int  c)

Returns a list representing a view on column c of this matrix of statistical probe.

The returned list cannot be modified, and becomes invalid if the number of columns in this matrix of statistical probes is changed.

Parameters
cthe column to look at.
Returns
the list of statistical probes on the column.

◆ viewRow()

List<E> viewRow ( int  r)

Returns a list representing a view on row r of this matrix of statistical probe.

The returned list cannot be modified, and becomes invalid if the number of rows in this matrix of statistical probes is changed.

Parameters
rthe row to look at.
Returns
the list of statistical probes on the row.

The documentation for this class was generated from the following file: