Data Flow¶
How data moves through Waremax.
Overview¶
Data flows through three main phases:
- Configuration → Parsed and validated
- Simulation → Events processed, state updated
- Output → Metrics collected and reported
Configuration Flow¶
┌──────────────┐ ┌───────────────┐ ┌──────────────┐
│ YAML File │────►│ waremax-config│────►│ Scenario │
│ (or preset) │ │ (parsing) │ │ (struct) │
└──────────────┘ └───────────────┘ └──────────────┘
│
┌────────────────────────────┤
│ │
┌──────▼──────┐ ┌──────▼──────┐
│ MapConfig │ │ RobotConfig │
└──────┬──────┘ └──────┬──────┘
│ │
┌──────▼──────┐ ┌──────▼──────┐
│WarehouseMap │ │ Vec<Robot> │
└─────────────┘ └─────────────┘
Parsing Steps¶
- Read YAML: Load file into string
- Deserialize: YAML → Rust structs
- Validate: Check constraints
- Transform: Config → Simulation objects
Initialization Flow¶
Scenario
│
├──► MapConfig ──────────────► WarehouseMap
│ │
├──► RobotConfig ───┬──────────────►│
│ │ │
├──► StationConfig ─┼──────────────►│
│ │ │
├──► StorageConfig ─┼──────────────►│
│ │ │
└──► PolicyConfig ──┴──► Policies │
│ │
▼ ▼
┌─────────────────────┐
│ SimulationState │
└─────────────────────┘
Event Flow¶
Event Lifecycle¶
┌────────────┐ schedule ┌────────────┐ dispatch ┌────────────┐
│ Created │──────────────►│ Scheduled │──────────────►│ Processed │
└────────────┘ └────────────┘ └────────────┘
│ │
│ │
in priority queue updates state,
sorted by time may create new events
Example: Order Processing¶
OrderArrival(Order)
│
▼
┌───────────────────┐
│ Create Task(s) │
│ from Order items │
└───────────────────┘
│
▼
TaskCreated(Task)
│
▼
┌───────────────────┐
│ TaskAllocation │
│ Policy selects │
│ robot │
└───────────────────┘
│
▼
TaskAssigned(Task, Robot)
│
▼
┌───────────────────┐
│ Robot starts │
│ moving │
└───────────────────┘
│
▼
RobotStartMove(Robot, Path)
│
▼
... (movement events)
│
▼
RobotArrival(Robot, Station)
│
▼
┌───────────────────┐
│ Station serves │
│ robot │
└───────────────────┘
│
▼
ServiceComplete(Robot, Station)
│
▼
TaskComplete(Task)
State Updates¶
Robot State Transitions¶
IDLE ──► assign ──► TRAVELING ──► arrive ──► WORKING ──► complete ──► IDLE
▲ │ │
│ │ blocked │ low battery
│ ▼ ▼
│ WAITING CHARGING
│ │ │
└─────────────────────┴────────────────────────┘
State Update Flow¶
Event arrives
│
▼
┌─────────────────┐
│ Read current │
│ state │
└─────────────────┘
│
▼
┌─────────────────┐
│ Apply changes │
│ - Update robot │
│ - Update station│
│ - Update map │
└─────────────────┘
│
▼
┌─────────────────┐
│ Schedule new │
│ events │
└─────────────────┘
│
▼
┌─────────────────┐
│ Record metrics │
└─────────────────┘
Metrics Flow¶
Collection Points¶
Event Processing
│
├──► Task created ──► task_count++
│
├──► Task completed ──► completion_time recorded
│
├──► Robot moves ──► travel_time++
│
├──► Robot waits ──► wait_time++
│
└──► Station serves ──► service_time++
Aggregation¶
Raw Events
│
▼
┌─────────────────┐
│ MetricsCollector│
│ - counts │
│ - sums │
│ - distributions │
└─────────────────┘
│
├──► Timeseries (periodic snapshots)
│
└──► Summary (end of simulation)
Output Flow¶
SimulationState
│
▼
┌─────────────────┐
│ MetricsCollector│
└─────────────────┘
│
├──────────────────┬──────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ summary.json│ │timeseries.csv│ │events.jsonl │
└─────────────┘ └─────────────┘ └─────────────┘
Output Contents¶
summary.json:
timeseries.csv:
events.jsonl:
{"time":0.0,"type":"OrderArrival","order_id":"O1"}
{"time":0.5,"type":"TaskAssigned","task_id":"T1","robot_id":"R1"}
Parallel Execution Flow¶
Sweep/Compare Operations¶
┌─────────────┐
│ Sweep Config│
└─────────────┘
│
▼
┌─────────────┐
│ Generate │
│ Variations │
└─────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Parallel Execution │
│ ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐ │
│ │Sim 1│ │Sim 2│ │Sim 3│ │Sim 4│ │
│ └─────┘ └─────┘ └─────┘ └─────┘ │
└─────────────────────────────────────────┘
│
▼
┌─────────────┐
│ Aggregate │
│ Results │
└─────────────┘
│
▼
┌─────────────┐
│ Comparison │
│ Report │
└─────────────┘
Data Structures in Flight¶
During Simulation¶
struct ActiveSimulation {
// Core state
time: SimTime,
scheduler: Scheduler,
// Entities (owned)
robots: Vec<Robot>,
stations: Vec<Station>,
tasks: TaskQueue,
// References (borrowed)
map: &WarehouseMap,
policies: &PolicySet,
// Output (accumulated)
metrics: MetricsCollector,
}
Memory Lifecycle¶
Initialization:
- Config loaded (temporary)
- Map built (persistent)
- Entities created (persistent)
Simulation:
- Events created/destroyed (transient)
- State updated (persistent)
- Metrics accumulated (growing)
Completion:
- Entities dropped
- Metrics finalized
- Results written