For running your model, the Repast development environment offers three options out of the box:
- run the model once, using the GUI you’ve developed, within the development environment
- export the model, such that you can install it in a production version on other computers (on those computers, it also runs under the GUI in single-run mode)
- run the model in “batch mode” from the development environment (in batch mode, the model runs multiple iterations as defined in the batch_params.xml file, without the involvement of the GUI)
It is missing the fourth option: export the model in a version that can run in “batch mode” in a production environment. The logical hole is palpable.
To create a standalone model that runs in batch mode, you’ll need to change the default batch (Windows) and/or command (Linux, Unix, Mac) file in your project. You need to change the classpath of the .bat/.command/.sh so that it includes all the files that are required for batch runs. You also need to change the invocation command from repast.simphony.runtime.RepastMain
into repast.simphony.batch.BatchMain
, and add the location of your batch parameters as a parameter to the command.
Stefan König and Axel Pürkhauer at the University of Bayreuth wrote a .command file with the appropriate modifications. I used this file as the basis for a batch file, after Mr. König and I corresponded based on an email he sent to the Repast-interest listserv. In 2012, Christof Zellweger, a postgraduate student at University of Melbourne, reached out with a further modified .sh shell script, which he kindly provided for posting here. Each script is provided in full on its own page:
- start_model.command for Mac and *nix, modified by Stefan König and Axel Pürkhauer in 2010 to use BatchMain
- start_model.bat for Windows, modified by Pamela Toman in 2010 to use BatchMain
- start_model.sh for Mac and *nix, modified by Christof Zellweger in 2012 to use BatchMain
So that’s all well and good. However, if you modify the original batch run file, you will lose the ability to run your model in a one-run-at-a-time-in-GUI-mode manner within standalone installs. So, if you would rather create a new .batch or .command file to handle BatchMain runs vs. RepastMain runs, you will also want to alter the files used by the installer to build the standalone installer package. Unless you alter those files, Repast will not know to include your new .batch file in the standalone installer package it builds.
If the new .batch or .command has a different name….
=> installer/installation_coordinator.xml
Add the third line below to the file at the appropriate place (around line 34):
<include name="installer/start_model.bat" />
<include name="installer/start_model.command" />
<include name="installer/yourNewBatchRunFile.fileType" />
=> installer/installation_components.xml
Add the sixth line below at the appropriate place in the file (around line 87):
<packs>
<pack name="Model" required="yes">
<description>The core model files</description>
<file src="repast.simphony.bin_and_src_$REPAST_VERSION/temp/installer/start_model.bat"
targetdir="$INSTALL_PATH"/>
<file src="repast.simphony.bin_and_src_$REPAST_VERSION/temp/installer/start_model.command"
targetdir="$INSTALL_PATH"/>
<file src="repast.simphony.bin_and_src_$REPAST_VERSION/temp/installer/yourNewBatchRunFile.fileType"
targetdir="$INSTALL_PATH"/>
With those two files modified, any future exports of the model will include your new .batch or .command file as well.
—
Updated 2012-07-28.