Commit 50e605a8 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

rename leader to pacemaker and fix json serialization bugs

parent 788a0d1c
Pipeline #55376 passed with stage
in 46 seconds
......@@ -24,6 +24,7 @@ public class AgentRender implements Renderer {
this.model = model;
this.defaultColor = model.config.getPedestrianDefaultColor();
this.colorMap = new ConcurrentHashMap<>();
this.colorMap.put(-1, defaultColor);
}
@Override
......@@ -76,6 +77,8 @@ public class AgentRender implements Renderer {
private VShape getShape(Pedestrian ped) {
if (ped.getGroupIds().isEmpty()) {
return ped.getShape();
} else if (ped.getGroupIds().getFirst() == 1) {
return ped.getShape();
} else {
return FormHelper.getShape(ped.getGroupIds().getFirst(), ped.getPosition(), ped.getRadius());
}
......
......@@ -213,23 +213,23 @@ public class CentroidGroup implements Group {
return result;
}
public Pedestrian getLeader(Pedestrian ped) {
Pedestrian result = members.get(0);
public Pedestrian getPacemaker(Pedestrian ped) {
Pedestrian pacemaker = members.get(0);
double smallestDistance = potentialFieldTarget.getPotential(result.getPosition(), ped);
double smallestDistance = potentialFieldTarget.getPotential(pacemaker.getPosition(), ped);
for (Pedestrian p : members) {
double pedDistance = potentialFieldTarget.getPotential(p.getPosition(), p);
if (pedDistance < smallestDistance) {
result = p;
pacemaker = p;
smallestDistance = pedDistance;
}
}
if (ped.getId() == result.getId() || isLostMember(ped)) {
result = null;
if (ped.getId() == pacemaker.getId() || isLostMember(ped)) {
pacemaker = null;
}
return result;
return pacemaker;
}
}
......@@ -4,8 +4,8 @@ import org.vadere.state.scenario.Pedestrian;
public class CentroidGroupFactory extends GroupFactory {
private CentroidGroupModel groupCollection;
private GroupSizeDeterminator groupSizeDeterminator;
transient private CentroidGroupModel groupCollection;
transient private GroupSizeDeterminator groupSizeDeterminator;
private CentroidGroup currentGroup;
......
......@@ -34,7 +34,7 @@ public class CentroidGroupModel
private AtomicInteger nextFreeGroupId;
public CentroidGroupModel() {
this.groupFactories = new TreeMap<>();
this.groupFactories = new HashMap<>();
this.pedestrianGroupData = new HashMap<>();
this.nextFreeGroupId = new AtomicInteger(0);
}
......
package org.vadere.simulator.models.groups;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.vadere.annotation.factories.models.ModelClass;
import org.vadere.simulator.models.potential.fields.PotentialFieldAgent;
import org.vadere.state.attributes.Attributes;
......@@ -19,6 +21,8 @@ import java.util.Random;
@ModelClass
public class CentroidGroupPotential implements PotentialFieldAgent {
private static Logger logger = LogManager.getLogger(CentroidGroupPotential.class);
private final AttributesCGM attributesCGM;
private final CentroidGroupModel groupCollection;
private final PotentialFieldAgent potentialFieldPedestrian;
......@@ -55,7 +59,7 @@ public class CentroidGroupPotential implements PotentialFieldAgent {
Pedestrian leader = null;
if (group != null) {
leader = group.getLeader(ped);
leader = group.getPacemaker(ped);
}
if (leader != null) {
......
......@@ -41,7 +41,7 @@ public class PedestrianOSM extends Pedestrian {
private transient IPotentialFieldTarget potentialFieldTarget;
private transient PotentialFieldObstacle potentialFieldObstacle;
private transient PotentialFieldAgent potentialFieldPedestrian;
private List<SpeedAdjuster> speedAdjusters;
private transient List<SpeedAdjuster> speedAdjusters;
private double durationNextStep;
private VPoint nextPosition;
private VPoint lastPosition;
......@@ -176,6 +176,7 @@ public class PedestrianOSM extends Pedestrian {
if (nextPosition.equals(currentPosition)) {
timeCredit = 0;
setVelocity(new Vector2D(0, 0));
} else {
timeCredit = timeCredit - durationNextStep;
setPosition(nextPosition);
......@@ -192,10 +193,11 @@ public class PedestrianOSM extends Pedestrian {
public double getStepSize() {
if (attributesOSM.isDynamicStepLength()) {
return attributesOSM.getStepLengthIntercept()
double step = attributesOSM.getStepLengthIntercept()
+ attributesOSM.getStepLengthSlopeSpeed()
* getDesiredSpeed()
+ stepDeviation;
return step;
} else {
return stepLength;
}
......
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