Commit 3eb083ae authored by Marion Goedel's avatar Marion Goedel
Browse files

Added MaxAreaDensityVoronoiProcessor

parent b2d5edf1
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.NoDataKey;
import org.vadere.state.attributes.processor.AttributesMaxAreaDensityVoronoiProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor;
import java.util.OptionalDouble;
/**
* Saves the maximum of the Voronoi density over the whole simulation time -> scalar output.
* Used for UQ analysis.
*/
@DataProcessorClass()
public class MaxAreaDensityVoronoiProcessor extends NoDataKeyProcessor<Double> {
private AreaDensityVoronoiProcessor areaDensityVoronoiProcessor;
public MaxAreaDensityVoronoiProcessor() {
super("max_area_density_voronoi_processor");
setAttributes(new AttributesMaxAreaDensityVoronoiProcessor());
}
@Override
protected void doUpdate(final SimulationState state) {
//ensure that all required DataProcessors are updated.
this.areaDensityVoronoiProcessor.update(state);
}
@Override
public void postLoop(final SimulationState state) {
this.areaDensityVoronoiProcessor.postLoop(state);
OptionalDouble maxDensity = this.areaDensityVoronoiProcessor.getData().values().stream().mapToDouble(Double::doubleValue).max();
if(maxDensity.isPresent()) {
this.putValue(NoDataKey.key(), maxDensity.getAsDouble());
}
}
@Override
public void init(final ProcessorManager manager) {
super.init(manager);
AttributesMaxAreaDensityVoronoiProcessor att = (AttributesMaxAreaDensityVoronoiProcessor) this.getAttributes();
this.areaDensityVoronoiProcessor = (AreaDensityVoronoiProcessor) manager.getProcessor(att.getPedestrianAreaDensityVoronoiProcessorId());
}
@Override
public AttributesProcessor getAttributes() {
if (super.getAttributes() == null) {
setAttributes(new AttributesMaxAreaDensityVoronoiProcessor());
}
return super.getAttributes();
}
}
package org.vadere.state.attributes.processor;
/**
* @author Marion Gödel
*
*/
public class AttributesMaxAreaDensityVoronoiProcessor extends AttributesProcessor {
private int pedestrianAreaDensityVoronoiProcessorId;
public int getPedestrianAreaDensityVoronoiProcessorId() {
return this.pedestrianAreaDensityVoronoiProcessorId;
}
public void setPedestrianAreaDensityVoronoiProcessorId(int pedestrianMaxAreaDensityVoronoiProcessorId) {
checkSealed();
this.pedestrianAreaDensityVoronoiProcessorId = pedestrianMaxAreaDensityVoronoiProcessorId;
}
}
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