Search code examples
agent-based-modelingrepast-simphony

Repast Java: how to run model directly in Eclipse without GUI and how to run it in headless mode without even Eclipse


I am wondering how to

1) how to run model directly in Eclipse without GUI - just run the model like run other java codes in Eclipse and print out something i am interested.

2) how to run it in headless mode without even Eclipse - I plan to deploy my model in a remote server, which the server or my own PC could run the model automatically at a specific time of the day.

3) Every time when I change the code, I have to launch a new GUI in order to reflect the code changes. It takes at least 5 seconds to open the GUI. This is very inefficient way of model development and debugging. What is the better strategy available?


Solution

  • For headless, or batch, running of models, take a look at the Repast Batch Getting Started Guide. This can either allow you to run multiple runs without a GUI, as in (1), or if you look at section 9.2, it will allow you to run from the command line without invoking Eclipse, as in your case (2). If you want more control, I'd suggest looking at the InstanceRunner class and utilize the complete_model.jar payload that is generated by the Batch GUI or batch_runner.jar.

    1. Unarchive the complete_model.jar
    2. Then use the InstanceRunner class from the command line, like so from within the complete_model directory
        java -Xmx512m -cp "../lib/*" repast.simphony.batch.InstanceRunner \
            -pxml ../scenario.rs/batch_params.xml \
            -scenario ../scenario.rs \
            -id $instance \
            -pinput localParamFile.txt
    

    where the localParamFile.txt is an unrolled parameter file specifying the combination(s) of parameters to run (see the unrolledParamFile.txt within the payload for an example) and if you're running just one instance this would just be one line.