uchicago.src.sim.network
Class NetworkRecorder

java.lang.Object
  extended by uchicago.src.sim.network.NetworkRecorder
All Implemented Interfaces:
NetworkConstants

public class NetworkRecorder
extends java.lang.Object
implements NetworkConstants

Records a network as a matrix or matrices in the appropriate format. NetworkRecorder is used to take a list of Nodes and write the corresponding adjacency matrix to a file. Three file formats are supported: UCINet's dl, Excel, and ASCII. The actual network matrix is written out in this format, although RePast records relevant non-matrix information as well: a file header containing the constant parameters for the model and a timestamp, and a block header that contains header information relevant to the network data recorded beneath it. The block header will contain the value of any dynamic model parameters at the time a network was recorded, as well as any user comments (typically the current tick count).

The actual format of the file is thus:

 file header

 block_header_1
 network data in the specified format

 block_header_2
 network data in the specified format

 ...
 
Specifying the format then specifies the format for the network data. The rest (file header and block header) will remain the same for all formats. The actual network data can easily be cut and pasted out of the file.

ASCII format will record the matrix and the matrix label in comma delimited plain text. Excel format will store it in an Excel file in a format suitable for importation into UCINet.

Note: Excel format should not be used as it is very time consuming and error prone to write to an Excel file. Use ASCII instead which is a plain text format suitable for importation into excel.

Version:
$Revision: 1.5 $ $Date: 2004/11/03 19:51:01 $
Author:
Nick Collier

Nested Class Summary
 class NetworkRecorder.MatrixData
           
 
Field Summary
 
Fields inherited from interface uchicago.src.sim.network.NetworkConstants
ASCII, BINARY, DL, EXCEL, LARGE, SMALL
 
Constructor Summary
NetworkRecorder(int format, java.lang.String fileName, SimModel model)
          Constructs a NetworkRecorder with the specified format and file name.
 
Method Summary
 void record(java.util.List nodeList)
          Deprecated. use record(List, String, int) instead.
 void record(java.util.List nodeList, int matrixType)
          Records the network described by the Nodes in nodeList.
 void record(java.util.List nodeList, java.lang.String comment)
          Deprecated. use record(List nodeList, String comment, int matrixType) instead.
 void record(java.util.List nodeList, java.lang.String comment, int matrixType)
          Records the network described by the Nodes in nodeList.
 void write()
          Writes the networks recorded by record(...) to the file specified in the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetworkRecorder

public NetworkRecorder(int format,
                       java.lang.String fileName,
                       SimModel model)
Constructs a NetworkRecorder with the specified format and file name. Networks will be recorded in the format specified by format to the file specified by fileName. The format can be one of NetworkRecorder.DL (UCINet dl), NetworkRecorder.EXCEL (UCINet Excel format), or NetworkRecorder.ASCII (plain text comma-delimeted). See the class description above for more information on each format and the actual format of the resulting file.

Parameters:
fileType - the network file format (NetworkRecorder.DL, NetworkRecorder.EXCEL, or NetworkRecorder.ASCII).
fileName - the name of the file to write the recorded network(s) to.
model - the model associated with this network
isBatch - whether this is a batch run or not
Method Detail

record

public void record(java.util.List nodeList)
Deprecated. use record(List, String, int) instead.

Records the network described by the Nodes in nodeList. It is assumed that each Node appears only once in the nodeList.

Parameters:
nodeList - the list of nodes that describe the network to record

record

public void record(java.util.List nodeList,
                   int matrixType)
Records the network described by the Nodes in nodeList. It is assumed that each Node appears only once in the nodeList.

The matrixType parameter refers to the size of the matrix elements, the ij values. A matrix of type of NetworkConstants.BINARY contains on 0 or 1 as elements. A matrix of type of NetworkConstants.SMALL contains values of -127 - 127 as elements. And a matrix of type NetworkConstants.LARGE contains anything else. Matrix ij values are assigned the edge strength of an edge, so unless you have explicitly set an edge strength of greater than 1, use NetworkConstants.BINARY.

Parameters:
nodeList - the list of nodes that describe the network to record
matrixType - the type of the matrix. type refers to the size of the matrix elements (ij values) and can be one of NetworkConstants.BINARY, NetworkConstants.LARGE, NetworkConstants.SMALL

record

public void record(java.util.List nodeList,
                   java.lang.String comment)
Deprecated. use record(List nodeList, String comment, int matrixType) instead.

Records the network described by the Nodes in nodeList. It is assumed that each Node appears only once in the nodeList. The comment is prepended to the formatted network data corresponding to the nodeList, and can be used to specify the tick at which the network was recorded, for example.

Parameters:
nodeList - the list of nodes that describe the network to record
comment - a comment associated with the network

record

public void record(java.util.List nodeList,
                   java.lang.String comment,
                   int matrixType)
Records the network described by the Nodes in nodeList. It is assumed that each Node appears only once in the nodeList. The comment is prepended to the formatted network data corresponding to the nodeList, and can be used to specify the tick at which the network was recorded, for example. The matrixType parameter refers to the size of the matrix elements, the ij values. A matrix of type of NetworkConstants.BINARY contains on 0 or 1 as elements. A matrix of type of NetworkConstants.SMALL contains values of -127 - 127 as elements. And a matrix of type NetworkConstants.LARGE contains anything else. Matrix ij values are assigned the edge strength of an edge, so unless you have explicitly set an edge strength of greater than 1, use NetworkConstants.BINARY.

Parameters:
nodeList - the list of nodes that describe the network to record
comment - a comment associated with the network
matrixType - the type of the matrix. type refers to the size of the matrix elements (ij values) and can be one of NetworkConstants.BINARY, NetworkConstants.LARGE, NetworkConstants.SMALL

write

public void write()
Writes the networks recorded by record(...) to the file specified in the constructor. See the class description above for the file format.