Commit 4846b945 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen

synchronize scenarioStore access. Use exact exponential function for...

synchronize scenarioStore access. Use exact exponential function for pedestrian and obstacle potential calculation
parent 9f043451
...@@ -61,10 +61,10 @@ public class PotentialFieldObstacleCompactSoftshell implements PotentialFieldObs ...@@ -61,10 +61,10 @@ public class PotentialFieldObstacleCompactSoftshell implements PotentialFieldObs
double currentPotential = 0; double currentPotential = 0;
if (distance < this.width) { if (distance < this.width) {
currentPotential = this.height * MathUtil.expAp(2 / (Math.pow(distance / (this.width), 2) - 1)); currentPotential = this.height * Math.exp(2 / (Math.pow(distance / (this.width), 2) - 1));
} }
if (distance < radius) { if (distance < radius) {
currentPotential += 100000 * MathUtil.expAp(1 / (Math.pow(distance / radius, 2) - 1)); currentPotential += 100000 * Math.exp(1 / (Math.pow(distance / radius, 2) - 1));
} }
if (potential < currentPotential) if (potential < currentPotential)
......
...@@ -62,14 +62,14 @@ public class PotentialFieldPedestrianCompactSoftshell implements PotentialFieldA ...@@ -62,14 +62,14 @@ public class PotentialFieldPedestrianCompactSoftshell implements PotentialFieldA
double factor = this.attributes.getIntimateSpaceFactor(); double factor = this.attributes.getIntimateSpaceFactor();
if (distance < personalWidth + radii) { if (distance < personalWidth + radii) {
potential += this.height * MathUtil.expAp(4 / (Math.pow(distance / (personalWidth + radii), (2 * perPower)) - 1)); potential += this.height * Math.exp(4 / (Math.pow(distance / (personalWidth + radii), (2 * perPower)) - 1));
} }
if (distance < this.intimateWidth + radii) { if (distance < this.intimateWidth + radii) {
potential += this.height / factor potential += this.height / factor
* MathUtil.expAp(4 / (Math.pow(distance / (this.intimateWidth + radii), (2 * intPower)) - 1)); * Math.exp(4 / (Math.pow(distance / (this.intimateWidth + radii), (2 * intPower)) - 1));
} }
if (distance < radii) { if (distance < radii) {
potential += 1000 * MathUtil.expAp(1 / (Math.pow(distance / radii, 4) - 1)); potential += 1000 * Math.exp(1 / (Math.pow(distance / radii, 4) - 1));
} }
} }
return potential; return potential;
......
...@@ -68,30 +68,37 @@ public class ScenarioRun implements Runnable { ...@@ -68,30 +68,37 @@ public class ScenarioRun implements Runnable {
@Override @Override
public void run() { public void run() {
try { try {
logger.info(String.format("Initializing scenario. Start of scenario '%s'...", scenario.getName())); /**
scenarioStore.getTopography().reset(); * To make sure that no other Thread changes the scenarioStore object during the initialization of a scenario run
* this is an atomic operation with respect to the scenarioStore. We observed that with Linux 18.04 KUbunto
MainModelBuilder modelBuilder = new MainModelBuilder(scenarioStore); * the GUI-Thread changes the scenarioStore object during a simulation run. Which can lead to any unexpected behaviour.
modelBuilder.createModelAndRandom(); */
synchronized (scenarioStore) {
final MainModel mainModel = modelBuilder.getModel(); logger.info(String.format("Initializing scenario. Start of scenario '%s'...", scenario.getName()));
final Random random = modelBuilder.getRandom(); scenarioStore.getTopography().reset();
// prepare processors and simulation data writer MainModelBuilder modelBuilder = new MainModelBuilder(scenarioStore);
if(scenarioStore.attributesSimulation.isWriteSimulationData()) { modelBuilder.createModelAndRandom();
processorManager = dataProcessingJsonManager.createProcessorManager(mainModel);
final MainModel mainModel = modelBuilder.getModel();
final Random random = modelBuilder.getRandom();
// prepare processors and simulation data writer
if(scenarioStore.attributesSimulation.isWriteSimulationData()) {
processorManager = dataProcessingJsonManager.createProcessorManager(mainModel);
}
// Only create output directory and write .scenario file if there is any output.
if(processorManager != null && !processorManager.isEmpty()) {
createAndSetOutputDirectory();
scenario.saveToOutputPath(outputPath);
}
sealAllAttributes();
// Run simulation main loop from start time = 0 seconds
simulation = new Simulation(mainModel, 0, scenarioStore.name, scenarioStore, passiveCallbacks, random, processorManager);
} }
// Only create output directory and write .scenario file if there is any output.
if(processorManager != null && !processorManager.isEmpty()) {
createAndSetOutputDirectory();
scenario.saveToOutputPath(outputPath);
}
sealAllAttributes();
// Run simulation main loop from start time = 0 seconds
simulation = new Simulation(mainModel, 0, scenarioStore.name, scenarioStore, passiveCallbacks, random, processorManager);
simulation.run(); simulation.run();
} catch (Exception e) { } catch (Exception e) {
......
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