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
916e7c5d
Commit
916e7c5d
authored
May 27, 2020
by
Christina
Browse files
Check PoissonDist with data processor
parent
ece3b417
Pipeline
#261886
passed with stages
in 147 minutes and 18 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/processor/NumberOfGeneratedPedsProcessor.java
View file @
916e7c5d
...
...
@@ -3,7 +3,6 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import
org.apache.commons.collections.CollectionUtils
;
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.TimestepKey
;
import
org.vadere.state.attributes.processor.AttributesNumberOfGeneratedPedsProcessor
;
import
org.vadere.state.scenario.Agent
;
...
...
@@ -17,39 +16,38 @@ import java.util.stream.Collectors;
@DataProcessorClass
(
label
=
"NumberOfGeneratedPedsProcessor"
)
public
class
NumberOfGeneratedPedsProcessor
extends
DataProcessor
<
TimestepKey
,
Double
>
{
private
List
<
Integer
>
pedIds
;
private
List
<
Integer
>
pedIds
=
new
ArrayList
<
Integer
>()
;
public
NumberOfGeneratedPedsProcessor
(){
super
(
"
n
um
berPed
sGener
ate
d"
);
super
(
"
N
um
Agent
sGen
P
er
Secon
d"
);
}
@Override
public
void
init
(
ProcessorManager
manager
)
{
super
.
init
(
manager
);
// setup filter
}
@Override
protected
void
doUpdate
(
SimulationState
state
)
{
Collection
<
Pedestrian
>
peds2
=
state
.
getTopography
().
getElements
(
Pedestrian
.
class
);
List
<
Integer
>
newPedIds
=
peds2
.
stream
().
map
(
Agent:
:
getId
).
collect
(
Collectors
.
toList
());
double
t
=
state
.
getSimTimeInSec
();
if
(
this
.
getPedsIds
()
==
null
){
this
.
setPedsIds
(
newPedIds
);
}
if
(
t
+
1
e
-
7
>=
getAttributes
().
getStartTime
()
&&
t
-
1
e
-
7
<=
getAttributes
().
getEndTime
()
)
{
List
<
Integer
>
oldPedIds
=
this
.
getPedsIds
()
;
List
<
Integer
>
list
=
new
ArrayList
<
In
tege
r
>(
CollectionUtils
.
disjunction
(
newPedIds
,
oldPedIds
)
);
list
.
removeAll
(
oldPedIds
);
int
numAgentsGen
;
Collection
<
Pedestrian
>
peds2
=
sta
te
.
ge
tTopography
().
getElements
(
Pedestrian
.
class
);
List
<
Integer
>
newPedIds
=
peds2
.
stream
().
map
(
Agent:
:
getId
).
collect
(
Collectors
.
toList
()
);
this
.
setPedsIds
(
newPedIds
);
if
(
this
.
getPedsIds
()
==
null
){
numAgentsGen
=
newPedIds
.
size
();
}
else
{
List
<
Integer
>
oldPedIds
=
this
.
getPedsIds
();
List
<
Integer
>
list
=
new
ArrayList
<
Integer
>(
CollectionUtils
.
disjunction
(
newPedIds
,
oldPedIds
));
list
.
removeAll
(
oldPedIds
);
numAgentsGen
=
list
.
size
();
}
this
.
setPedsIds
(
newPedIds
);
double
poissonParameter
=
list
.
size
()/
state
.
getScenarioStore
().
getAttributesSimulation
().
getSimTimeStepLength
();
double
poissonParameter
=
numAgentsGen
/
state
.
getScenarioStore
().
getAttributesSimulation
().
getSimTimeStepLength
();
putValue
(
new
TimestepKey
(
state
.
getStep
()),
poissonParameter
);
}
putValue
(
new
TimestepKey
(
state
.
getStep
()),
poissonParameter
);
}
@Override
...
...
@@ -60,6 +58,7 @@ public class NumberOfGeneratedPedsProcessor extends DataProcessor<TimestepKey, D
return
(
AttributesNumberOfGeneratedPedsProcessor
)
super
.
getAttributes
();
}
private
List
<
Integer
>
getPedsIds
(){
return
this
.
pedIds
;
}
...
...
@@ -70,4 +69,5 @@ public class NumberOfGeneratedPedsProcessor extends DataProcessor<TimestepKey, D
}
VadereState/src/org/vadere/state/attributes/processor/AttributesNumberOfGeneratedPedsProcessor.java
View file @
916e7c5d
...
...
@@ -11,6 +11,10 @@ public class AttributesNumberOfGeneratedPedsProcessor extends AttributesProcesso
}
public
double
getEndTime
()
{
return
endTime
;
if
(
endTime
>=
startTime
-
1
e
-
7
)
return
endTime
;
else
return
Float
.
POSITIVE_INFINITY
;
}
}
VadereState/src/org/vadere/state/scenario/PoissonDistribution.java
0 → 100644
View file @
916e7c5d
package
org.vadere.state.scenario
;
import
org.apache.commons.math3.distribution.ExponentialDistribution
;
import
org.apache.commons.math3.random.RandomGenerator
;
/**
* -> Scope: Definition of spawn generation in source
* Use the PoissonDistribution to generate agents with a Poisson process.
* The Poisson process is a random process.
* Hence, the generation time of a specific agent is independent from other generation times.
* The Poisson distribution and the exponential distribution are related.
* The reciprocal value of the Poisson parameter is the mean inter arrival time used in the exponential distribution.
* @author Christina Mayr
* @since 2020-05-27
*/
public
class
PoissonDistribution
extends
ExponentialDistribution
{
/**
*
* @param numberPedsPerSecond Unit: agents/second. Reciprocal value of mean inter-arrival time [seconds].
*/
public
PoissonDistribution
(
RandomGenerator
rng
,
double
numberPedsPerSecond
)
{
super
(
rng
,
1
/
numberPedsPerSecond
);
}
}
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