Commit 8644643c authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

Merge branch 'Attributes_Ped_in_source' into 'master'

Optional source dependent PedestrianAttributes

See merge request !121
parents ce22d318 886e3c3a
Pipeline #230470 passed with stages
in 127 minutes and 36 seconds
{
"name" : "separation_slow_fast",
"description" : "",
"release" : "1.11",
"commithash" : "f1fb53d68af6f8f4b84898b4e1c6a4be0bc89982",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
"filename" : "postvis.traj",
"processors" : [ 1, 2 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOverlapOutputFile",
"filename" : "overlaps.csv",
"processors" : [ 3 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "overlapCount.txt",
"processors" : [ 4 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepProcessor",
"id" : 1
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepTargetIDProcessor",
"id" : 2
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOverlapProcessor",
"id" : 3
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.NumberOverlapsProcessor",
"id" : 4,
"attributesType" : "org.vadere.state.attributes.processor.AttributesNumberOverlapsProcessor",
"attributes" : {
"pedestrianOverlapProcessorId" : 3
}
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
"attributesModel" : {
"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.1,
"minimumStepLength" : true,
"maxStepDuration" : 1.7976931348623157E308,
"dynamicStepLength" : true,
"updateType" : "EVENT_DRIVEN",
"seeSmallWalls" : false,
"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.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.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
}
}
},
"attributesSimulation" : {
"finishTime" : 500.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.1,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : -2527134724682099102,
"simulationSeed" : 0
},
"attributesPsychology" : {
"usePsychologyLayer" : false,
"psychologyLayer" : {
"perception" : "SimplePerceptionModel",
"cognition" : "CooperativeCognitionModel"
}
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 100.0,
"height" : 60.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true,
"referenceCoordinateSystem" : null
},
"obstacles" : [ {
"shape" : {
"x" : 0.0,
"y" : 10.0,
"width" : 90.0,
"height" : 90.0,
"type" : "RECTANGLE"
},
"id" : 3
} ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 92.0,
"y" : 55.0,
"width" : 5.5,
"height" : 3.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"targetChangers" : [ ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : 1,
"shape" : {
"x" : 1.0,
"y" : 5.5,
"width" : 3.0,
"height" : 4.0,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 3,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : {
"id" : -1,
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.8,
"speedDistributionStandardDeviation" : 0.0,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footstepHistorySize" : 4,
"searchRadius" : 1.0,
"walkingDirectionCalculation" : "BY_TARGET_CENTER",
"walkingDirectionSameIfAngleLessOrEqual" : 45.0
}
}, {
"id" : 2,
"shape" : {
"x" : 1.0,
"y" : 1.0,
"width" : 3.0,
"height" : 4.0,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 3,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : false,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : {
"id" : -1,
"radius" : 0.2,
"densityDependentSpeed" : false,
"speedDistributionMean" : 0.9,
"speedDistributionStandardDeviation" : 0.0,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footstepHistorySize" : 4,
"searchRadius" : 1.0,
"walkingDirectionCalculation" : "BY_TARGET_CENTER",
"walkingDirectionSameIfAngleLessOrEqual" : 45.0
}
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"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
},
"teleporter" : 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" : [ ]
}
}
\ No newline at end of file
package org.vadere.simulator.control.scenarioelements;
import org.apache.commons.math3.distribution.RealDistribution;
import org.apache.commons.math3.random.JDKRandomGenerator;
import org.apache.commons.math3.random.RandomGenerator;
import org.vadere.simulator.models.DynamicElementFactory;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.attributes.scenario.AttributesDynamicElement;
......@@ -17,6 +19,7 @@ import org.vadere.util.geometry.LinkedCellsGrid;
import org.vadere.util.geometry.shapes.VCircle;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VShape;
import org.vadere.util.math.TruncatedNormalDistribution;
import java.util.LinkedList;
import java.util.List;
......@@ -162,11 +165,15 @@ public abstract class SourceController {
topography.addElement(newElement);
}
private DynamicElement createDynamicElement(final VPoint position) {
Agent result;
switch (sourceAttributes.getDynamicElementType()) {
case PEDESTRIAN:
result = (Agent) dynamicElementFactory.createElement(position, AttributesAgent.ID_NOT_SET, Pedestrian.class);
if (source.getAttributes().getAttributesPedestrian() == null) {
result = (Agent) dynamicElementFactory.createElement(position, AttributesAgent.ID_NOT_SET, Pedestrian.class);}
else{
result = (Agent) dynamicElementFactory.createElement(position, AttributesAgent.ID_NOT_SET, source.getAttributes().getAttributesPedestrian(), Pedestrian.class); }
break;
case CAR:
result = (Agent) dynamicElementFactory.createElement(position, AttributesAgent.ID_NOT_SET, Car.class);
......
package org.vadere.simulator.models;
import org.jetbrains.annotations.NotNull;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.scenario.DynamicElement;
import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.shapes.VPoint;
......@@ -14,7 +15,16 @@ public interface DynamicElementFactory {
* Note: Every attribute of the given element should be cloned for each individual in this
* method, because some fields are individual.
*/
<T extends DynamicElement> DynamicElement createElement(VPoint position, int id, Class<T> type);
<T extends DynamicElement> DynamicElement createElement(VPoint position, int id, Class<T> type);
/**
* Override the DynamicElement Attributes given in the topography by the values given here.
* Note: The Attribute values come from the source and are set by the SourceController
* during DynamicElement Creation.
*/
<T extends DynamicElement> DynamicElement createElement(VPoint position, int id, Attributes attr, Class<T> type);
/**
* Ensure all Ids are unique within the topography.
......
......@@ -84,11 +84,19 @@ public class BehaviouralHeuristicsModel implements MainModel {
@Override
public <T extends DynamicElement> PedestrianBHM createElement(VPoint position, int id, Class<T> type) {
return createElement(position, id, this.attributesPedestrian, type);
}
@Override
public <T extends DynamicElement> PedestrianBHM createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesAgent aAttr = (AttributesAgent)attr;
if (!Pedestrian.class.isAssignableFrom(type))
throw new IllegalArgumentException("BHM cannot initialize " + type.getCanonicalName());
AttributesAgent pedAttributes = new AttributesAgent(
this.attributesPedestrian, registerDynamicElementId(topography, id));
aAttr, registerDynamicElementId(topography, id));
PedestrianBHM pedestrian = createElement(position, pedAttributes);
pedestrian.setPosition(position);
......
......@@ -58,10 +58,18 @@ public class BiomechanicsModel implements MainModel {
@Override
public <T extends DynamicElement> PedestrianBMM createElement(VPoint position, int id, Class<T> type) {
return createElement(position, id, this.attributesPedestrian, type);
}
@Override
public <T extends DynamicElement> PedestrianBMM createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesAgent aAttr = (AttributesAgent)attr;
if (!Pedestrian.class.isAssignableFrom(type))
throw new IllegalArgumentException("BMM cannot initialize " + type.getCanonicalName());
AttributesAgent pedAttributes = new AttributesAgent(
this.attributesPedestrian, registerDynamicElementId(topography, id));
aAttr, registerDynamicElementId(topography, id));
PedestrianBMM pedestrian = createElement(position, pedAttributes);
this.pedestriansBMM.add(pedestrian);
......
......@@ -152,10 +152,17 @@ public class GradientNavigationModel extends ODEModel<Pedestrian, AttributesAgen
@Override
public <T extends DynamicElement> Pedestrian createElement(VPoint position, int id, Class<T> type) {
return createElement(position, id, this.elementAttributes, type);
}
public <T extends DynamicElement> Pedestrian createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesAgent aAttr = (AttributesAgent)attr;
if (!Pedestrian.class.isAssignableFrom(type))
throw new IllegalArgumentException("GNM cannot initialize " + type.getCanonicalName());
AttributesAgent pedAttributes = new AttributesAgent(elementAttributes, registerDynamicElementId(domain.getTopography(), id));
AttributesAgent pedAttributes = new AttributesAgent(aAttr, registerDynamicElementId(domain.getTopography(), id));
Pedestrian result = create(position, pedAttributes);
return result;
}
......
......@@ -237,11 +237,19 @@ public class OptimalStepsModel implements MainModel, PotentialFieldModel {
*/
@Override
public <T extends DynamicElement> PedestrianOSM createElement(VPoint position, int id, Class<T> type) {
return createElement(position, id, this.attributesPedestrian, type);
}
@Override
public <T extends DynamicElement> PedestrianOSM createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesAgent aAttr = (AttributesAgent)attr;
if (!Pedestrian.class.isAssignableFrom(type))
throw new IllegalArgumentException("OSM cannot initialize " + type.getCanonicalName());
AttributesAgent pedAttributes = new AttributesAgent(
this.attributesPedestrian, registerDynamicElementId(domain.getTopography(), id));
aAttr, registerDynamicElementId(domain.getTopography(), id));
PedestrianOSM pedestrianOSM = createElement(position, pedAttributes);
return pedestrianOSM;
......
......@@ -19,6 +19,7 @@ import org.vadere.state.scenario.DynamicElement;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VShape;
import org.vadere.util.parallel.ParallelWorkerUtil;
import org.w3c.dom.Attr;
import java.util.Collection;
import java.util.Collections;
......@@ -90,15 +91,23 @@ public class OptimalVelocityModel extends ODEModel<Car, AttributesCar> {
* @return single Car-Object
*/
public <T extends DynamicElement> Agent createElement(VPoint position, int id, Class<T> type) {
return createElement(position, id, this.elementAttributes, type);
}
public <T extends DynamicElement> Agent createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesCar aAttr = (AttributesCar)attr;
if (!Car.class.isAssignableFrom(type))
throw new IllegalArgumentException("OVM cannot initialize " + type.getCanonicalName());
AttributesCar carAttributes = new AttributesCar(elementAttributes, registerDynamicElementId(domain.getTopography(), id));
AttributesCar carAttributes = new AttributesCar(aAttr, registerDynamicElementId(domain.getTopography(), id));
Car result = new Car(carAttributes, random);
result.setPosition(position);
// result.setVelocity(result.getCarAttrributes().getDirection());
return result;
}
@Override
public VShape getDynamicElementRequiredPlace(@NotNull VPoint position) {
return new Car(new AttributesCar(elementAttributes, -1), random).getShape();
......
......@@ -89,11 +89,20 @@ public class SelfCatThreatModel implements MainModel {
@Override
public <T extends DynamicElement> DynamicElement createElement(VPoint position, int id, Class<T> type) {
return createElement(position, id, this.attributesPedestrian, type);
}
@Override
public <T extends DynamicElement> DynamicElement createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesAgent aAttr = (AttributesAgent)attr;
if (!Pedestrian.class.isAssignableFrom(type))
throw new IllegalArgumentException("cannot initialize " + type.getCanonicalName());
AttributesAgent pedAttributes = new AttributesAgent(
this.attributesPedestrian, registerDynamicElementId(domain.getTopography(), id));
aAttr, registerDynamicElementId(domain.getTopography(), id));
PedestrianSelfCatThreat pedestrian = createElement(position, pedAttributes);
......
......@@ -112,10 +112,17 @@ public class ReynoldsSteeringModel implements MainModel {
@Override
public <T extends DynamicElement> Pedestrian createElement(VPoint position, int id, Class<T> type) {
return createElement(position, id, this.attributesPedestrian, type);
}
@Override
public <T extends DynamicElement> Pedestrian createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesAgent aAttr = (AttributesAgent)attr;
if (!Pedestrian.class.isAssignableFrom(type))
throw new IllegalArgumentException("RSM cannot initialize " + type.getCanonicalName());
AttributesAgent pedAttributes = new AttributesAgent(
attributesPedestrian, registerDynamicElementId(domain.getTopography(), id));
aAttr, registerDynamicElementId(domain.getTopography(), id));
Pedestrian result = create(position, pedAttributes);
return result;
}
......
......@@ -146,14 +146,22 @@ public class SocialForceModel extends ODEModel<Pedestrian, AttributesAgent> {
@Override
public <T extends DynamicElement> Pedestrian createElement(VPoint position, int id, Class<T> type) {
return createElement(position, id, this.elementAttributes, type);
}
@Override
public <T extends DynamicElement> Pedestrian createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesAgent aAttr = (AttributesAgent)attr;
if (!Pedestrian.class.isAssignableFrom(type))
throw new IllegalArgumentException("SFM cannot initialize " + type.getCanonicalName());
AttributesAgent pedAttributes = new AttributesAgent(elementAttributes, registerDynamicElementId(domain.getTopography(), id));
AttributesAgent pedAttributes = new AttributesAgent(aAttr, registerDynamicElementId(domain.getTopography(), id));
Pedestrian result = create(position, pedAttributes);
return result;
}
private Pedestrian create(@NotNull final VPoint position, @NotNull final AttributesAgent pedAttributes) {
Pedestrian pedestrian = new Pedestrian(pedAttributes, random);
pedestrian.setPosition(position);
......
......@@ -97,8 +97,17 @@ public class GroupSourceControllerTest extends TestSourceControllerUsingConstant
@Override
public <T extends DynamicElement> DynamicElement createElement(VPoint position, int id, Class<T> type) {
return createElement(position, id, d.attributesPedestrian, type);
}
@Override
public <T extends DynamicElement> DynamicElement createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesAgent aAttr = (AttributesAgent) attr;
AttributesAgent att = new AttributesAgent(
d.attributesPedestrian, registerDynamicElementId(null, id));
aAttr, registerDynamicElementId(null, id));
Pedestrian ped = new Pedestrian(att, d.random);
ped.setPosition(position);
return ped;
......
......@@ -6,6 +6,7 @@ import org.vadere.simulator.control.factory.SingleSourceControllerFactory;
import org.vadere.simulator.control.factory.SourceControllerFactory;
import org.vadere.simulator.control.scenarioelements.SourceController;
import org.vadere.simulator.models.DynamicElementFactory;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.attributes.scenario.AttributesSource;
import org.vadere.state.attributes.scenario.SourceTestAttributesBuilder;
......@@ -79,6 +80,15 @@ public class TestSourceController {
return ped;
}
@Override
public <T extends DynamicElement> DynamicElement createElement(VPoint position, int id, Attributes attr, Class<T> type) {
AttributesAgent att = new AttributesAgent(
d.attributesPedestrian, registerDynamicElementId(null, id));
Pedestrian ped = new Pedestrian(att, d.random);
ped.setPosition(position);
return ped;
}
@Override
public int registerDynamicElementId(Topography topography, int id) {
return id > 0 ? id : ++pedestrianIdCounter;
......
......@@ -94,6 +94,8 @@ public class AttributesSource extends AttributesEmbedShape {
@JsonView(Views.CacheViewExclude.class) // ignore when determining if floor field cache is valid
private DynamicElementType dynamicElementType = DynamicElementType.PEDESTRIAN;
@JsonView(Views.CacheViewExclude.class) // ignore when determining if floor field cache is valid
private AttributesAgent attributesPedestrian = null;
@SuppressWarnings("unused")
private AttributesSource() {}
......@@ -160,6 +162,9 @@ public class AttributesSource extends AttributesEmbedShape {
public boolean isSpawnAtGridPositionsCA(){ return spawnAtGridPositionsCA; }
public AttributesAgent getAttributesPedestrian() {
return attributesPedestrian;
}
public boolean isUseFreeSpaceOnly() {
return useFreeSpaceOnly;
......@@ -250,4 +255,7 @@ public class AttributesSource extends AttributesEmbedShape {
checkSealed();
this.id = id;
}