Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit b50befdd authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

add additional call to topographyController to synchronize the LinkedCellGrid.

parent a1f3607a
Pipeline #77737 failed with stages
in 109 minutes and 33 seconds
......@@ -14,6 +14,8 @@ import re
import shutil
import subprocess
import time
import argparse
def find_scenario_files(path="VadereModelTests", scenario_search_pattern = "*.scenario", exclude_patterns = ["TESTOVM", "output","legacy"]):
scenario_files = []
......@@ -44,17 +46,22 @@ def run_scenario_files_with_vadere_console(scenario_files, vadere_console="Vader
passed_scenarios = []
failed_scenarios_with_exception = []
failed_summary = []
for i, scenario_file in enumerate(scenario_files):
try:
print("Running scenario file ({}/{}): {}".format(i + 1, total_scenario_files, scenario_file))
scenario_name = os.path.basename(scenario_file).split('.')[0]
log_file = os.path.join(scenario_name + ".log")
# Measure wall time and not CPU time simply because it is the simplest method.
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 = subprocess.run(args=["java", "-enableassertions", "-jar", vadere_console, "scenario-run", "-f", scenario_file, "-o", output_dir],
completed_process = subprocess.run(args=["java", "-enableassertions", "-jar", vadere_console,
"--logname", log_file, "scenario-run", "-f",
scenario_file, "-o", output_dir],
timeout=scenario_timeout_in_sec,
check=True,
stdout=subprocess.PIPE,
......@@ -65,6 +72,7 @@ def run_scenario_files_with_vadere_console(scenario_files, vadere_console="Vader
print("Finished scenario file ({:.1f} s): {}".format(wall_time_delta, scenario_file))
passed_scenarios.append(scenario_file)
except subprocess.TimeoutExpired as exception:
print("Scenario file failed: {}".format(scenario_file))
......@@ -76,17 +84,39 @@ def run_scenario_files_with_vadere_console(scenario_files, vadere_console="Vader
prefix = " * OSM * "
print(prefix + "Scenario file failed: {}".format(scenario_file))
print("-> Reason: non-zero return value {}".format(exception.returncode))
print(" {}".format(read_first_error_linies(exception.stderr)))
failed_summary.append(prefix + "Scenario file failed: {}".format(scenario_file))
failed_summary.append("-> Reason: non-zero return value {}".format(exception.returncode))
failed_summary.append(" {}".format(read_first_error_linies(exception.stderr)))
failed_scenarios_with_exception.append((scenario_file, exception))
if os.path.exists(output_dir):
shutil.rmtree(output_dir)
return {"passed": passed_scenarios, "failed": failed_scenarios_with_exception}
return {"passed": passed_scenarios, "failed": failed_scenarios_with_exception, "failed_summary": failed_summary}
def read_first_error_linies(error_byte_string):
err_string_lines = error_byte_string.decode('utf-8').split('\n')
if len(err_string_lines) >= 2:
return re.sub('\s+', ' ', ' '.join(err_string_lines[:2]))
else:
return 'unknown error see vadere log file.'
def print_summary(passed_and_failed_scenarios):
total_passed_scenarios = len(passed_and_failed_scenarios["passed"])
total_failed_scenarios = + len(passed_and_failed_scenarios["failed"])
total_scenarios = total_passed_scenarios + total_failed_scenarios
faild_summary = passed_and_failed_scenarios["failed_summary"]
if len(faild_summary) > 0:
print("#################")
print("# Faild Summary #")
print("#################")
for line in faild_summary:
print(line)
print("###########")
print("# Summary #")
......@@ -96,17 +126,16 @@ def print_summary(passed_and_failed_scenarios):
print("Passed: {}".format(total_passed_scenarios))
print("Failed: {}".format(total_failed_scenarios))
if __name__ == "__main__":
def run_all():
long_running_scenarios = [
"basic_4_1_wall_gnm1",
"queueing",
"rimea_09",
"rimea_11",
"TestSFM",
"thin_wall_and_closer_source_nelder_mead_ok",
"thin_wall_and_closer_source_pso_could_fail",
"rimea_04_flow_osm1_550_up",
"basic_4_1_wall_gnm1",
"queueing",
"rimea_09",
"rimea_11",
"TestSFM",
"thin_wall_and_closer_source_nelder_mead_ok",
"thin_wall_and_closer_source_pso_could_fail",
"rimea_04_flow_osm1_550_up",
]
excluded_scenarios = ["TESTOVM", "output", "legacy"]
......@@ -118,9 +147,24 @@ if __name__ == "__main__":
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)
tmp_passed_and_failed_scenarios = run_scenario_files_with_vadere_console(scenario_files_long,
scenario_timeout_in_sec=480)
passed_and_failed_scenarios["passed"].extend(tmp_passed_and_failed_scenarios["passed"])
passed_and_failed_scenarios["failed"].extend(tmp_passed_and_failed_scenarios["failed"])
passed_and_failed_scenarios["failed_summary"].extend(tmp_passed_and_failed_scenarios["failed_summary"])
return passed_and_failed_scenarios
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Run ModelTest')
parser.add_argument('--scenario', '-s', nargs='?', default='', metavar='S', help='only run one selected scenario')
args = vars(parser.parse_args())
if args['scenario'] == '':
passed_and_failed_scenarios = run_all()
else:
passed_and_failed_scenarios = run_scenario_files_with_vadere_console([args['scenario']])
print_summary(passed_and_failed_scenarios)
......
......@@ -289,12 +289,13 @@ public class Simulation {
targetController.update(simTimeInSec);
}
topographyController.update(simTimeInSec);
topographyController.update(simTimeInSec); //rebuild CellGrid
step++;
for (Model m : models) {
m.update(simTimeInSec);
}
topographyController.update(simTimeInSec); //rebuild CellGrid
if (topographyController.getTopography().hasTeleporter()) {
teleporterController.update(simTimeInSec);
......
......@@ -27,9 +27,9 @@ public class TargetController {
public TrafficLightPhase phase = TrafficLightPhase.GREEN;
public TargetController(Topography scenario, Target target) {
public TargetController(Topography topography, Target target) {
this.target = target;
this.topography = scenario;
this.topography = topography;
if (this.target.isStartingWithRedLight()) {
phase = TrafficLightPhase.RED;
......
......@@ -21,6 +21,9 @@ public class VadereConsole {
private final static Logger logger = Logger.getLogger(VadereConsole.class);
public static void main(String[] args) {
// rimea_01_pathway_gnm1.scenario rimea_04_flow_gnm1_050_h.scenario
// String[] tmp = {"scenario-run", "-f", "VadereModelTests/TestGNM/scenarios/rimea_04_flow_gnm1_050_h.scenario"};
// args = tmp;
ArgumentParser parser = createArgumentParser();
try {
......
......@@ -61,7 +61,9 @@ public class DynamicElementContainer<T extends DynamicElement> {
this.elementMap.put(element.getId(), element);
this.cellsElements.addObject(element);
assert (elementMap.size() == cellsElements.size());
assert (elementMap.size() == cellsElements.size())
: "Number of pedestrians in LinkedCellGrid does not match number of pedestrians" +
" in topography";
for (DynamicElementAddListener<T> listener : addListener) {
listener.elementAdded(element);
......@@ -71,7 +73,10 @@ public class DynamicElementContainer<T extends DynamicElement> {
public synchronized void moveElement(T element, VPoint oldPosition) {
this.cellsElements.moveObject(element, oldPosition);
assert (elementMap.size() == cellsElements.size());
assert (elementMap.size() == cellsElements.size())
: "Number of pedestrians in LinkedCellGrid does not match number of pedestrians" +
" in topography";
for (DynamicElementMoveListener<T> listener : moveListener) {
listener.elementMove(element);
}
......@@ -81,7 +86,9 @@ public class DynamicElementContainer<T extends DynamicElement> {
this.elementMap.remove(element.getId());
this.cellsElements.removeObject(element);
assert (elementMap.size() == cellsElements.size());
assert (elementMap.size() == cellsElements.size())
: "Number of pedestrians in LinkedCellGrid does not match number of pedestrians" +
" in topography";
for (DynamicElementRemoveListener<T> listener : removeListener) {
listener.elementRemoved(element);
}
......
......@@ -76,6 +76,33 @@ public class LinkedCellsGrid<T extends PointPositioned> implements Iterable<T> {
}
}
private class ContainerisedElement {
final private int[] cell;
final private T object;
ContainerisedElement(int[] cell, T object){
this.cell = cell;
this.object = object;
}
public int[] getCell() {
return cell;
}
public T getObject() {
return object;
}
@Override
public String toString() {
return "ContainerisedElement{" +
"cell=" + Arrays.toString(cell) +
", object=" + object +
", pos= " + ((PointPositioned)object).getPosition() +
'}';
}
}
/**
* Generates an empty grid of GridCell&lt;T&gt; objects.
*
......@@ -301,6 +328,19 @@ public class LinkedCellsGrid<T extends PointPositioned> implements Iterable<T> {
return false;
}
public List<ContainerisedElement> getElementContainer(final T element){
List<ContainerisedElement> elements = new ArrayList<>();
for (int r = 0; r < grid.length; r++) {
// TODO [priority=medium] [task=test] changed this [20.08.2014] here 1 to r - pls check this
for (int c = 0; c < grid[r].length; c++) {
if (grid[r][c].objects.contains(element)){
elements.add(new ContainerisedElement(new int[]{r, c}, element));
}
}
}
return elements;
}
@Override
public int hashCode() {
final int prime = 31;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment