Commit e9f93a7c authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

resolve merge conflicts.

parents b33810e8 599a95e0
......@@ -70,7 +70,7 @@ stages:
artifacts:
when: on_failure
paths:
- "log_dir"
- "vadere_logs"
expire_in: 1 week
when: on_success
......
......@@ -2,12 +2,19 @@
**Note:** Before writing into this file, read the guidelines in [Writing Changelog Entries.md](Documentation/contributing/Writing Changelog Entries.md).
## In Progress: v0.7
## In Progress:
### Added
### Changed
## v1.0 (2019-06-13)
### Added
- Open a trajectory file in the stand-alone application `vadere-postvis.jar` via drag and drop from file explorer.
- Scenario elements like obstacles and targets can now be resized using the mouse in the topography creator tab (first, select element via left-click and then move mouse to one of its edges to get the resize handles).
- Draw also Voronoi diagram in `TikeGenerator`.
- Draw also Voronoi diagram in `TikzGenerator`.
- Added new scenario element `AbsorbingArea` to absorb agents immediately.
* The new scenario element can be selected in `TopographyCreator` via the "emergency exit" button.
* The new scenario element is also taken into account by `SettingsDialaog` and `TikzGenerator`.
......@@ -42,9 +49,9 @@
will check for overlapping `ScenarioElements` and check for inconsistence
settings such as missing TargetIDs for sources or inconsistenct speed ranges
for pedestrians. See this
[table](Documentation/changelLogImages/TopographyCheckerMessages.md) for
[table](Documentation/changelog/TopographyCheckerMessages.md) for
supported warnings and erros as well as this
[picture](Documentation/changelLogImages/TopographyChecker.png) to see which
[picture](Documentation/changelog/TopographyChecker.png) to see which
kind of overlap produces erros or warnings.
- `VadereConsole`: Add `--output-dir [on, off]` (default: `on`) switch to `scenario-run`
sub-command. This will will turn the ScenarioChecker on or off for the command
......@@ -69,6 +76,7 @@
* vadere.jar -> vadere-gui.jar
* postvis.jar -> vadere-postvis.jar
* vadere-console.jar -> remained unchanged
- Header in output file have now the following form "[NAME]-PID[ID]". This avoids name conflicts and makes mapping to the relevant processor easy and fast.
- Migration to Java 11 (OpenJDK).
- Removed directory `Documentation/version-control` which contained the Git hooks. The Git hooks are not required anymore. Instead, added `git rev-parse HEAD` to file `VadereSimulator/pom.xml` to create `VadereSimulator/resources/current_commit_hash.txt` during each build via `mvn compile`.
**Note:** The file `current_commit_hash.txt` is created during Maven's validation phase, i.e., before the actual build.
......
# OpenCL Installation (optional but recommended)
Vadere uses computer's video card to speed up some computations. Therefore, following OpenCL components should be installed:
* the OpenCL Installable Client Driver loader also called ICD loader (Opencl.dll for Windows and libOpenCL.so for Linux)
* drivers for your device(s)
Both should be offered by the vendor of your device (often there are also open-source solutions). The device can be a CPU as well as a GPU (recommanded). For example, if you have a NVIDIA GPU instaling your drivers should be enough to install both components.
Vadere will search for the best suiable device which is supported. On a desktop workstation this should be your video card (GPU). If there is no device supporting OpenCL Vadere will use a plain and slower Java-implementation instead.
Please, use following instructions to set up the OpenCL components for your operating system:
* Windows: For further information using OpenCL on Windows read the paragraph Running an OpenCL application [click here](https://streamcomputing.eu/blog/2015-03-16/how-to-install-opencl-on-windows/).
* OS X: OpenCL is pre-installed for OS X.
* Linux: Please refer to the installation manual of your Linux distribution.
* [Sources: OpenCL HowTo](https://wiki.tiker.net/OpenCLHowTo)
* Tips and official packages (Ubuntu):
<details>
* Use the console tool `clinfo` (`sudo apt-get install clinfo`) to see the current status in terminal
* Drivers commonly have the prefix `opencl-icd` (to look at most opencl related packages run `apt search opencl`). Some that may be helpful:
* `beignet-opencl-icd` (OpenCL library for Intel GPUs)
* `mesa-opencl-icd` (free and open source implementation of the OpenCL API)
* `nvidia-opencl-icd`
* `ocl-icd-opencl-dev` (installs opencl development files and can be required for compiling)
* `ocl-icd-libopencl1` (Generic OpenCL ICD Loader)
</details>
* [Intel Driverpack (only driver needed)](https://software.intel.com/en-us/articles/opencl-drivers#latest_linux_driver)
......@@ -24,13 +24,19 @@ The Vadere framework includes a mesh generator for unstructured high-quality 2D
## Installation
### Download Releases
### Dependencies
* Java 11 or above (OpenJDK recommended -> see the official [Java website](https://jdk.java.net/))
* OpenCL (optional but recommended -> see the [install instructions](https://gitlab.lrz.de/vadere/vadere/tree/master/Documentation/installation/OpenCL-Installation.md) for details)
### Pre-Built Releases
Latest build of master:
* [Windows](http://www.vadere.org/builds/master/vadere.master.windows.zip)
* [Linux](http://www.vadere.org/builds/master/vadere.master.linux.zip)
Stable releases and selected branch-builds are located on [www.vadere.org/releases/](http://www.vadere.org/releases/)
Stable releases and selected branch-builds:
* [www.vadere.org/releases/](http://www.vadere.org/releases/)
The ZIP file contains:
* **README.md** - this README file.
......@@ -38,65 +44,36 @@ The ZIP file contains:
* **vadere-console.jar** - provides the command line version of Vadere and allows easy integration into other applications.
* **VadereModelTests** - contains test scenarios for pedestrian locomotion models. Note: The tests are also useful for a "getting started" (see below "Run Built-In Examples" for details).
To execute the `.jar` files it is highly recommended to use Java 11 (OpenJDK).
### Build from Source
#### Dependencies
* Java 11 (OpenJDK recommended)
* Maven 3.0
* Git
* OpenCL (optional but recommended)
**Note:** Please, ensure that the Git executable can be found in the `PATH` variable of your operating system.
#### Install OpenCL (optional but recommended)
Vadere uses computer's video card to speed up some computations. Therefore, following OpenCL components should be installed:
### Run the Application
* the OpenCL Installable Client Driver loader also called ICD loader (Opencl.dll for Windows and libOpenCL.so for Linux)
* drivers for your device(s)
Open a terminal and enter `path/to/openjdk/java -jar vadere-gui.jar`.
Both should be offered by the vendor of your device (often there are also open-source solutions). The device can be a CPU as well as a GPU (recommanded). For example, if you have a NVIDIA GPU instaling your drivers should be enough to install both components.
Vadere will search for the best suiable device which is supported. On a desktop workstation this should be your video card (GPU). If there is no device supporting OpenCL Vadere will use a plain and slower Java-implementation instead.
### Run Built-In Examples
Please, use following instructions to set up the OpenCL components for your operating system:
With the following steps, you can run a simulation with one of the built-in examples from [VadereModelTests](VadereModelTests):
* Windows: For further information using OpenCL on Windows read the paragraph Running an OpenCL application [click here](https://streamcomputing.eu/blog/2015-03-16/how-to-install-opencl-on-windows/).
* OS X: OpenCL is pre-installed for OS X.
* Linux: Please refer to the installation manual of your Linux distribution.
* [Sources: OpenCL HowTo](https://wiki.tiker.net/OpenCLHowTo)
* Tips and official packages (Ubuntu):
<details>
- Start Vadere
- Click *Project* > *Open*
- Choose `vadere.project` of one of the test projects, e.g. [TestOSM](https://gitlab.lrz.de/vadere/vadere/tree/master/VadereModelTests/TestOSM) and click *open*
- Select tahe scenario on the left and press *run selected scenario*
* Use the console tool `clinfo` (`sudo apt-get install clinfo`) to see the current status in terminal
* Drivers commonly have the prefix `opencl-icd` (to look at most opencl related packages run `apt search opencl`). Some that may be helpful:
* `beignet-opencl-icd` (OpenCL library for Intel GPUs)
* `mesa-opencl-icd` (free and open source implementation of the OpenCL API)
* `nvidia-opencl-icd`
* `ocl-icd-opencl-dev` (installs opencl development files and can be required for compiling)
* `ocl-icd-libopencl1` (Generic OpenCL ICD Loader)
</details>
* [Intel Driverpack (only driver needed)](https://software.intel.com/en-us/articles/opencl-drivers#latest_linux_driver)
## Build from Source
#### Run the Application
### Dependencies
1. Get the Source: Run `git clone https://gitlab.lrz.de/vadere/vadere.git`.
2. Build the Application: Go to the project directory and run `mvn clean package` (or `mvn clean package -Dmaven.test.skip` if you want to skip the unit tests). This will build `vadere.jar`, `vadere-console.jar` and `postvis.jar`.
3. Start the Application: After building the application, you can start Vadere by running `java -jar VadereGui/target/vadere.jar`.
4. (If you only want to use the Postvisualization-Tool you can do so by running `java -jar VadereGui/target/postvis.jar`).
* Java 11 or above (OpenJDK recommended)
* Maven 3.0
* Git
* OpenCL (optional but recommended)
## Run Built-In Examples
**Note:** Please, ensure that the Git executable can be found in the `PATH` variable of your operating system.
With the following steps, you can run a simulation with one of the built-in examples from [VadereModelTests](VadereModelTests):
### Build Instructions
- start Vadere
- *Project* > *Open*
- choose `vadere.project` of one of the projects e.g. [TestOSM](https://gitlab.lrz.de/vadere/vadere/tree/master/VadereModelTests/TestOSM) and click *open*
- select the scenario on the left and press *run selected scenario*
1. git clone https://gitlab.lrz.de/vadere/vadere.git
2. cd vadere
3. mvn clean
4. mvn -Dmaven.test.skip=true package
## Changelog
......
......@@ -21,7 +21,7 @@ short_timeout_in_seconds = 2 * 60
def parse_command_line_arguments():
parser = argparse.ArgumentParser(description="Run all scenario files.")
parser.add_argument("--scenario", "-s", type=str, nargs="?", help="Run only the given scenario file and not all. E.g. \"VadereModelTests/TestOSM/scenarios/basic_2_density_discrete_ca.scenario\"")
parser.add_argument("scenario", type=str, nargs="?", help="Run only the given scenario file and not all. E.g., \"VadereModelTests/TestOSM/scenarios/basic_2_density_discrete_ca.scenario\"")
args = parser.parse_args()
......@@ -80,13 +80,10 @@ def find_scenario_files(path="VadereModelTests", scenario_search_pattern = "*.sc
def run_scenario_files_with_vadere_console(scenario_files, vadere_console="VadereSimulator/target/vadere-console.jar", scenario_timeout_in_sec=short_timeout_in_seconds):
output_dir = "output"
log_dir = "log_dir"
log_base_dir = "vadere_logs"
if not os.path.exists(output_dir):
os.makedirs(output_dir)
if not os.path.exists(log_dir):
os.makedirs(log_dir)
makedirs_if_non_existing(output_dir)
makedirs_if_non_existing(log_base_dir)
total_scenario_files = len(scenario_files)
......@@ -98,10 +95,18 @@ def run_scenario_files_with_vadere_console(scenario_files, vadere_console="Vader
try:
print("Running scenario file ({}/{}): {}".format(i + 1, total_scenario_files, scenario_file))
# A scenario filename has the form "VadereModelTests/TestOSM/scenarios/chicken_floorfield_ok.scenario"
# Use second-level directory as subdirectory for logging (e.g., "TestOSM").
log_sub_dir = scenario_file.split(os.path.sep)[1]
log_dir = os.path.join(".", log_base_dir, log_sub_dir)
makedirs_if_non_existing(log_dir)
scenario_name = os.path.basename(scenario_file).split('.')[0]
log_file = os.path.join(".", log_dir, scenario_name + ".log")
log_file = os.path.join(log_dir, scenario_name + ".log")
print(log_file)
print(" Log file: " + log_file)
# Measure wall time and not CPU time.
wall_time_start = time.time()
......@@ -124,17 +129,16 @@ def run_scenario_files_with_vadere_console(scenario_files, vadere_console="Vader
except subprocess.TimeoutExpired as exception:
print("Scenario file failed: {}".format(scenario_file))
print("-> Reason: timeout after {} s".format(exception.timeout))
failed_summary.append("Scenario file failed: {}".format(scenario_file))
failed_summary.append("-> Reason: timeout after {} s".format(exception.timeout))
failed_scenarios_with_exception.append((scenario_file, exception))
except subprocess.CalledProcessError as exception:
prefix = ""
if "TestOSM" in scenario_file:
prefix = " * OSM * "
print(prefix + "Scenario file failed: {}".format(scenario_file))
print("Scenario file failed: {}".format(scenario_file))
print("-> Reason: non-zero return value {}".format(exception.returncode))
print(" {}".format(read_first_error_linies(exception.stderr)))
failed_summary.append(prefix + "Scenario file failed: {}".format(scenario_file))
failed_summary.append("Scenario file failed: {}".format(scenario_file))
failed_summary.append("-> Reason: non-zero return value {}".format(exception.returncode))
failed_summary.append(" {}".format(read_first_error_linies(exception.stderr)))
......@@ -145,6 +149,10 @@ def run_scenario_files_with_vadere_console(scenario_files, vadere_console="Vader
return {"passed": passed_scenarios, "failed": failed_scenarios_with_exception, "failed_summary": failed_summary}
def makedirs_if_non_existing(directory):
if not os.path.exists(directory):
os.makedirs(directory)
def read_first_error_linies(error_byte_string):
err_string_lines = error_byte_string.decode('utf-8').split('\n')
if len(err_string_lines) >= 2:
......
%% Cell type:markdown id: tags:
### Note
You can find the required data on the Nextcloud data/Paperdaten/2019/TGF2019-vadere
%% Cell type:code id: tags:
``` python
# expand the cell of the notebook
import json
import gc
import numpy as np
import pandas as pd
import math
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import seaborn as sns
import functools
import operator
sns.set_context("poster")
sns.set(style="whitegrid", font_scale=1.8)
from IPython.core.display import display, HTML
display(HTML('<style>.container { width:100% !important; }</style>'))
```
%% Cell type:markdown id: tags:
# Convert Vadere trajectories into a DataFrame
%% Cell type:code id: tags:
``` python
def fs_append(pedestrianId, fs, llist):
llist.append([pedestrianId, fs['start']['x'], fs['start']['y'], fs['startTime'], fs['end']['x'], fs['end']['y'], fs['endTime']])
def trajectory_append(pedestrianId, trajectory, llist):
for fs in trajectory:
fs_append(pedestrianId, fs, llist)
def trajectories_to_dataframe(trajectories):
llist = []
for pedId in trajectories:
trajectory_append(pedId, trajectories[pedId], llist)
dataframe = pd.DataFrame(llist, columns=['pedestrianId','startX','startY','startTime','endX','endY','endTime'])
dataframe["distance"] = np.sqrt(np.square(dataframe["endX"] - dataframe["startX"]) + np.square(dataframe["endY"] - dataframe["startY"]))
dataframe["velocity"] = dataframe["distance"] / (dataframe["endTime"] - dataframe["startTime"])
return dataframe
```
%% Cell type:code id: tags:
``` python
def load_simulation_data(file):
f = open(file, "r")
header = f.readline();
trajectories = dict({});
for row in f:
s = row.split(" ");
pedId = int(s[0]);
footsteps = json.loads(s[1]);
trajectories[pedId] = footsteps[0]['footSteps'];
return trajectories_to_dataframe(trajectories)
```
%% Cell type:markdown id: tags:
# Convert experiment data into a DataFrame
%% Cell type:code id: tags:
``` python
def load_experiment(file):
fps = 16
data = pd.read_csv(
file,
sep=' ',
names=['pedestrianId', 'timeStep', 'x', 'y', 'e'],
index_col=False,
header=None,
skiprows=0)
rows = []
#print(trajectories)
last_ped_id = None
lastX = None
lastY = None
for row in data.itertuples():
endX = row.x / 100.0 + 18.7
endY = row.y / 100.0 + 4.2
startTime = row.timeStep / fps - 1/fps
endTime = row.timeStep / fps
if last_ped_id is None or last_ped_id != row.pedestrianId:
startX = np.nan
startY = np.nan
distance = np.nan
velocity = np.nan
else:
startX = lastX / 100.0 + 18.7
startY = lastY / 100.0 + 4.2
distance = np.sqrt(np.square(endX - startX) + np.square(endY - startY))
velocity = distance / (endTime - startTime)
rows.append([row.pedestrianId, startX, startY, endX, endY, startTime, endTime, distance, velocity])
last_ped_id = row.pedestrianId
lastX = row.x
lastY = row.y
dataframe = pd.DataFrame(rows, columns=['pedestrianId', 'startX', 'startY', 'endX', 'endY','startTime','endTime','distance','velocity'])
return dataframe
def to_trajectories(data):
trajectories = dict({})
trajectory = []
for i in range(len(data)-1):
pedId = data['pedestrianId'][i]
if pedId == data['pedestrianId'][i+1]:
pedId = data['pedestrianId'][i]
x1 = data['x'][i]
y1 = data['y'][i]
x2 = data['x'][i+1]
y2 = data['y'][i+1]
startTime = data['timeStep'][i]
endTime = data['timeStep'][i+1]
fs = {'startTime':startTime, 'endTime': endTime, 'start':{'x':x1, 'y':y1}, 'end':{'x':x2, 'y':y2}}
trajectory.append(fs)
else:
trajectories[pedId] = trajectory
trajectory = []
pedId = data['pedestrianId'][i]
return trajectories
```
%% Cell type:markdown id: tags:
# Load all data
The following code loads the experiment data as well as the simulated data and transforms everything into the same format (data frame). The simulated trajectories are cut with respect to the camera bounds of the experiment.
%% Cell type:code id: tags:
``` python
#times = np.linspace(4,10,10)
#euclid_d(get_trajectory(1), get_trajectory(1), times)
#to_trajectories(load_experiment(real_file))[1]
trajectories240o050o240 = load_experiment("./T-junction-experiment-trajectories-files/KO/ko-240-050-240/ko-240-050-240_combined_MB.txt")
trajectories240o060o240 = load_experiment("./T-junction-experiment-trajectories-files/KO/ko-240-060-240/ko-240-060-240_combined_MB.txt")
trajectories240o080o240 = load_experiment("./T-junction-experiment-trajectories-files/KO/ko-240-080-240/ko-240-080-240_combined_MB.txt")
trajectories240o100o240 = load_experiment("./T-junction-experiment-trajectories-files/KO/ko-240-100-240/ko-240-100-240_combined_MB.txt")
trajectories240o120o240 = load_experiment("./T-junction-experiment-trajectories-files/KO/ko-240-120-240/ko-240-120-240_combined_MB.txt")
trajectories240o150o240 = load_experiment("./T-junction-experiment-trajectories-files/KO/ko-240-150-240/ko-240-150-240_combined_MB.txt")
trajectories240o240o240 = load_experiment("./T-junction-experiment-trajectories-files/KO/ko-240-240-240/ko-240-240-240_combined_MB.txt")
trajectoriesReal = pd.concat([trajectories240o050o240, trajectories240o060o240, trajectories240o080o240,
trajectories240o100o240, trajectories240o120o240, trajectories240o150o240,
trajectories240o240o240], ignore_index=True)
# trajectories starting from left
cut_minX = trajectoriesReal[trajectoriesReal["endX"] < 15].groupby(["pedestrianId"])["startX"].min().max() + 0.12
file = "./data/trajectories_distance.txt"
real_file = "./data/KO/ko-240-120-240/ko-240-120-240_combined_MB.txt"
f = open(file, "r")
header = f.readline();
trajectories = dict({});
for row in f:
s = row.split(" ");
pedId = int(s[0]);
footsteps = json.loads(s[1]);
trajectories[pedId] = footsteps[0]['footSteps'];
# trajectories starting from right
cut_maxX = trajectoriesReal[trajectoriesReal["endX"] > 21].groupby(["pedestrianId"])["startX"].max().min() - 0.2
def get_trajectory(pedId):
return trajectories[pedId]
# trajectories ending at top
cut_maxY = trajectoriesReal.groupby(["pedestrianId"])["endY"].max().min() - 0.168
trajectories240o050o240 = cut(trajectories240o050o240, cut_minX, cut_maxX, cut_maxY)
trajectories240o060o240 = cut(trajectories240o060o240, cut_minX, cut_maxX, cut_maxY)
trajectories240o080o240 = cut(trajectories240o080o240, cut_minX, cut_maxX, cut_maxY)
trajectories240o100o240 = cut(trajectories240o100o240, cut_minX, cut_maxX, cut_maxY)
trajectories240o120o240 = cut(trajectories240o120o240, cut_minX, cut_maxX, cut_maxY)
trajectories240o150o240 = cut(trajectories240o150o240, cut_minX, cut_maxX, cut_maxY)
trajectories240o240o240 = cut(trajectories240o240o240, cut_minX, cut_maxX, cut_maxY)
osm_trajectories240o050o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-OSM-240-050-240.txt")
osm_trajectories240o050o240 = cut(osm_trajectories240o050o240, cut_minX, cut_maxX, cut_maxY)
osm_trajectories240o060o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-OSM-240-060-240.txt")
osm_trajectories240o060o240 = cut(osm_trajectories240o060o240, cut_minX, cut_maxX, cut_maxY)
osm_trajectories240o080o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-OSM-240-080-240.txt")
osm_trajectories240o080o240 = cut(osm_trajectories240o080o240, cut_minX, cut_maxX, cut_maxY)
osm_trajectories240o100o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-OSM-240-100-240.txt")
osm_trajectories240o100o240 = cut(osm_trajectories240o100o240, cut_minX, cut_maxX, cut_maxY)
osm_trajectories240o120o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-OSM-240-120-240.txt")
osm_trajectories240o120o240 = cut(osm_trajectories240o120o240, cut_minX, cut_maxX, cut_maxY)
osm_trajectories240o150o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-OSM-240-150-240.txt")
osm_trajectories240o150o240 = cut(osm_trajectories240o150o240, cut_minX, cut_maxX, cut_maxY)
osm_trajectories240o240o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-OSM-240-240-240.txt")
osm_trajectories240o240o240 = cut(osm_trajectories240o240o240, cut_minX, cut_maxX, cut_maxY)
trajectoriesOSM = pd.concat([osm_trajectories240o050o240, osm_trajectories240o060o240, osm_trajectories240o080o240, osm_trajectories240o100o240, osm_trajectories240o120o240, osm_trajectories240o150o240, osm_trajectories240o240o240], ignore_index=True)
bhm_trajectories240o050o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-BHM-240-050-240.txt")
bhm_trajectories240o050o240 = cut(bhm_trajectories240o050o240, cut_minX, cut_maxX, cut_maxY)
bhm_trajectories240o060o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-BHM-240-060-240.txt")
bhm_trajectories240o060o240 = cut(bhm_trajectories240o060o240, cut_minX, cut_maxX, cut_maxY)
bhm_trajectories240o080o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-BHM-240-080-240.txt")
bhm_trajectories240o080o240 = cut(bhm_trajectories240o080o240, cut_minX, cut_maxX, cut_maxY)
bhm_trajectories240o100o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-BHM-240-100-240.txt")
bhm_trajectories240o100o240 = cut(bhm_trajectories240o100o240, cut_minX, cut_maxX, cut_maxY)
bhm_trajectories240o120o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-BHM-240-120-240.txt")
bhm_trajectories240o120o240 = cut(bhm_trajectories240o120o240, cut_minX, cut_maxX, cut_maxY)
bhm_trajectories240o150o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-BHM-240-150-240.txt")
bhm_trajectories240o150o240 = cut(bhm_trajectories240o150o240, cut_minX, cut_maxX, cut_maxY)
bhm_trajectories240o240o240 = load_simulation_data("./T-junction-sim-trajectory-files/trajectories-BHM-240-240-240.txt")
bhm_trajectories240o240o240 = cut(bhm_trajectories240o240o240, cut_minX, cut_maxX, cut_maxY)
trajectoriesBHM = pd.concat([bhm_trajectories240o050o240, bhm_trajectories240o060o240, bhm_trajectories240o080o240,
bhm_trajectories240o100o240, bhm_trajectories240o120o240, bhm_trajectories240o150o240,
bhm_trajectories240o240o240], ignore_index=True)
```
%% Cell type:code id: tags:
``` python
# Sum up all measured time deltas of a pedestrian to get the final evacuation time
copy = trajectoriesReal.copy(deep=True)
copy["timeDelta"] = copy["endTime"] - copy["startTime"]
et = copy.groupby(["pedestrianId"])["timeDelta"].sum()
print("Evacuation time (real data)")
print("- mean: {:.2f} [s]".format(et.mean()))
print("- std: {:.2f} [s]".format(et.std()))
print("- min: {:.2f} [s]".format(et.min()))
print("- max: {:.2f} [s]".format(et.max()))
print("- minX: {:.2f} [m]".format(cut_minX))
print("- maxX: {:.2f} [m]".format(cut_maxX))
print("- maxY: {:.2f} [m]".format(cut_maxY))
```
%% Cell type:markdown id: tags:
# Convert DataFrame to postvis DataFrame
%% Cell type:code id: tags:
``` python
def to_postVis(df):
simTimeStep = 0.4
fps = 16
df['timeStep'] = np.ceil(df['endTime'] / (1/fps)).astype(np.int)
df['x'] = df['endX']
df['y'] = df['endY']
df['simTime'] = df['endTime']
df = df.drop(columns=['startX','startY','endX','endY','startTime', 'endTime'])
return df
```
%% Cell type:markdown id: tags:
## Simulation data
%% Cell type:markdown id: tags:
TODO: Use `PedestrianEvacuationTimeProcessor` to log evacuation time during simulation and analyze it here.
%% Cell type:markdown id: tags:
# Helper method to access parts of the trajectory
%% Cell type:code id: tags:
``` python
def get_trajectory(pedId, trajectories):
"""returns a data frame containing the trajectory of one specific agent."""
query = 'pedestrianId == ' + str(pedId)
return trajectories.query(query)
def get_trajectories(t, trajectories):
return trajectories[np.logical_and(trajectories.startTime <= t, trajectories.endTime > t)]
def get_pedestrianIds(trajectories):
return trajectories['pedestrianId'].unique()
#def get_velocity(trajectories, t, dt):
# trajectories[np.logical_and(trajectory.endX >= xmax, trajectory.startX < xmax)]
def get_footstep(trajectory, i):
return trajectory[i];
"""returns the i-ths footstep."""
return trajectory.iloc[i];
def start_time(trajectory):
return trajectory[0]['startTime'];
def get_footstep_by_time(trajectory, time):
"""returns the footstep which happens at time or nothing (None)."""
query = 'startTime <= ' + str(time) + ' and ' + str(time) + ' < endTime'
fs = trajectories.query(query)
assert len(fs) >= 1
return fs