Commit 8d7ad27f authored by Marion Goedel's avatar Marion Goedel
Browse files

Added new checks in the Scenariochecker for groups.

parent 648c9bc2
Pipeline #185058 passed with stages
in 212 minutes and 46 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.simulationAttrWarning()
.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.simulationAttrWarning()
.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.simulationAttrWarning()
.reason(ScenarioCheckerReason.GROUP_SETUP_IGNORED, "Group setup works currently only with the Optimal Steps Model. Group settings will be ignored! ")
.build());
}
}
return ret;
}
}
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