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

Refactored and simplified "TargetChangerController.java" to improve...

Refactored and simplified "TargetChangerController.java" to improve readability and added test scenarios under "ModelTests/TestPsychology/ScenarioElements" to demonstrate new functionality
parent c76db872
Pipeline #240791 passed with stages
in 142 minutes and 41 seconds
{
"name" : "05-Test-SpeedInAreaProcessor-SpeedByHeight",
"name" : "04-Test-TargetChanger-SupportsListsOfTargets",
"description" : "",
"release" : "1.12",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
"filename" : "speedInArea.txt",
"processors" : [ 1, 2, 6 ]
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
"filename" : "postvis.traj",
"processors" : [ 5, 6 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOverlapOutputFile",
"filename" : "overlaps.csv",
......@@ -15,22 +15,8 @@
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "overlapCount.txt",
"processors" : [ 4 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
"filename" : "postvis.traj",
"processors" : [ 7, 8 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianPositionProcessor",
"id" : 1,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianPositionProcessor",
"attributes" : {
"interpolate" : true
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianTargetIdProcessor",
"id" : 2
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOverlapProcessor",
"id" : 3
}, {
......@@ -40,24 +26,12 @@
"attributes" : {
"pedestrianOverlapProcessorId" : 3
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianTrajectoryProcessor",
"id" : 5
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianSpeedInAreaProcessorUsingAgentTrajectory",
"id" : 6,
"attributesType" : "org.vadere.state.attributes.processor.AttributesSpeedInAreaProcessorUsingAgentTrajectory",
"attributes" : {
"measurementAreaId" : 1,
"pedestrianTrajectoryProcessorId" : 5,
"speedCalculationStrategy" : "BY_MEASUREMENT_AREA_HEIGHT"
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepProcessor",
"id" : 7
"id" : 5
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepTargetIDProcessor",
"id" : 8
"id" : 6
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
......@@ -119,7 +93,7 @@
}
},
"attributesSimulation" : {
"finishTime" : 30.0,
"finishTime" : 100.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
......@@ -127,7 +101,7 @@
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : -4846208968571738224,
"fixedSeed" : -3989740141114319444,
"simulationSeed" : 0
},
"attributesPsychology" : {
......@@ -150,25 +124,67 @@
"referenceCoordinateSystem" : null
},
"obstacles" : [ ],
"measurementAreas" : [ {
"shape" : {
"x" : 2.8,
"y" : 2.2,
"width" : 7.2,
"height" : 5.9,
"type" : "RECTANGLE"
},
"id" : 1
} ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 17.4,
"y" : 3.7,
"width" : 1.6,
"height" : 3.6,
"x" : 9.0,
"y" : 8.0,
"width" : 1.0,
"height" : 1.0,
"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" : 9.0,
"y" : 0.9,
"width" : 1.1,
"height" : 1.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
}, {
"id" : 3,
"absorbing" : false,
"shape" : {
"x" : 12.0,
"y" : 4.5,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
}, {
"id" : 4,
"absorbing" : true,
"shape" : {
"x" : 18.0,
"y" : 4.5,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
......@@ -179,63 +195,72 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"targetChangers" : [ ],
"targetChangers" : [ {
"id" : 5,
"shape" : {
"x" : 7.9,
"y" : 0.4801097393689986,
"width" : 0.8242798353909446,
"height" : 8.97119341563786,
"type" : "RECTANGLE"
},
"reachDistance" : 0.0,
"nextTargetIsPedestrian" : false,
"nextTarget" : [ 3, 4 ],
"probabilityToChangeTarget" : [ 1.0 ]
} ],
"absorbingAreas" : [ ],
"sources" : [ ],
"dynamicElements" : [ {
"attributes" : {
"id" : 2,
"radius" : 0.2,
"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
"sources" : [ {
"id" : 3,
"shape" : {
"x" : 1.0,
"y" : 8.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"source" : null,
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 5,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"nextTargetListIndex" : 0,
"isCurrentTargetAnAgent" : false,
"position" : {
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
}, {
"id" : 4,
"shape" : {
"x" : 1.0,
"y" : 5.6
},
"velocity" : {
"x" : 0.0,
"y" : 0.0
},
"freeFlowSpeed" : 1.7573879731780782,
"followers" : [ ],
"idAsTarget" : -1,
"isChild" : false,
"isLikelyInjured" : false,
"psychologyStatus" : {
"mostImportantStimulus" : null,
"threatMemory" : {
"allThreats" : [ ],
"latestThreatUnhandled" : false
},
"selfCategory" : "TARGET_ORIENTED",
"groupMembership" : "OUT_GROUP"
},
"groupIds" : [ ],
"groupSizes" : [ ],
"trajectory" : {
"footSteps" : [ ]
"y" : 0.9,
"width" : 1.1,
"height" : 1.1,
"type" : "RECTANGLE"
},
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 5,
"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.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"speedDistributionMean" : 0.5,
"speedDistributionStandardDeviation" : 0.1,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
......@@ -245,7 +270,26 @@
"walkingDirectionSameIfAngleLessOrEqual" : 45.0
},
"teleporter" : null,
"attributesCar" : null
"attributesCar" : {
"id" : -1,
"radius" : 0.2,
"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,
"length" : 4.5,
"width" : 1.7,
"direction" : {
"x" : 1.0,
"y" : 0.0
}
}
},
"stimulusInfos" : [ ]
}
......
{
"name" : "06-Test-SpeedInAreaProcessor-SpeedByWidth",
"name" : "05-Test-TargetChanger-CanCreateAListOfTargets",
"description" : "",
"release" : "1.12",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
"filename" : "speedInArea.txt",
"processors" : [ 1, 2, 6 ]
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
"filename" : "postvis.traj",
"processors" : [ 5, 6 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOverlapOutputFile",
"filename" : "overlaps.csv",
......@@ -15,22 +15,8 @@
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "overlapCount.txt",
"processors" : [ 4 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
"filename" : "postvis.traj",
"processors" : [ 7, 8 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianPositionProcessor",
"id" : 1,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianPositionProcessor",
"attributes" : {
"interpolate" : true
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianTargetIdProcessor",
"id" : 2
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOverlapProcessor",
"id" : 3
}, {
......@@ -40,24 +26,12 @@
"attributes" : {
"pedestrianOverlapProcessorId" : 3
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianTrajectoryProcessor",
"id" : 5
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianSpeedInAreaProcessorUsingAgentTrajectory",
"id" : 6,
"attributesType" : "org.vadere.state.attributes.processor.AttributesSpeedInAreaProcessorUsingAgentTrajectory",
"attributes" : {
"measurementAreaId" : 1,
"pedestrianTrajectoryProcessorId" : 5,
"speedCalculationStrategy" : "BY_MEASUREMENT_AREA_WIDTH"
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepProcessor",
"id" : 7
"id" : 5
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepTargetIDProcessor",
"id" : 8
"id" : 6
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
......@@ -119,7 +93,7 @@
}
},
"attributesSimulation" : {
"finishTime" : 30.0,
"finishTime" : 100.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
......@@ -127,7 +101,7 @@
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : -4846208968571738224,
"fixedSeed" : -3989740141114319444,
"simulationSeed" : 0
},
"attributesPsychology" : {
......@@ -150,25 +124,67 @@
"referenceCoordinateSystem" : null
},
"obstacles" : [ ],
"measurementAreas" : [ {
"shape" : {
"x" : 2.8,
"y" : 2.2,
"width" : 7.2,
"height" : 5.9,
"type" : "RECTANGLE"
},
"id" : 1
} ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 17.4,
"y" : 3.7,
"width" : 1.6,
"height" : 3.6,
"x" : 9.0,
"y" : 8.0,
"width" : 1.0,
"height" : 1.0,
"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" : 9.0,
"y" : 0.9,
"width" : 1.1,
"height" : 1.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
}, {
"id" : 3,
"absorbing" : false,
"shape" : {
"x" : 12.0,
"y" : 4.5,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
}, {
"id" : 4,
"absorbing" : true,
"shape" : {
"x" : 18.0,
"y" : 4.5,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
......@@ -179,63 +195,72 @@
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"targetChangers" : [ ],
"targetChangers" : [ {
"id" : 5,
"shape" : {
"x" : 7.9,
"y" : 0.4801097393689986,
"width" : 0.8242798353909446,
"height" : 8.97119341563786,
"type" : "RECTANGLE"
},
"reachDistance" : 0.0,
"nextTargetIsPedestrian" : false,
"nextTarget" : [ 3, 4 ],
"probabilityToChangeTarget" : [ 1.0, 0.5 ]
} ],
"absorbingAreas" : [ ],
"sources" : [ ],
"dynamicElements" : [ {
"attributes" : {
"id" : 2,
"radius" : 0.2,
"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
"sources" : [ {
"id" : 3,
"shape" : {
"x" : 1.0,
"y" : 8.0,
"width" : 1.0,
"height" : 1.0,
"type" : "RECTANGLE"
},
"source" : null,
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 5,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"nextTargetListIndex" : 0,
"isCurrentTargetAnAgent" : false,
"position" : {
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
}, {
"id" : 4,
"shape" : {
"x" : 1.0,
"y" : 5.6
},
"velocity" : {
"x" : 0.0,
"y" : 0.0
},
"freeFlowSpeed" : 1.7573879731780782,
"followers" : [ ],
"idAsTarget" : -1,
"isChild" : false,
"isLikelyInjured" : false,
"psychologyStatus" : {
"mostImportantStimulus" : null,
"threatMemory" : {
"allThreats" : [ ],
"latestThreatUnhandled" : false
},
"selfCategory" : "TARGET_ORIENTED",
"groupMembership" : "OUT_GROUP"
},
"groupIds" : [ ],
"groupSizes" : [ ],
"trajectory" : {
"footSteps" : [ ]
"y" : 0.9,
"width" : 1.1,
"height" : 1.1,
"type" : "RECTANGLE"
},
"modelPedestrianMap" : null,
"type" : "PEDESTRIAN"
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 5,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 2 ],