RePast
v. 2.0

uchicago.src.sim.engine
Class BatchController

java.lang.Object
  |
  +--uchicago.src.sim.engine.BaseController
        |
        +--uchicago.src.sim.engine.BatchController
All Implemented Interfaces:
IController, SimEventListener

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.

See Also:
SimInit

Field Summary
protected  long batchCount
           
protected  ArrayList dynNameList
           
protected  boolean finished
           
protected  ArrayList nameList
           
protected  Hashtable nameParam
           
protected  String[] pArray
           
protected  Hashtable writeHeader
           
 
Fields inherited from class uchicago.src.sim.engine.BaseController
done, doStep, executeBegin, go, isGui, listenerList, model, monitor, params, pauseActionsExecuted, pauseAt, pauseAtAction, pauseSim, persistentObj, runFinished, runThread, schedule, simRun, sleepValue, time
 
Constructor Summary
BatchController(Vector parameters)
          Creates a BatchController with the specified model parameters.
 
Method Summary
 void begin()
          Begins the batch runs
 boolean doWriteHeader(String fileName)
          Should the header for the specified file be written.
 void exitSim()
          Exits the entire simulation.
 long getBatchCount()
          Gets the number of the current batch run
 ArrayList getDynamicParameterNames()
          Gets a list of the Dynamic (non-constant) Parameter names.
 ArrayList getParameterNames()
          Gets a list of the parameter names.
 String getParameterValue(String name)
          Gets the current value of the named Parameter.
 boolean isBatch()
          Is this a batch run.
 boolean isParameter(String name)
          Is the named property a Parameter from a Parameter file.
 boolean isParameterConstant(String name)
          Is the named Parameter a constant Parameter.
 void onTickCountUpdate()
          Empty method as nothing to update when the tick count is incremented
 void removeParameter(String name)
          Removes the named Parameter from the internal list of model parameter names, but not from the Parameter list itself.
 void setModel(SimModel model)
          Sets the model to be controlled by this BatchController.
 void setWriteHeader(String filename, boolean val)
          Sets whether the header for the specified file should be written.
 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, getCurrentTimeDouble, getDefaultModelParameters, getModel, getModelParameters, getPauseAt, getPersistentObj, getRandomSeed, getSchedule, notifyMonitor, pauseSim, putPersistentObj, removeSimEventListener, setCellDepth, setCellHeight, setCellWidth, 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 String[] pArray

batchCount

protected long batchCount

writeHeader

protected Hashtable writeHeader

nameList

protected ArrayList nameList

dynNameList

protected ArrayList dynNameList

nameParam

protected Hashtable nameParam

finished

protected volatile boolean finished
Constructor Detail

BatchController

public BatchController(Vector 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

removeParameter

public void removeParameter(String name)
Removes the named Parameter from the internal list of model parameter names, but not from the Parameter list itself. Used in writing batch run data.

Parameters:
name - the name of the parameter to remove

isParameterConstant

public boolean isParameterConstant(String name)
Is the named Parameter a constant Parameter.

Parameters:
name - the name of the Parameter
Returns:
true if the Parameter is constant, otherwise false

isParameter

public boolean isParameter(String name)
Is the named property a Parameter from a Parameter file.


getParameterValue

public String getParameterValue(String name)
Gets the current value of the named Parameter.

Parameters:
name - the name of the Parameter
Returns:
the current value of the named Parameter

getParameterNames

public ArrayList getParameterNames()
Gets a list of the parameter names.


getDynamicParameterNames

public ArrayList getDynamicParameterNames()
Gets a list of the Dynamic (non-constant) Parameter names.


getBatchCount

public long getBatchCount()
Gets the number of the current batch run


doWriteHeader

public boolean doWriteHeader(String fileName)
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(String filename,
                           boolean val)
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()
Empty method as nothing to update when the tick count is incremented

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


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.


exitSim

public void exitSim()
Description copied from interface: IController
Exits the entire simulation. No more runs can be executed after a simulation has exited.


isBatch

public boolean isBatch()
Is this a batch run. Always returns true as this is a BatchController.

Overrides:
isBatch in class BaseController
Returns:
true

RePast
v. 2.0

Bug reports and feature requests to RePast