Commit d9019566 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

resolve merge conflict with local changes (HEAD).

parents a2895ab1 72194a05
Pipeline #68150 failed with stages
in 46 seconds
......@@ -3,6 +3,9 @@ target/
#Tools and build utils
......@@ -17,22 +20,38 @@ target/
#model test output
VadereModelTests/TestOSM/processed output/*
VadereModelTests/TestOSM_Group/processed output/*
VadereModelTests/TestSFM/processed output/*
VadereModelTests/TestGNM/processed output/*
VadereModelTests/TestOVM/processed output/*
#deprecated: can potentially be removed
#mac osx files
#linux deskopt dotfiles
# # GitLab CI Jobs
# Each of the jobs defined here is triggered by GitLab's CI pipeline.
# ## GitLab YAML Job Description Syntax
# <job_name>: # Job name which is displayed in web interface.
# stage: <stage_name> # <build|test|deploy>: these stages are executed
# # one after another. A stage can contain multiple
# # jobs.
# script:
# - <arbitrary_commands> # Here you can execute arbitratry terminal
# # commands. If any of the commands return a
# # non-zero exit code, the job fails.
# ## Maven Syntax for Skipping Unit Tests
# General syntax to execute unit tests:
# ```
# mvn test
# ```
# The comma-separated list of tests after "-Dtest=<list>" is skipped. All other
# tests are executed normally:
# ```
# mvn -Dtest=!TestClassA,!TestClassB,!TestClassC
# ```
# **Note:** on some CI instances the exclamation mark must be escaped by a
# backslash. Otherwise, it is interpreted by the executing shell as special
# command.
# ## Unit Test Limitations
# **Watch out:** OpenCL code cannot be run on virtual machines where tests are
# executed. Therefore, skip this tests.
stage: test
- mvn clean
- mvn -Dtest=!TestConvolution,!TestBitonicSort,!TestCLLinkedList test
- python3 Tools/ContinuousIntegration/
stage: deploy
- mvn clean
- mvn -Dmaven.test.skip=true package
- python3 Tools/ContinuousIntegration/
Copy files "post-checkout", "post-merge", "post-applypatch" and "post-commit" to .git/hooks/
The file "current_commit_hash.txt" will be created after a change to the current commit status. To create this file without changes to the current commit, you can choose "Switch/Checkout..." on the Repository folder.
\ No newline at end of file
......@@ -47,8 +47,9 @@ For this project, GPGPU with OpenCL is used to speed up some computations. There
### Run the Application
1. Get the Source: Run `git clone`.
2. Build the Application: Go to the project directory and run `mvn clean package` (or `mvn clean package -DskipTests` if you want to skip the unit tests).
3. Start the Application: After building the application, you can start Vadere by running `java -jar VadereGui/target/gui-0.1-SNAPSHOT-jar-with-dependencies.jar`.
2. Build the Application: Go to the project directory and run `mvn clean package` (or `mvn clean package -DskipTests` if you want to skip the unit tests). This will build `vadere.jar`and `postvis.jar`.
3. Start the Application: After building the application, you can start Vadere by running `java -jar VadereGui/target/vadere.jar`.
4. (If you only want to use the Postvisualization-Tool you can do so by running `java -jar VadereGui/target/postvis.jar`).
## Usage Example
# Extract line and branch coverage (in percentage) from HTML coverage reports
# which are created by Maven's jacoco plugin.
# Use top-level pom.xml to search in correct subdirectories.
# Wach out: call this script from root directory of project. E.g.
# python Tools/
import xml.etree.ElementTree as ET
import os
import re
def get_modules_from_pom_file(filename="pom.xml"):
"""Return a list of submodules which where found in passed "pom.xml"."""
xml_name_spaces = {
"default": ""
xml_tree = ET.parse(filename)
xml_root = xml_tree.getroot()
exclude_list = ["./VadereAnnotation", "./VadereGui"]
modules = xml_root.findall("default:modules/default:module", xml_name_spaces)
module_names = [module.text for module in modules if module.text not in exclude_list]
return module_names
def extract_line_and_branch_coverage(module_names):
"""Return a dictionary which maps module name to line and branch coverage tuple."""
module_to_coverage = dict()
default_coverage_file = "target/site/coverage-reports/index.html"
for module in module_names:
coverage_path = os.path.join(module, default_coverage_file)
with open(coverage_path, "r") as file:
coverage_report =
regex_pattern = re.compile(r"Total.*?([0-9]{1,3})%.*?([0-9]{1,3})%")
match =
if match:
line_coverage = float(
branch_coverage = float(
module_to_coverage[module] = (line_coverage, branch_coverage)
raise Exception("Coverage data not found for module: {}".format(module))
return module_to_coverage
def print_averaged_line_coverage(coverage_data):
"""GitLab CI tools read out the stdout output of the build process. Therefore, print coverage info to stdout."""
total_modules = len(coverage_data)
line_coverage_data = [line_coverage for (line_coverage, branch_coverage) in coverage_data.values()]
branch_coverage_data = [branch_coverage for (line_coverage, branch_coverage) in coverage_data.values()]
summed_line_coverage_data = sum(line_coverage_data)
summed_branch_coverage_data = sum(branch_coverage_data)
# By default, GitLab CI parses only integers.
averaged_line_coverage = int(round(summed_line_coverage_data / total_modules, 0))
averaged_branch_coverage = int(round(summed_branch_coverage_data / total_modules, 0))
print("Analyzed modules: {}".format(sorted(coverage_data.keys())))
print("Line Coverage: Total {}%".format(averaged_line_coverage))
print("Branch Coverage: Total {}%".format(averaged_branch_coverage))
if __name__ == "__main__":
module_names = get_modules_from_pom_file()
module_to_coverage = extract_line_and_branch_coverage(module_names)
# Use "vadere-console.jar", which is created by "mvn package", to run all
# scenario files under "VadereModelTests" subdirectory.
# Note: script contains some print statements so that progress can be tracked
# a little bit
# Wach out: call this script from root directory of project. E.g.
# python Tools/
import fnmatch
import os
import re
import shutil
import subprocess
import time
def find_scenario_files(path="VadereModelTests", scenario_search_pattern = "*.scenario", exclude_patterns = ["TESTOVM", "output","legacy"]):
scenario_files = []
for root, dirnames, filenames in os.walk(path):
for filename in fnmatch.filter(filenames, scenario_search_pattern):
scenario_path = os.path.join(root, filename)
scenario_path_excluded = False
for exclude_pattern in exclude_patterns:
regex_pattern = re.compile(exclude_pattern)
match =
if match:
scenario_path_excluded = True
if scenario_path_excluded == False:
print("Total scenario files: {}".format(len(scenario_files)))
# print("Exclude patterns: {}".format(exclude_patterns))
return sorted(scenario_files)
def run_scenario_files_with_vadere_console(scenario_files, vadere_console="VadereGui/target/vadere-console.jar", scenario_timeout_in_sec=60):
output_dir = "output"
if not os.path.exists(output_dir):
total_scenario_files = len(scenario_files)
passed_scenarios = []
failed_scenarios_with_exception = []
for i, scenario_file in enumerate(scenario_files):
# Surpress this output to print only failed scenarios.
# print("Running scenario file ({}/{}): {}".format(i + 1, total_scenario_files, scenario_file))
# Measure wall time and not cpu because it is the easiest.
wall_time_start = time.time()
# Use timout feature, check return value and capture stdout/stderr to a PIPE (use completed_process.stdout to get it).
completed_process =["java", "-enableassertions", "-jar", vadere_console, "scenario-run", "-f", scenario_file, "-o", output_dir],
wall_time_end = time.time()
wall_time_delta = wall_time_end - wall_time_start
# Surpress this output to print only failed scenarios.
# print("Finished scenario file ({:.1f} s): {}".format(wall_time_delta, scenario_file))
except subprocess.TimeoutExpired as exception:
prefix = ""
if "TestOSM" in scenario_file:
prefix = " * OSM * "
print(prefix + "Scenario file failed: {}".format(scenario_file))
print("-> Reason: timeout after {} s".format(exception.timeout))
failed_scenarios_with_exception.append((scenario_file, exception))
except subprocess.CalledProcessError as exception:
prefix = ""
if "TestOSM" in scenario_file:
prefix = " * OSM * "
print(prefix + "Scenario file failed: {}".format(scenario_file))
print("-> Reason: non-zero return value {}".format(exception.returncode))
failed_scenarios_with_exception.append((scenario_file, exception))
if os.path.exists(output_dir):
return {"passed": passed_scenarios, "failed": failed_scenarios_with_exception}
if __name__ == "__main__":
print("Output is only shown for failed scenarios!")
long_running_scenarios = [
excluded_scenarios = ["TESTOVM", "output", "legacy"]
scenario_files_regular_length = find_scenario_files(exclude_patterns=excluded_scenarios)
passed_and_failed_scenarios = run_scenario_files_with_vadere_console(scenario_files_regular_length)
for scenario in long_running_scenarios:
search_pattern = "*" + scenario + "*.scenario"
scenario_files_long = find_scenario_files(scenario_search_pattern=search_pattern)
tmp_passed_and_failed_scenarios = run_scenario_files_with_vadere_console(scenario_files_long, scenario_timeout_in_sec=480)
if len(passed_and_failed_scenarios["failed"]) > 0:
# Marker-File for MigrationUtil
The content of this file is ignored
All scenario files in this directory will NOT be migrated.
This Marker-File will allow traversal down the directory tree.
Use DO_NOT_MIGRATE_TREE or .DO_NOT_MIGRATE_TREE to stop migration for
the complete subtree of the current directory.
\ No newline at end of file
# Marker-File for MigrationUtil
The content of this file is ignored.
All scenario files in this directory and all child directories will _NOT_ be migrated.
Use DO_NOT_MIGRATE or .DO_NOT_MIGRATE to stop migration only for the current directory and
allow traversal down to child directories.
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""
<name>Vadere Annotation</name>
<!-- Use JaCoCo's Java agents to record coverage data by using on-the-fly class file instrumentation. -->
<!-- Use JaCoCo agent output to create coverage reports in CSV, HTML and XML format. -->
<!-- Maven Surefire is used to execute unit tests. -->
\ No newline at end of file
package org.vadere.annotation.factories;
import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.annotation.factories.outputfiles.OutputFileClass;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
* Base FactoryProcessor to generate Factories
* Factories are crated with two annotations: {@link FactoryType} and a specific Annotation Interface
* declaring a new Factory. {@link FactoryType} is used to annotate the specific annotation used
* for factories (i.e. {@link OutputFileClass}, {@link DataProcessorClass},
* {@link org.vadere.annotation.factories.models.ModelClass} and
* {@link org.vadere.annotation.factories.attributes.ModelAttributeClass})
* The {@link AbstractFactoryProcessor} defines process loop used to
* generate java source files. It also provides abstract methods as hooks to allow
* child classes to add additional elements into the generated java source file.
* All hooks have access to the PrintWriter used to create the java source file as well
* the Set of TypElements annotated with the specific annotation used in this {@link javax.annotation.processing.Processor}
* <ul>
* <li>{@link #addImports(Set, PrintWriter)}: </br>
* This hook allows the implementing class to add additional import statements
* which where not mentioned in the {@link FactoryType} annotation interface.
* </li>
* <li>{@link #addMembers(Set, PrintWriter)}: </br>
* This hook allows the implementing class to add additional members to the new
* java source file.
* </li>
* <li>{@link #addLastConstructor(Set, PrintWriter)}: </br>
* This hook allows the implementing class to add additional statement to the
* Constructor of the new Factory. Only the Default constructor is implemented!
* </li>
* <li>{@link #addLastConstructor(Set, PrintWriter)}: </br>
* This hook allows the implementing class to add additional function to the
* new java source file.
* </li>
* </ul>
* {@link #addImports(Set, PrintWriter)}
public abstract class AbstractFactoryProcessor extends AbstractProcessor {
private static final String QUOTE = "\"";
protected String factoryClassName; //Name of the new Factory
protected String extendedClassName; //Name of the Factory which needs to be extended.
protected String genericFactoryTypes; //Generics if extendedClass needs it.
protected String factoryPackage; //Where to place the new Factory.
protected String[] factoryImports; //Imports needed by the new Factory.
* This method is called from the java compiler directly*
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
for (TypeElement annotation : annotations) {
//only no abstract classes...
Set<? extends Element> annotatedElements =
.filter(e -> e.getKind().isClass()
&& !e.getKind().equals(ElementKind.ENUM)
&& !e.getModifiers().contains(Modifier.ABSTRACT)
if (annotatedElements.isEmpty())
try {
} catch (IOException e) {
return true;
protected abstract void addImports(Set<? extends Element> elements, PrintWriter writer);
protected abstract void addMembers(Set<? extends Element> elements, PrintWriter writer);
protected abstract void addLastConstructor(Set<? extends Element> elements, PrintWriter writer);
protected abstract void addLast(Set<? extends Element> elements, PrintWriter writer);
protected String name(Element e) {
return e.getSimpleName().toString();
* This method is called for each SupportedAnnotationTypes from the {@link #process(Set, RoundEnvironment)}
* method. The current implementation only allows ONE SupportedAnnotationTypes because this
* method build the whole java source file.
* @param elements Elements annotated with one of the SupportedAnnotationTypes
protected abstract void writeFactory(Set<? extends Element> elements) throws IOException;
* Create class statement based on information provided by the {@link FactoryType} annotation
* @param elements Elements annotated with one of the SupportedAnnotationTypes
* @param writer PrintWriter used to create the source file.
protected void buildClass(Set<? extends Element> elements, PrintWriter writer) {
writer.append("public class ").append(factoryClassName);
if (!extendedClassName.isEmpty()) {
writer.append(" extends ").append(extendedClassName);
if (!genericFactoryTypes.isEmpty()) {
writer.append("<").append(genericFactoryTypes).append("> ");
* Create a getter for each Element in elements set. The underling TypeElement
* is a Class and must have a constructor without parameters.