Skip to main content
Version: 🚧 Alpha 🚧

Headless Legacy

Overview​

Headless Legacy mode uses XML experiment plan files to run multiple simulations. This is an older mode but still useful for simple scripted runs and legacy workflows.

For batch experiments defined directly in your .gaml model, use Headless Batch. For interactive remote control, use Headless Server.


Quick Start​

Generate an XML experiment plan from a model:

gama-headless.sh -xml experimentName /path/to/model.gaml plan.xml

Then run it:

gama-headless.sh plan.xml /path/to/results/

Simple One-Shot Run​

For a single experiment without XML:

gama-headless.sh -gaml -steps 1000 experimentName /path/to/model.gaml /path/to/results/

XML Experiment Plan​

Structure​

<?xml version="1.0" encoding="UTF-8"?>
<Experiment_plan>
<Simulation experiment="expName" finalStep="1000" id="0" seed="42">
<source_path>/path/to/model.gaml</source_path>
<Parameters>
<Parameter name="Parameter Display Name" type="INT" value="10"/>
</Parameters>
<Outputs>
<Output name="Monitor Name" framerate="1"/>
</Outputs>
</Simulation>
</Experiment_plan>

Multiple <Simulation> blocks can be added to run experiments in parallel (limited by the -hpc flag).

Element Reference​

<Simulation>​

AttributeRequiredDescription
experimentYesName of the experiment in the GAML model
finalStepYesNumber of steps to run
idYesID to prefix output files
seedNoRandom seed value
source_pathYesPath to the .gaml model file
untilNoGAML stop condition (combinable with finalStep)

<Parameter>​

AttributeRequiredDescription
nameYes (if var not set)Display name as written in the GAML parameter statement
varYes (if name not set)Variable name in the GAML model
typeYesData type: INT, FLOAT, BOOLEAN, STRING
valueYesValue to assign

Note: Set either name or var, not both.

<Output>​

AttributeRequiredDescription
nameYesName of a monitor, display, or global variable
framerateYesLog frequency in steps
idNoPrefix for output files (if multiple outputs share a name)

Note: Lower framerate values → more data but longer execution time.


Output Structure​

Results are saved to the output directory:

results/
├── console-outputs-0.txt # Console output
├── simulation-output0.xml # Variable values over time
└── snapshot/ # Display screenshots
└── displayName-0-N.png # Screen capture at step N

simulation-output0.xml​

<?xml version="1.0" encoding="UTF-8"?>
<Simulation id="0">
<Step id='0'>
<Variable name='number_of_agents' value='50'/>
<Variable name='main_display' value='main_display0-0.png'/>
<Variable name='duration' value='4'/>
</Step>
</Simulation>

Displays save screenshots as .png files; their path is stored in the XML.


Calling from Scripts​

Python​

import os
os.system(f"gama-headless.sh -xml exp /path/to/model.gaml plan.xml")
os.system(f"gama-headless.sh plan.xml /path/to/results/")

JavaScript/Node.js​

const { exec } = require('child_process');
exec('gama-headless.sh -xml exp /path/to/model.gaml plan.xml', (err) => {
exec('gama-headless.sh plan.xml /path/to/results/', (err) => {});
});

Common Errors​

ErrorCauseSolution
No parameter named X in experiment YTypo in parameter name or variable nameCheck spaces, capitalization, and exact wording
Model file does not existIncorrect model pathUse absolute paths, or verify relative paths from XML location
NumberFormatExceptionType mismatch in XMLEnsure type matches value (INT vs FLOAT)
NoClassDefFoundError / resourcesResourcesPluginNo write permissionRun from a writable directory (not Program Files on Windows)