In [1]:
from datetime import datetime, timezone
print(datetime.now(timezone.utc).isoformat())
2026-12-01T15:30:13.921452+00:00
In [2]:
import sys
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from shapely import wkt
from shapely.geometry import Polygon
repository = Path.cwd().parents[1]
sys.path.insert(0, str(repository / "tests" / "vv"))
sys.path.insert(0, str(repository / "standards" / "rimea"))
sys.path.insert(0, str(repository / "standards"))
from vv_helpers import (
run_vv_scenario,
agents_outside_polygon,
specific_exit_flow,
with_flow_limiter,
MAX_SPECIFIC_FLOW,
FLOW_CAP_TOLERANCE,
)
from imo.scenario_builders.imo06_rounding_corners import build_scenario
In [3]:
plt.rcParams.update({
"figure.facecolor": "white",
"axes.facecolor": "#f7f7f5",
"axes.spines.top": False,
"axes.spines.right": False,
"font.size": 11,
"figure.dpi": 120,
})
Scenario¶
The geometry, exit and population distribution are loaded from the same scenario definition used by pytest.
In [4]:
scenario = build_scenario()
geometry = wkt.loads(scenario["walkable_area_wkt"])
distribution = next(
iter(scenario["distributions"].values())
)
exit_definition = next(
iter(scenario["exits"].values())
)
parameters = distribution["parameters"]
print(f"Population: {parameters['number']}")
print(f"Desired speed: {parameters['v0']} m/s")
print(f"Agent radius: {parameters['radius']} m")
Population: 20 Desired speed: 1.2 m/s Agent radius: 0.15 m
In [5]:
def draw_geometry(ax):
x, y = geometry.exterior.xy
ax.plot(x, y, color="black", linewidth=1.5)
for interior in geometry.interiors:
x, y = interior.xy
ax.plot(x, y, color="black")
ax.set(
xlabel="x [m]",
ylabel="y [m]",
aspect="equal",
)
fig, ax = plt.subplots(figsize=(10, 5))
draw_geometry(ax)
for definition, color, label in [
(distribution, "tab:blue", "Starting region"),
(exit_definition, "tab:green", "Exit"),
]:
polygon = Polygon(definition["coordinates"])
x, y = polygon.exterior.xy
ax.fill(x, y, color=color, alpha=0.25, label=label)
ax.set_title("Scenario geometry")
ax.legend()
plt.tight_layout()
plt.show()
Simulation¶
The simulation uses the existing verification runner and the original pytest simulation settings.
In [6]:
metrics, trajectory = run_vv_scenario(
**scenario,
max_simulation_time=120.0,
)
data = trajectory.data
print(metrics)
print(f"Trajectory samples: {len(data)}")
{'success': True, 'status': 'completed', 'message': 'All agents evacuated before reaching the maximum simulation time.', 'evacuation_time': 24.63, 'total_agents': 20, 'agents_evacuated': 20, 'agents_remaining': 0, 'all_evacuated': True, 'frame_rate': 10.0, 'dt': 0.01, 'seed': 42, 'walkable_polygon': <POLYGON ((0 0, 10 0, 10 -2, 12 -2, 12 10, 10 10, 10 2, 0 2, 0 0))>}
Trajectory samples: 3552
Results¶
Recorded pedestrian trajectories show movement through the 90-degree corner toward the exit.
In [7]:
fig, ax = plt.subplots(figsize=(10, 5))
draw_geometry(ax)
for _, group in data.sort_values("frame").groupby("id"):
ax.plot(
group["x"], group["y"],
linewidth=0.8, alpha=0.65,
)
ax.set_title("Recorded pedestrian trajectories")
plt.tight_layout()
plt.show()
Acceptance criteria¶
- All occupants evacuate successfully.
- No recorded agent position violates the walkable geometry, accounting for the agent radius.
In [8]:
violations = agents_outside_polygon(
trajectory,
scenario["walkable_area_wkt"],
radius=parameters["radius"],
)
print(f"Remaining occupants: {metrics['agents_remaining']}")
print(f"Geometry violations: {len(violations)}")
assert metrics["agents_remaining"] == 0
assert not violations
print("All acceptance criteria passed.")
Remaining occupants: 0 Geometry violations: 0 All acceptance criteria passed.