10.12., 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit ab7db35b authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

Renamed "CognitionLayer" to "EventCognition", added class...

Renamed "CognitionLayer" to "EventCognition", added class "SalientBehaviorCognition" and added test scenario "01-ExperimentSetup.scenario".
parent f3e5f552
TestSalientBehavior
\ No newline at end of file
package org.vadere.simulator.control;
import org.vadere.simulator.control.cognition.CognitionLayer;
import org.vadere.simulator.control.cognition.EventCognition;
import org.vadere.simulator.control.events.EventController;
import org.vadere.simulator.control.factory.SourceControllerFactory;
import org.vadere.simulator.models.DynamicElementFactory;
......@@ -70,7 +70,7 @@ public class Simulation {
private final SourceControllerFactory sourceControllerFactory;
private SimulationResult simulationResult;
private final EventController eventController;
private final CognitionLayer cognitionLayer;
private final EventCognition eventCognition;
public Simulation(MainModel mainModel, double startTimeInSec, final String name, ScenarioStore scenarioStore,
List<PassiveCallback> passiveCallbacks, Random random, ProcessorManager processorManager,
......@@ -101,7 +101,7 @@ public class Simulation {
// "eventController" is final. Therefore, create object here and not in helper method.
this.eventController = new EventController(scenarioStore);
this.cognitionLayer = new CognitionLayer();
this.eventCognition = new EventCognition();
createControllers(topography, mainModel, random);
......@@ -317,7 +317,7 @@ public class Simulation {
step++;
Collection<Pedestrian> pedestrians = topography.getElements(Pedestrian.class);
cognitionLayer.prioritizeEventsForPedestrians(events, pedestrians);
eventCognition.prioritizeEventsForPedestrians(events, pedestrians);
for (Model m : models) {
List<SourceController> stillSpawningSource = this.sourceControllers.stream().filter(s -> !s.isSourceFinished(simTimeInSec)).collect(Collectors.toList());
......
......@@ -8,10 +8,10 @@ import java.util.List;
import java.util.stream.Collectors;
/**
* The CognitionLayer class should provide logic to prioritize {@link Event}
* objects based on attributes of a pedestrian.
* The EventCognition class should provide logic to prioritize {@link Event}s for a pedestrian based on its
* current state/attributes (e.g., a {@link BangEvent} is more important than a {@link WaitEvent}.
*/
public class CognitionLayer {
public class EventCognition {
public void prioritizeEventsForPedestrians(List<Event> events, Collection<Pedestrian> pedestrians){
for (Pedestrian pedestrian : pedestrians) {
......
package org.vadere.simulator.control.cognition;
import org.vadere.state.events.types.BangEvent;
import org.vadere.state.behavior.SalientBehavior;
import org.vadere.state.events.types.Event;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography;
import java.util.Collection;
import java.util.List;
/**
* The SalientBehaviorCognition class should provide logic to change the salient behavior of a pedestrian
* (e.g., change to cooperative behavior when no movement is possible for n steps).
*
* Watch out: The {@link EventCognition} should be finished before using methods in this class because usually
* first an event occurs and then pedestrians decide about their behavior. E.g., first a {@link BangEvent} occurs
* and then a pedestrian decides to follow a {@link SalientBehavior#COOPERATIVE} behavior.
*/
public class SalientBehaviorCognition {
/** The salient behavior depends also on the surrounding environment. */
private Topography topography;
public SalientBehaviorCognition(Topography topography) {
this.topography = topography;
}
public void setSalientBehaviorForPedestrians(Collection<Pedestrian> pedestrians) {
for (Pedestrian pedestrian : pedestrians) {
// TODO: Set salient behavior for each pedestrian individually based on the most important event and/or if
// the pedestrian could not move for several time steps.
// TODO: Use pedestrian.getFootSteps() to calculate average velocity for last
}
}
}
package org.vadere.state.behavior;
/**
* A pedestrian follows one of these behaviors during the simulation.
* Please note thate the behavior of a pedestrian can change during the simulation.
*/
public enum SalientBehavior {
TARGET_ORIENTED, COOPERATIVE
}
package org.vadere.state.scenario;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.behavior.SalientBehavior;
import org.vadere.state.events.types.Event;
import org.vadere.state.simulation.FootStep;
import org.vadere.state.simulation.VTrajectory;
......@@ -20,7 +21,8 @@ public class Pedestrian extends Agent {
private int idAsTarget; // TODO should actually be an attribute or a member of a subclass
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 Event mostImportantEvent; /** Evaluated in each time step in "CognitionLayer". */
private Event mostImportantEvent; /** Evaluated in each time step in "EventCognition". */
private SalientBehavior salientBehavior;
private LinkedList<Integer> groupIds; // TODO should actually be an attribute or a member of a subclass
/**
* Footsteps is a list of foot steps a pedestrian made during the duration of one time step.
......@@ -53,6 +55,7 @@ public class Pedestrian extends Agent {
isChild = false;
isLikelyInjured = false;
mostImportantEvent = null;
salientBehavior = SalientBehavior.TARGET_ORIENTED;
groupIds = new LinkedList<>();
groupSizes = new LinkedList<>();
modelPedestrianMap = new HashMap<>();
......@@ -97,6 +100,7 @@ public class Pedestrian extends Agent {
return isLikelyInjured;
}
public Event getMostImportantEvent() { return mostImportantEvent; }
public SalientBehavior getSalientBehavior() { return salientBehavior; }
public LinkedList<Integer> getGroupIds() { return groupIds; }
public LinkedList<Integer> getGroupSizes() {
return groupSizes;
......@@ -116,6 +120,7 @@ public class Pedestrian extends Agent {
this.isLikelyInjured = likelyInjured;
}
public void setMostImportantEvent(Event mostImportantEvent) { this.mostImportantEvent = mostImportantEvent; }
public void setSalientBehavior(SalientBehavior salientBehavior) { this.salientBehavior = salientBehavior; }
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