Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
6c627813
Commit
6c627813
authored
Apr 08, 2019
by
Stefan Schuhbaeck
Browse files
Merge branch 'measurementAreaRefactorProcessors_rebased' into 'master'
Measurement area refactor processors rebased See merge request
!55
parents
dcffc7d3
83cb5e48
Pipeline
#103785
passed with stages
in 137 minutes and 9 seconds
Changes
296
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereModelTests/TestStairs/scenarios/stairs_upward_direction_up_-1.scenario
View file @
6c627813
{
"name" : "stairs_upward_direction_up_-1",
"description" : "",
"release" : "0.
7
",
"release" : "0.
8
",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
...
...
@@ -15,7 +15,8 @@
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianTargetIdProcessor",
"id" : 2
} ],
"isTimestamped" : true
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
...
...
@@ -40,19 +41,19 @@
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18,
"numberOfCircles" : 1,
"optimizationType" : "DISCRETE",
"varyStepDirection" : false,
"movementType" : "ARBITRARY",
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036,
"movementThreshold" : 0.0,
"minStepLength" : 0.4625,
"minimumStepLength" : false,
"maxStepDuration" : 1.7976931348623157E308,
"optimizationType" : "DISCRETE",
"movementType" : "ARBITRARY",
"dynamicStepLength" : false,
"updateType" : "EVENT_DRIVEN",
"seeSmallWalls" : false,
"minimumStepLength" : false,
"targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell",
...
...
@@ -111,6 +112,7 @@
},
"id" : -1
} ],
"measurementAreas" : [ ],
"stairs" : [ {
"shape" : {
"x" : 2.0,
...
...
@@ -144,6 +146,7 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : -1,
"shape" : {
...
...
VadereSimulator/resources/i18n_simulation.properties
View file @
6c627813
...
...
@@ -39,6 +39,8 @@ ScenarioChecker.overlap.obstacle.obstacle=Two obstacles overlap / is enclosed co
ScenarioChecker.simAttr.simTimeStepWrong
=
simTimeStep parameter outside of allowed range
ScenarioChecker.processor.measuremetarea.doesNotExist
=
MeasurementArea referenced in processor does not exist.
ScenarioChecker.msg.ok
=
Scenario ok.
ScenarioChecker.msg.warn
=
Scenario contains warnings.
ScenarioChecker.msg.err
=
Scenario contains errors.
VadereSimulator/resources/i18n_simulation_de_DE.properties
View file @
6c627813
...
...
@@ -39,6 +39,8 @@ ScenarioChecker.overlap.obstacle.obstacle=Zwei identische bzw. eingeschlossene H
ScenarioChecker.simAttr.simTimeStepWrong
=
simTimeStep Parameter au
\u
00dferhalb des Definitionsbereichs
ScenarioChecker.processor.measuremetarea.doesNotExist
=
Referenzierte Messfläche im Daten Prozessor existiert nicht.
ScenarioChecker.msg.ok
=
Szenario ok.
ScenarioChecker.msg.warn
=
Szenario hat Warnungen.
ScenarioChecker.msg.err
=
Szenario ist Fehlerhaft.
VadereSimulator/src/org/vadere/simulator/entrypoints/Version.java
View file @
6c627813
package
org.vadere.simulator.entrypoints
;
import
org.jetbrains.annotations.NotNull
;
import
org.vadere.simulator.projects.migration.incidents.VersionBumpIncident
;
import
java.util.Arrays
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
/**
* Versions in strict order from oldest to newest.
...
...
@@ -20,7 +18,8 @@ public enum Version {
V0_4
(
"0.4"
),
V0_5
(
"0.5"
),
V0_6
(
"0.6"
),
V0_7
(
"0.7"
)
V0_7
(
"0.7"
),
V0_8
(
"0.8"
),
;
private
String
label
;
...
...
VadereSimulator/src/org/vadere/simulator/entrypoints/cmd/commands/MigrationSubCommand.java
View file @
6c627813
...
...
@@ -5,11 +5,11 @@ import net.sourceforge.argparse4j.inf.Namespace;
import
org.vadere.simulator.entrypoints.Version
;
import
org.vadere.simulator.entrypoints.cmd.SubCommandRunner
;
import
org.vadere.simulator.projects.migration.
Jolt
MigrationAssistant
;
import
org.vadere.simulator.projects.migration.
jsontranformation.Json
MigrationAssistant
;
import
org.vadere.simulator.projects.migration.MigrationAssistant
;
import
org.vadere.simulator.projects.migration.MigrationException
;
import
org.vadere.simulator.projects.migration.MigrationOptions
;
import
org.vadere.simulator.projects.migration.helper.MigrationUtil
;
import
org.vadere.simulator.projects.migration.
incident.
helper.MigrationUtil
;
import
org.vadere.util.logging.Logger
;
import
java.io.IOException
;
...
...
@@ -94,7 +94,7 @@ public class MigrationSubCommand implements SubCommandRunner {
for
(
Path
dir
:
dirs
)
{
logger
.
info
(
"migrate directory to version("
+
targetVersion
.
label
()
+
"): "
+
dir
.
toAbsolutePath
().
toString
());
if
(
projectOnly
){
J
olt
MigrationAssistant
migrationAssistant
=
new
J
olt
MigrationAssistant
();
J
son
MigrationAssistant
migrationAssistant
=
new
J
son
MigrationAssistant
();
migrationAssistant
.
analyzeProject
(
dir
.
toString
());
}
else
{
migrationUtil
.
migrateDirectoryTree
(
dir
,
targetVersion
,
recursive
);
...
...
@@ -147,7 +147,7 @@ public class MigrationSubCommand implements SubCommandRunner {
outputFile
=
Paths
.
get
(
outputPathString
).
resolve
(
scenarioFile
.
getFileName
());
}
ma
.
migrateFile
(
scenarioFile
,
targetVersion
,
outputFile
);
ma
.
migrate
Scenario
File
(
scenarioFile
,
targetVersion
,
outputFile
);
}
catch
(
Exception
e
)
{
...
...
VadereSimulator/src/org/vadere/simulator/projects/ScenarioRun.java
View file @
6c627813
...
...
@@ -97,7 +97,7 @@ public class ScenarioRun implements Runnable {
// prepare processors and simulation data writer
if
(
scenarioStore
.
getAttributesSimulation
().
isWriteSimulationData
())
{
processorManager
=
dataProcessingJsonManager
.
createProcessorManager
(
mainModel
);
processorManager
=
dataProcessingJsonManager
.
createProcessorManager
(
mainModel
,
scenarioStore
.
getTopography
()
);
processorManager
.
setSimulationResult
(
simulationResult
);
}
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/DataProcessingJsonManager.java
View file @
6c627813
...
...
@@ -16,6 +16,7 @@ import org.vadere.simulator.projects.dataprocessing.processor.DataProcessorFacto
import
org.vadere.simulator.projects.dataprocessing.store.DataProcessorStore
;
import
org.vadere.simulator.projects.dataprocessing.store.OutputFileStore
;
import
org.vadere.state.attributes.processor.AttributesProcessor
;
import
org.vadere.state.scenario.Topography
;
import
org.vadere.state.util.StateJsonConverter
;
import
java.io.IOException
;
...
...
@@ -281,14 +282,14 @@ public class DataProcessingJsonManager {
return
main
;
}
public
ProcessorManager
createProcessorManager
(
MainModel
mainModel
)
{
public
ProcessorManager
createProcessorManager
(
MainModel
mainModel
,
final
Topography
topography
)
{
// this function is called when the simulation starts running
for
(
OutputFile
f
:
outputFiles
)
{
f
.
setWriteMetaData
(
isWriteMetaData
());
// allow to write meta data
}
return
new
ProcessorManager
(
dataProcessors
,
outputFiles
,
mainModel
);
return
new
ProcessorManager
(
dataProcessors
,
outputFiles
,
mainModel
,
topography
);
}
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/ProcessorManager.java
View file @
6c627813
...
...
@@ -5,6 +5,8 @@ import org.vadere.simulator.models.MainModel;
import
org.vadere.simulator.projects.SimulationResult
;
import
org.vadere.simulator.projects.dataprocessing.outputfile.OutputFile
;
import
org.vadere.simulator.projects.dataprocessing.processor.DataProcessor
;
import
org.vadere.state.scenario.MeasurementArea
;
import
org.vadere.state.scenario.Topography
;
import
java.io.File
;
import
java.nio.file.Paths
;
...
...
@@ -19,14 +21,17 @@ import java.util.Map;
public
class
ProcessorManager
{
private
MainModel
mainModel
;
private
final
Topography
topography
;
private
Map
<
Integer
,
DataProcessor
<?,
?>>
processorMap
;
private
List
<
OutputFile
<?>>
outputFiles
;
private
SimulationResult
simulationResult
;
public
ProcessorManager
(
List
<
DataProcessor
<?,
?>>
dataProcessors
,
List
<
OutputFile
<?>>
outputFiles
,
MainModel
mainModel
)
{
List
<
OutputFile
<?>>
outputFiles
,
MainModel
mainModel
,
final
Topography
topography
)
{
this
.
mainModel
=
mainModel
;
this
.
topography
=
topography
;
this
.
outputFiles
=
outputFiles
;
...
...
@@ -49,6 +54,10 @@ public class ProcessorManager {
return
this
.
processorMap
.
getOrDefault
(
id
,
null
);
}
public
MeasurementArea
getMeasurementArea
(
int
measurementAreaId
){
return
topography
.
getMeasurementArea
(
measurementAreaId
);
}
public
MainModel
getMainModel
()
{
return
mainModel
;
}
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/flags/ProcessorFlag.java
0 → 100644
View file @
6c627813
package
org.vadere.simulator.projects.dataprocessing.flags
;
/**
* Marker interface to identify a {@link org.vadere.simulator.projects.dataprocessing.processor.DataProcessor}
* based on some arbitrary property. These Interfaces are useful to filter processors of a
* scenario to check if the settings of the processor are correct.
*/
public
interface
ProcessorFlag
{
}
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/flags/UsesMeasurementArea.java
0 → 100644
View file @
6c627813
package
org.vadere.simulator.projects.dataprocessing.flags
;
/**
* Return all id's referencing a {@link org.vadere.state.scenario.MeasurementArea}. These
* are used to check if the specified {@link org.vadere.state.scenario.MeasurementArea}
* exist in the simulation.
*/
public
interface
UsesMeasurementArea
extends
ProcessorFlag
{
int
[]
getReferencedMeasurementAreaId
();
}
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/AreaDataProcessor.java
View file @
6c627813
...
...
@@ -3,6 +3,7 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import
org.vadere.simulator.projects.dataprocessing.ProcessorManager
;
import
org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey
;
import
org.vadere.state.attributes.processor.AttributesAreaProcessor
;
import
org.vadere.state.scenario.MeasurementArea
;
import
org.vadere.util.geometry.shapes.VRectangle
;
/**
...
...
@@ -11,7 +12,7 @@ import org.vadere.util.geometry.shapes.VRectangle;
*/
public
abstract
class
AreaDataProcessor
<
V
>
extends
DataProcessor
<
TimestepKey
,
V
>
{
private
VRectangle
measurementArea
;
private
MeasurementArea
measurementArea
;
protected
AreaDataProcessor
(
final
String
...
headers
)
{
super
(
headers
);
...
...
@@ -21,10 +22,15 @@ public abstract class AreaDataProcessor<V> extends DataProcessor<TimestepKey, V>
public
void
init
(
final
ProcessorManager
manager
)
{
super
.
init
(
manager
);
AttributesAreaProcessor
att
=
(
AttributesAreaProcessor
)
this
.
getAttributes
();
this
.
measurementArea
=
att
.
getMeasurementArea
();
this
.
measurementArea
=
manager
.
getMeasurementArea
(
att
.
getMeasurementAreaId
());
if
(
measurementArea
==
null
)
throw
new
RuntimeException
(
String
.
format
(
"MeasurementArea with index %d does not exist."
,
att
.
getMeasurementAreaId
()));
if
(!
measurementArea
.
isRectangular
())
throw
new
RuntimeException
(
"DataProcessor and IntegralVoronoiAlgorithm only supports Rectangular measurement areas."
);
}
public
VRectangle
getMeasurementArea
()
{
public
MeasurementArea
getMeasurementArea
()
{
return
this
.
measurementArea
;
}
}
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/AreaDensityVoronoiAlgorithm.java
View file @
6c627813
...
...
@@ -3,6 +3,7 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import
org.jetbrains.annotations.NotNull
;
import
org.vadere.simulator.control.SimulationState
;
import
org.vadere.state.scenario.Agent
;
import
org.vadere.state.scenario.MeasurementArea
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.geometry.shapes.VRectangle
;
import
org.vadere.util.voronoi.Face
;
...
...
@@ -21,11 +22,11 @@ public class AreaDensityVoronoiAlgorithm extends AreaDensityAlgorithm {
private
VRectangle
measurementArea
;
private
VRectangle
voronoiArea
;
public
AreaDensityVoronoiAlgorithm
(
final
VRectangle
measurementArea
,
final
VRectangle
voronoiArea
)
{
public
AreaDensityVoronoiAlgorithm
(
final
MeasurementArea
measurementArea
,
final
MeasurementArea
voronoiArea
)
{
super
(
"areaVoronoi"
);
this
.
measurementArea
=
measurementArea
;
this
.
voronoiArea
=
voronoiArea
;
this
.
measurementArea
=
measurementArea
.
asVRectangle
()
;
this
.
voronoiArea
=
voronoiArea
.
asVRectangle
()
;
}
@Override
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/AreaDensityVoronoiProcessor.java
View file @
6c627813
package
org.vadere.simulator.projects.dataprocessing.processor
;
import
org.vadere.simulator.projects.dataprocessing.ProcessorManager
;
import
org.vadere.simulator.projects.dataprocessing.flags.UsesMeasurementArea
;
import
org.vadere.state.attributes.processor.AttributesAreaDensityVoronoiProcessor
;
import
org.vadere.state.attributes.processor.AttributesProcessor
;
import
org.vadere.annotation.factories.dataprocessors.DataProcessorClass
;
import
org.vadere.state.scenario.MeasurementArea
;
import
org.vadere.util.factory.processors.Flag
;
import
java.util.List
;
/**
* @author Mario Teixeira Parente
*
*/
@DataProcessorClass
(
label
=
"AreaDensityVoronoiProcessor"
)
public
class
AreaDensityVoronoiProcessor
extends
AreaDensityProcessor
{
public
class
AreaDensityVoronoiProcessor
extends
AreaDensityProcessor
implements
UsesMeasurementArea
{
public
AreaDensityVoronoiProcessor
(){
super
();
...
...
@@ -23,7 +28,13 @@ public class AreaDensityVoronoiProcessor extends AreaDensityProcessor {
super
.
init
(
manager
);
AttributesAreaDensityVoronoiProcessor
att
=
(
AttributesAreaDensityVoronoiProcessor
)
this
.
getAttributes
();
this
.
setAlgorithm
(
new
AreaDensityVoronoiAlgorithm
(
this
.
getMeasurementArea
(),
att
.
getVoronoiArea
()));
MeasurementArea
measurementArea
=
manager
.
getMeasurementArea
(
att
.
getMeasurementAreaId
());
if
(
measurementArea
==
null
)
throw
new
RuntimeException
(
String
.
format
(
"MeasurementArea with index %d does not exist."
,
att
.
getMeasurementAreaId
()));
if
(!
measurementArea
.
isRectangular
())
throw
new
RuntimeException
(
"DataProcessor and IntegralVoronoiAlgorithm only supports Rectangular measurement areas."
);
this
.
setAlgorithm
(
new
AreaDensityVoronoiAlgorithm
(
this
.
getMeasurementArea
(),
measurementArea
));
}
@Override
...
...
@@ -34,4 +45,11 @@ public class AreaDensityVoronoiProcessor extends AreaDensityProcessor {
return
super
.
getAttributes
();
}
@Override
public
int
[]
getReferencedMeasurementAreaId
()
{
AttributesAreaDensityVoronoiProcessor
att
=
(
AttributesAreaDensityVoronoiProcessor
)
this
.
getAttributes
();
return
new
int
[]{
att
.
getMeasurementAreaId
(),
att
.
getMeasurementAreaId
()};
}
}
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/AreaSpeedProcessor.java
View file @
6c627813
...
...
@@ -43,7 +43,7 @@ public class AreaSpeedProcessor extends AreaDataProcessor<Double> {
final
int
pedId
=
entry
.
getKey
().
getPedestrianId
();
final
VPoint
pos
=
entry
.
getValue
();
if
(
getMeasurementArea
().
contains
(
pos
))
{
if
(
getMeasurementArea
().
asVRectangle
().
contains
(
pos
))
{
sumVelocities
+=
this
.
pedVelProc
.
getValue
(
new
TimestepPedestrianIdKey
(
step
,
pedId
));
pedCount
++;
}
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/DataProcessor.java
View file @
6c627813
...
...
@@ -53,6 +53,7 @@ public abstract class DataProcessor<K extends DataKey<K>, V> {
this
.
lastStep
=
0
;
}
protected
Map
<
K
,
V
>
getData
()
{
return
this
.
data
;
}
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/FundamentalDiagramBProcessor.java
View file @
6c627813
...
...
@@ -6,12 +6,18 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import
org.vadere.simulator.control.SimulationState
;
import
org.vadere.simulator.projects.dataprocessing.ProcessorManager
;
import
org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey
;
import
org.vadere.simulator.projects.dataprocessing.flags.UsesMeasurementArea
;
import
org.vadere.state.attributes.processor.AttributesFundamentalDiagramBProcessor
;
import
org.vadere.state.attributes.processor.AttributesProcessor
;
import
org.vadere.state.scenario.MeasurementArea
;
import
org.vadere.state.scenario.Topography
;
import
org.vadere.state.simulation.VTrajectory
;
import
org.vadere.util.factory.processors.Flag
;
import
org.vadere.util.geometry.shapes.VRectangle
;
import
org.vadere.util.logging.Logger
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -30,9 +36,12 @@ import java.util.Map;
* @author Benedikt Zoennchen
*/
@DataProcessorClass
()
public
class
FundamentalDiagramBProcessor
extends
DataProcessor
<
PedestrianIdKey
,
Pair
<
Double
,
Double
>>
{
public
class
FundamentalDiagramBProcessor
extends
DataProcessor
<
PedestrianIdKey
,
Pair
<
Double
,
Double
>>
implements
UsesMeasurementArea
{
private
VRectangle
measurementArea
;
private
static
Logger
logger
=
Logger
.
getLogger
(
Topography
.
class
);
private
MeasurementArea
measurementArea
;
private
VRectangle
measurementAreaVRec
;
private
PedestrianTrajectoryProcessor
pedestrianTrajectoryProcessor
;
public
FundamentalDiagramBProcessor
()
{
...
...
@@ -44,7 +53,12 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey,
super
.
init
(
manager
);
AttributesFundamentalDiagramBProcessor
att
=
(
AttributesFundamentalDiagramBProcessor
)
this
.
getAttributes
();
pedestrianTrajectoryProcessor
=
(
PedestrianTrajectoryProcessor
)
manager
.
getProcessor
(
att
.
getPedestrianTrajectoryProcessorId
());
measurementArea
=
att
.
getMeasurementArea
();
measurementArea
=
manager
.
getMeasurementArea
(
att
.
getMeasurementAreaId
());
if
(
measurementArea
==
null
)
throw
new
RuntimeException
(
String
.
format
(
"MeasurementArea with index %d does not exist."
,
att
.
getMeasurementAreaId
()));
if
(!
measurementArea
.
isRectangular
())
throw
new
RuntimeException
(
"DataProcessor only supports Rectangular measurement areas."
);
measurementAreaVRec
=
measurementArea
.
asVRectangle
();
}
@Override
...
...
@@ -78,7 +92,7 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey,
for
(
Map
.
Entry
<
PedestrianIdKey
,
VTrajectory
>
trajectoryEntry
:
trajectoryMap
.
entrySet
())
{
PedestrianIdKey
key
=
trajectoryEntry
.
getKey
();
VTrajectory
trajectory
=
trajectoryEntry
.
getValue
();
VTrajectory
clone
=
trajectory
.
cut
(
measurementArea
);
VTrajectory
clone
=
trajectory
.
cut
(
measurementArea
VRec
);
cutTrajectoryMap
.
put
(
key
,
clone
);
}
...
...
@@ -109,7 +123,7 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey,
.
sum
();
densityIntegral
/=
duration
;
densityIntegral
/=
measurementArea
.
getArea
();
densityIntegral
/=
measurementArea
VRec
.
getArea
();
return
densityIntegral
;
/*List<Triple<Double, Double, Integer>> integralValues = new LinkedList<>();
...
...
@@ -159,4 +173,11 @@ public class FundamentalDiagramBProcessor extends DataProcessor<PedestrianIdKey,
public
String
[]
toStrings
(
@NotNull
final
PedestrianIdKey
key
)
{
return
new
String
[]{
Double
.
toString
(
getValue
(
key
).
getLeft
()),
Double
.
toString
(
getValue
(
key
).
getRight
())
};
}
@Override
public
int
[]
getReferencedMeasurementAreaId
()
{
AttributesFundamentalDiagramBProcessor
att
=
(
AttributesFundamentalDiagramBProcessor
)
this
.
getAttributes
();
return
new
int
[]{
att
.
getMeasurementAreaId
()};
}
}
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/FundamentalDiagramCProcessor.java
View file @
6c627813
...
...
@@ -7,10 +7,15 @@ import org.vadere.simulator.control.SimulationState;
import
org.vadere.simulator.projects.dataprocessing.ProcessorManager
;
import
org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey
;
import
org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdKey
;
import
org.vadere.simulator.projects.dataprocessing.flags.UsesMeasurementArea
;
import
org.vadere.state.attributes.processor.AttributesFundamentalDiagramCProcessor
;
import
org.vadere.state.attributes.processor.AttributesProcessor
;
import
org.vadere.state.scenario.MeasurementArea
;
import
org.vadere.util.factory.processors.Flag
;
import
org.vadere.util.geometry.shapes.VRectangle
;
import
java.util.List
;
/**
* <p>This processor computes the fundamental diagram by computing at a certain time the
* <tt>density</tt> defined by the number of pedestrians contained in the <tt>measurementArea</tt>
...
...
@@ -23,9 +28,11 @@ import org.vadere.util.geometry.shapes.VRectangle;
* @author Benedikt Zoennchen
*/
@DataProcessorClass
()
public
class
FundamentalDiagramCProcessor
extends
AreaDataProcessor
<
Pair
<
Double
,
Double
>>
{
public
class
FundamentalDiagramCProcessor
extends
AreaDataProcessor
<
Pair
<
Double
,
Double
>>
implements
UsesMeasurementArea
{
private
MeasurementArea
measurementArea
;
private
VRectangle
measurementAreaVRec
;
private
VRectangle
measurementArea
;
private
APedestrianVelocityProcessor
pedestrianVelocityProcessor
;
public
FundamentalDiagramCProcessor
()
{
...
...
@@ -36,8 +43,13 @@ public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double,
public
void
init
(
final
ProcessorManager
manager
)
{
super
.
init
(
manager
);
AttributesFundamentalDiagramCProcessor
att
=
(
AttributesFundamentalDiagramCProcessor
)
this
.
getAttributes
();
measurementArea
=
att
.
getMeasurementArea
(
);
measurementArea
=
manager
.
getMeasurementArea
(
att
.
getMeasurementArea
Id
()
);
pedestrianVelocityProcessor
=
(
APedestrianVelocityProcessor
)
manager
.
getProcessor
(
att
.
getPedestrianVelocityProcessorId
());
if
(
measurementArea
==
null
)
throw
new
RuntimeException
(
String
.
format
(
"MeasurementArea with index %d does not exist."
,
att
.
getMeasurementAreaId
()));
if
(!
measurementArea
.
isRectangular
())
throw
new
RuntimeException
(
"DataProcessor only supports Rectangular measurement areas."
);
measurementAreaVRec
=
measurementArea
.
asVRectangle
();
}
@Override
...
...
@@ -58,11 +70,11 @@ public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double,
pedestrianVelocityProcessor
.
update
(
state
);
long
N
=
state
.
getTopography
().
getPedestrianDynamicElements
().
getElements
()
.
stream
()
.
filter
(
pedestrian
->
measurementArea
.
contains
(
pedestrian
.
getPosition
()))
.
filter
(
pedestrian
->
measurementArea
VRec
.
contains
(
pedestrian
.
getPosition
()))
.
count
();
double
velocity
=
state
.
getTopography
().
getPedestrianDynamicElements
().
getElements
()
.
stream
()
.
filter
(
pedestrian
->
measurementArea
.
contains
(
pedestrian
.
getPosition
()))
.
filter
(
pedestrian
->
measurementArea
VRec
.
contains
(
pedestrian
.
getPosition
()))
.
mapToDouble
(
pedestrian
->
//pedestrian.getVelocity().getLength()
pedestrianVelocityProcessor
.
getValue
(
new
TimestepPedestrianIdKey
(
state
.
getStep
(),
pedestrian
.
getId
()))
...
...
@@ -76,7 +88,7 @@ public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double,
velocity
/=
N
;
}
double
density
=
N
/
measurementArea
.
getArea
();
double
density
=
N
/
measurementArea
VRec
.
getArea
();
putValue
(
new
TimestepKey
(
state
.
getStep
()),
Pair
.
of
(
velocity
,
density
));
}
...
...
@@ -85,4 +97,10 @@ public class FundamentalDiagramCProcessor extends AreaDataProcessor<Pair<Double,
public
String
[]
toStrings
(
@NotNull
final
TimestepKey
key
)
{
return
new
String
[]{
Double
.
toString
(
getValue
(
key
).
getLeft
()),
Double
.
toString
(
getValue
(
key
).
getRight
())
};
}
@Override
public
int
[]
getReferencedMeasurementAreaId
()
{
AttributesFundamentalDiagramCProcessor
att
=
(
AttributesFundamentalDiagramCProcessor
)
this
.
getAttributes
();
return
new
int
[]{
att
.
getMeasurementAreaId
()};
}
}
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/FundamentalDiagramDProcessor.java
View file @
6c627813
...
...
@@ -6,9 +6,13 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import
org.vadere.simulator.control.SimulationState
;
import
org.vadere.simulator.projects.dataprocessing.ProcessorManager
;
import
org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey
;
import
org.vadere.simulator.projects.dataprocessing.flags.UsesMeasurementArea
;
import
org.vadere.state.attributes.processor.AttributesFundamentalDiagramDProcessor
;
import
org.vadere.state.attributes.processor.AttributesProcessor
;
import
org.vadere.util.geometry.shapes.VRectangle
;
import
org.vadere.state.scenario.MeasurementArea
;
import
org.vadere.util.factory.processors.Flag
;
import
java.util.List
;
/**
* <p>This processor computes the fundamental diagram by computing at a certain time the
...
...
@@ -24,7 +28,7 @@ import org.vadere.util.geometry.shapes.VRectangle;
* @author Benedikt Zoennchen
*/
@DataProcessorClass
()
public
class
FundamentalDiagramDProcessor
extends
AreaDataProcessor
<
Pair
<
Double
,
Double
>>
{
public
class
FundamentalDiagramDProcessor
extends
AreaDataProcessor
<
Pair
<
Double
,
Double
>>
implements
UsesMeasurementArea
{
private
IntegralVoronoiAlgorithm
integralVoronoiAlgorithm
;
private
APedestrianVelocityProcessor
pedestrianVelocityProcessor
;
...
...
@@ -38,7 +42,17 @@ public class FundamentalDiagramDProcessor extends AreaDataProcessor<Pair<Double,
super
.
init
(
manager
);
AttributesFundamentalDiagramDProcessor
att
=
(
AttributesFundamentalDiagramDProcessor
)
this
.
getAttributes
();
pedestrianVelocityProcessor
=
(
APedestrianVelocityProcessor
)
manager
.
getProcessor
(
att
.
getPedestrianVelocityProcessorId
());
integralVoronoiAlgorithm
=
new
IntegralVoronoiAlgorithm
(
key
->
pedestrianVelocityProcessor
.
getValue
(
key
),
att
.
getMeasurementArea
(),
att
.
getVoronoiArea
());
MeasurementArea
measurementArea
=
manager
.
getMeasurementArea
(
att
.
getMeasurementAreaId
());
MeasurementArea
voronoiMeasurementArea
=
manager
.
getMeasurementArea
(
att
.
getVoronoiMeasurementAreaId
());
if
(
measurementArea
==
null
||
voronoiMeasurementArea
==
null
)
throw
new
RuntimeException
(
String
.
format
(
"MeasurementArea with index %d does not exist."
,
att
.
getMeasurementAreaId
()));
if
(!
measurementArea
.
isRectangular
()
||
!
voronoiMeasurementArea
.
isRectangular
())
throw
new
RuntimeException
(
"DataProcessor and IntegralVoronoiAlgorithm only supports Rectangular measurement areas."
);
integralVoronoiAlgorithm
=
new
IntegralVoronoiAlgorithm
(
key
->
pedestrianVelocityProcessor
.
getValue
(
key
),
measurementArea
,
voronoiMeasurementArea
);
}
@Override
...
...
@@ -65,4 +79,11 @@ public class FundamentalDiagramDProcessor extends AreaDataProcessor<Pair<Double,
public
String
[]
toStrings
(
@NotNull
final
TimestepKey
key
)
{
return
new
String
[]{
Double
.
toString
(
getValue
(
key
).
getLeft
()),
Double
.
toString
(
getValue
(
key
).
getRight
())
};
}
@Override
public
int
[]
getReferencedMeasurementAreaId
()
{
AttributesFundamentalDiagramDProcessor
att
=
(
AttributesFundamentalDiagramDProcessor
)
this
.
getAttributes
();
return
new
int
[]{
att
.
getVoronoiMeasurementAreaId
(),
att
.
getMeasurementAreaId
()};
}
}
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/FundamentalDiagramEProcessor.java