Commit 04ddcb92 authored by Jakob Schöttl's avatar Jakob Schöttl
Browse files

Remove parameter targetIds from PotentialFieldTarget (non-compiling state)

parent 21c602f4
...@@ -7,7 +7,6 @@ import java.util.List; ...@@ -7,7 +7,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.vadere.simulator.models.potential.fields.PotentialFieldTarget; import org.vadere.simulator.models.potential.fields.PotentialFieldTarget;
import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
...@@ -33,11 +32,11 @@ public class CentroidGroup implements Group { ...@@ -33,11 +32,11 @@ public class CentroidGroup implements Group {
this.id = id; this.id = id;
this.size = size; this.size = size;
this.potentialFieldTarget = potentialFieldTarget; this.potentialFieldTarget = potentialFieldTarget;
members = new ArrayList<Pedestrian>(); members = new ArrayList<>();
this.lastVision = new HashMap<Pedestrian, Map<Pedestrian, VPoint>>(); this.lastVision = new HashMap<>();
this.lostMembers = new LinkedList<Pedestrian>(); this.lostMembers = new LinkedList<>();
this.noVisionOfLeaderCount = new HashMap<Pedestrian, Integer>(); this.noVisionOfLeaderCount = new HashMap<>();
} }
@Override @Override
...@@ -199,10 +198,8 @@ public class CentroidGroup implements Group { ...@@ -199,10 +198,8 @@ public class CentroidGroup implements Group {
double result; double result;
VPoint pedLocation = ped.getPosition(); VPoint pedLocation = ped.getPosition();
double pedDistance = potentialFieldTarget.getTargetPotential( double pedDistance = potentialFieldTarget.getTargetPotential(pedLocation, ped);
ped.getTargets(), pedLocation, ped); double centroidDistance = potentialFieldTarget.getTargetPotential(getCentroidOthers(ped), ped);
double centroidDistance = potentialFieldTarget.getTargetPotential(
ped.getTargets(), getCentroidOthers(ped), ped);
result = centroidDistance - pedDistance; result = centroidDistance - pedDistance;
...@@ -216,12 +213,10 @@ public class CentroidGroup implements Group { ...@@ -216,12 +213,10 @@ public class CentroidGroup implements Group {
public Pedestrian getLeader(Pedestrian ped) { public Pedestrian getLeader(Pedestrian ped) {
Pedestrian result = members.get(0); Pedestrian result = members.get(0);
double smallestDistance = potentialFieldTarget.getTargetPotential( double smallestDistance = potentialFieldTarget.getTargetPotential(result.getPosition(), ped);
ped.getTargets(), result.getPosition(), ped);
for (Pedestrian p : members) { for (Pedestrian p : members) {
double pedDistance = potentialFieldTarget.getTargetPotential( double pedDistance = potentialFieldTarget.getTargetPotential(p.getPosition(), p);
ped.getTargets(), p.getPosition(), p);
if (pedDistance < smallestDistance) { if (pedDistance < smallestDistance) {
result = p; result = p;
smallestDistance = pedDistance; smallestDistance = pedDistance;
......
...@@ -221,7 +221,7 @@ public class PedestrianOSM extends Pedestrian { ...@@ -221,7 +221,7 @@ public class PedestrianOSM extends Pedestrian {
public double getPotential(VPoint newPos) { public double getPotential(VPoint newPos) {
double targetPotential = potentialFieldTarget.getTargetPotential(getTargets(), newPos, this); double targetPotential = potentialFieldTarget.getTargetPotential(newPos, this);
double pedestrianPotential = potentialFieldPedestrian double pedestrianPotential = potentialFieldPedestrian
.getAgentPotential(newPos, this, relevantPedestrians); .getAgentPotential(newPos, this, relevantPedestrians);
...@@ -239,7 +239,7 @@ public class PedestrianOSM extends Pedestrian { ...@@ -239,7 +239,7 @@ public class PedestrianOSM extends Pedestrian {
// Getters... // Getters...
public double getTargetPotential(VPoint pos) { public double getTargetPotential(VPoint pos) {
return potentialFieldTarget.getTargetPotential(getTargets(), pos, this); return potentialFieldTarget.getTargetPotential(pos, this);
} }
public PotentialFieldTarget getPotentialFieldTarget() { public PotentialFieldTarget getPotentialFieldTarget() {
...@@ -247,8 +247,7 @@ public class PedestrianOSM extends Pedestrian { ...@@ -247,8 +247,7 @@ public class PedestrianOSM extends Pedestrian {
} }
public Vector2D getTargetGradient(VPoint pos) { public Vector2D getTargetGradient(VPoint pos) {
return potentialFieldTarget.getTargetPotentialGradient(getTargets(), return potentialFieldTarget.getTargetPotentialGradient(pos, this);
pos, this);
} }
public Vector2D getObstacleGradient(VPoint pos) { public Vector2D getObstacleGradient(VPoint pos) {
......
...@@ -50,7 +50,7 @@ public abstract class AbstractPotentialFieldTarget implements IPotentialTargetGr ...@@ -50,7 +50,7 @@ public abstract class AbstractPotentialFieldTarget implements IPotentialTargetGr
* *
*/ */
@Override @Override
public double getTargetPotential(final List<Integer> targetIds, final VPoint pos, final Agent ped) { public double getTargetPotential(final VPoint pos, final Agent ped) {
CellGrid potentialField; CellGrid potentialField;
Topography floor = topography; Topography floor = topography;
...@@ -107,7 +107,7 @@ public abstract class AbstractPotentialFieldTarget implements IPotentialTargetGr ...@@ -107,7 +107,7 @@ public abstract class AbstractPotentialFieldTarget implements IPotentialTargetGr
incY = 0; incY = 0;
} }
List<Point> points = new LinkedList<Point>(); List<Point> points = new LinkedList<>();
points.add(gridPoint); points.add(gridPoint);
points.add(new Point(gridPoint.x + incX, gridPoint.y)); points.add(new Point(gridPoint.x + incX, gridPoint.y));
points.add(new Point(gridPoint.x + incX, gridPoint.y + incY)); points.add(new Point(gridPoint.x + incX, gridPoint.y + incY));
...@@ -222,7 +222,7 @@ public abstract class AbstractPotentialFieldTarget implements IPotentialTargetGr ...@@ -222,7 +222,7 @@ public abstract class AbstractPotentialFieldTarget implements IPotentialTargetGr
*/ */
@Override @Override
public HashMap<Integer, CellGrid> getCellGrids() { public HashMap<Integer, CellGrid> getCellGrids() {
HashMap<Integer, CellGrid> map = new HashMap<Integer, CellGrid>(); HashMap<Integer, CellGrid> map = new HashMap<>();
for (Map.Entry<Integer, PotentialFieldAndInitializer> entry2 : targetPotentialFields for (Map.Entry<Integer, PotentialFieldAndInitializer> entry2 : targetPotentialFields
......
...@@ -8,7 +8,6 @@ import org.vadere.state.attributes.Attributes; ...@@ -8,7 +8,6 @@ import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.models.AttributesFloorField; import org.vadere.state.attributes.models.AttributesFloorField;
import org.vadere.state.attributes.scenario.AttributesAgent; import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.scenario.Agent; import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Target; import org.vadere.state.scenario.Target;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
import org.vadere.util.geometry.Vector2D; import org.vadere.util.geometry.Vector2D;
...@@ -59,7 +58,7 @@ public class PotentialFieldMultiTargetGrid<T extends Agent> extends AbstractPote ...@@ -59,7 +58,7 @@ public class PotentialFieldMultiTargetGrid<T extends Agent> extends AbstractPote
} }
@Override @Override
public Vector2D getTargetPotentialGradient(List<Integer> targetIds, VPoint pos, Agent ped) { public Vector2D getTargetPotentialGradient(VPoint pos, Agent ped) {
throw new UnsupportedOperationException("method not jet implemented."); throw new UnsupportedOperationException("method not jet implemented.");
} }
......
...@@ -50,7 +50,7 @@ public class PotentialFieldSingleTargetGrid extends AbstractPotentialFieldTarget ...@@ -50,7 +50,7 @@ public class PotentialFieldSingleTargetGrid extends AbstractPotentialFieldTarget
} }
@Override @Override
public Vector2D getTargetPotentialGradient(List<Integer> targetIds, VPoint pos, Agent ped) { public Vector2D getTargetPotentialGradient(VPoint pos, Agent ped) {
throw new UnsupportedOperationException("method not jet implemented."); throw new UnsupportedOperationException("method not jet implemented.");
} }
......
package org.vadere.simulator.models.potential.fields; package org.vadere.simulator.models.potential.fields;
import java.util.List;
import org.vadere.simulator.control.ActiveCallback; import org.vadere.simulator.control.ActiveCallback;
import org.vadere.simulator.models.Model; import org.vadere.simulator.models.Model;
import org.vadere.state.scenario.Agent; import org.vadere.state.scenario.Agent;
...@@ -10,9 +9,7 @@ import org.vadere.util.geometry.shapes.VPoint; ...@@ -10,9 +9,7 @@ import org.vadere.util.geometry.shapes.VPoint;
public interface PotentialFieldTarget extends ActiveCallback, Model { public interface PotentialFieldTarget extends ActiveCallback, Model {
boolean needsUpdate(); boolean needsUpdate();
double getTargetPotential(List<Integer> targetIds, double getTargetPotential(final VPoint pos, final Agent ped);
final VPoint pos, final Agent ped);
Vector2D getTargetPotentialGradient(final List<Integer> targetIds, Vector2D getTargetPotentialGradient(final VPoint pos, final Agent ped);
final VPoint pos, final Agent ped);
} }
...@@ -53,8 +53,7 @@ public class PotentialFieldTargetGrid<T extends Agent> extends AbstractPotential ...@@ -53,8 +53,7 @@ public class PotentialFieldTargetGrid<T extends Agent> extends AbstractPotential
@Override @Override
public Vector2D getTargetPotentialGradient(List<Integer> targetIds, public Vector2D getTargetPotentialGradient(VPoint pos, Agent ped) {
VPoint pos, Agent ped) {
throw new UnsupportedOperationException("gradient not yet implemented"); throw new UnsupportedOperationException("gradient not yet implemented");
} }
......
...@@ -44,8 +44,7 @@ public class PotentialFieldTargetRingExperiment implements IPotentialTargetGrid ...@@ -44,8 +44,7 @@ public class PotentialFieldTargetRingExperiment implements IPotentialTargetGrid
* Afterwards, rate "pos" and check if it lies in the same direction as tangent vector. * Afterwards, rate "pos" and check if it lies in the same direction as tangent vector.
*/ */
@Override @Override
public double getTargetPotential(List<Integer> targetIds, VPoint pos, public double getTargetPotential(VPoint pos, Agent ped) {
Agent ped) {
Vector2D pedestrian = new Vector2D(ped.getPosition()); Vector2D pedestrian = new Vector2D(ped.getPosition());
Vector2D center = new Vector2D(attributes.getCenter()); Vector2D center = new Vector2D(attributes.getCenter());
...@@ -69,8 +68,7 @@ public class PotentialFieldTargetRingExperiment implements IPotentialTargetGrid ...@@ -69,8 +68,7 @@ public class PotentialFieldTargetRingExperiment implements IPotentialTargetGrid
} }
@Override @Override
public Vector2D getTargetPotentialGradient(List<Integer> targetIds, public Vector2D getTargetPotentialGradient(VPoint pos, Agent ped) {
VPoint pos, Agent ped) {
Vector2D pedestrian = new Vector2D(ped.getPosition()); Vector2D pedestrian = new Vector2D(ped.getPosition());
Vector2D center = new Vector2D(attributes.getCenter()); Vector2D center = new Vector2D(attributes.getCenter());
......
...@@ -126,7 +126,7 @@ public class PotentialFieldTargetQueuingGrid implements IPotentialTargetGrid, Dy ...@@ -126,7 +126,7 @@ public class PotentialFieldTargetQueuingGrid implements IPotentialTargetGrid, Dy
} }
@Override @Override
public double getTargetPotential(final List<Integer> targetIds, final VPoint pos, final Agent pedArgument) { public double getTargetPotential(final VPoint pos, final Agent pedArgument) {
if (Pedestrian.class.isAssignableFrom(pedArgument.getClass())) if (Pedestrian.class.isAssignableFrom(pedArgument.getClass()))
throw new IllegalArgumentException("Target grid can only handle type Pedestrian"); throw new IllegalArgumentException("Target grid can only handle type Pedestrian");
Pedestrian ped = (Pedestrian) pedArgument; Pedestrian ped = (Pedestrian) pedArgument;
...@@ -134,14 +134,14 @@ public class PotentialFieldTargetQueuingGrid implements IPotentialTargetGrid, Dy ...@@ -134,14 +134,14 @@ public class PotentialFieldTargetQueuingGrid implements IPotentialTargetGrid, Dy
if (pedestrianAttitudeMap.containsKey(ped) && queues.stream().anyMatch(queue -> queue.isQueued(ped))) { if (pedestrianAttitudeMap.containsKey(ped) && queues.stream().anyMatch(queue -> queue.isQueued(ped))) {
switch (pedestrianAttitudeMap.get(ped)) { switch (pedestrianAttitudeMap.get(ped)) {
case COMPETITIVE: case COMPETITIVE:
return competitiveField.getTargetPotential(targetIds, pos, ped); return competitiveField.getTargetPotential(pos, ped);
case GENTLE: case GENTLE:
return gentleField.getTargetPotential(targetIds, pos, ped); return gentleField.getTargetPotential(pos, ped);
default: default:
throw new IllegalArgumentException(ped + " is not contained in the attitude map."); throw new IllegalArgumentException(ped + " is not contained in the attitude map.");
} }
} else if (queues.stream().noneMatch(queue -> queue.isQueued(ped))) { } else if (queues.stream().noneMatch(queue -> queue.isQueued(ped))) {
return competitiveField.getTargetPotential(targetIds, pos, ped); return competitiveField.getTargetPotential(pos, ped);
} else { } else {
logger.warn("ped is neither queued nor not-queued."); logger.warn("ped is neither queued nor not-queued.");
return 0; return 0;
...@@ -149,7 +149,7 @@ public class PotentialFieldTargetQueuingGrid implements IPotentialTargetGrid, Dy ...@@ -149,7 +149,7 @@ public class PotentialFieldTargetQueuingGrid implements IPotentialTargetGrid, Dy
} }
@Override @Override
public Vector2D getTargetPotentialGradient(final List<Integer> targetIds, final VPoint pos, final Agent ped) { public Vector2D getTargetPotentialGradient(final VPoint pos, final Agent ped) {
throw new UnsupportedOperationException("method not implemented jet."); throw new UnsupportedOperationException("method not implemented jet.");
} }
......
Supports Markdown
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