Commit 6547e3bf authored by Christina's avatar Christina
Browse files

resolve comments

parent ebecfbdb
Pipeline #625512 passed with stages
in 157 minutes and 24 seconds
......@@ -68,13 +68,18 @@ public abstract class ControlModel implements IControlModel {
}
public double getBernoulliParameter(){
return this.reactionModel.getBernoulliParameter();
return this.reactionModel.getBernoulliParameter(getOptionIndex());
}
public abstract boolean isPedReact();
protected abstract void triggerPedReaction(Pedestrian ped);
int getOptionIndex(){
// if there is one option only
return 0;
};
public void setProcessedAgents(Pedestrian ped, LinkedList<Integer> ids){
......
......@@ -38,10 +38,7 @@ public class RouteChoice extends ControlModel {
@Override
public boolean isPedReact() {
LinkedList<Integer> alternativeTargets = readTargetsFromJson();
int i = alternativeTargets.indexOf(newTargetList.get(0));
int i = getOptionIndex();
try {
return reactionModel.isPedReact(i);
} catch (Exception e) {
......@@ -51,6 +48,10 @@ public class RouteChoice extends ControlModel {
}
protected int getOptionIndex() {
LinkedList<Integer> alternativeTargets = readTargetsFromJson();
return alternativeTargets.indexOf(newTargetList.get(0));
}
@Override
......
......@@ -59,10 +59,6 @@ public class ReactionModel implements IReactModel{
return isPedReact(0);
}
public double getBernoulliParameter(){
return getBernoulliParameter(0);
}
public double getBernoulliParameter(int i){
......
......@@ -15,7 +15,7 @@ public class CognitionModelBuilder {
public static final String JAVA_PACKAGE_SEPARATOR = ".";
public static ICognitionModel instantiateModel(ScenarioStore scenarioStore) {
public static ICognitionModel instantiateModel(final ScenarioStore scenarioStore) {
String simpleClassName = scenarioStore.getAttributesPsychology().getPsychologyLayer().getCognition();
String classSearchPath = ICognitionModel.class.getPackageName();
String fullyQualifiedClassName = classSearchPath + JAVA_PACKAGE_SEPARATOR + simpleClassName;
......
......@@ -15,7 +15,7 @@ public class PerceptionModelBuilder {
public static final String JAVA_PACKAGE_SEPARATOR = ".";
public static IPerceptionModel instantiateModel(ScenarioStore scenarioStore) {
public static IPerceptionModel instantiateModel(final ScenarioStore scenarioStore) {
String simpleClassName = scenarioStore.getAttributesPsychology().getPsychologyLayer().getPerception();
String classSearchPath = IPerceptionModel.class.getPackageName();
String fullyQualifiedClassName = classSearchPath + JAVA_PACKAGE_SEPARATOR + simpleClassName;
......
......@@ -24,7 +24,7 @@ public class ProbabilisticPerceptionModel implements IPerceptionModel {
@Override
public void initialize(Topography topography, final double simTimeStepLengh) {
rng = new JDKRandomGenerator(new Random().nextInt());
rng = new JDKRandomGenerator(0); //TODO: use seed from json?
processedStimuli = new HashMap<>();
this.simulationStepLength = simTimeStepLengh;
}
......@@ -32,17 +32,18 @@ public class ProbabilisticPerceptionModel implements IPerceptionModel {
@Override
public void update(HashMap<Pedestrian, List<Stimulus>> pedSpecificStimuli) {
for (Pedestrian pedestrian : pedSpecificStimuli.keySet()) {
for (Map.Entry<Pedestrian, List<Stimulus>> entry : pedSpecificStimuli.entrySet()) {
Stimulus mostImportantStimulus;
if (isStimulusNew(pedSpecificStimuli.get(pedestrian), pedestrian)) {
mostImportantStimulus = getMostImportantStimulusFromProbabilites(pedSpecificStimuli.get(pedestrian));
logger.info("Pedestrian with id=" + pedestrian.getId() + " got new Stimulus " + mostImportantStimulus.toString());
if (isStimulusNew(entry.getValue(), entry.getKey())) {
mostImportantStimulus = getMostImportantStimulusFromProbabilites(entry.getValue());
logger.info("Pedestrian with id=" + entry.getKey().getId() + " got new Stimulus " + mostImportantStimulus.toString());
}
else {
mostImportantStimulus = getStimulusExisting(pedSpecificStimuli, pedestrian);
logger.info("Pedestrian with id=" + pedestrian.getId() + " has most important stimulus " + mostImportantStimulus.toString());
mostImportantStimulus = getStimulusExisting(pedSpecificStimuli, entry.getKey());
logger.info("Pedestrian with id=" + entry.getKey().getId() + " has most important stimulus " + mostImportantStimulus.toString());
}
pedestrian.setMostImportantStimulus(mostImportantStimulus);
entry.getKey().setMostImportantStimulus(mostImportantStimulus);
}
setProcessedStimuli(pedSpecificStimuli);
}
......
......@@ -71,9 +71,11 @@ public class UpdateSchemeEventDriven implements UpdateSchemeOSM {
osmBehaviorController.makeStepToTarget(pedestrian, topography);
} else if (selfCategory == SelfCategory.WAIT) {
osmBehaviorController.wait(pedestrian, topography, timeStepInSec);
// needed for postvis to correctly reproduce state.
pedestrian.getTrajectory().add(new FootStep(pedestrian.getPosition(), pedestrian.getPosition(), currentTimeInSec, pedestrian.getTimeOfNextStep()));
} else if (selfCategory == SelfCategory.CHANGE_TARGET) {
osmBehaviorController.changeTarget(pedestrian, topography);
// needed for postvis to correctly reproduce state.
pedestrian.getTrajectory().add(new FootStep(pedestrian.getPosition(), pedestrian.getPosition(), currentTimeInSec, pedestrian.getTimeOfNextStep()));
}
}
......
......@@ -67,9 +67,11 @@ public class UpdateSchemeSequential implements UpdateSchemeOSM {
stepForward(pedestrian, currentTimeInSec, timeStepInSec);
} else if (selfCategory == SelfCategory.WAIT) {
osmBehaviorController.wait(pedestrian, topography, timeStepInSec);
// needed for postvis to correctly reproduce state.
pedestrian.getTrajectory().add(new FootStep(pedestrian.getPosition(), pedestrian.getPosition(), currentTimeInSec, pedestrian.getTimeOfNextStep()));
} else if (selfCategory == SelfCategory.CHANGE_TARGET) {
osmBehaviorController.changeTarget(pedestrian, topography);
// needed for postvis to correctly reproduce state.
pedestrian.getTrajectory().add(new FootStep(pedestrian.getPosition(), pedestrian.getPosition(), currentTimeInSec, pedestrian.getTimeOfNextStep()));
}
}
......
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