Package repast.simphony.batch
Class BatchScenario
- java.lang.Object
-
- repast.simphony.scenario.Scenario
-
- repast.simphony.batch.BatchScenario
-
- All Implemented Interfaces:
ScenarioChangedListener
public class BatchScenario extends Scenario
Allows the programmatic creation of a scenario for use in a batch run.- Author:
- Nick Collier
-
-
Field Summary
Fields Modifier and Type Field Description protected ParameterSweeper
parameterSweeper
protected ModelInitializer
userInit
-
Fields inherited from class repast.simphony.scenario.Scenario
context, DEFAULT_MASTER_PARENT, dirty, file, masterActions, modelData, modelInitName, modelPluginPath, paramSweepers, registry, SCENARIO_FILE_NAME
-
-
Constructor Summary
Constructors Constructor Description BatchScenario(File scenarioDir, ContextData contextData, UserPathData modelData, Object masterContextID)
BatchScenario(Object masterContextID)
Creates a BatchScenario with the specified master context id.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends ContextBuilder>
voidaddDataLoader(Object contextTypeID, T loader)
Adds a data loader to this scenario.ControllerRegistry
createRegistry(RunEnvironmentBuilder builder)
Creates a ControllerRegistry from this BatchScenario.ModelInitializer
getModelInitializer()
Gets a custom ModelInitializer, if any, supplied by the user.ParameterSweeper
getParameterSweeper()
void
prepareWatchee(String className, String fieldName, String classpath)
Prepare the specified field in the specified class for watching.void
setParameterSweeper(ParameterSweeper sweeper)
void
setUserInitializer(ModelInitializer userInit)
Sets a ModelInitializer that will be run when the scenario is loaded.-
Methods inherited from class repast.simphony.scenario.Scenario
addMasterControllerAction, addParameterSetter, getContext, getControllerRegistry, getMasterControllerActions, getModelData, getModelInitName, getModelPluginPath, getParameterSetters, getScenarioDirectory, isDirty, removeMasterControllerAction, removeParameterSetter, scenarioChanged, setControllerRegistry, setDirty, setModelInitName, setModelPluginPath, setScenarioDirectory
-
-
-
-
Field Detail
-
parameterSweeper
protected ParameterSweeper parameterSweeper
-
userInit
protected ModelInitializer userInit
-
-
Constructor Detail
-
BatchScenario
public BatchScenario(Object masterContextID)
Creates a BatchScenario with the specified master context id.- Parameters:
masterContextID
-
-
BatchScenario
public BatchScenario(File scenarioDir, ContextData contextData, UserPathData modelData, Object masterContextID)
-
-
Method Detail
-
prepareWatchee
public void prepareWatchee(String className, String fieldName, String classpath)
Prepare the specified field in the specified class for watching. If this is not done, any watcher annotations will not work.- Parameters:
className
- the name of the class to watchfieldName
- the name of the field to watchclasspath
- the classpath on which to find the watcher and watched classes. The separator must be appropriate for the OS.
-
addDataLoader
public <T extends ContextBuilder> void addDataLoader(Object contextTypeID, T loader)
Adds a data loader to this scenario. The data loader will be associated with the specific context. If the contextTypeID refers to the master context, then this data loader is responsible for creating the master context and its children. If the contextTypeID refers to a subcontext type, then the data loader is responsible for creating the children of any contexts of that type.- Parameters:
contextTypeID
- the context type to associate the data loader withloader
- the loader to add to the scenario
-
createRegistry
public ControllerRegistry createRegistry(RunEnvironmentBuilder builder) throws ClassNotFoundException, IOException
Creates a ControllerRegistry from this BatchScenario. This registry is then used to do the actual batch runs.- Parameters:
builder
- used to create the run enviroment and passed to a user's model initializer, if any- Returns:
- a ControllerRegistry created from this BatchScenario.
- Throws:
ClassNotFoundException
- if this BatchScenario is unable process (read annotations etc.) the agent classes.IOException
-
getModelInitializer
public ModelInitializer getModelInitializer()
Gets a custom ModelInitializer, if any, supplied by the user.- Overrides:
getModelInitializer
in classScenario
- Returns:
- a custom RunInitializer, if any, supplied by the user.
-
setUserInitializer
public void setUserInitializer(ModelInitializer userInit)
Sets a ModelInitializer that will be run when the scenario is loaded. This is optional and need not be set unless a custom initializer is desired.- Parameters:
userInit
- a customized ModelInitializer
-
setParameterSweeper
public void setParameterSweeper(ParameterSweeper sweeper)
-
getParameterSweeper
public ParameterSweeper getParameterSweeper()
-
-