Skip to content

EMLab in Headless Mode

RubenVerweij edited this page May 18, 2013 · 20 revisions

EMLab-Generation can be run in headless mode, and can in this way automatically run a range of scenarios on a single machine, or even on a High-Performance Cluster. This description is written for linux.

Configuration

The necessary scripts to do so, can be found in the folder shellscripts/headlessScripts. Before starting to use them, it is necessary to configure their usage by filling out the template TEMPLATE_scriptConfigurations.cfg and saving it as scriptConfigurations.cfg. In this way the scenario folder, results folder etc. can be defined. If the scripts are only to be run locally, the fields with REMOTE or SERVER can be left empty.

Running EMLab locally

The scripts to run EMLab locally are localHeadlessSingle.sh, to run a single run of EMLab and localHeadlessArray.sh to run a range of scenarios. localHeadlessSingle.sh can be called with localHeadlessSingle.sh YOURJOBNAME SCENARIONAME (QUERYFILE) where YOURJOBNAME is an arbitrary name, SCENARIONAME the scenario file name without the .xml file ending and QUERYFILE an optional parameter that can be passed to change the query file, which determines which queries are saved at the end of each tick.

There could be a configuration of the localHeadlessSingle.sh and localHeadlessArray.sh necessary in case of 1. a 32 bit operating system or 2. a limited RAM capacity. In this situation the mentioned files need an adjustment. In the last 10 lines of code java -d64 -server -Xmx3072m can be found. In case of a 32 bit operating system remove the -d64 -server part in his totality. In case of limited RAM capacity check the memory available of the machine and change -Xmx3072m into for example -Xmx1000m when you have one GB memory left.

localHeadlessArray.sh is run similarly with localHeadlessSingle.sh YOURJOBNAME SCENARIONAME START END (QUERYFILE). START and END should be numbers and define the set of scenarios that are run, if these scenario files follow the naming start SCENARIONAME-START.xml to SCENARIONAME-END.xml (e.g. scenarioA-ToyModel-0.xml, scenarioA-ToyModel-1.xml, scenarioA-ToyModel-2.xml, ...).

Running HPC on a TORQUE cluster

The other scripts in the headless are folder are for running and maintaining jobs on a HPC (that uses TORQUE as a job manager, also see http://www.clusterresources.com/torquedocs21/). The most important of these scripts are hpcArrayRun.sh JOBNAME SCENARIOFILE(incl. xml-ending) NUMBEROFRUNS and scenarioRuns.sh JOBNAME SCENARIO(excl. xml-ending) NUMBEROFRUNS START END. NUMBEROFRUNS defines the number of repetitions for each scenario file that is run, in case that the simulation itself contains stochastic elements.

However, before starting any jobs the folder headlessScripts, as well as the file epilogueHpc.sh should have the correct permissions set, which can be done with chmod go+x FOLDER/FILE. For the correct functioning of all scripts, the filled out scriptConfigurations.cfg needs to be present on the HPC.

Technical details

The script files make use of the headless or HPC mode of AgentSpring. In this mode several system arguments can be passed to the simulation to set the output folder, scenario file folder etc. The full statement usually is: java -d64 -server -Xmx3072m -Drun.id=$JOBNAME -DSCENARIO_FOLDER=$SCENARIOPATH -Dresults.path=$LOCALRESULTFOLDER/$JOBNAME -Dscenario.file=$SCENARIO".xml" $QUERYFILEPATH -jar $LOCALJARFILE.

The flags `-Xmx3072m' sets the java heap size that the simulation is allowed to use, and might need to be adjusted to the system configuration.

Clone this wiki locally