14 KiB
Phase 6: Analytics and Experiment Framework
1. Architectural Overview
Phase 6 implements a modular, mathematically rigorous analytics and experiment evaluation framework for the Warehouse Robot Fleet Digital Twin. It transforms discrete-event simulation runs into reproducible, audit-ready operational intelligence through:
- Mathematical KPI Calculation Engine (
src/warehouse_twin/analytics/kpi_calculator.py): Computes standardized, unit-defined metrics for throughput, latency distributions (mean, std dev, min, p50, p90, p95, p99, max), fleet utilization, loaded vs. empty travel distances, energy intensity, charging queue dynamics, and SLA compliance. Strictly isolates incomplete tasks (pending/in-progress) from completed turnaround distributions. - Event & Telemetry Streaming Store (
src/warehouse_twin/storage/event_store.py): Exports structured event streams (events.jsonl), task lifecycle tabular logs (tasks.csv), robot operational summaries (robots.csv), aisle congestion records (aisle_congestion.csv), and serialized KPI summaries (kpi_summary.json). - Spatial Congestion & Heatmap Generator (
src/warehouse_twin/analytics/heatmap.py): Renders high-fidelity, self-contained SVG heatmaps and ASCII terminal representations of warehouse traffic intensity, corridor contention, and automated bottleneck diagnosis with mitigation recommendations. - Executive Markdown Report Generator (
src/warehouse_twin/analytics/report_generator.py): Generates audit-ready Markdown experiment reports (report.md) featuring executive dashboards, latency percentiles, fleet distance matrices, and bottleneck diagnosis tables. - Experiment Runner & Scenario Comparator (
src/warehouse_twin/analytics/experiment_runner.py): Orchestrates repeatable experiments with deterministic PRNG seeds, Monte Carlo multi-seed replications with 95% confidence intervals, and automated parameter sweeps (fleet sizing: 2, 4, 6, 8 AMRs; dispatching heuristics).
+---------------------------------------+
| SimulationEnvironment |
| (SimPy discrete-event clock) |
+-------------------+-------------------+
|
+-------------------------+-------------------------+
| |
v v
+-----------------------+ +-----------------------+
| EventStore | | KPICalculator |
| - events.jsonl | | - Throughput & SLAs |
| - tasks.csv | | - Latency p50..p99 |
| - robots.csv | | - Loaded/Empty Ratio |
| - kpi_summary.json | | - Energy & Batteries |
+-----------+-----------+ +-----------+-----------+
| |
+-------------------------+-------------------------+
|
v
+---------------------------------------+
| CongestionHeatmapGenerator |
| - SVG 2D Interactive Heatmap |
| - ASCII Floorplan Heatmap |
| - Automated Bottleneck Diagnostics |
+-------------------+-------------------+
|
v
+---------------------------------------+
| ExperimentReportGenerator |
| - Executive Markdown Reports |
| - Scenario Comparison Matrices |
+---------------------------------------+
2. Mathematical KPI Definitions
Every operational KPI is defined mathematically, with its aggregation method, unit of measure, and handling of edge cases documented below:
2.1 Order Volume & Throughput
| KPI | Mathematical Formula | Unit | Aggregation Method | Description |
|---|---|---|---|---|
| Orders Released | N_{\text{created}} = \sum 1 |
orders | Count | Total tasks generated by stochastic arrival process |
| Orders Completed | N_{\text{completed}} = \sum_{t \in \text{Tasks}} \mathbb{I}(status(t) = \text{COMPLETED}) |
orders | Count | Tasks successfully picked and delivered before simulation end |
| Completion Rate | R_{\text{comp}} = \frac{N_{\text{completed}}}{N_{\text{created}}} \times 100\% |
% | Ratio | Percentage of created tasks that reached terminal completion |
| Throughput | \Theta = \frac{N_{\text{completed}}}{T_{\text{sim}}} \times 3600 |
tasks/hr | Rate | Normalized hourly order fulfillment rate |
2.2 Latency & Turnaround Distributions
Only completed tasks are included in turnaround metrics. Unstarted (pending) and in-progress tasks are strictly isolated to prevent skewing completion latency:
| KPI | Mathematical Formula | Unit | Aggregation Method | Description |
|---|---|---|---|---|
| Turnaround Time | T_{\text{turnaround}}(i) = t_{\text{completed}}(i) - t_{\text{released}}(i) |
s | Percentiles: Mean, p50, p90, p95, p99 | End-to-end order fulfillment latency |
| Queue Waiting Time | T_{\text{wait}}(i) = t_{\text{assigned}}(i) - t_{\text{released}}(i) |
s | Percentiles: Mean, p50, p90, p95 | Time spent waiting in dispatch queue |
| Execution Time | T_{\text{exec}}(i) = t_{\text{completed}}(i) - t_{\text{started}}(i) |
s | Percentiles: Mean, p50, p90, p95 | Active travel and handling transit duration |
Percentiles are calculated using linear interpolation between closest ranks:
p = \frac{P}{100} \times (n - 1), \quad k = \lfloor p \rfloor, \quad d = p - k
V_P = (1 - d) \cdot x_{(k)} + d \cdot x_{(k+1)}
2.3 Fleet Spatial, Distance & Efficiency
| KPI | Mathematical Formula | Unit | Aggregation Method | Description |
|---|---|---|---|---|
| Total Travel Distance | D_{\text{total}} = \sum_{r \in \text{Robots}} d_{\text{total}}(r) |
meters | Sum | Cumulative odometer distance across all AMRs |
| Loaded Travel Distance | D_{\text{loaded}} = \sum_{r} d_{\text{loaded}}(r) |
meters | Sum | Distance traversed while carrying payload |
| Empty Travel Distance | D_{\text{empty}} = \sum_{r} d_{\text{empty}}(r) |
meters | Sum | Repositioning distance traversed without payload |
| Loaded Distance Ratio | \rho_{\text{loaded}} = \frac{D_{\text{loaded}}}{D_{\text{total}}} \times 100\% |
% | Ratio | Measure of transport efficiency (higher = less deadhead travel) |
| Fleet Utilization | $U_{\text{fleet}} = \frac{\sum_{r} T_{\text{busy}}(r)}{ | \text{Robots} | \times T_{\text{sim}}} \times 100%$ | % |
2.4 Energy & Battery Performance
| KPI | Mathematical Formula | Unit | Aggregation Method | Description |
|---|---|---|---|---|
| Total Energy Consumed | E_{\text{consumed}} = \sum_{r} E_{\text{consumed}}(r) |
kWh | Sum | Load-dependent battery energy draw across all mission legs |
| Total Energy Charged | E_{\text{charged}} = \sum_{r} E_{\text{charged}}(r) |
kWh | Sum | Electrical energy delivered by charging stations |
| Net Energy Balance | \Delta E = E_{\text{charged}} - E_{\text{consumed}} |
kWh | Difference | Net fleet battery balance over simulation duration |
| Energy Intensity | \epsilon = \frac{E_{\text{consumed}}}{N_{\text{completed}}} |
kWh/task | Ratio | Electrical energy consumed per completed mission |
| Minimum Fleet Battery | \text{SoC}_{\min} = \min_{r} \min_{t} \text{SoC}(r, t) |
% | Minimum | Lowest State of Charge recorded across the fleet |
2.5 SLA Compliance & Lateness
| KPI | Mathematical Formula | Unit | Aggregation Method | Description |
|---|---|---|---|---|
| On-Time Delivery Rate | R_{\text{on-time}} = \frac{\sum_{i} \mathbb{I}(t_{\text{completed}}(i) \le t_{\text{deadline}}(i))}{N_{\text{completed}}} \times 100\% |
% | Ratio | Percentage of missions meeting contractual SLA |
| Lateness | L(i) = \max(0, t_{\text{completed}}(i) - t_{\text{deadline}}(i)) |
s | Max / Mean | Seconds past deadline for completed orders |
| Overdue Tasks | N_{\text{overdue}} = \sum \mathbb{I}(L(i) > 0) |
count | Count | Number of SLA breaches |
3. Telemetry File Formats
Experiments produce standardized data stores in results/experiments/<experiment_id>/:
3.1 events.jsonl
Streaming newline-delimited JSON log of all state transitions:
{"event_id": "evt_0001", "simulation_time": 12.500, "event_type": "TASK_RELEASED", "entity_id": "task_01", "task_id": "task_01", "metadata": {"priority": 1}}
{"event_id": "evt_0002", "simulation_time": 14.200, "event_type": "ROBOT_DISPATCHED", "entity_id": "amr_light_01", "task_id": "task_01", "metadata": {}}
3.2 tasks.csv
Tabular lifecycle audit of every work order:
task_id,task_type,priority,status,source_station,destination_station,item_id,quantity,payload_weight_kg,created_at,assigned_at,started_at,completed_at,waiting_time_seconds,execution_time_seconds,turnaround_time_seconds,deadline,lateness_seconds,is_overdue,assigned_robot_id
task_0001,ORDER_PICK,2,COMPLETED,storage_zone_a_rack_02,pack_station_01,sku_small_bearing,5,1.25,12.50,14.20,16.50,68.20,1.70,51.70,55.70,,0.00,0,amr_light_01
3.3 robots.csv
Operational performance metrics per AMR:
robot_id,robot_type,total_distance_meters,loaded_distance_meters,empty_distance_meters,loaded_ratio_percent,busy_seconds,idle_seconds,charging_seconds,handling_seconds,yield_wait_seconds,utilization_percent,energy_consumed_kwh,energy_charged_kwh,min_battery_percent,final_battery_percent
amr_light_01,light_amr,1769.60,868.20,901.40,49.06,1943.00,1657.00,0.00,825.00,18.00,53.97,0.1210,0.0000,96.0,96.0
3.4 aisle_congestion.csv
Per-edge traffic contention data:
source_node,target_node,traversals,conflicts,total_wait_time_seconds,avg_wait_time_seconds
wp_180_20,wp_200_20,38,4,8.50,2.12
wp_180_60,wp_160_60,9,3,5.50,1.83
4. Scenario Comparison Benchmarks
4.1 Fleet Sizing Sweep (1-Hour Simulation, Seed 42)
Evaluated under normal warehouse demand profile (~85 orders/hour):
| Fleet Size | Throughput | Mean Turnaround | p95 Turnaround | Mean Wait | Fleet Utilization | Loaded Ratio | On-Time Rate | Contention Conflicts |
|---|---|---|---|---|---|---|---|---|
| 2 AMRs | 77.0 t/hr | 315.5s | 663.7s | 253.9s | 95.6% | 43.4% | 71.4% | 39 |
| 4 AMRs | 85.0 t/hr | 91.2s | 134.6s | 29.8s | 50.9% | 46.6% | 100.0% | 36 |
| 6 AMRs | 85.0 t/hr | 83.0s | 118.7s | 22.0s | 32.7% | 49.6% | 100.0% | 51 |
| 8 AMRs | 85.0 t/hr | 78.9s | 113.0s | 18.7s | 23.4% | 52.0% | 100.0% | 39 |
Key Engineering Findings:
- Severe Undersizing at 2 AMRs: With only 2 AMRs, the fleet is saturated at
95.6\%utilization, unable to clear the arrival backlog (77 vs 86 tasks). Mean turnaround balloons to315.5\,\text{s}and on-time delivery collapses to71.4\%. - Optimal Sizing at 4 AMRs: Expanding to 4 AMRs resolves all queueing backlogs. Throughput hits the maximum arrival capacity (
85.0\,\text{tasks/hr}), mean turnaround drops by71\%to91.2\,\text{s}, and on-time delivery reaches100.0\%with a healthy50.9\%utilization headroom. - Diminishing Returns Above 4 AMRs: Increasing fleet size to 6 or 8 yields marginal latency improvements (
91.2\,\text{s} \rightarrow 78.9\,\text{s}) while fleet utilization drops below33\%, resulting in idle capital expenditure and slightly increased corridor contention (36 \rightarrow 51conflicts).
5. Test & Validation Summary
============================= test session starts ==============================
collected 129 items
tests/unit/test_battery_model.py ...... [ 4%]
tests/unit/test_charging_manager.py ... [ 6%]
tests/unit/test_config_loader.py ......... [ 13%]
tests/unit/test_dispatcher.py .... [ 17%]
tests/unit/test_environment.py ..... [ 20%]
tests/unit/test_event_store.py .... [ 24%]
tests/unit/test_events_model.py . [ 24%]
tests/unit/test_experiment_runner.py .... [ 27%]
tests/unit/test_heatmap.py ..... [ 31%]
tests/unit/test_inventory_model.py .... [ 34%]
tests/unit/test_kpi_calculator.py ..... [ 38%]
tests/unit/test_logging.py ... [ 41%]
tests/unit/test_order_generator.py ...... [ 45%]
tests/unit/test_path_planner.py ......... [ 52%]
tests/unit/test_production_deadlines.py ... [ 55%]
tests/unit/test_reservations.py ...... [ 59%]
tests/unit/test_robot_model.py .............. [ 70%]
tests/unit/test_scenario_comparison.py .. [ 72%]
tests/unit/test_sim_engine.py ..... [ 75%]
tests/unit/test_stockout_and_replenishment.py . [ 76%]
tests/unit/test_task_model.py ......... [ 83%]
tests/unit/test_task_reassignment.py .. [ 85%]
tests/unit/test_traffic_manager.py ....... [ 90%]
tests/unit/test_trajectory_export.py . [ 91%]
tests/unit/test_warehouse_graph.py ............ [100%]
============================= 129 passed in 0.97s ==============================