Commit ac36df09 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Merge branch 'master' into psychology

parents 49e3f67a 801b7818
Pipeline #186489 failed with stages
in 94 minutes and 58 seconds
......@@ -5,6 +5,7 @@ import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.utils.scenariochecker.checks.ScenarioCheckerTest;
import org.vadere.simulator.utils.scenariochecker.checks.dataProcessors.CheckAreasInAreaDensityVoronoiProcessor;
import org.vadere.simulator.utils.scenariochecker.checks.dataProcessors.DataProcessorsLinkedToMeasurementArea;
import org.vadere.simulator.utils.scenariochecker.checks.simulation.GroupSetupCheck;
import org.vadere.simulator.utils.scenariochecker.checks.simulation.SimulationTimeStepLengthCheck;
import org.vadere.simulator.utils.scenariochecker.checks.topography.PedestrianSpeedSetupCheck;
import org.vadere.simulator.utils.scenariochecker.checks.topography.SourceMinRadiusCheck;
......@@ -71,6 +72,7 @@ public class ScenarioChecker {
ret.addAll(runCheck(new TopographyOffsetCheck()));
ret.addAll(runCheck(new DataProcessorsLinkedToMeasurementArea()));
ret.addAll(runCheck(new CheckAreasInAreaDensityVoronoiProcessor()));
ret.addAll(runCheck(new GroupSetupCheck()));
return ret;
}
......
......@@ -46,7 +46,10 @@ public enum ScenarioCheckerReason {
// AreaDensityVoronoiProcessor
AREAS_DENSITY_VORONOI_PROCESSOR_MISMATCH("ScenarioChecker.processor.checkAreasInAreaDensityVoronoiProcessor.mismatch"),
MEASUREMENT_AREA_NOT_RECTANGULAR("ScenarioChecker.processor.measurementArea.hasToBeRectangular");
MEASUREMENT_AREA_NOT_RECTANGULAR("ScenarioChecker.processor.measurementArea.hasToBeRectangular"),
// Group attributes
GROUP_SETUP_IGNORED("ScenarioChecker.simAttr.GroupSetup.ignored");
private String msgId;
......
package org.vadere.simulator.utils.scenariochecker.checks.simulation;
import org.vadere.simulator.models.groups.cgm.CentroidGroupModel;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.utils.scenariochecker.ScenarioCheckerMessage;
import org.vadere.simulator.utils.scenariochecker.ScenarioCheckerReason;
import org.vadere.simulator.utils.scenariochecker.checks.AbstractScenarioCheck;
import org.vadere.state.attributes.models.AttributesCGM;
import org.vadere.state.attributes.models.AttributesOSM;
import org.vadere.state.scenario.Topography;
import java.util.Optional;
import java.util.PriorityQueue;
/**
* @author hm-mgoedel
* Warnings if group settings are used in the source with
* - another model than OSM (currently not implemented)
* - adding CentroidGroupModel as a submodel to the OSM
* - added AttributesCGM to the model attributes
* todo: Add methods to resolve missing information to the scenario file (as automatic id assigment for other checks)
*/
public class GroupSetupCheck extends AbstractScenarioCheck {
@Override
public PriorityQueue<ScenarioCheckerMessage> runScenarioCheckerTest(Scenario scenario) {
PriorityQueue<ScenarioCheckerMessage> ret = new PriorityQueue<>();
Topography topography = scenario.getTopography();
if(topography.getSources().stream().anyMatch(source -> source.getAttributes().getGroupSizeDistribution().size() > 1)){
// check if OSM is used (currently groups only work with OSM)
Optional attr_osm_opt = scenario.getModelAttributes().stream().filter(attr -> attr.getClass().equals(AttributesOSM.class)).findFirst();
if(attr_osm_opt.isPresent()){
AttributesOSM attr_osm = (AttributesOSM) attr_osm_opt.get();
// check if submodel was added
boolean contains_submodel = attr_osm.getSubmodels().stream().anyMatch(submodel -> submodel.equals(CentroidGroupModel.class.getName()));
if(!contains_submodel) {
ret.add(msgBuilder.simulationAttrError()
.reason(ScenarioCheckerReason.GROUP_SETUP_IGNORED, "CentroidGroupModel has to be added to the submodels of the Optimal Steps Model in order to simulate groups. Group settings will be ignored!")
.build());
}
// check if CGM attributes were added
boolean contains_attr = scenario.getModelAttributes().stream().anyMatch(attr -> attr.getClass().equals(AttributesCGM.class));
if(!contains_attr){
ret.add(msgBuilder.simulationAttrError()
.reason(ScenarioCheckerReason.GROUP_SETUP_IGNORED, "AttributesCGM need to be added to the models and configured in order to simulate groups. Group settings will be ignored!")
.build());
}
}else{
ret.add(msgBuilder.simulationAttrError()
.reason(ScenarioCheckerReason.GROUP_SETUP_IGNORED, "Group setup works currently only with the Optimal Steps Model. Group settings will be ignored! ")
.build());
}
}
return ret;
}
}
......@@ -15,8 +15,12 @@ public class TruncatedNormalDistribution extends NormalDistribution {
public TruncatedNormalDistribution(RandomGenerator rng, double mean, double standardDeviation, double min,
double max, int maxIterations) {
super(rng, mean, standardDeviation);
if (max <= min)
throw new IllegalArgumentException("Parameter min must be less than bound.");
if (max <= min){
// TODO: this check should actually go into the ScenarioChecker?
throw new IllegalArgumentException("Parameters 'min < max'.");
}
this.min = min;
this.max = max;
this.maxIterations = maxIterations;
......
Supports Markdown
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