In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see https://doku.lrz.de/display/PUBLIC/GitLab for more information.

Commit 2725213d authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier

In "OptimalStepsModel.java", added proof of concept again after merging master into this branch.

parent 443af4b3
Pipeline #73616 failed with stages
in 77 minutes and 5 seconds
......@@ -29,6 +29,9 @@ import org.vadere.simulator.models.potential.fields.PotentialFieldObstacle;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.models.AttributesOSM;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.events.types.ElapsedTimeEvent;
import org.vadere.state.events.types.Event;
import org.vadere.state.events.types.WaitEvent;
import org.vadere.state.scenario.DynamicElement;
import org.vadere.state.scenario.DynamicElementRemoveListener;
import org.vadere.state.scenario.Pedestrian;
......@@ -38,13 +41,10 @@ import org.vadere.state.types.UpdateType;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VShape;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
@ModelClass(isMainModel = true)
public class OptimalStepsModel implements MainModel, PotentialFieldModel, DynamicElementRemoveListener<Pedestrian> {
......@@ -239,7 +239,58 @@ public class OptimalStepsModel implements MainModel, PotentialFieldModel, Dynami
lastSimTimeInSec = simTimeInSec;
}
/*
@Override
public void update(final List<Event> events) {
// TODO: improve proof of concept (prioritize events etc.)
Event mostImportantEvent = prioritizeEvents(events);
if (mostImportantEvent instanceof ElapsedTimeEvent) {
handleElapsedTimeEvent(mostImportantEvent);
} else if (mostImportantEvent instanceof WaitEvent) {
handleWaitEvent(mostImportantEvent);
} else {
throw new IllegalArgumentException("Cannot handle event: " + mostImportantEvent);
}
}
private Event prioritizeEvents(List<Event> events) {
Event mostImportantEvent = null;
List<Event> waitEvents = events.stream().filter(event -> event instanceof WaitEvent).collect(Collectors.toList());
if (waitEvents.size() >= 1) {
mostImportantEvent = waitEvents.get(0);
} else {
List<Event> elapsedTimeEvents = events.stream().filter(event -> event instanceof ElapsedTimeEvent).collect(Collectors.toList());
mostImportantEvent = elapsedTimeEvents.get(0);
}
return mostImportantEvent;
}
private void handleElapsedTimeEvent(final Event event) {
if (!(event instanceof ElapsedTimeEvent)) {
throw new IllegalArgumentException("Wrong event type passed, expected: " + ElapsedTimeEvent.class.getName());
}
update(event.getTime());
}
private void handleWaitEvent(final Event event) {
if (!(event instanceof WaitEvent)) {
throw new IllegalArgumentException(String.format("Wrong event type passed, expected: %s", WaitEvent.class.getName()));
}
Collection<PedestrianOSM> pedestrians = topography.getElements(PedestrianOSM.class);
for (PedestrianOSM pedestrian : pedestrians) {
pedestrian.setTimeOfNextStep(pedestrian.getTimeOfNextStep() + pedestrian.getDurationNextStep());
}
this.lastSimTimeInSec = event.getTime();
}
/*
* At the moment all pedestrians also the initalPedestrians get this.attributesPedestrain!!!
*/
@Override
......
......@@ -2,10 +2,7 @@ package org.vadere.state.events.json;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.vadere.state.events.types.ElapsedTimeEvent;
import org.vadere.state.events.types.Event;
import org.vadere.state.events.types.EventTimeframe;
import org.vadere.state.events.types.WaitInAreaEvent;
import org.vadere.state.events.types.*;
import org.vadere.state.util.JacksonObjectMapper;
import org.vadere.util.geometry.shapes.VCircle;
import org.vadere.util.geometry.shapes.VRectangle;
......@@ -61,7 +58,8 @@ public class EventInfoStore {
EventTimeframe eventTimeframe = new EventTimeframe(5, 30, false, 0);
List<Event> events = new ArrayList<>();
events.add(new WaitInAreaEvent(0, new VRectangle(12.5, 0, 5, 6)));
events.add(new WaitEvent());
// events.add(new WaitInAreaEvent(0, new VRectangle(12.5, 0, 5, 6)));
// events.add(new WaitInAreaEvent(0, new VCircle(5, 5, 5)));
EventInfo eventInfo1 = new EventInfo();
......
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