Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 4c38ef02 authored by Christina Maria Mayr's avatar Christina Maria Mayr
Browse files

Merge branch 'bug_and_refactor' into 'master'

refactoring + bug fix

See merge request !164
parents ad56441d e95ffc21
Pipeline #618331 passed with stages
in 139 minutes and 47 seconds
......@@ -202,10 +202,11 @@ public class SimulationCommandHandler extends CommandHandler<SimulationVar> {
Topography topography = state.getTopography();
boolean isUsePsychologyLayer = state.getScenarioStore().getAttributesPsychology().isUsePsychologyLayer();
ReactionModel reactionModel = new ReactionModel(reactionModelParameter);
double simTimeStepLength = state.getScenarioStore().getAttributesSimulation().getSimTimeStepLength();
if (!iControlModelHashMap.containsKey(controlModelName)) {
IControlModel controlModel = ControlModelBuilder.getModel(controlModelType);
controlModel.init(topography, stimulusController, isUsePsychologyLayer, reactionModel);
controlModel.init(topography, stimulusController, isUsePsychologyLayer, reactionModel, simTimeStepLength);
iControlModelHashMap.put(controlModelName, controlModel);
}
......@@ -244,9 +245,10 @@ public class SimulationCommandHandler extends CommandHandler<SimulationVar> {
Topography topography = state.getTopography();
boolean isUsePsychologyLayer = state.getScenarioStore().getAttributesPsychology().isUsePsychologyLayer();
ReactionModel reactionModel = new ReactionModel();
double simTimeStepLength = state.getScenarioStore().getAttributesSimulation().getSimTimeStepLength();
IControlModel controlModel = ControlModelBuilder.getModel(model_name);
controlModel.init(topography, stimulusController, isUsePsychologyLayer, reactionModel);
controlModel.init(topography, stimulusController, isUsePsychologyLayer, reactionModel, simTimeStepLength);
iControlModelHashMap.put(model_name, controlModel);
});
}
......
......@@ -4,7 +4,6 @@ package org.vadere.simulator.control.external.models;
import org.json.JSONObject;
import org.vadere.simulator.control.external.reaction.ReactionModel;
import org.vadere.simulator.control.psychology.perception.StimulusController;
import org.vadere.simulator.projects.ScenarioStore;
import org.vadere.state.psychology.information.InformationState;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography;
......@@ -26,6 +25,7 @@ public abstract class ControlModel implements IControlModel {
protected HashMap<Pedestrian,LinkedList<Integer>> processedAgents;
protected StimulusController stimulusController;
private boolean isUsePsychologyLayer = false;
private double simTimeStepLength;
public ControlModel(){
......@@ -35,6 +35,18 @@ public abstract class ControlModel implements IControlModel {
}
@Override
public void init(final Topography topography, final StimulusController stimulusController, final boolean isUsePsychologyLayer, final ReactionModel reactionModel, final double simTimeStepLength) {
processedAgents = new HashMap<>();
simTime = 0.0;
this.topography = topography;
this.stimulusController = stimulusController;
this.isUsePsychologyLayer = isUsePsychologyLayer;
this.reactionModel = reactionModel;
this.simTimeStepLength = simTimeStepLength;
}
@Override
public void init(final Topography topography, final StimulusController stimulusController, final boolean isUsePsychologyLayer, final ReactionModel reactionModel) {
processedAgents = new HashMap<>();
......@@ -70,7 +82,7 @@ public abstract class ControlModel implements IControlModel {
public abstract boolean isPedReact();
protected abstract void triggerRedRaction(Pedestrian ped);
protected abstract void triggerPedReaction(Pedestrian ped);
public void setProcessedAgents(Pedestrian ped, LinkedList<Integer> ids){
......@@ -155,7 +167,7 @@ public abstract class ControlModel implements IControlModel {
public void setAction(Pedestrian ped){
if (isPedReact()){
triggerRedRaction(ped);
triggerPedReaction(ped);
}
else{
ped.getKnowledgeBase().setInformationState(InformationState.INFORMATION_UNCONVINCING_RECEIVED);
......@@ -188,4 +200,20 @@ public abstract class ControlModel implements IControlModel {
public boolean isUsePsychologyLayer() {
return isUsePsychologyLayer;
}
public double getSimTimeStepLength() {
return simTimeStepLength;
}
public void setSimTimeStepLength(final double simTimeStepLength) {
this.simTimeStepLength = simTimeStepLength;
}
public double getTimeOfNextStimulusAvailable(){
return getTimeOfNextStimulusAvailable(this.simTime);
}
public double getTimeOfNextStimulusAvailable(double currentSimTime){
return this.simTime + getSimTimeStepLength();
}
}
......@@ -15,6 +15,8 @@ import org.vadere.state.scenario.Topography;
public interface IControlModel {
void init(final Topography topo, final StimulusController stimulusController, final boolean isUsePsychologyLayer, final ReactionModel reactionModel, final double simTimeStepLength);
void init(final Topography topo, final StimulusController stimulusController, final boolean isUsePsychologyLayer, final ReactionModel reactionModel);
void init(final Topography topo, final StimulusController stimulusController, final boolean isUsePsychologyLayer);
void init(final Topography topo, final ReactionModel reactionModel);
......
......@@ -52,21 +52,22 @@ public class RouteChoice extends ControlModel {
}
@Override
protected void triggerRedRaction(Pedestrian ped) {
protected void triggerPedReaction(Pedestrian ped) {
LinkedList<Integer> oldTarget = ped.getTargets();
if (isUsePsychologyLayer()) {
double timeCommandExecuted = this.simTime + 0.4;
// in this case the targets are set in the next time step when updating the psychology layer
double timeCommandExecuted = getTimeOfNextStimulusAvailable();
this.stimulusController.setDynamicStimulus(ped, new ChangeTarget(timeCommandExecuted, newTargetList), timeCommandExecuted);
logger.debug("Pedestrian " + ped.getId() + ": created Stimulus ChangeTarget. New target list " + newTargetList);
}else{
ped.setTargets(newTargetList);
ped.getKnowledgeBase().setInformationState(InformationState.INFORMATION_CONVINCING_RECEIVED);
// in this case the targets are set directly
logger.debug("Pedestrian " + ped.getId() + ": changed target list from " + oldTarget + " to " + newTargetList);
}
}
......
......@@ -164,6 +164,8 @@ public class StimulusController {
stimulusInfo.setTimeframe(new Timeframe(0, simTimeNextTimeStep, false, 0));
stimulusInfo.setStimuli(newStimulus);
stimuliList.add(stimulusInfo);
pedSpecificStimuli.put(ped, stimuliList);
}
......
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