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

## uchicago.src.sim.engine
Class BatchController

    java.lang.Object
      uchicago.src.sim.engine.BaseController
          uchicago.src.sim.engine.BatchController

All Implemented Interfaces:
  IController, SimEventListener, TickCounter

Direct Known Subclasses:
  RemoteBatchController

    public class BatchController

extends BaseController

A controller for running a simulation over multiple runs. See `SimInit` for more on how to run a simulation in batch mode. `BatchController` should not be created by a user under normal circumstances.

Version:
  $Revision: 1.29 $ $Date: 2005/03/31 22:40:28 $
Author:
  Nick Collier (Modified by Michael J. North)
See Also:
  `SimInit`

Field Summary
`protected boolean` | `autoRecording` whether or not the controller is automatically recording the parameters of the model
`protected long` | `batchCount`
`protected java.util.ArrayList` | `batchListeners`
`protected java.util.ArrayList` | `dynNameList`
`protected boolean` | `finished`
`protected java.util.ArrayList` | `nameList`
`protected java.util.Hashtable` | `nameParam`
`protected java.lang.String[]` | `pArray`
`protected DataRecorder` | `recorder`
`protected boolean` | `stopped`

Fields inherited from class uchicago.src.sim.engine.BaseController
`done, doStep, executeBegin, exitOnExit, go, isGui, listenerList, model, monitor, params, pauseActionsExecuted, pauseAt, pauseAtAction, pauseSim, persistentObj, runFinished, runThread, schedule, simRun, sleepValue, time`

Constructor Summary
`BatchController(ParameterSetter parameters)` Creates a BatchController with the specified model parameters.

Method Summary
`void` | `addBatchListener(BatchListener listener)` adds a batch listener to this batch controller
`void` | `begin()` Begins the batch runs
`boolean` | `doWriteHeader(java.lang.String fileName)` Deprecated. now uses the persistent object mechanism.
`void` | `endSim()` shuts down a simulation even if it is in the middle of a run
`void` | `exitSim()` Exits the entire simulation.
`protected void` | `fireBatchEvent(BatchEvent evt)`
`long` | `getRunCount()` Gets the number of the current batch run
`void` | `incrementBatchCount()` Increment the batchCount.
`boolean` | `isAutoRecording()` This determines if the BatchController will automatically record the parameters from the model at the end of a simulation run.
`boolean` | `isBatch()` Is this a batch run.
`boolean` | `isGUI()` If this is a GUI controller, always false.
`void` | `onTickCountUpdate()` This fires a tick changed batch event every tick
`void` | `removeBatchListener(BatchListener listener)` removes a batch listener from this controller
`void` | `setAutoRecording(boolean autoRecording)` This determines if the BatchController will automatically record the parameters from the model at the end of a simulation run.
`void` | `setModel(SimModel model)` Sets the model to be controlled by this BatchController.
`void` | `setWriteHeader(java.lang.String filename, boolean val)` Deprecated.
`void` | `simEventPerformed(SimEvent evt)` Called by a source on which this is a listener when a `SimEvent` is performed.
`void` | `start()` Starts an individual run of the simulation
`void` | `stopRun()` Stops an individual run of the simulation, increments the parameters appropriately, and if necessary starts another run.

Methods inherited from class uchicago.src.sim.engine.BaseController
`addSimEventListener, beginModel, fireSimEvent, getCellDepth, getCellHeight, getCellWidth, getCurrentTime, getDefaultModelParameters, getExitOnExit, getModel, getModelParameters, getPauseAt, getPersistentObj, getRandomSeed, getSchedule, notifyMonitor, pauseSim, putPersistentObj, removeSimEventListener, setCellDepth, setCellHeight, setCellWidth, setExitOnExit, setPauseAt, setRandomSeed, setSchedule, setupSchedule, startSim, stopSim`

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

Field Detail

### pArray

    protected java.lang.String[] pArray

### batchCount

    protected long batchCount

### nameList

    protected java.util.ArrayList nameList

### dynNameList

    protected java.util.ArrayList dynNameList

