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 cb01a010 authored by Christina Maria Mayr's avatar Christina Maria Mayr Committed by Daniel Lehmberg
Browse files

Same Target change behavior for all pedestrians in a group

parent 324e5329
{
"name" : "group_OSM_target_changer",
"description" : "",
"release" : "1.15",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
"filename" : "postvis.traj",
"processors" : [ 8, 9, 10, 11 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepRowOutputFile",
"filename" : "out.txt",
"processors" : [ 7 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.TargetFloorFieldGridProcessor",
"id" : 7,
"attributesType" : "org.vadere.state.attributes.processor.AttributesFloorFieldProcessor",
"attributes" : {
"targetId" : 5,
"resolution" : 1.0
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepProcessor",
"id" : 8
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepTargetIDProcessor",
"id" : 9
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepGroupIDProcessor",
"id" : 10
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepGroupSizeProcessor",
"id" : 11
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesFloorField" : {
"createMethod" : "HIGH_ACCURACY_FAST_MARCHING",
"potentialFieldResolution" : 0.1,
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"cacheType" : "NO_CACHE",
"cacheDir" : "",
"timeCostAttributes" : {
"standardDeviation" : 0.7,
"type" : "UNIT",
"obstacleDensityWeight" : 3.5,
"pedestrianSameTargetDensityWeight" : 3.5,
"pedestrianOtherTargetDensityWeight" : 3.5,
"pedestrianWeight" : 3.5,
"queueWidthLoading" : 1.0,
"pedestrianDynamicWeight" : 6.0,
"loadingType" : "CONSTANT",
"width" : 0.2,
"height" : 1.0
}
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 4,
"numberOfCircles" : 1,
"optimizationType" : "NELDER_MEAD",
"varyStepDirection" : true,
"movementType" : "ARBITRARY",
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036,
"movementThreshold" : 0.0,
"minStepLength" : 0.17,
"minimumStepLength" : true,
"maxStepDuration" : 3.0,
"dynamicStepLength" : true,
"updateType" : "EVENT_DRIVEN",
"seeSmallWalls" : true,
"targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell",
"submodels" : [ "org.vadere.simulator.models.groups.cgm.CentroidGroupModel" ]
},
"org.vadere.state.attributes.models.AttributesPotentialCompactSoftshell" : {
"pedPotentialIntimateSpaceWidth" : 0.45,
"pedPotentialPersonalSpaceWidth" : 1.2,
"pedPotentialHeight" : 50.0,
"obstPotentialWidth" : 0.8,
"obstPotentialHeight" : 6.0,
"intimateSpaceFactor" : 1.2,
"personalSpacePower" : 1,
"intimateSpacePower" : 1
},
"org.vadere.state.attributes.models.AttributesCGM" : {
"groupMemberRepulsionFactor" : 0.01,
"leaderAttractionFactor" : 0.003
}
},
"attributesSimulation" : {
"finishTime" : 40.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.5,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 4,
"useFixedSeed" : true,
"fixedSeed" : 8544059563994946215,
"simulationSeed" : 8544059563994946215
},
"attributesPsychology" : {
"usePsychologyLayer" : false,
"psychologyLayer" : {
"perception" : "SimplePerceptionModel",
"cognition" : "CooperativeCognitionModel"
}
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 40.0,
"height" : 20.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true,
"referenceCoordinateSystem" : null
},
"obstacles" : [ ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {
"id" : 5,
"absorbing" : true,
"shape" : {
"x" : 0.5,
"y" : 0.5,
"width" : 4.5,
"height" : 4.4,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
}, {
"id" : 2,
"absorbing" : true,
"shape" : {
"x" : 35.0,
"y" : 15.0,
"width" : 4.5,
"height" : 4.5,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"targetChangers" : [ {
"id" : 3,
"shape" : {
"x" : 17.0,
"y" : 18.0,
"width" : 2.5,
"height" : 1.5,
"type" : "RECTANGLE"
},
"reachDistance" : 0.0,
"changeAlgorithmType" : "SELECT_LIST",
"nextTarget" : [ 5 ],
"probabilityToChangeTarget" : [ 1.0 ]
} ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : 1,
"shape" : {
"x" : 0.5,
"y" : 15.0,
"width" : 4.5,
"height" : 4.5,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 3.0 ],
"spawnNumber" : 2,
"maxSpawnNumberTotal" : 100,
"startTime" : 10.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : true,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 0.0, 0.0, 0.0, 1.0 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
}, {
"id" : 4,
"shape" : {
"x" : 5.0,
"y" : 18.0,
"width" : 1.5,
"height" : 1.5,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 1,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footstepHistorySize" : 4,
"searchRadius" : 1.0,
"walkingDirectionCalculation" : "BY_TARGET_CENTER",
"walkingDirectionSameIfAngleLessOrEqual" : 45.0
},
"teleporter" : null,
"attributesCar" : null
},
"stimulusInfos" : [ ]
}
}
\ No newline at end of file
......@@ -83,6 +83,15 @@ public class TargetChangerController {
logEnteringTimeOfAgent(agent, simTimeInSec);
changerAlgorithm.setAgentTargetList(agent);
notifyListenersTargetChangerAreaReached(agent);
if (agent instanceof Pedestrian){
Pedestrian p = (Pedestrian) agent;
if (p.isAgentsInGroup()) {
for (Pedestrian ped : p.getPedGroupMembers()) {
processedAgents.put(ped.getId(), ped);
}
}
}
processedAgents.put(agent.getId(), agent);
}
}
......
......@@ -22,6 +22,7 @@ import org.vadere.state.scenario.Topography;
;
import java.util.*;
import java.util.stream.Collectors;
public class PedestrianOSM extends Pedestrian {
......@@ -420,4 +421,22 @@ public class PedestrianOSM extends Pedestrian {
public String toString() {
return "id = " + getId() + " memory " + super.toString();
}
public LinkedList<Pedestrian> getPedGroupMembers(){
LinkedList<Pedestrian> peds = new LinkedList<>();
if (this.getGroupIds() != null) {
if (this.getGroupIds().size() == 1) {
for (int i : getGroupIds()) {
Collection<Pedestrian> pp = getTopography().getPedestrianDynamicElements().getElements().stream().filter(p -> p.getGroupIds().getFirst() == i && p.getId() != getId()).collect(Collectors.toList());
for (Pedestrian ped : pp) {
peds.add(ped);
}
}
}
}
return peds;
}
}
......@@ -100,6 +100,46 @@ public class TargetChangerControllerTest {
return pedestrians;
}
private List<Pedestrian> createGroupOfPedestriansTargetT1(int startId) {
int seed = 0;
Random random = new Random(seed);
LinkedList<Integer> target= new LinkedList<>();
target.add(1);
LinkedList<Integer> groupId= new LinkedList<>();
groupId.add(42);
Pedestrian pedestrian1 = new Pedestrian(new AttributesAgent(startId), random);
pedestrian1.setPosition(new VPoint(5, 1));
pedestrian1.setTargets(target);
pedestrian1.setGroupIds(groupId);
Pedestrian pedestrian2 = new Pedestrian(new AttributesAgent(startId + 1), random);
pedestrian2.setPosition(new VPoint(1, 1));
pedestrian2.setTargets(target);
pedestrian2.setGroupIds(groupId);
LinkedList<Pedestrian> list1 = new LinkedList<>();
list1.add(pedestrian1);
LinkedList<Pedestrian> list2 = new LinkedList<>();
list2.add(pedestrian2);
pedestrian1.setAgentsInGroup(list2);
pedestrian2.setAgentsInGroup(list1);
// Watch out: Use an "ArrayList" to keep order and
// index 0 refers to pedestrian p1!
List<Pedestrian> pedestrians = new ArrayList<>();
pedestrians.add(pedestrian1);
pedestrians.add(pedestrian2);
return pedestrians;
}
private List<Target> createTwoTargets() {
boolean absorbing = true;
AttributesTarget attributesTarget1 = new AttributesTarget(new VRectangle(7, 1, 2, 2), 1, absorbing);
......@@ -453,6 +493,10 @@ public class TargetChangerControllerTest {
assertListContainsSingleTarget(pedestrians.get(1).getTargets(), expectedTargetIdForPed2);
}
@Test
public void updateModifiesFollowersIfTargetIsDynamic() {
LinkedList<Integer> nextTarget = createIntegerList(1);
......@@ -618,6 +662,7 @@ public class TargetChangerControllerTest {
}
private void assertListContainsSingleTarget(LinkedList<Integer> targetList, Integer targetId) {
assertEquals(1, targetList.size());
assertEquals(targetList.getFirst(), targetId);
......@@ -632,5 +677,41 @@ public class TargetChangerControllerTest {
assertEquals(targetList, targetId);
}
@Test
public void updateChangesTargetGroup() {
Topography topography = new Topography();
List<Pedestrian> peds = createGroupOfPedestriansTargetT1(1);
List<Target> targs = createTwoTargets();
for (Pedestrian pedestrian : peds) {
topography.addElement(pedestrian);
}
for (Target target : targs) {
topography.addTarget(target);
}
LinkedList<Double> probability = new LinkedList<Double>(Arrays.asList(1.0));
AttributesTargetChanger attributesTargetChanger = createAttributesWithFixedRectangle();
attributesTargetChanger.setChangeAlgorithmType(TargetChangerAlgorithmType.SELECT_LIST);
attributesTargetChanger.setNextTarget(createIntegerList(2));
attributesTargetChanger.setProbabilitiesToChangeTarget(probability);
TargetChanger targetChanger = new TargetChanger(attributesTargetChanger);
TargetChangerController controllerUnderTest = new TargetChangerController(topography, targetChanger, new Random(0));
assertEquals(peds.get(0).getNextTargetId(), 1);
assertEquals(peds.get(1).getNextTargetId(), 1);
controllerUnderTest.update(simTimeInSec);
assertEquals(peds.get(0).getNextTargetId(), 2);
assertEquals(peds.get(1).getNextTargetId(), 2);
}
}
\ No newline at end of file
......@@ -10,10 +10,7 @@ import org.vadere.util.geometry.shapes.VShape;
import org.vadere.util.geometry.shapes.Vector2D;
import org.vadere.util.math.TruncatedNormalDistribution;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.*;
public abstract class Agent extends DynamicElement {
......
......@@ -13,10 +13,7 @@ import org.vadere.state.simulation.VTrajectory;
import org.vadere.state.types.ScenarioElementType;
import org.vadere.util.geometry.shapes.VPoint;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Random;
import java.util.*;
public class Pedestrian extends Agent {
......@@ -37,6 +34,9 @@ public class Pedestrian extends Agent {
private LinkedList<Integer> groupIds; // TODO should actually be an attribute or a member of a subclass
private LinkedList<Integer> groupSizes;
private LinkedList<Pedestrian> agentsInGroup = new LinkedList<>();
/**
* trajectory is a list of foot steps a pedestrian made during the duration of one time step.
* For all non event driven models this is exactly one foot step. For the event driven update
......@@ -45,7 +45,9 @@ public class Pedestrian extends Agent {
* can write out those foot steps.
*/
private VTrajectory trajectory;
/** This list stores the last n footsteps. I.e., this list is NOT cleared after each simulation loop like "trajectory" variable. */
/**
* This list stores the last n footsteps. I.e., this list is NOT cleared after each simulation loop like "trajectory" variable.
*/
private transient FootstepHistory footstepHistory;
private Map<Class<? extends ModelPedestrian>, ModelPedestrian> modelPedestrianMap;
......@@ -101,22 +103,47 @@ public class Pedestrian extends Agent {
public int getIdAsTarget() {
return this.idAsTarget;
}
public boolean isChild() {
return isChild;
}
public boolean isLikelyInjured() {
return isLikelyInjured;
}
public Stimulus getMostImportantStimulus() { return psychologyStatus.getMostImportantStimulus(); }
public ThreatMemory getThreatMemory() { return psychologyStatus.getThreatMemory(); }
public SelfCategory getSelfCategory() { return psychologyStatus.getSelfCategory(); }
public GroupMembership getGroupMembership() { return psychologyStatus.getGroupMembership(); }
public KnowledgeBase getKnowledgeBase() {return psychologyStatus.getKnowledgeBase(); }
public LinkedList<Integer> getGroupIds() { return groupIds; }
public Stimulus getMostImportantStimulus() {
return psychologyStatus.getMostImportantStimulus();
}
public ThreatMemory getThreatMemory() {
return psychologyStatus.getThreatMemory();
}
public SelfCategory getSelfCategory() {
return psychologyStatus.getSelfCategory();
}
public GroupMembership getGroupMembership() {
return psychologyStatus.getGroupMembership();
}
public KnowledgeBase getKnowledgeBase() {
return psychologyStatus.getKnowledgeBase();
}
public LinkedList<Integer> getGroupIds() {
return groupIds;
}
public LinkedList<Integer> getGroupSizes() {
return groupSizes;
}
public <T extends ModelPedestrian> T getModelPedestrian(Class<? extends T> modelType) { return (T) modelPedestrianMap.get(modelType); }
public <T extends ModelPedestrian> T getModelPedestrian(Class<? extends T> modelType) {
return (T) modelPedestrianMap.get(modelType);
}
@Override
public ScenarioElementType getType() {
return ScenarioElementType.PEDESTRIAN;
......@@ -130,44 +157,63 @@ public class Pedestrian extends Agent {
return footstepHistory;
}
public VPoint getInterpolatedFootStepPosition(double time){
if(this.footstepHistory.getCapacity() <= 0){
public VPoint getInterpolatedFootStepPosition(double time) {
if (this.footstepHistory.getCapacity() <= 0) {
throw new IllegalArgumentException("Cannot interpolate foot steps if there is no capacity (larger than zero) " +
"for storing foot steps (see 'scenario.attributesPedestrian.footStepsToStore' field)");
}
FootStep currentFootStep = this.footstepHistory.getYoungestFootStep();
if(currentFootStep == null){
if (currentFootStep == null) {
return getPosition();
}else{
if(time > currentFootStep.getEndTime()){
} else {
if (time > currentFootStep.getEndTime()) {
// This happens for example if a pedestrian is waiting (see Events)
return currentFootStep.getEnd();
}else{
} else {
return FootStep.interpolateFootStep(currentFootStep, time);
}
}
}
// Setter
public void setIdAsTarget(int id) { this.idAsTarget = id; }
public void setIdAsTarget(int id) {
this.idAsTarget = id;
}
public void setChild(boolean child) {
this.isChild = child;
}
public void setLikelyInjured(boolean likelyInjured) {
this.isLikelyInjured = likelyInjured;
}
public void setMostImportantStimulus(Stimulus mostImportantStimulus) { psychologyStatus.setMostImportantStimulus(mostImportantStimulus); }
public void setThreatMemory(ThreatMemory threatMemory) { psychologyStatus.setThreatMemory(threatMemory); }
public void setSelfCategory(SelfCategory selfCategory) { psychologyStatus.setSelfCategory(selfCategory); }
public void setGroupMembership(GroupMembership groupMembership) { psychologyStatus.setGroupMembership(groupMembership); }
public void setMostImportantStimulus(Stimulus mostImportantStimulus) {
psychologyStatus.setMostImportantStimulus(mostImportantStimulus);
}
public void setThreatMemory(ThreatMemory threatMemory) {
psychologyStatus.setThreatMemory(threatMemory);
}
public void setSelfCategory(SelfCategory selfCategory) {
psychologyStatus.setSelfCategory(selfCategory);
}
public void setGroupMembership(GroupMembership groupMembership) {
psychologyStatus.setGroupMembership(groupMembership);
}
public void setGroupIds(LinkedList<Integer> groupIds) {
this.groupIds = groupIds;
}
public void setGroupSizes(LinkedList<Integer> groupSizes) {
this.groupSizes = groupSizes;
}
public <T extends ModelPedestrian> ModelPedestrian setModelPedestrian(T modelPedestrian) {
return modelPedestrianMap.put(modelPedestrian.getClass(), modelPedestrian);
}
......@@ -177,17 +223,17 @@ public class Pedestrian extends Agent {
return this.idAsTarget != -1;
}
public void addGroupId(int groupId, int size){
public void addGroupId(int groupId, int size) {
groupIds.add(groupId);
groupSizes.add(size);
}
public void addFootStepToTrajectory(FootStep footStep){
public void addFootStepToTrajectory(FootStep footStep) {
this.trajectory = this.trajectory.add(footStep);
}
public void clearFootSteps() {
if (!trajectory.isEmpty()){
if (!trajectory.isEmpty()) {