Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at and make sure that your projects conform to the requirements.

Commit 8902ec63 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

close #110. add ScenarioStore copy for simulation so current Scenario does not...

close #110. add ScenarioStore copy for simulation so current Scenario does not change after simulation.
parent 969d4f54
Pipeline #69608 passed with stages
in 66 minutes and 8 seconds
......@@ -34,9 +34,11 @@ public class Scenario {
private static Logger logger = LogManager.getLogger(Scenario.class);
private ScenarioStore scenarioStore;
private ScenarioStore simulationScenarioStore;
private DataProcessingJsonManager dataProcessingJsonManager;
private String savedStateSerialized;
private String currentStateSerialized;
private boolean simulationRunning; // manage which copy of ScenarioStore is currently used.
public Scenario(final String name) {
......@@ -45,12 +47,41 @@ public class Scenario {
public Scenario(@NotNull final ScenarioStore store) {
this.scenarioStore = store;
this.simulationRunning = false;
this.dataProcessingJsonManager = new DataProcessingJsonManager();
public boolean isSimulationRunning() {
return simulationRunning;
* Creates a copy {@link ScenarioStore} which will be used in the simulation. After the simulation
* finishes, this copy is removed and the base version is used again. This is necessary, because
* the simulation seed is calculated for each simulation run and thus would change the base
* version of the simulation. The newly generated seed must be saved in the output copy of the
* {@link Scenario} file but not in the base version of the Scenario file.
public void setSimulationRunning(boolean simulationRunning) {
if (simulationRunning){
simulationScenarioStore = copyScenarioStore();
} else {
simulationScenarioStore = null;
this.simulationRunning = simulationRunning;
public ScenarioStore copyScenarioStore() {
try {
return JsonConverter.cloneScenarioStore(this.scenarioStore);
} catch (IOException e) {
throw new RuntimeException();
public void saveChanges() { // get's called by VadereProject.saveChanges on init
savedStateSerialized = JsonConverter.serializeScenarioRunManager(this);
currentStateSerialized = savedStateSerialized;
......@@ -86,7 +117,7 @@ public class Scenario {
public ScenarioStore getScenarioStore() {
return scenarioStore;
return simulationRunning ? simulationScenarioStore : scenarioStore;
public List<Attributes> getModelAttributes() {
......@@ -64,6 +64,7 @@ public class ScenarioRun implements Runnable {
// if overwriteTimestampSetting is true do note use timestamp in output directory
public ScenarioRun(final Scenario scenario, final String outputDir, boolean overwriteTimestampSetting, final RunnableFinishedListener scenarioFinishedListener) {
this.scenario = scenario;
this.scenario.setSimulationRunning(true); // create copy of ScenarioStore and redirect getScenarioStore to this copy for simulation.
this.scenarioStore = scenario.getScenarioStore();
this.dataProcessingJsonManager = scenario.getDataProcessingJsonManager();
this.setOutputPaths(Paths.get(outputDir), overwriteTimestampSetting); // TODO [priority=high] [task=bugfix] [Error?] this is a relative path. If you start the application via eclipse this will be VadereParent/output
......@@ -138,6 +139,7 @@ public class ScenarioRun implements Runnable {
if (finishedListener != null)
scenario.setSimulationRunning(false); // remove simulation copy of ScenarioStore and redirect getScenarioStore to base copy."Simulation of scenario %s finished.", scenario.getName()));
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