Commit 197b5cf9 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Renamed enum "SocialCategory" to "SelfCategory" and renamed all dependent codeselfCategoryEnumName

parent a53f0162
......@@ -7,8 +7,7 @@ import org.vadere.gui.postvisualization.utils.PotentialFieldContainer;
import org.vadere.simulator.projects.Scenario;
import org.vadere.state.attributes.AttributesSimulation;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.psychology.cognition.SocialCategory;
import org.vadere.state.psychology.perception.types.Stimulus;
import org.vadere.state.psychology.cognition.SelfCategory;
import org.vadere.state.psychology.perception.types.StimulusFactory;
import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.Pedestrian;
......@@ -232,9 +231,9 @@ public class PostvisualizationModel extends SimulationModel<PostvisualizationCon
pedestrian.setMostImportantStimulus(StimulusFactory.stringToStimulus(mostImportantStimulusString));
}
if(trajectories.socialCategoryCol != -1) {
String socialCategoryString = row.getString(trajectories.socialCategoryCol);
pedestrian.setSocialCategory(SocialCategory.valueOf(socialCategoryString));
if(trajectories.selfCategoryCol != -1) {
String selfCategoryString = row.getString(trajectories.selfCategoryCol);
pedestrian.setSelfCategory(SelfCategory.valueOf(selfCategoryString));
}
return pedestrian;
......
......@@ -6,7 +6,7 @@ import it.unimi.dsi.fastutil.ints.Int2IntMap;
import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.projects.io.ColumnNames;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.psychology.cognition.SocialCategory;
import org.vadere.state.psychology.cognition.SelfCategory;
import org.vadere.state.psychology.perception.types.Stimulus;
import org.vadere.state.psychology.perception.types.StimulusFactory;
import org.vadere.state.scenario.Agent;
......@@ -55,7 +55,7 @@ public class TableTrajectoryFootStep {
public final int groupSizeCol;
public final int mostImportantStimulusCol;
public final int socialCategoryCol;
public final int selfCategoryCol;
public static final int agentDFPedIdCol = 0;
public static final int birthTimeCol = 1;
......@@ -85,7 +85,7 @@ public class TableTrajectoryFootStep {
groupIdCol = columnNames.getGroupIdCol(dataFrame);
groupSizeCol = columnNames.getGroupSizeCol(dataFrame);
mostImportantStimulusCol = columnNames.getMostImportantStimulusCol(dataFrame);
socialCategoryCol = columnNames.getSocialCategoryCol(dataFrame);
selfCategoryCol = columnNames.getSelfCategoryCol(dataFrame);
this.trajectoryDataFrame = dataFrame;
......@@ -143,10 +143,10 @@ public class TableTrajectoryFootStep {
pedestrian.setMostImportantStimulus(stimulus);
}
if(socialCategoryCol != ColumnNames.NOT_SET_COLUMN_INDEX_IDENTIFIER) {
String socialCategoryEnumName = row.getString(socialCategoryCol);
SocialCategory socialCategory = SocialCategory.valueOf(socialCategoryEnumName);
pedestrian.setSocialCategory(socialCategory);
if(selfCategoryCol != ColumnNames.NOT_SET_COLUMN_INDEX_IDENTIFIER) {
String selfCategoryEnumName = row.getString(selfCategoryCol);
SelfCategory selfCategory = SelfCategory.valueOf(selfCategoryEnumName);
pedestrian.setSelfCategory(selfCategory);
}
return pedestrian;
......
package org.vadere.simulator.control;
import org.vadere.simulator.control.psychology.cognition.SelfCategoryProcessor;
import org.vadere.simulator.control.psychology.perception.StimulusProcessor;
import org.vadere.simulator.control.psychology.cognition.SocialCategoryProcessor;
import org.vadere.simulator.control.psychology.perception.StimulusController;
import org.vadere.simulator.control.factory.SourceControllerFactory;
import org.vadere.simulator.models.DynamicElementFactory;
......@@ -80,7 +80,7 @@ public class Simulation {
private SimulationResult simulationResult;
private final StimulusController stimulusController;
private final StimulusProcessor stimulusProcessor;
private final SocialCategoryProcessor socialCategoryProcessor;
private final SelfCategoryProcessor selfCategoryProcessor;
private final ScenarioCache scenarioCache;
public Simulation(MainModel mainModel, double startTimeInSec, final String name, ScenarioStore scenarioStore,
......@@ -118,7 +118,7 @@ public class Simulation {
// "stimulusController" is final. Therefore, create object here and not in helper method.
this.stimulusController = new StimulusController(scenarioStore);
this.stimulusProcessor = new StimulusProcessor();
this.socialCategoryProcessor = new SocialCategoryProcessor(topography);
this.selfCategoryProcessor = new SelfCategoryProcessor(topography);
createControllers(topography, mainModel, random);
......@@ -390,7 +390,7 @@ public class Simulation {
stimulusProcessor.prioritizeStimuliForPedestrians(stimuli, pedestrians);
if (attributesSimulation.isUsePsychologyLayer()) {
socialCategoryProcessor.setSocialCategoryOfPedestrian(pedestrians, simTimeInSec);
selfCategoryProcessor.setSelfCategoryOfPedestrian(pedestrians, simTimeInSec);
}
for (Model m : models) {
......
package org.vadere.simulator.control.psychology.cognition;
import org.vadere.simulator.control.psychology.perception.StimulusProcessor;
import org.vadere.state.psychology.cognition.SocialCategory;
import org.vadere.state.psychology.cognition.SelfCategory;
import org.vadere.state.psychology.perception.types.Bang;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography;
......@@ -10,26 +10,26 @@ import org.vadere.state.simulation.FootstepHistory;
import java.util.Collection;
/**
* The SocialCategoryProcessor class should provide logic to change the social
* category of a pedestrian (e.g., change to cooperative if no movement is
* possible for n steps).
* The SelfCategoryProcessor class should provide logic to change the self
* category of a pedestrian (see "reicher-2010"). E.g., change to cooperative
* if no movement is possible for n steps.
*
* Watch out: The {@link StimulusProcessor} should be finished before using
* methods in this class because, usually, first a stimulus is processed and
* then pedestrians decide which behavior to follow. E.g., first a {@link Bang}
* occurs and then a pedestrian decides to follow a {@link SocialCategory#TARGET_ORIENTED}
* occurs and then a pedestrian decides to follow a {@link SelfCategory#TARGET_ORIENTED}
* behavior.
*/
public class SocialCategoryProcessor {
public class SelfCategoryProcessor {
/** The social category may also depend on the surrounding environment. */
/** The self category may also depend on the surrounding environment. */
private Topography topography;
public SocialCategoryProcessor(Topography topography) {
public SelfCategoryProcessor(Topography topography) {
this.topography = topography;
}
public void setSocialCategoryOfPedestrian(Collection<Pedestrian> pedestrians, double simTimeInSec) {
public void setSelfCategoryOfPedestrian(Collection<Pedestrian> pedestrians, double simTimeInSec) {
// TODO: Include more (pedestrian) attributes into decision process.
for (Pedestrian pedestrian : pedestrians) {
......@@ -42,11 +42,11 @@ public class SocialCategoryProcessor {
// Adapt category only if we have seen some footsteps in the past
if (footstepHistory.size() >= requiredFootSteps) {
if (footstepHistory.getAverageSpeedInMeterPerSecond() <= requiredSpeedInMetersPerSecondToBeCooperative) {
pedestrian.setSocialCategory(SocialCategory.COOPERATIVE);
pedestrian.setSelfCategory(SelfCategory.COOPERATIVE);
} else {
// TODO: Maybe, check if area directed to target is free for a step
// (only then change to "TARGET_ORIENTED").
pedestrian.setSocialCategory(SocialCategory.TARGET_ORIENTED);
pedestrian.setSelfCategory(SelfCategory.TARGET_ORIENTED);
}
}
}
......
......@@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.vadere.simulator.models.potential.combinedPotentials.CombinedPotentialStrategy;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.psychology.cognition.SocialCategory;
import org.vadere.state.psychology.cognition.SelfCategory;
import org.vadere.state.psychology.perception.types.Bang;
import org.vadere.state.psychology.perception.types.ChangeTarget;
import org.vadere.state.psychology.perception.types.Stimulus;
......@@ -133,7 +133,7 @@ public class OSMBehaviorController {
if (closestPedestrians.size() > 0) {
for (Pedestrian closestPedestrian : closestPedestrians) {
if(pedestrian.hasNextTarget()) {
boolean closestPedIsCooperative = closestPedestrian.getSocialCategory() == SocialCategory.COOPERATIVE;
boolean closestPedIsCooperative = closestPedestrian.getSelfCategory() == SelfCategory.COOPERATIVE;
boolean targetOrientationDiffers = false;
// TODO: Use "pedestrian.getTargetGradient()" instead of "calculateAngleBetweenTargets()".
......
......@@ -3,7 +3,7 @@ package org.vadere.simulator.models.osm.updateScheme;
import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.models.osm.OSMBehaviorController;
import org.vadere.simulator.models.osm.PedestrianOSM;
import org.vadere.state.psychology.cognition.SocialCategory;
import org.vadere.state.psychology.cognition.SelfCategory;
import org.vadere.state.psychology.perception.types.*;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography;
......@@ -54,12 +54,12 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
if (mostImportantStimulus instanceof ElapsedTime) {
double stepDuration = pedestrian.getDurationNextStep();
if (pedestrian.getSocialCategory() == SocialCategory.TARGET_ORIENTED) {
if (pedestrian.getSelfCategory() == SelfCategory.TARGET_ORIENTED) {
// this can cause problems if the pedestrian desired speed is 0 (see speed adjuster)
pedestrian.updateNextPosition();
osmBehaviorController.makeStep(pedestrian, topography, stepDuration);
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + stepDuration);
} else if (pedestrian.getSocialCategory() == SocialCategory.COOPERATIVE) {
} else if (pedestrian.getSelfCategory() == SelfCategory.COOPERATIVE) {
// this call will also invoke setTimeOfNextStep
PedestrianOSM candidate = osmBehaviorController.findSwapCandidate(pedestrian, topography);
//TODO: Benedikt Kleinmeier:
......
......@@ -3,7 +3,7 @@ package org.vadere.simulator.models.osm.updateScheme;
import org.jetbrains.annotations.NotNull;
import org.vadere.simulator.models.osm.OSMBehaviorController;
import org.vadere.simulator.models.osm.PedestrianOSM;
import org.vadere.state.psychology.cognition.SocialCategory;
import org.vadere.state.psychology.cognition.SelfCategory;
import org.vadere.state.psychology.perception.types.*;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography;
......@@ -55,9 +55,9 @@ public class UpdateSchemeSequential implements UpdateSchemeOSM {
if (mostImportantStimulus instanceof ElapsedTime) {
pedestrian.setTimeCredit(pedestrian.getTimeCredit() + timeStepInSec);
pedestrian.clearStrides();
if (pedestrian.getSocialCategory() == SocialCategory.TARGET_ORIENTED) {
if (pedestrian.getSelfCategory() == SelfCategory.TARGET_ORIENTED) {
useTimeCredit(pedestrian, timeStepInSec);
} else if (pedestrian.getSocialCategory() == SocialCategory.COOPERATIVE) {
} else if (pedestrian.getSelfCategory() == SelfCategory.COOPERATIVE) {
PedestrianOSM candidate = osmBehaviorController.findSwapCandidate(pedestrian, topography);
if(candidate != null) {
candidate.setTimeCredit(pedestrian.getTimeCredit() + timeStepInSec);
......
......@@ -10,14 +10,14 @@ import org.vadere.state.simulation.VTrajectory;
import java.util.Collection;
/**
* Save social category of a pedestrian in each time step in an own column.
* Save self category of a pedestrian in each time step in an own column.
*/
@DataProcessorClass()
public class FootStepSocialCategoryProcessor extends DataProcessor<EventtimePedestrianIdKey, String> {
public class FootStepSelfCategoryProcessor extends DataProcessor<EventtimePedestrianIdKey, String> {
public static String HEADER = "socialCategory";
public static String HEADER = "selfCategory";
public FootStepSocialCategoryProcessor() {
public FootStepSelfCategoryProcessor() {
super(HEADER);
}
......@@ -27,9 +27,9 @@ public class FootStepSocialCategoryProcessor extends DataProcessor<EventtimePede
for(Pedestrian p : pedestrians){
VTrajectory traj = p.getTrajectory();
String slaientBehavior = p.getSocialCategory().toString();
String selfCategoryString = p.getSelfCategory().toString();
for(FootStep fs : traj.getFootSteps()){
this.putValue(new EventtimePedestrianIdKey(fs.getStartTime(), p.getId()), slaientBehavior);
this.putValue(new EventtimePedestrianIdKey(fs.getStartTime(), p.getId()), selfCategoryString);
}
}
}
......
......@@ -21,7 +21,7 @@ public final class ColumnNames {
private Set<String> startTimeKeys;
private Set<String> endTimeKeys;
private Set<String> mostImportantStimulusKeys;
private Set<String> socialCategoryKeys;
private Set<String> selfCategoryKeys;
private List<Set<String>> keys;
public static final int NOT_SET_COLUMN_INDEX_IDENTIFIER = -1;
......@@ -46,7 +46,7 @@ public final class ColumnNames {
groupIdKeys = new HashSet<>();
groupSizeKeys = new HashSet<>();
mostImportantStimulusKeys = new HashSet<>();
socialCategoryKeys = new HashSet<>();
selfCategoryKeys = new HashSet<>();
startTimeKeys = new HashSet<>();
endTimeKeys = new HashSet<>();
......@@ -68,7 +68,7 @@ public final class ColumnNames {
groupIdKeys.add("groupId");
groupSizeKeys.add("groupSize");
mostImportantStimulusKeys.add("mostImportantStimulus");
socialCategoryKeys.add("socialCategory");
selfCategoryKeys.add("selfCategory");
keys.add(pedestrianIdKeys);
keys.add(startX);
......@@ -79,13 +79,13 @@ public final class ColumnNames {
keys.add(groupIdKeys);
keys.add(groupSizeKeys);
keys.add(mostImportantStimulusKeys);
keys.add(socialCategoryKeys);
keys.add(selfCategoryKeys);
keys.add(startTimeKeys);
keys.add(endTimeKeys);
}
public int getSocialCategoryCol(@NotNull final Table dataFrame) {
return getColId(dataFrame, socialCategoryKeys);
public int getSelfCategoryCol(@NotNull final Table dataFrame) {
return getColId(dataFrame, selfCategoryKeys);
}
public int getMostImportantStimulusCol(@NotNull final Table dataFrame) {
......
......@@ -44,7 +44,7 @@ import org.vadere.simulator.projects.migration.jsontranformation.SimpleJsonTrans
* Also, rename
* - "useSalientBehavior" to "usePsychologyLayer" under "attributesSimulation" node
* - "FootStepMostImportantEventProcessor" to "FootStepMostImportantStimulusProcessor"
* - "FootStepSalientBehaviorProcessor" to "FootStepSocialCategoryProcessor"
* - "FootStepSalientBehaviorProcessor" to "FootStepSelfCategoryProcessor"
* - "salientBehavior" in "dynamicElements" node
*/
@MigrationTransformation(targetVersionLabel = "1.5")
......@@ -182,7 +182,7 @@ public class TargetVersionV1_5 extends SimpleJsonTransformation {
private void renameOutputProcessorSalientBehavior(JsonNode node) throws MigrationException {
String oldName = "FootStepSalientBehaviorProcessor";
String newName = "FootStepSocialCategoryProcessor";
String newName = "FootStepSelfCategoryProcessor";
renameOutputProcessor(node, oldName, newName);
}
......@@ -205,7 +205,7 @@ public class TargetVersionV1_5 extends SimpleJsonTransformation {
private void renameSalientBehaviorInDynamicElements(JsonNode node) throws MigrationException {
String oldName = "salientBehavior";
String newName = "socialCategory";
String newName = "selfCategory";
JsonNode dynamicElementsNode = path(node, "scenario/topography/dynamicElements");
......
package org.vadere.state.psychology.cognition;
/**
* According to the self-categorization theory ("reicher-2010"), people define
* themselves as member of a social category. Often, people act collectively
* when being in the same category. E.g., protesters - which define themselves
* as protesers - walk together during a demonstration.
*
* Our agents can use these categorizations to to derive a specific behavior.
* E.g., if an agents is "COOPERATIVE", the pedestrian swaps places
* with other "COOPERATIVE" pedestrians.
*
* Watch out: The self category of an agent can change during a simulation.
*/
public enum SelfCategory {
TARGET_ORIENTED, COOPERATIVE
}
package org.vadere.state.psychology.cognition;
/**
* A pedestrian uses these social categories to derive a specific behavior.
* E.g., if a pedestrian is "COOPERATIVE", the pedestrian swaps places
* with other "COOPERATIVE" pedestrians.
*
* Watch out: The social category of a pedestrian can change during a simulation.
*/
public enum SocialCategory {
TARGET_ORIENTED, COOPERATIVE
}
package org.vadere.state.scenario;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.psychology.cognition.SocialCategory;
import org.vadere.state.psychology.cognition.SelfCategory;
import org.vadere.state.psychology.perception.types.Stimulus;
import org.vadere.state.simulation.FootStep;
import org.vadere.state.simulation.FootstepHistory;
......@@ -25,7 +25,7 @@ public class Pedestrian extends Agent {
private boolean isChild; // TODO should actually be an attribute or a member of a subclass
private boolean isLikelyInjured; // TODO should actually be an attribute or a member of a subclass
private Stimulus mostImportantStimulus; /** Evaluated in each time step in "EventCognition". */
private SocialCategory socialCategory;
private SelfCategory selfCategory;
private LinkedList<Integer> groupIds; // TODO should actually be an attribute or a member of a subclass
/**
* trajectory is a list of foot steps a pedestrian made during the duration of one time step.
......@@ -59,7 +59,7 @@ public class Pedestrian extends Agent {
isChild = false;
isLikelyInjured = false;
mostImportantStimulus = null;
socialCategory = SocialCategory.TARGET_ORIENTED;
selfCategory = SelfCategory.TARGET_ORIENTED;
groupIds = new LinkedList<>();
groupSizes = new LinkedList<>();
modelPedestrianMap = new HashMap<>();
......@@ -74,7 +74,7 @@ public class Pedestrian extends Agent {
isChild = other.isChild;
isLikelyInjured = other.isLikelyInjured;
mostImportantStimulus = other.mostImportantStimulus;
socialCategory = other.socialCategory;
selfCategory = other.selfCategory;
if (other.groupIds != null) {
groupIds = new LinkedList<>(other.groupIds);
......@@ -100,7 +100,7 @@ public class Pedestrian extends Agent {
return isLikelyInjured;
}
public Stimulus getMostImportantStimulus() { return mostImportantStimulus; }
public SocialCategory getSocialCategory() { return socialCategory; }
public SelfCategory getSelfCategory() { return selfCategory; }
public LinkedList<Integer> getGroupIds() { return groupIds; }
public LinkedList<Integer> getGroupSizes() {
return groupSizes;
......@@ -148,7 +148,7 @@ public class Pedestrian extends Agent {
this.isLikelyInjured = likelyInjured;
}
public void setMostImportantStimulus(Stimulus mostImportantStimulus) { this.mostImportantStimulus = mostImportantStimulus; }
public void setSocialCategory(SocialCategory socialCategory) { this.socialCategory = socialCategory; }
public void setSelfCategory(SelfCategory selfCategory) { this.selfCategory = selfCategory; }
public void setGroupIds(LinkedList<Integer> groupIds) {
this.groupIds = groupIds;
}
......
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