mech.app
AI Agents

MATraM: Incremental State Updates in Agent-Based Transport Simulation

How MATraM's activity modification layer lets transport agents reschedule trips without full network recalculation, exposing reactive vs proactive ABM p...

Source: arxiv.org
MATraM: Incremental State Updates in Agent-Based Transport Simulation

Agent-based transport models run into a hard infrastructure problem: when one agent reschedules a trip, network congestion shifts for thousands of others. Traditional activity-based models (ABMs) sidestep this by locking agents into pre-computed daily schedules. MATraM, a new framework from ArXiv, introduces an activity modification layer that lets agents flag rescheduling requests mid-simulation without triggering full network recalculation.

This is not about transport planning. It is about how to design incremental state updates in multi-agent systems where one agent’s decision cascades through shared infrastructure.

The Fixed Schedule Problem

Most activity-based transport models work like this:

  1. Generate a daily schedule for each agent (home → work → shop → home)
  2. Convert activities into trips with departure times
  3. Simulate all trips on a network model (flow-based, queue-based, or interaction-based)
  4. Measure congestion and travel times

The schedule is frozen. If an agent hits unexpected congestion, it cannot reschedule the grocery trip or leave work early. The model captures network dynamics but not behavioral flexibility.

MATraM breaks this by introducing a feedback loop: agents can request activity modifications when travel conditions degrade. The system must then reconcile those requests without recomputing every agent’s plan from scratch.

Activity Modification Layer Architecture

MATraM adds three components on top of a standard ABM. The framework follows the ODD (Overview, Design concepts, Details) protocol for agent-based model documentation, which structures the model around agent entities, their decision rules, and interaction patterns.

Modification Request Queue
Agents flag activities for rescheduling when travel time exceeds a threshold. Requests include activity type, current time slot, and alternative windows. The queue batches requests to avoid per-agent processing overhead.

Scheduling Constraint Solver
A separate module evaluates modification requests against:

  • Activity duration requirements (shopping needs 30 minutes minimum)
  • Location constraints (work is fixed, leisure is flexible)
  • Temporal dependencies (pick up kids before 6pm)

The solver does not replan the entire day. It searches for local swaps: move activity X to time slot Y, shift activity Z by 15 minutes.

State Synchronization Primitive
When an agent modifies its schedule, the network model must update:

  • Remove old trips from the event queue
  • Insert new trips with revised departure times
  • Recalculate link loads only for affected routes

This is where most ABMs break. MATraM uses a two-phase commit: agents propose changes, the network model validates capacity, then both commit atomically.

Reactive vs Proactive Agent Patterns

MATraM exposes a design choice in agent architectures:

PatternTriggerState UpdateConsistency Model
ReactiveAgent responds to observed congestionModify schedule after experiencing delayEventually consistent (agents see stale network state)
ProactiveAgent anticipates congestion from forecastsModify schedule before trip startsStrongly consistent (requires global state snapshot)
Hybrid (MATraM)Agents flag requests, solver batches updatesIncremental modification with validationBounded staleness (requests processed in time windows)

Reactive agents are simpler but create feedback loops: one agent’s rescheduling changes congestion, triggering more rescheduling. Proactive agents need accurate forecasts, which require expensive global state queries.

MATraM’s hybrid approach batches modification requests into time windows (e.g., every 15 simulated minutes). Agents see slightly stale network state but avoid cascading updates.

Event Queue and Priority Scheduling

The core infrastructure challenge is managing the event queue when agents can insert, remove, or modify trips dynamically.

Standard discrete-event simulation uses a priority queue sorted by event time:

import heapq

class EventQueue:
    def __init__(self):
        self.events = []  # Min-heap sorted ascending by timestamp for earliest-first processing
    
    def schedule(self, agent_id, event_type, timestamp):
        heapq.heappush(self.events, (timestamp, agent_id, event_type))
    
    def next_event(self):
        return heapq.heappop(self.events)

When an agent modifies an activity, you must:

  1. Find and remove the old trip events (O(n) scan or maintain a secondary index)
  2. Insert new trip events with updated timestamps
  3. Ensure no orphaned events remain in the queue

MATraM maintains a secondary index mapping agent_id → [event_ids] so removals are O(log n). The trade-off is memory overhead: 10,000 agents with 10 daily activities = 100,000 index entries.

State Consistency Boundaries

When agent A reschedules a trip, it affects:

  • Link loads: Fewer cars on route X at time T
  • Congestion state: Travel time estimates for other agents
  • Activity feasibility: If A cancels a carpool, agent B’s trip becomes invalid

MATraM defines consistency boundaries:

Strong consistency: Within an agent’s own schedule. If you reschedule activity 3, activities 4-6 must respect temporal dependencies.

Eventual consistency: Across agents. Your rescheduling changes network congestion, but other agents see the update only after the next batch window.

No consistency: Historical data. Once a trip is completed, it cannot be modified (even if the agent later realizes it was suboptimal).

This matches real-world behavior: you can change your own plans instantly, but you only learn about traffic changes when you check your phone.

Failure Modes

Modification Request Storms
If 30% of agents hit congestion simultaneously, the request queue floods. MATraM needs rate limiting: agents can request modifications at most once per time window, and the solver processes requests in priority order (e.g., time-critical activities first).

Infeasible Schedule States
An agent might request a modification that violates hard constraints (e.g., work ends at 5pm, but the only feasible grocery slot is 4pm). The solver must either reject the request or relax soft constraints (e.g., reduce shopping duration).

Stale Network State
Agents make decisions based on travel time estimates from the last batch window. If congestion changes rapidly, agents reschedule into worse conditions. MATraM mitigates this by limiting the batch window size (shorter windows = fresher state but higher overhead).

Implementation Sketch

A minimal activity modification engine needs:

class ActivityModificationEngine:
    def __init__(self, network_model, batch_window_minutes=15):
        self.network = network_model
        self.batch_window = batch_window_minutes
        self.pending_requests = []
        self.agent_schedules = {}  # agent_id -> Schedule
    
    def request_modification(self, agent_id, activity_id, reason):
        """Agent flags an activity for rescheduling."""
        request = ModificationRequest(
            agent_id=agent_id,
            activity_id=activity_id,
            reason=reason,
            timestamp=self.network.current_time
        )
        self.pending_requests.append(request)
    
    def process_batch(self):
        """Called every batch_window minutes."""
        if not self.pending_requests:
            return
        
        # Sort by priority (time-critical activities first)
        self.pending_requests.sort(key=lambda r: r.priority)
        
        approved = []
        for req in self.pending_requests:
            schedule = self.agent_schedules[req.agent_id]
            new_schedule = self.try_reschedule(schedule, req.activity_id)
            
            if new_schedule and self.network.validate_capacity(new_schedule):
                approved.append((req.agent_id, new_schedule))
        
        # Atomic commit: update all schedules and network state
        for agent_id, new_schedule in approved:
            self.agent_schedules[agent_id] = new_schedule
            self.network.update_trips(agent_id, new_schedule.trips)
        
        self.pending_requests.clear()
    
    def try_reschedule(self, schedule, activity_id):
        """Find a feasible time slot for the activity."""
        activity = schedule.get_activity(activity_id)
        
        # Search alternative time windows
        for slot in activity.alternative_windows:
            if schedule.can_insert(activity, slot):
                return schedule.with_activity_moved(activity_id, slot)
        
        return None  # No feasible reschedule

The key is the two-phase commit in process_batch: validate all modifications against network capacity before committing any. This prevents partial updates that leave the simulation in an inconsistent state.

Observability Needs

To debug modification storms or infeasible schedules, you need:

  • Modification request metrics: Count by reason (congestion, time conflict, preference change)
  • Approval rate: Percentage of requests that pass validation
  • Schedule churn: How many times each agent modifies its schedule per day
  • Network state lag: Time delta between congestion change and agent awareness

Without these, you cannot tell whether low approval rates mean the solver is too conservative or agents are making unrealistic requests.

Technical Verdict

Use MATraM’s approach when:

  • Your multi-agent system has shared infrastructure (network links, server capacity, warehouse inventory)
  • Agents need to adapt plans based on runtime conditions
  • Full replanning is too expensive (thousands of agents, complex constraints)
  • You can tolerate bounded staleness (agents see slightly outdated state)

Avoid it when:

  • Agents operate independently (no shared resources to contend for)
  • Strong consistency is required (financial transactions, safety-critical systems)
  • Modification requests occur less than 5% of simulation time (simpler to replan from scratch)
  • You need deterministic replay for debugging (batching introduces non-determinism if request order varies)
  • System requires sub-100ms latency for state updates (batch windows add inherent delay)

The core lesson transfers beyond transport: when agents share mutable infrastructure, you need explicit state synchronization primitives. MATraM’s batched modification queue with two-phase commit is one solution. The alternative is optimistic concurrency (agents modify freely, rollback on conflict) or pessimistic locking (agents acquire locks before modifying). Each has different failure modes and performance characteristics.

Tags

agentic-ai orchestration infrastructure

Primary Source

arxiv.org