uchicago.src.sim.engine
Class SimInit

java.lang.Object
  extended by uchicago.src.sim.engine.SimInit

public class SimInit
extends java.lang.Object

Creates and initializes a simulation. A RePast model (one that implements the SimModel interface) can either use this class to load themselves, or be loaded by this class and associated with the appropriate controller. In the first case, a RePast model would create and instance of itself and SimInit in a main method, and the load itself using SimInits.load method. For example,

 public static void main(String[] args) {
   MyModel model = new MyModel();
   SimInit init = new SimInit();
   init.load(model, null, false);
 }
 
And the model name then passed as argument to "java" on the command line,
 java -cp ... mymodels.MyModel
 
Model's loaded this way can load parameter files and specify whether they are batch models are not. For how to do this, see the load definition below.

Using SimInit to load your model works as follows. SimInit is passed as an argument on the command line to "java" and your fully qualified model name should follow "uchicago.src.sim.engine.SimInit". Two option switch can be passed to SimInit that determine how SimInit will treat your model.

With no switches, RePast assumes your model is a gui model (that is, you want to start and stop it via the graphical toolbar). You can pass your gui model the full name of a parameter file as well, and these will be treated as default model parameters. For more on parameter files, see ParameterReader and the Repast how to documentation.

Some sample ways to start the model models.MyModel. The model loading itself:

java -cp ... models.MyModel

Loading a models.MyModel as a batch model via SimInit

java -cp ...uchicago.src.sim.engine.SimInit -b models.MyModel my_params

Version:
$Revision: 1.26 $ $Date: 2004/11/15 17:22:34 $
Author:
Nick Collier
See Also:
Controller, BatchController, BaseController

Field Summary
static java.lang.String VERSION
           
 
Constructor Summary
SimInit()
           
 
Method Summary
 void loadModel(SimModel model, java.lang.String fileName, boolean isBatch)
          Loads the specified model as if it was given on the command line.
static void main(java.lang.String[] args)
           
 void setExitOnExit(boolean val)
          Sets whether the simulation application should exit with a System.exit(0) call on exit (pressing the exit button), or dispose of all windows, release the model without killing this instance of the virtual machine.
 void setNumRuns(int numRuns)
          Sets the number of runs in a batch run.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
See Also:
Constant Field Values
Constructor Detail

SimInit

public SimInit()
Method Detail

setNumRuns

public void setNumRuns(int numRuns)
Sets the number of runs in a batch run. Note that is only applies when doing a batch run with no parameter file. Otherwise, the parameter space defined by the parameter file determines how many runs will occur.

Parameters:
numRuns - the number of runs to perform

loadModel

public void loadModel(SimModel model,
                      java.lang.String fileName,
                      boolean isBatch)
Loads the specified model as if it was given on the command line. RePast models can use this to load themselves in their own main methods. The fileName is optional if this is not a batch simulation. If specified the parameters and their values specified in the parameter file will become the default parameters for the model.

Parameters:
model - the model to load
fileName - the name of a parameter file. This can be null, or an empty String if no parameter file is desired.
isBatch - whether this is a batch simulation or not.

setExitOnExit

public void setExitOnExit(boolean val)
Sets whether the simulation application should exit with a System.exit(0) call on exit (pressing the exit button), or dispose of all windows, release the model without killing this instance of the virtual machine.


main

public static void main(java.lang.String[] args)