Commit 198a1495 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Merge branch 'master' into add_event_handling

# Conflicts:
#	VadereSimulator/src/org/vadere/simulator/models/osm/updateScheme/UpdateSchemeEventDriven.java
parents 183c0de1 ea45334e
Pipeline #80991 failed
......@@ -194,6 +194,10 @@ public abstract class SimulationRenderer extends DefaultRenderer {
potentialFieldImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
double maxDistance = Math.sqrt(model.getTopography().getBounds().getWidth() * model.getTopography().getBounds().getWidth() +
model.getTopography().getBounds().getHeight() * model.getTopography().getBounds().getHeight());
colorHelper = new ColorHelper((int)(maxDistance * 0.7));
for (int x = 0; x < potentialFieldImage.getWidth(); x++) {
for (int y = 0; y < potentialFieldImage.getHeight(); y++) {
Color c;
......
......@@ -319,7 +319,7 @@ public class PedestrianOSM extends Pedestrian {
* @return the step duration of this agent
*/
public double getDurationNextStep() {
return getDesiredStepSize() / getDesiredSpeed();
return Math.min(getAttributesOSM().getMaxStepDuration(), getDesiredStepSize() / getDesiredSpeed());
}
public AttributesOSM getAttributesOSM() {
......
......@@ -55,12 +55,9 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
}
// this can cause problems if the pedestrian desired speed is 0 (see speed adjuster)
if(pedestrian.getDesiredSpeed() >= pedestrian.getAttributes().getMinimumSpeed()) {
pedestrian.updateNextPosition();
makeStep(topography, pedestrian, pedestrian.getDurationNextStep());
}
double stepDuration = Math.min(pedestrian.getAttributesOSM().getMaxStepDuration(), pedestrian.getDurationNextStep());
pedestrian.updateNextPosition();
double stepDuration = pedestrian.getDurationNextStep();
makeStep(topography, pedestrian, stepDuration);
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + stepDuration);
} else if (mostImportantEvent instanceof WaitEvent || mostImportantEvent instanceof WaitInAreaEvent) {
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep());
......
......@@ -155,7 +155,9 @@ public interface IPotentialField {
* A default distance function which uses all shapes to compute the distance.
*/
IDistanceFunction distanceFunc = new DistanceFunction(bbox, holes);
IEdgeLengthFunction edgeLengthFunction = p -> 1.0 + Math.max(0, -distanceFunc.apply(p));
IEdgeLengthFunction edgeLengthFunction = p -> 1.0 + Math.max(0, Math.min(-distanceFunc.apply(p), 22));
//IEdgeLengthFunction edgeLengthFunction = p -> 1.0;
/**
* Generate the mesh, we use the pointer based implementation here.
......
......@@ -164,11 +164,12 @@ public class TestSourceControllerUsingConstantSpawnRate {
@Test
public void testUpdateUseFreeSpaceOnly() {
AttributesAgent attributesAgent = new AttributesAgent();
SourceTestAttributesBuilder builder = new SourceTestAttributesBuilder()
.setOneTimeSpawn(0)
.setSpawnNumber(100)
.setUseFreeSpaceOnly(true)
.setSourceDim(new VRectangle(0, 0, 0.4, 0.4)); // small source
.setSourceDim(new VRectangle(0, 0, attributesAgent.getRadius()*2 + 0.05, attributesAgent.getRadius()*2 + 0.05)); // small source
initialize(builder);
for (double simTimeInSec = 0; simTimeInSec < 1000; simTimeInSec += 1.0) {
......
......@@ -3,6 +3,7 @@ package org.vadere.simulator.control;
import org.apache.commons.math3.distribution.ConstantRealDistribution;
import org.apache.commons.math3.random.RandomGenerator;
import org.junit.Test;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.attributes.scenario.AttributesSource;
import org.vadere.state.attributes.scenario.SourceTestAttributesBuilder;
import org.vadere.state.scenario.Pedestrian;
......@@ -100,11 +101,12 @@ public class TestSourceControllerUsingDistributions extends TestSourceController
double startTime = 0;
double endTime = 1;
int spawnNumber = 100;
AttributesAgent attributesAgent = new AttributesAgent();
SourceTestAttributesBuilder builder = new SourceTestAttributesBuilder()
.setStartTime(startTime).setEndTime(endTime)
.setSpawnNumber(100)
.setUseFreeSpaceOnly(true)
.setSourceDim(new VRectangle(0, 0, 0.4, 0.4));
.setSourceDim(new VRectangle(0, 0, attributesAgent.getRadius()*2 + 0.05, attributesAgent.getRadius()*2 + 0.05));
initialize(builder);
doUpdates(0, 100, startTime, endTime + 1);
......@@ -124,11 +126,12 @@ public class TestSourceControllerUsingDistributions extends TestSourceController
// expected: not stop spawning before all pedestrians are created (even after end time)
double startTime = 1;
int spawnNumber = 100;
AttributesAgent attributesAgent = new AttributesAgent();
SourceTestAttributesBuilder builder = new SourceTestAttributesBuilder()
.setOneTimeSpawn(startTime)
.setSpawnNumber(100)
.setUseFreeSpaceOnly(true)
.setSourceDim(new VRectangle(0, 0, 0.4, 0.4));
.setSourceDim(new VRectangle(0, 0, attributesAgent.getRadius()*2 + 0.05, attributesAgent.getRadius()*2 + 0.05));
initialize(builder);
doUpdates(0, 100, 0, startTime + 1);
......
......@@ -53,7 +53,7 @@ public class PedestrianOverlapProcessorTestEnv extends ProcessorTestEnv<Timestep
@Override
public void loadDefaultSimulationStateMocks() {
double minDist = 0.195*2;
double minDist = new AttributesAgent().getRadius()*2;
addSimState(new SimulationStateMock(1) {
@Override
......
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