Run Model (almost) w/o Eclipse
March 14, 2022 ยท View on GitHub
This project uses the Repast Simphony JZombies Model, taken from the Repast Java Tutorials and shows how to use Repast Simphony (almost) without Eclipse.
This is especially useful, when the model is built in a ci pipeline or one wants to use another IDE, like Intellij IDEA.
The approach is developed and widely used by the team of the topic field Cognitive Social Simulation of the Research Department Smart Data & Knowledge Services at DFKI.
Requirements
Install adoptopenjdk11
To run and build the model, Repast Simphony Runtime Libraries are needed. It is sufficient to just download (and unzip)
the plugins folder. Alternatively you can use your local
installation of Repast Simphony 2.9 .
- Note the path to the
pluginsfolder. For Eclipse under macOS the path can look like
/Applications/Repast Simphony 2.9.0/Eclipse.app/Contents/Eclipse/ - The path has to be build with forward-slashes (
/), on Windows too
Run from Command Line
-
Install
ant -
Set the
JAVA_HOMEenvironment variable to youradoptopenjdk11installation -
Clone the Repository
-
In the project root run:
ant build "-Dplugins_loc=[/absolute/path/to/plugins]" "-Dmodel_loc=[relative/path/to/model.rs]" ant run-model "-Dplugins_loc=[/absolute/path/to/plugins]" "-Dmodel_loc=[relative/path/to/model.rs]" -
Example:
ant run-model "-Dplugins_loc=/Applications/Repast Simphony 2.9.0/Eclipse.app/Contents/Eclipse/" "-Dmodel_loc=./JZombies_Demo.rs"
Available Targets
- Headless Batch Run as described in https://repast.github.io/docs/RepastBatchRunsGettingStarted.pdf
ant run-batch "-Dplugins_loc=[/absolute/path/to/plugins]" "-Dmodel_loc=[relative/path/to/model.rs]" "-Dargs=-hl -r -model_dir [/absolute/path/to/project/root] -b batch/batch_params.xml -o output -c batch_config.properties" - Build the Model
ant build "-Dplugins_loc=[/absolute/path/to/plugins]" "-Dmodel_loc=[relative/path/to/model.rs]" - Debug Model, opening Port 5005 for a Remote JVM Debugging Session
ant debug-model "-Dplugins_loc=[/absolute/path/to/plugins]" "-Dmodel_loc=[relative/path/to/model.rs]" - Run the Batch-Runner GUI
ant run-batch "-Dplugins_loc=[/absolute/path/to/plugins]" "-Dmodel_loc=[relative/path/to/model.rs]" - Run the Model GUI
ant run-model "-Dplugins_loc=[/absolute/path/to/plugins]" "-Dmodel_loc=[relative/path/to/model.rs]"
Run the Repast Server as Docker Container
Reference to Repast Server: https://repast.github.io/docs/RepastNG/browser.html
docker-compose up -d --build
Go to http://localhost:5000
- To run a different Ant Target, like a headless batch run, change the executed
CMDin thedocker-compose.yml
Build and Run in Intellij IDEA
- Clone the Repository
- Create new project from existing sources and choose import project from external model

- Select the
build.xmlfile in the project root and set it asAnt Build Filefrom the context menu - Open the
Ant Viewand edit the properties of thebuildAnt Target - Add the
plugins_locproperty with the path to thepluginsfolder as value - Add the
model_locproperty with the value./JZombies_Demo.rs
- ๐จ Build the Model by executing the
buildAnt Target - ๐ Run the Model by executing one of the
run-*Ant Targets
Create a Run Config (recommended)
Example for run-model:
- In the Context Menu of Ant Target select
Create Run Configuration - In the pop-up at
Before Launchremove the defaultBuildprocess and dd thebuildAnt Target
Syntax Highlighting in Intellij
Under File > Project Structure > Project Settings > Modules > JZombies_Demo > Dependencies
- Add the
libfolder in the project root - Add the
repast.simphony.bin_and_src.jarfrom thepluginsfolder:[path_to_plugins]/plugins/repast.simphony.bin_and_src_2.9.0/repast.simphony.bin_and_src.jar
Add a Debugger ๐
- Create a
Remote JVM Debugrun configuration (the default settings should be correct) - Run the
debug-modelAnt Target - Start the
Debugger