-
Notifications
You must be signed in to change notification settings - Fork 99
HeadlessTutorial
This tutorial presents an example for using Headless. The tutorial shows how to use Headless Legacy mode, Headless batch and Headless server. All the files related to this tutorial (images and models) are available in the Headless folder (headless/samples/predatorPrey).
import os
# GAMA Folder is the full path to you GAMA headless folder.
GAMA_folder_with_SDK = r"D:\software\GAMA_1.9.0_Windows_with_JDK\headless"
# The example model can be found in the sample folder.
Model_file = GAMA_folder_with_SDK + r"\samples\predatorPrey\predatorPrey.gaml"
# The experiment should be a GUI experiment.
ExperimentName = "prey_predator"
XML_file = GAMA_folder_with_SDK + r"\samples\predatorPrey.xml"
Output_folder = GAMA_folder_with_SDK + r"\samples\predatorPrey"
# We need to go to the folder of GAMA headless
os.chdir(GAMA_folder_with_SDK)
os.system("gama-headless.bat -xml " + ExperimentName + " " + Model_file + " " + XML_file)
os.system("gama-headless.bat " + XML_file + " "+ Output_folder)
print("Results of the model is in the folder:" + Output_folder)
print("Snapshot is store in the folder:" + Output_folder + r"\snapshot")
The results of the experiment is stored in the set folder. In which the snapshot for every step is also saved in the snapshot folder.
# This is an example using python to call GAMA headless batch.
import os
# GAMA Folder is the full path to you GAMA headless folder.
GAMA_folder_with_SDK = r"D:\software\GAMA_1.9.0_Windows_with_JDK\headless"
# The example model can be found in the sample folder.
Model_file = GAMA_folder_with_SDK + r"\samples\predatorPrey\predatorPrey.gaml"
# The experiment should be the GUI experiment. Optimization is an experiment batch of the model.
ExperimentName = "Optimization"
os.chdir(GAMA_folder_with_SDK)
os.system("gama-headless.bat -batch " + ExperimentName + " " + Model_file)
# The results of optimization is stored in a csv file as defined in the experiment.
print("The result is store in the file:" + GAMA_folder_with_SDK + r"\samples\predatorPrey\results.csv")
The legacy version allows you to access the headless feature of GAMA by controling the model parameters and experiment plan from oustide GAMA model file . The headless batch, allows you to access the headless feature of GAMA with the model parameters and experiment plans defined inside the GAMA model file. The headless server, allows you to not only to access the headless feature but also to interact with the currently running GAMA experiment. You can load, play, pause, reload, stop and exit an experiment with very specific commands as described here.
The general sequence of operations is:
- Start the server from a command line
gama-headless.sh -socket 6868
, this opens the communication via port 6868 using websockets. - Connect to the server from another application/script that supports interacting with websockets. e.g., python.
- Start with the
load
command to load an experiment and then use one of the specific commands as described here to construct a sequence of operations as required by your workflow.
- Installation and Launching
- Workspace, Projects and Models
- Editing Models
- Running Experiments
- Running Headless
- Preferences
- Troubleshooting
- Introduction
- Manipulate basic Species
- Global Species
- Defining Advanced Species
- Defining GUI Experiment
- Exploring Models
- Optimizing Model Section
- Multi-Paradigm Modeling
- Manipulate OSM Data
- Diffusion
- Using Database
- Using FIPA ACL
- Using BDI with BEN
- Using Driving Skill
- Manipulate dates
- Manipulate lights
- Using comodel
- Save and restore Simulations
- Using network
- Headless mode
- Using Headless
- Writing Unit Tests
- Ensure model's reproducibility
- Going further with extensions
- Built-in Species
- Built-in Skills
- Built-in Architecture
- Statements
- Data Type
- File Type
- Expressions
- Exhaustive list of GAMA Keywords
- Installing the GIT version
- Developing Extensions
- Introduction to GAMA Java API
- Using GAMA flags
- Creating a release of GAMA
- Documentation generation