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

Added "LinkedList<Agent> followers" to "Agent"

VadereSimulator/src/org/vadere/simulator/models/osm/OptimalStepsModel.java:
- Added TODO to use new list "Agent.getFollowers()".
parent 285b637b
......@@ -146,6 +146,7 @@ public class TargetChangerController {
// Make "agent" a follower of "pedToFollow".
agent.setSingleTarget(pedToFollow.getId(), true);
pedToFollow.getFollowers().add(agent);
}
private void useStaticTargetForAgent(Agent agent) {
......
......@@ -33,9 +33,7 @@ import org.vadere.simulator.utils.cache.ScenarioCache;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.models.AttributesOSM;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.scenario.DynamicElement;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography;
import org.vadere.state.scenario.*;
import org.vadere.state.types.OptimizationType;
import org.vadere.state.types.UpdateType;
import org.vadere.util.geometry.shapes.VPoint;
......@@ -286,10 +284,19 @@ public class OptimalStepsModel implements MainModel, PotentialFieldModel {
@Override
public void update(final double simTimeInSec) {
double timeStepInSec = simTimeInSec - this.lastSimTimeInSec;
// TODO: Update followers
updateSchemeOSM.update(timeStepInSec, simTimeInSec);
lastSimTimeInSec = simTimeInSec;
}
private void updateTargetPotentialsOfFollowers() {
for (Target target : topography.getTargets()) {
if (target.isTargetPedestrian()) {
// TODO: follower.setTargetPotential().
}
}
}
/*
* At the moment all pedestrians also the initalPedestrians get this.attributesPedestrain!!!
*/
......
......@@ -39,6 +39,7 @@ public class PedestrianOSM extends Pedestrian {
private final double stepLength;
private final double stepDeviation;
private final double minStepLength;
private transient IPotentialFieldTarget potentialFieldTarget;
private transient PotentialFieldObstacle potentialFieldObstacle;
private transient PotentialFieldAgent potentialFieldPedestrian;
......@@ -318,6 +319,10 @@ public class PedestrianOSM extends Pedestrian {
this.relevantPedestrians = relevantPedestrians;
}
public void setPotentialFieldTarget(IPotentialFieldTarget potentialFieldTarget) {
this.potentialFieldTarget = potentialFieldTarget;
}
public void setCombinedPotentialStrategy(CombinedPotentialStrategy newStrategy) {
if (newStrategy == CombinedPotentialStrategy.TARGET_ATTRACTION_STRATEGY) {
this.combinedPotentialStrategy = new TargetAttractionStrategy(this.potentialFieldTarget,
......
......@@ -35,6 +35,8 @@ public abstract class Agent extends DynamicElement {
private Vector2D velocity;
private double freeFlowSpeed;
private LinkedList<Agent> followers;
// TODO: Maybe, add also a List<Agent> of followers for an agent.
// Constructors
......@@ -46,6 +48,8 @@ public abstract class Agent extends DynamicElement {
targetIds = new LinkedList<>();
nextTargetListIndex = 0;
isCurrentTargetAnAgent = false;
followers = new LinkedList<>();
}
public Agent(AttributesAgent attributesAgent, Random random) {
......@@ -75,6 +79,8 @@ public abstract class Agent extends DynamicElement {
this.position = other.position;
this.velocity = other.velocity;
this.freeFlowSpeed = other.freeFlowSpeed;
this.setFollowers(new LinkedList<>(other.followers));
}
// Getters
......@@ -159,6 +165,10 @@ public abstract class Agent extends DynamicElement {
return new VCircle(position, attributes.getRadius());
}
public LinkedList<Agent> getFollowers() {
return followers;
}
// Setters
@Override
public void setAttributes(Attributes attributes) {
......@@ -270,4 +280,8 @@ public abstract class Agent extends DynamicElement {
return agentPositions;
}
public void setFollowers(LinkedList<Agent> followers) {
this.followers = followers;
}
}
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