Library for launching ZMT simulations. Recent javadoc can be found here: https://dochost.leibniz-zmt.de/javadoc/zmt-launcher/
## Minimal Setup
[zmt-core](https://gitlab.leibniz-zmt.de/ecomod/zmt-core) provides an interface for zmt-launcher to launch simulations. The minimal setup for that consists of the following:
* Add zmt-core to the classpath of your simulation, i.e. add a dependency for it in build.gradle:
```
compile 'de.zmt:zmt-core:latest.release'
```
* Create a parameters class implementing `de.zmt.params.SimParams`.
* Let your main simulation class extend `sim.engine.BaseZmtSimState` and place it in package `sim.engine`. Use your parameters class for the type parameter and supply the class via `getParamsClass()` method.
* If you want to customize the GUI, let your class extend `sim.display.ZmtGuiState` and place it in package `sim.display`.
With this setup, you can launch your simulation via zmt-launcher. For an example, consult [test files](https://gitlab.leibniz-zmt.de/ecomod/zmt-launcher/tree/master/src/test/java) of zmt-launcher.
### Example
You can find the whole example project in the `example/` sub directory.
```java
packagesim.engine;
importde.zmt.params.SimParams;
importsim.engine.MySim.MyParams;
publicclassMySimextendsBaseZmtSimState<MyParams>{
privatestaticfinallongserialVersionUID=1L;
@Override
publicClass<?extendsMyParams>getParamsClass(){
returnMyParams.class;
}
publicstaticclassMyParamsimplementsSimParams{
privatestaticfinallongserialVersionUID=1L;
privatelongseed;
@Override
publiclonggetSeed(){
returnseed;
}
publicvoidsetSeed(longseed){
this.seed=seed;
}
}
}
```
## The Launcher Application
The launcher is a command-line application that will be distributed together with your simulation when using [zmt-build](https://gitlab.leibniz-zmt.de/ecomod/zmt-build). You can use the `run-launcher` shortcut in your distribution's root directory to access it. Use option `--help` to display all available options.
### Launch Modes
Simulations can be launched in 3 different modes:
***GUI**: Opens the GUI of the simulation.
***SINGLE**: Launches a single run of the simulation.
***BATCH**: Launches a parallel batch run of simulations.
For example, to launch the [example](#example) simulation MySim in GUI mode, enter:
```shell
./run-launcher MySim gui
```
The package of the simulation can be omitted, if `sim.engine`.
### Batch Runs
Batch runs require an automation parameters XML file. To create one, you can use the option `--export-auto-params <FILE>` to export all available automation parameters to a file. Use this file to create your own set of automation parameters. Several parameter iterations can be specified after the locator tag ending with `</locator>`.
To export the [example simulation](#example)'s automation parameters, enter:
and the file exported-auto-params.xml will contain:
```
<AutoParams>
<simTime>1000.0</simTime>
<AutoDefinition>
<locator>
<field>
<name>seed</name>
<clazz>sim.engine.MySim$MyParams</clazz>
</field>
</locator>
<long>0</long>
</AutoDefinition>
</AutoParams>
```
If you want to automate with seeds 21, 22, 23, change the file to:
```
<AutoParams>
<simTime>1000.0</simTime>
<AutoDefinition>
<locator>
<field>
<name>seed</name>
<clazz>sim.engine.MySim$MyParams</clazz>
</field>
</locator>
<long>21</long>
<long>22</long>
<long>23</long>
</AutoDefinition>
</AutoParams>
```
At last, do not forget to adjust the simulation time as needed via the `<simTime>` tag and save the file. `parameters/autoParams.xml` is used in the example. Then start your batch run with: