feat: edge-trace replay, departure destination choice, network updates#44
Merged
stedrew merged 29 commits intodenoslab:mainfrom Mar 25, 2026
Merged
Conversation
Changes to be committed: modified: agentevac/simulation/main.py modified: agentevac/simulation/spawn_events.py modified: agentevac/utils/replay.py modified: sumo/Repaired.netecfg modified: sumo/Repaired.sumocfg
Module updated: agentevac/utils/replay.py
- Fixed RouteReplay._load_schedule(...) so it only reads step and veh_id for replayable events:
- route_change
- departure_release
- Non-replayable events like agent_cognition and metrics_snapshot are now ignored without touching veh_id.
Cause
- The loader was accessing rec["veh_id"] before checking the event type.
- metrics_snapshot records do not have veh_id, so replay loading crashed with KeyError.
Verification
1. python3 -m py_compile agentevac/utils/replay.py passed.
2. Reproduced the failing case with a small local script:
- one route_change
- one agent_cognition
- one metrics_snapshot
- replay load now succeeds and only indexes the route-change step.
…s and agent communication
…t_round_timeline.py
…gs for documentation
…g, and per-agent heterogeneity - Add compute_signal_conflict() using Jensen-Shannon divergence in belief_model.py - Restructure all three LLM prompts (pre-departure, destination, route) to expose raw env vs. social disagreement via your_observation/neighbor_assessment/ information_conflict/combined_belief fields - Add conflict_assessment field to all Pydantic response models - Add conflict recording to metrics (record_conflict_sample, compute_average_signal_conflict) - Implement distance-based noise scaling (proposal Eq. 1): effective sigma scales with fire margin / reference distance via DIST_REF_M config - Add per-agent parameter heterogeneity via sample_profile_params() with truncated normal distributions; configurable via *_SPREAD env vars (default 0 = legacy) - Fix stale subjective_information reference in scenarios.py - Add experiment stage scripts (stages 0-5) for RQ1/RQ2/RQ3 sweeps - Add comprehensive tests for all new features (291 tests passing) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… recording - Add observation-based exposure function for no_notice scenario that uses agent belief state and route length instead of route-specific fire data - Enable expected_utility in all three scenarios (no_notice, alert_guided, advice_guided) with scenario-aware LLM policy text - Update menu filtering to retain travel time and utility for no_notice agents - Fix NET_FILE default from .rou.xml (route file) to .net.xml (network file), which caused EDGE_SHAPE to be empty and all exposure scores to be zero - Fix exposure recording to fire only on decision rounds instead of every simulation step, preventing dilution of the exposure average - Add Repaired.net.xml to repo; update SUMO configs to use local net file Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e parameters Use SIM_END_TIME_S (default 1200s) to control simulation duration instead of relying on getMinExpectedNumber(), which terminated early when no agents had departed yet. Remove dummy t_0 vehicle from route file. Add --sim-end-time CLI flag and SIM_END_TIME_S env var. Update fire source growth rates and timing for more aggressive spread scenarios. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add input-hash caching (Plan C) across all 3 LLM call sites to skip redundant API calls when agent inputs haven't changed between rounds - Add parallel LLM dispatch (Plan A) for process_pending_departures using ThreadPoolExecutor — two-phase collect-then-process pattern fires all non-cached predeparture LLM calls concurrently (up to MAX_CONCURRENT_LLM) - Add 4 new fields to AgentRuntimeState for cache state tracking - Add RQ1–RQ4 experiment runner scripts for automated parameter sweeps Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Stop the simulation loop as soon as every spawned vehicle has departed and arrived at its destination, instead of running until SIM_END_TIME_S. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Restructure LLM decision prompts with explicit priority levels (safety > official guidance > risk assessment), add EOC guidance_source to operator briefings, and fix early termination to check actual arrivals via metrics.arrived_count() instead of active vehicle count. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…dule-plots # Conflicts: # agentevac/agents/agent_state.py # agentevac/analysis/metrics.py # agentevac/simulation/main.py # sumo/Repaired.netecfg # sumo/Repaired.sumocfg
…etwork updates - Record per-step edge traces via getRoadID() for faithful replay of actual routes taken (not just planned routes) - Add departure destination choice: agents pick a destination via LLM before spawning, so vehicles head the right direction from step zero (parallel LLM dispatch via ThreadPoolExecutor) - Fix early termination to check arrived_count instead of empty vehicle list (prevents premature exit when SUMO defers vehicle insertion) - Replay mode reads to_edge from departure records for correct initial routing - Update SUMO network with new shelter edges (E#S0, E#S1, E#S2) and refreshed spawn_events - Refine scenario prompt suffixes and DecisionModel schema (situation_summary field, expanded reason descriptions) - Update forecast_layer and corresponding tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…dule-plots # Conflicts: # agentevac/simulation/main.py # sumo/Repaired.net.xml # sumo/Repaired.netecfg # sumo/Repaired.sumocfg
…selection - Record departure destination choice in metrics via record_decision_snapshot so destination_choice_share counts all agents (not just those processed by process_vehicles) - Replace fixed-offset vehicle selection with round-robin so all agents get mid-route LLM re-evaluation over successive decision ticks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The experiment runner lacked a --sumo-seed argument, so RQ scripts passed the seed via env var prefix which broke under dash (/bin/sh). Add --sumo-seed to experiments.py and rewrite all four RQ scripts to use POSIX-compatible for-loops with the new flag. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Record each agent's sampled psychological parameters (theta_trust, theta_r, theta_u, gamma, lambda_e, lambda_t) and write them to an agent_profiles JSON file alongside the metrics file. Enables post-hoc verification of population heterogeneity distributions in RQ4 runs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…stances The old thresholds (danger ≤100m, risky ≤300m, buffered ≤700m) were calibrated for a city-block mental model. In the actual simulation, the minimum observed margin is 619m, so every agent always classified the fire as "safe" and never perceived risk. Scale thresholds to danger ≤1200m, risky ≤2500m, buffered ≤5000m so agents meaningfully perceive fire hazard. Also scale RISK_DECAY_M from 80 to 960 to keep the exponential risk curve proportional. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
En-route agents in no_notice mode can now see fire on the first few edges ahead of their current position (VISUAL_LOOKAHEAD_EDGES, default 3). This adds a penalty to the current destination's exposure score, making agents more likely to switch shelters when fire blocks their route. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ling _observation_based_exposure() now prefers travel_time_s_fastest_path (minutes * 0.3) over len_edges (count * 0.15) to better reflect actual exposure duration. Falls back to edge count when travel time is unavailable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…y prompts Adds an explicit instruction to all three LLM policy locations (pre-departure, en-route destination, en-route route) requiring agents to only reference information explicitly present in the prompt data. Prevents GPT-4o-mini from fabricating neighbor behaviors, evacuation patterns, or shelter choices that cascade through the messaging system. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Agents in no_notice mode now only perceive fires within FIRE_PERCEPTION_RANGE_M (default 1200m) of their position: - Perception horizon: if no fire is in range, env_signal margins are None → observed_state="unknown" (genuine uncertainty instead of false "safe"). When fire is in range, margins are computed from visible fires only. - Route-level fire data: all reachable menu items gain proximity_blocked_edges and proximity_min_margin_m from visible fires, enabling the utility function to differentiate destinations by hazard. - Exposure scoring: _observation_based_exposure() adds a proximity penalty (blocked * 8.0 + margin_penalty) matching _expected_exposure weights, so routes through visible fire are strongly deprioritised. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
stedrew
approved these changes
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getRoadID()every simulation step) and replays them faithfully, replacing the lossy route-snapshot approachnot active_vehicle_ids(which fires prematurely due to SUMO's deferred vehicle insertion) toarrived_count == total_agentssituation_summaryfield to DecisionModel, expanded reason descriptions, refined scenario prompt suffixesTest plan
advice_guidedsimulation and verify agents spawn heading toward LLM-chosen destinations (check[DEPART-DEST]log lines)🤖 Generated with Claude Code