Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
V
vadere
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
110
Issues
110
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
3
Merge Requests
3
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vadere
vadere
Commits
abce0295
Commit
abce0295
authored
Jun 23, 2020
by
Marion Goedel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a processor to save the free-flow speeds (+ mean + std)
to evaluate the mean and std in the sample.
parent
769f50b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/PedestrianFreeFlowSpeedProcessor.java
...rocessing/processor/PedestrianFreeFlowSpeedProcessor.java
+63
-0
No files found.
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/PedestrianFreeFlowSpeedProcessor.java
0 → 100644
View file @
abce0295
package
org.vadere.simulator.projects.dataprocessing.processor
;
import
org.vadere.annotation.factories.dataprocessors.DataProcessorClass
;
import
org.vadere.simulator.control.simulation.SimulationState
;
import
org.vadere.simulator.projects.dataprocessing.ProcessorManager
;
import
org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey
;
import
org.vadere.state.scenario.Pedestrian
;
import
java.util.OptionalDouble
;
import
java.util.Set
;
/**
* @author Marion Gödel
* Save free-flow speeds for each pedestrian in the simulation to evaluate how well the sample fits the defined distribution.
* In the entry (pedestrianIdKey) "-1" the average is saved
* In the entry (pedestrianIdKey) "-2" the std of the samples is saved
*/
@DataProcessorClass
()
public
class
PedestrianFreeFlowSpeedProcessor
extends
DataProcessor
<
PedestrianIdKey
,
Double
>
{
public
PedestrianFreeFlowSpeedProcessor
()
{
super
(
"freeFlowSpeed"
);
}
@Override
protected
void
doUpdate
(
final
SimulationState
state
)
{
state
.
getTopography
().
getElements
(
Pedestrian
.
class
)
.
forEach
(
ped
->
this
.
update
(
new
PedestrianIdKey
(
ped
.
getId
()),
ped
.
getFreeFlowSpeed
()));
}
private
void
update
(
PedestrianIdKey
pedIdKey
,
double
freeFlowSpeed
)
{
Set
<
PedestrianIdKey
>
keys
=
this
.
getKeys
();
if
(!
keys
.
contains
(
pedIdKey
))
this
.
putValue
(
pedIdKey
,
freeFlowSpeed
);
}
@Override
public
void
postLoop
(
final
SimulationState
state
)
{
// save average in -1 entry
OptionalDouble
meanVal
=
this
.
getValues
().
stream
().
mapToDouble
(
a
->
a
).
average
();
if
(
meanVal
.
isPresent
()){
this
.
putValue
(
new
PedestrianIdKey
(-
1
),
meanVal
.
getAsDouble
());
}
double
tmp_sum
=
this
.
getValues
().
stream
().
mapToDouble
(
speed
->
Math
.
pow
(
speed
-
meanVal
.
getAsDouble
(),
2
)).
sum
();
double
std
=
Math
.
sqrt
(
tmp_sum
/
(
this
.
getValues
().
size
()-
1
));
this
.
putValue
(
new
PedestrianIdKey
(-
2
),
std
);
}
@Override
public
void
init
(
final
ProcessorManager
manager
)
{
super
.
init
(
manager
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment