Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 916e7c5d authored by Christina's avatar Christina
Browse files

Check PoissonDist with data processor

parent ece3b417
Pipeline #261886 passed with stages
in 147 minutes and 18 seconds
......@@ -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("numberPedsGenerated");
super("NumAgentsGenPerSecond");
}
@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 + 1e-7 >= getAttributes().getStartTime() && t - 1e-7 <= getAttributes().getEndTime() ) {
List<Integer> oldPedIds = this.getPedsIds();
List<Integer> list = new ArrayList<Integer>(CollectionUtils.disjunction(newPedIds, oldPedIds));
list.removeAll(oldPedIds);
int numAgentsGen;
Collection<Pedestrian> peds2 = state.getTopography().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
}
......@@ -11,6 +11,10 @@ public class AttributesNumberOfGeneratedPedsProcessor extends AttributesProcesso
}
public double getEndTime() {
return endTime;
if (endTime >= startTime - 1e-7)
return endTime;
else
return Float.POSITIVE_INFINITY;
}
}
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);
}
}
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