### nameParam

    protected java.util.Hashtable nameParam

### batchListeners

    protected java.util.ArrayList batchListeners

### finished

    protected volatile boolean finished

### stopped

    protected boolean stopped

### recorder

    protected DataRecorder recorder

### autoRecording

    protected boolean autoRecording

  whether or not the controller is automatically recording the parameters of the model

Constructor Detail

### BatchController

    public BatchController(ParameterSetter parameters)

  Creates a BatchController with the specified model parameters. The actual model is (inelegantly) loaded via setModel().

  Parameters:
    `parameters` - the parameters with which to run the simulation

Method Detail

### setModel

    public void setModel(SimModel model)

  Sets the model to be controlled by this BatchController.

  Specified by:
    `setModel` in interface `IController`
  Overrides:
    `setModel` in class `BaseController`
  Parameters:
    `model` - the model to be controlled by this BatchController

### getRunCount

    public long getRunCount()

  Gets the number of the current batch run

### doWriteHeader

    public boolean doWriteHeader(java.lang.String fileName)

  Deprecated. now uses the persistent object mechanism.

  Should the header for the specified file be written. The BatchController is persistent over the course of all the batch runs, and a non-persistent object can query this BatchController to see if the file header has already been written.

  Parameters:
    `fileName` - the name of the file whose header should or should not be written.
  Returns:
    true if the header should be written, otherwise false.

### setWriteHeader

    public void setWriteHeader(java.lang.String filename,
                               boolean val)

  Deprecated.

  Sets whether the header for the specified file should be written.

  Parameters:
    `filename` - the name of the file whose header should or should not be written
    `val` - true if the header should be written, otherwise false

### onTickCountUpdate

    public void onTickCountUpdate()

  This fires a tick changed batch event every tick

  Specified by:
    `onTickCountUpdate` in class `BaseController`

### begin

    public void begin()

  Begins the batch runs

### start

    public void start()

  Starts an individual run of the simulation

### isAutoRecording

    public boolean isAutoRecording()

  This determines if the BatchController will automatically record the parameters from the model at the end of a simulation run. These parameters will be recorded to a file called ModelName.out.

  Returns:
    If the BatchController is automatically recording the model's parameters.

### setAutoRecording

    public void setAutoRecording(boolean autoRecording)

  This determines if the BatchController will automatically record the parameters from the model at the end of a simulation run. These parameters will be recorded to a file called ModelName.out.
  This must be set before calling BatchController.begin for it to be effective. The parameters that are recorded are based on those returned by the getInitParams() method. If a get method cannot be found, it ignores that parameter.

  Parameters:
    `autoRecording` - whether or not to automatically record the parameters

### stopRun

    public void stopRun()

  Stops an individual run of the simulation, increments the parameters appropriately, and if necessary starts another run.

### simEventPerformed

    public void simEventPerformed(SimEvent evt)

  Called by a source on which this is a listener when a `SimEvent` is performed. This only listens for stop events and stops the sim when it receives the event.

### endSim

    public void endSim()

  shuts down a simulation even if it is in the middle of a run

### exitSim

    public void exitSim()

  Description copied from interface: `IController`
  Exits the entire simulation. No more runs can be executed after a simulation has exited.

### fireBatchEvent

    protected void fireBatchEvent(BatchEvent evt)

### incrementBatchCount

    public void incrementBatchCount()

  Increment the batchCount. This is added for parallel models.

### addBatchListener

    public void addBatchListener(BatchListener listener)

  adds a batch listener to this batch controller

  Parameters:
    `listener` - the listener to remove

### removeBatchListener

    public void removeBatchListener(BatchListener listener)

  removes a batch listener from this controller

  Parameters:
    `listener` - the listener to remove

### isBatch

    public boolean isBatch()

  Is this a batch run. Always returns true as this is a BatchController.

  Specified by:
    `isBatch` in interface `IController`
  Overrides:
    `isBatch` in class `BaseController`
  Returns:
    true

### isGUI

    public boolean isGUI()

  If this is a GUI controller, always false.

  Returns:
    false

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