# A Model-Driven Approach for Conducting Simulation Experiments
## 4 Implementation  
Our model-driven framework for conducting simulation experiments is realized in Java 8. This proof-of-concept implementation, thus far, comprises meta models for three simulation domains and different experiment types, the validation component, transformations and bindings to several backends, as well as the GUI and the CLI. The source code is publicly available in a Git repository ([[https://git.informatik.uni-rostock.de/mosi/exp-generation](https://git.informatik.uni-rostock.de/mosi/exp-generation)]([https://git.informatik.uni-rostock.de/mosi/exp-generation](https://git.informatik.uni-rostock.de/mosi/exp-generation)), accessed on 26 July 2022).  
At the heart of the implementation are the simulation experiment meta models, which are implemented using JSON Schema, Draft-07 [40]. We selected JSON Schema as a basis to formulate our schemas, since over the past few years, JSON has probably become the most popular format for exchanging data on the web, and therefore, a variety of capable parsers and validators exist.  
When launching the application, our dynamic GUI, implemented using JavaFX, is opened by default. After the user selects one of the included schemas, the GUI generates the necessary input tabs and fields (as shown in Figure 3). When pressing the \"Generate Experiment\" button, all collected user inputs are stored in the multipurpose data interchange format JSON [44] and presented to the user. The JSON files are validated against the JSON schemas using an open-source JSON Schema validator for Java, based on the org.json API [45]. Thereafter, the experiment specification for the selected backend is generated.  
For the mapping between the general schema inputs in JSON and the syntax of actual modeling and simulation tools, we used the template engine FreeMarker [46]. FreeMarker has a built-in template language in which the mappings can be specified. For each backend and schema input property, a mini template is implemented. A master template joins all the template snippets together. The template engine takes this master template and fills the template variables with the data from the JSON file.  
As an alternative to the GUI, we also provide a CLI, which allows for even more flexibility when working with our framework. For instance, one can transform an existing experiment specification for a target backend by running the command-line tool with the option -t <originalFile> <targetBackend>.  
The backends and formats currently supported by our framework are SESSL/ML-Rules with R, SystemC-AMS with Python, the Python libraries EMStimTools and Uncertainipy, and SED-ML (see the Evaluation Section, where their application is described).  
The time required for the experiment generation and transformation took less than a second on a standard laptop for the experiments shown in the evaluation. Thus, the execution time can be regarded as negligible in comparison to the time needed for experiment planning and input collection (which still have to be performed by the user and can only partly be automated). In fact, the overall time to create a simulation experiment may be decreased as the user is not bothered with the syntactical intricacies of the experiment types in the various specification languages and tools.