Commit 7062c914 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen

Merge branch 'master' into dev/parallelEventDrivenOSM-CPU

parents 7e716c00 17ea3e8c
Pipeline #266820 passed with stages
in 142 minutes and 19 seconds
......@@ -99,7 +99,7 @@
"attributesSimulation" : {
"finishTime" : 500.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"realTimeSimTimeRatio" : 0.2,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
......@@ -157,7 +157,7 @@
"height" : 2.1,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTime" : 10.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
......@@ -208,7 +208,7 @@
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 3 ],
"groupSizeDistribution" : [ 0.2, 0.6, 0.1, 0.1 ],
"groupSizeDistribution" : [ 0.5, 0.5, 0.0, 0.1 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
......
......@@ -62,7 +62,7 @@
"timeCostAttributes" : {
"standardDeviation" : 0.7,
"type" : "NAVIGATION",
"obstacleDensityWeight" : 3.5,
"obstacleDensityWeight" : 2.0,
"pedestrianSameTargetDensityWeight" : 3.5,
"pedestrianOtherTargetDensityWeight" : 3.5,
"pedestrianWeight" : 3.5,
......
......@@ -61,8 +61,8 @@
"cacheDir" : "",
"timeCostAttributes" : {
"standardDeviation" : 0.7,
"type" : "UNIT",
"obstacleDensityWeight" : 3.5,
"type" : "OBSTACLES",
"obstacleDensityWeight" : 0.3,
"pedestrianSameTargetDensityWeight" : 3.5,
"pedestrianOtherTargetDensityWeight" : 3.5,
"pedestrianWeight" : 3.5,
......@@ -307,7 +307,7 @@
}
} ],
"targets" : [ {
"id" : 1,
"id" : 2,
"absorbing" : true,
"shape" : {
"type" : "POLYGON",
......@@ -381,7 +381,7 @@
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 4,
"spawnNumber" : 2,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 200.0,
......@@ -389,7 +389,38 @@
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 0.2, 0.6, 0.1, 0.1 ],
"groupSizeDistribution" : [ 0.1, 0.3, 0.3, 0.2, 0.1 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
}, {
"id" : 6,
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 23.5,
"y" : 49.5
}, {
"x" : 23.5,
"y" : 46.0
}, {
"x" : 33.1,
"y" : 46.0
}, {
"x" : 34.96,
"y" : 49.5
} ]
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 2,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 200.0,
"spawnAtRandomPositions" : true,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 0.1, 0.3, 0.3, 0.2, 0.1 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
......
......@@ -102,7 +102,7 @@
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 50.0,
"width" : 40.0,
"height" : 50.0
},
"boundingBoxWidth" : 0.5,
......@@ -179,10 +179,7 @@
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 49.5,
"y" : 42.50668004900217
}, {
"x" : 49.5,
"x" : 39.5,
"y" : 49.5
}, {
"x" : 35.0,
......@@ -203,11 +200,8 @@
"x" : 34.0,
"y" : 0.5
}, {
"x" : 49.5,
"x" : 39.5,
"y" : 0.5
}, {
"x" : 49.5,
"y" : 5.936819093301892
} ]
},
"id" : 1
......@@ -390,11 +384,11 @@
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 21.010790275986494,
"y" : 10.9817920099541
"x" : 21.35,
"y" : 11.9817920099541
}, {
"x" : 20.591772163127747,
"y" : 11.191301066383476
"x" : 21.0,
"y" : 12.191301066383476
}, {
"x" : 30.333943287093724,
"y" : 40.94158707935486
......@@ -442,17 +436,17 @@
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 28.05470964448629,
"y" : 32.1
"x" : 27.59572110981215,
"y" : 32.531925106398724
}, {
"x" : 21.44285351378531,
"y" : 38.0
"x" : 21.92020158984668,
"y" : 37.59639785139872
}, {
"x" : 21.572497751642192,
"y" : 38.2
"x" : 22.031486286316593,
"y" : 37.76807489360211
}, {
"x" : 28.184353882343178,
"y" : 32.3
"x" : 27.707005806282062,
"y" : 32.70360214860211
} ]
},
"reachDistance" : 0.3,
......@@ -464,17 +458,17 @@
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 27.439446014333257,
"y" : 28.285981700079258
"x" : 26.4,
"y" : 28.76583413402359
}, {
"x" : 20.516322240376294,
"y" : 34.66978655463252
"x" : 21.035818063599688,
"y" : 34.21113803183719
}, {
"x" : 20.66055398566706,
"y" : 34.81401829992329
"x" : 21.15884589773846,
"y" : 34.33416586597596
}, {
"x" : 27.58367775962403,
"y" : 28.43021344537003
"x" : 26.55,
"y" : 28.888861968162367
} ]
},
"reachDistance" : 0.3,
......@@ -486,17 +480,17 @@
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 25.486634085766024,
"y" : 24.273692002794803
"x" : 24.885354903217365,
"y" : 25.012990569770203
}, {
"x" : 19.464312459212408,
"y" : 31.208835176007327
"x" : 20.189569160702,
"y" : 30.420530793375065
}, {
"x" : 19.62789284634321,
"y" : 31.372415563138134
"x" : 20.31711772042307,
"y" : 30.54807935309614
}, {
"x" : 25.783622615467696,
"y" : 24.42218626764563
"x" : 25.116925813896508,
"y" : 25.128776025109765
} ]
},
"reachDistance" : 0.3,
......@@ -508,17 +502,17 @@
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 28.870142404485026,
"y" : 36.3
"x" : 28.297727260115597,
"y" : 36.84630908567894
}, {
"x" : 22.12557986285388,
"y" : 42.197088668076134
"x" : 22.860684684954602,
"y" : 41.600171468883275
}, {
"x" : 22.582838340252597,
"y" : 42.23462847644043
"x" : 23.229297740897717,
"y" : 41.63043370384369
}, {
"x" : 29.783408945102963,
"y" : 36.0
"x" : 29.033945366651064,
"y" : 36.60446793401341
} ]
},
"reachDistance" : 0.3,
......@@ -530,17 +524,17 @@
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 15.0,
"y" : 14.1
"x" : 15.634497775611411,
"y" : 13.74942251791075
}, {
"x" : 15.1,
"y" : 14.2
"x" : 15.713747928509028,
"y" : 13.828672670808366
}, {
"x" : 21.3,
"y" : 10.6
"x" : 21.1,
"y" : 10.975667166494198
}, {
"x" : 21.25,
"y" : 10.5
"x" : 21.0,
"y" : 10.896417013596583
} ]
},
"reachDistance" : 0.3,
......@@ -552,17 +546,17 @@
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 24.6,
"y" : 19.8
"x" : 23.76944034179448,
"y" : 20.72968424052916
}, {
"x" : 18.3,
"y" : 26.4
"x" : 19.10710546641564,
"y" : 25.614035062354606
}, {
"x" : 18.5,
"y" : 26.7
"x" : 19.255116097380046,
"y" : 25.836051008801217
}, {
"x" : 24.7,
"y" : 20.1
"x" : 23.843445657276682,
"y" : 20.95170018697577
} ]
},
"reachDistance" : 0.3,
......@@ -574,17 +568,17 @@
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 22.262999925516617,
"y" : 14.042403212776234
"x" : 21.688139768064744,
"y" : 14.602062605134757
}, {
"x" : 16.741663364019423,
"y" : 19.05399091833302
"x" : 17.406095132531206,
"y" : 18.488774094474955
}, {
"x" : 16.841273409781802,
"y" : 19.253211009857786
"x" : 17.483347199553613,
"y" : 18.643278228519776
}, {
"x" : 22.462220017041382,
"y" : 14.241623304301
"x" : 21.842643902109565,
"y" : 14.756566739179574
} ]
},
"reachDistance" : 0.3,
......@@ -596,17 +590,17 @@
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 22.86047995471745,
"y" : 16.59554945886502
"x" : 22.482542681969914,
"y" : 17.061895214242636
}, {
"x" : 17.780470554881653,
"y" : 22.491988940817286
"x" : 18.223023396221993,
"y" : 22.00598009948576
}, {
"x" : 17.871185008450148,
"y" : 22.673417847954276
"x" : 18.299086240610347,
"y" : 22.158105788262468
}, {
"x" : 23.041908861854445,
"y" : 16.776978366002012
"x" : 22.634668370746628,
"y" : 17.214020903019346
} ]
},
"reachDistance" : 0.3,
......
......@@ -81,7 +81,7 @@
"attributesSimulation" : {
"finishTime" : 500.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.0,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
......
......@@ -51,7 +51,7 @@ public abstract class SimulationModel<T extends DefaultSimulationConfig> extends
return config;
}
public IMesh<?, ?, ?> getDiscretization() {
public IMesh<?, ?, ?> getFloorFieldMesh() {
return new PMesh();
}
......
......@@ -673,7 +673,10 @@ public abstract class DefaultRenderer {
@NotNull final Graphics2D g,
@NotNull final IMesh<?, ?, ?> mesh,
@NotNull final VRectangle bound) {
MeshRenderer<?, ?, ?> meshRenderer = new MeshRenderer<>(mesh);
MeshRenderer<?, ?, ?> meshRenderer = new MeshRenderer<>(mesh, false);
meshRenderer.renderPostTransform(g, bound);
//meshRenderer.renderGraphics(g, bound);
}
......
......@@ -108,7 +108,7 @@ public abstract class SimulationRenderer extends DefaultRenderer {
}
if(model.config.isShowTargetPotentielFieldMesh()) {
renderMesh(graphics, model.getDiscretization(), new VRectangle(model.getTopographyBound()));
renderMesh(graphics, model.getFloorFieldMesh(), new VRectangle(model.getTopographyBound()));
}
renderSimulationContent(graphics);
......
......@@ -9,6 +9,7 @@ import org.vadere.meshing.mesh.inter.IMesh;
import org.vadere.simulator.control.simulation.PassiveCallback;
import org.vadere.simulator.models.potential.fields.IPotentialField;
import org.vadere.simulator.models.potential.fields.IPotentialFieldTarget;
import org.vadere.simulator.projects.Domain;
import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VRectangle;
......@@ -25,7 +26,7 @@ public class OnlineVisualization implements PassiveCallback {
*/
public class ObservationAreaSnapshotData {
public final double simTimeInSec;
public final Topography scenario;
public final Domain domain;
public final IPotentialField potentialFieldTarget;
public final Agent selectedAgent;
public final IPotentialField potentialField;
......@@ -33,13 +34,13 @@ public class OnlineVisualization implements PassiveCallback {
public ObservationAreaSnapshotData(
final double simTimeInSec,
@NotNull final Topography scenario,
@NotNull final Domain scenario,
@Nullable final IPotentialField potentialFieldTarget,
@Nullable final IPotentialField potentialField,
@Nullable final Agent selectedAgent,
@Nullable final Function<Agent, IMesh<?, ?, ?>> discretizations) {
this.simTimeInSec = simTimeInSec;
this.scenario = scenario;
this.domain = scenario;
this.potentialFieldTarget = potentialFieldTarget;
this.potentialField = potentialField;
this.selectedAgent = selectedAgent;
......@@ -50,7 +51,7 @@ public class OnlineVisualization implements PassiveCallback {
private MainPanel window;
private OnlineVisualisationWindow onlineVisualisationPanel;
private OnlineVisualizationModel model;
private Topography scenario;
private Domain domain;
/**
* Target potential.
......@@ -75,8 +76,8 @@ public class OnlineVisualization implements PassiveCallback {
}
@Override
public void setTopography(final Topography scenario) {
this.scenario = scenario;
public void setDomain(final Domain domain) {
this.domain = domain;
}
@Override
......@@ -146,7 +147,7 @@ public class OnlineVisualization implements PassiveCallback {
pedPotentialField = IPotentialField.copyAgentField(potentialField, selectedAgent, new VRectangle(model.getTopographyBound()), 0.1);
}
ObservationAreaSnapshotData data = new ObservationAreaSnapshotData(simTimeInSec, scenario.clone(), pft, pedPotentialField, selectedAgent, discretizations);
ObservationAreaSnapshotData data = new ObservationAreaSnapshotData(simTimeInSec, domain.clone(), pft, pedPotentialField, selectedAgent, discretizations);
model.pushObservationAreaSnapshot(data);
}
}
......
......@@ -14,9 +14,11 @@ import org.vadere.gui.components.model.AgentColoring;
import org.vadere.gui.components.model.DefaultSimulationConfig;
import org.vadere.gui.components.model.SimulationModel;
import org.vadere.gui.onlinevisualization.OnlineVisualization;
import org.vadere.meshing.mesh.gen.AMesh;
import org.vadere.meshing.mesh.gen.PMesh;
import org.vadere.meshing.mesh.inter.IMesh;
import org.vadere.simulator.models.potential.fields.IPotentialField;
import org.vadere.simulator.projects.Domain;
import org.vadere.state.scenario.*;
import org.vadere.util.geometry.shapes.IPoint;
import org.vadere.util.voronoi.VoronoiDiagram;
......@@ -38,8 +40,6 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
private IPotentialField potentialField = null;
private Function<Agent, IMesh<?, ?, ?>> discretizations = null;
private Agent agent = null;
/**
......@@ -63,7 +63,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
* The observation area to display. Updated by popDrawData() with the latest
* observation area snapshot.
*/
private Topography topography;
private Domain domain;
public OnlineVisualizationModel() {
super(new DefaultSimulationConfig());
......@@ -75,21 +75,21 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
@Override
public Collection<Agent> getAgents() {
if (topography == null) {
if (domain == null || domain.getTopography() == null) {
return new ArrayList<>();
}
Collection<Agent> result = new LinkedList<>();
result.addAll(topography.getElements(Agent.class));
result.addAll(domain.getTopography().getElements(Agent.class));
return result;
}
@Override
public Collection<Pedestrian> getPedestrians() {
if (topography == null) {
if (domain == null) {
return new ArrayList<>();
}
Collection<Pedestrian> result = new LinkedList<>();
result.addAll(topography.getElements(Pedestrian.class));
result.addAll(domain.getTopography().getElements(Pedestrian.class));
return result;
}
......@@ -100,15 +100,18 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
@Override
public Topography getTopography() {
return topography;
if(domain == null) {
return null;
}
return domain.getTopography();
}
@Override
public Iterator<ScenarioElement> iterator() {
if (topography == null) {
if (domain == null) {
return new ArrayList<ScenarioElement>().iterator();
}
return new TopographyIterator(topography);
return new TopographyIterator(domain.getTopography());
}
/**
......@@ -130,7 +133,6 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
potentialFieldTarget = observationAreaSnapshot.potentialFieldTarget;
potentialField = observationAreaSnapshot.potentialField;
agent = observationAreaSnapshot.selectedAgent;
discretizations = observationAreaSnapshot.discretizations;
/*
* if(topography == null ||
......@@ -139,30 +141,30 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
* }
*/
if (topography == null) {
topography = observationAreaSnapshot.scenario;
if (domain == null) {
domain = observationAreaSnapshot.domain;
// recalculate GUI (fireChangeViewportEvent will synchronize on model which is also
// needed by some awt event. Therefore do this in EDT (Event Dispatching Thread)
EventQueue.invokeLater(() -> {
fireChangeViewportEvent(new Rectangle2D.Double(topography.getBounds().x, topography.getBounds().y,
topography.getBounds().width, topography.getBounds().height));
fireChangeViewportEvent(new Rectangle2D.Double(getTopography().getBounds().x, getTopography().getBounds().y,
getTopography().getBounds().width, getTopography().getBounds().height));
});
} else {
topography = observationAreaSnapshot.scenario;
domain = observationAreaSnapshot.domain;
}
if (getSelectedElement() instanceof Car) {
int carId = getSelectedElement().getId();
Car car = topography.getElement(Car.class, carId);
Car car = domain.getTopography().getElement(Car.class, carId);
setSelectedElement(car);
} else if (getSelectedElement() instanceof Pedestrian) {
int pedId = getSelectedElement().getId();
Pedestrian ped = topography.getElement(Pedestrian.class, pedId);
Pedestrian ped = domain.getTopography().getElement(Pedestrian.class, pedId);
setSelectedElement(ped);
}
if (isVoronoiDiagramAvailable() && isVoronoiDiagramVisible()) {
getVoronoiDiagram().computeVoronoiDiagram(topography.getPedestrianDynamicElements().getElements()
getVoronoiDiagram().computeVoronoiDiagram(domain.getTopography().getPedestrianDynamicElements().getElements()
.stream()
.map(ped -> ped.getPosition())
.collect(Collectors.toList()));
......@@ -186,7 +188,7 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
selectedElement = null;
voronoiDiagram = null;
topography = null;
domain = null;
simTimeInSec = 0.0;
}
......@@ -225,12 +227,12 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
}
@Override
public IMesh<?, ?, ?> getDiscretization() {
if(agent != null && discretizations != null && config.isShowTargetPotentielFieldMesh() && agent.equals(getSelectedElement())) {
return discretizations.apply(agent);
public IMesh<?, ?, ?> getFloorFieldMesh() {
if(domain.getFloorFieldMesh() != null) {
return domain.getFloorFieldMesh();
} else {
return new AMesh();
}
return new PMesh();
}
@Override
......@@ -263,6 +265,6 @@ public class OnlineVisualizationModel extends SimulationModel<DefaultSimulationC
@Override
public boolean isAlive(int pedId) {
return topography.getPedestrianDynamicElements().idExists(pedId);
return domain.getTopography().getPedestrianDynamicElements().idExists(pedId);
}
}
......@@ -72,6 +72,8 @@ public class MeshRenderer<V extends IVertex, E extends IHalfEdge, F extends IFac
private BufferedImage bufferedImage = null;