# skypitcher/risk_aware_marl architecture

> Architecture diagram of the GitHub repository skypitcher/risk_aware_marl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/skypitcher/risk_aware_marl
- Repository: https://github.com/skypitcher/risk_aware_marl

## Overview

This repository implements PRIMAL, an event-driven LEO satellite packet-routing simulator with pluggable routing and reinforcement-learning solvers. A run initializes traffic and network state, processes packet and topology events, asks a solver for satellite next hops, and records delivery, drops, and performance statistics. Training is integrated through solver callbacks; evaluation and plotting expose results, while a separate viewer renders the network. The graph follows documented and excerpted relationships; unsampled solver and statistics details are represented conservatively.

Main entry points: [`sat_net/routing_env.py`](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/routing_env.py) (Event simulation), [`sat_net/solver/__init__.py`](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/__init__.py) (Solver factory), [`sat_net/network.py`](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/network.py) (Constellation network), [`sat_net/nn.py`](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/nn.py) (RL networks and buffer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Network simulation"]
  node_environment["Event simulation<br/>[routing_env.py]"]
  node_event["Event scheduler<br/>[event.py]"]
  node_network["Constellation network<br/>[network.py]"]
  node_node["Satellite and station nodes<br/>[node.py]"]
  node_link["Communication links<br/>[link.py]"]
  node_packet["Packet flowlets<br/>[datablock.py]"]
  node_geometry["Orbit geometry<br/>[geometric.py]"]
  node_traffic["Traffic regions<br/>[traffic_region.py]"]
end

subgraph group_routing["Routing and learning"]
  node_solverfactory["Solver factory<br/>[__init__.py]"]
  node_base["Solver callbacks<br/>[base_solver.py]"]
  node_primalcvar["PRIMAL-CVaR<br/>[primal_cvar.py]"]
  node_primalavg["PRIMAL-Avg<br/>[primal_avg.py]"]
  node_iqn["Multi-agent IQN<br/>[iqn.py]"]
  node_dqn["Multi-agent DQN<br/>[dqn.py]"]
  node_sac["Multi-agent SAC<br/>[sac.py]"]
  node_spf["Shortest-path routing<br/>[spf.py]"]
  node_nn["RL networks and buffer<br/>[nn.py]"]
end

subgraph group_analysis["Results and visualization"]
  node_stats["Run statistics<br/>[stats.py]"]
  node_plots["Evaluation plots<br/>[plot_eval.py]"]
  node_viewer["Interactive network viewer<br/>[renderer.py]"]
  node_viewerapp["Viewer application<br/>[app.py]"]
end

node_operator(("Experiment operator"))
node_trainrun["Training runner<br/>[run_train.py]"]
node_evalrun["Evaluation runner<br/>[run_eval.py]"]

node_operator -->|"starts training"| node_trainrun
node_operator -->|"starts evaluation"| node_evalrun
node_trainrun -->|"runs simulation"| node_environment
node_evalrun -->|"runs simulation"| node_environment
node_trainrun -->|"creates solver"| node_solverfactory
node_evalrun -->|"creates solver"| node_solverfactory
node_environment -->|"schedules events"| node_event
node_environment -->|"updates topology"| node_network
node_network -->|"uses calculations"| node_geometry
node_network -->|"creates nodes"| node_node
node_network -->|"creates links"| node_link
node_environment -->|"processes packets"| node_packet
node_environment -->|"uses regions"| node_traffic
node_environment -->|"transmits packets"| node_link
node_environment -->|"forwards packets"| node_node
node_environment -.->|"selects solver"| node_solverfactory
node_environment -->|"invokes callbacks"| node_base
node_solverfactory -->|"constructs solver"| node_primalcvar
node_solverfactory -->|"constructs solver"| node_primalavg
node_solverfactory -->|"constructs solver"| node_iqn
node_solverfactory -->|"constructs solver"| node_dqn
node_solverfactory -->|"constructs solver"| node_sac
node_solverfactory -->|"constructs solver"| node_spf
node_primalcvar -->|"uses networks"| node_nn
node_primalavg -->|"uses networks"| node_nn
node_iqn -->|"uses networks"| node_nn
node_dqn -->|"uses networks"| node_nn
node_sac -->|"uses networks"| node_nn
node_environment -.->|"records metrics"| node_stats
node_evalrun -.->|"supports analysis"| node_plots
node_operator -.->|"opens viewer"| node_viewerapp
node_viewerapp -->|"uses renderer"| node_viewer
node_viewer -->|"renders topology"| node_network

click node_trainrun "https://github.com/skypitcher/risk_aware_marl/blob/main/run_train.py"
click node_evalrun "https://github.com/skypitcher/risk_aware_marl/blob/main/run_eval.py"
click node_environment "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/routing_env.py"
click node_event "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/event.py"
click node_network "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/network.py"
click node_node "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/node.py"
click node_link "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/link.py"
click node_packet "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/datablock.py"
click node_geometry "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/geometric.py"
click node_traffic "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/traffic_region.py"
click node_solverfactory "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/__init__.py"
click node_base "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/base_solver.py"
click node_primalcvar "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/primal_cvar.py"
click node_primalavg "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/primal_avg.py"
click node_iqn "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/iqn.py"
click node_dqn "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/dqn.py"
click node_sac "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/sac.py"
click node_spf "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/spf.py"
click node_nn "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/nn.py"
click node_stats "https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/stats.py"
click node_plots "https://github.com/skypitcher/risk_aware_marl/blob/main/plot_eval.py"
click node_viewer "https://github.com/skypitcher/risk_aware_marl/blob/main/satnet_viewer/renderer.py"
click node_viewerapp "https://github.com/skypitcher/risk_aware_marl/blob/main/satnet_viewer/app.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_environment,node_event,node_network,node_node,node_link,node_packet,node_geometry,node_traffic toneBlue
class node_solverfactory,node_base,node_primalcvar,node_primalavg,node_iqn,node_dqn,node_sac,node_spf,node_nn toneAmber
class node_stats,node_plots,node_viewer,node_viewerapp toneMint
class node_operator toneIndigo
class node_trainrun,node_evalrun toneTeal
```

## Components

### Network simulation

- [Event simulation](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/routing_env.py): `sat_net/routing_env.py`
- [Event scheduler](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/event.py): `sat_net/event.py`
- [Constellation network](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/network.py): `sat_net/network.py`
- [Satellite and station nodes](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/node.py): `sat_net/node.py`
- [Communication links](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/link.py): `sat_net/link.py`
- [Packet flowlets](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/datablock.py): `sat_net/datablock.py`
- [Orbit geometry](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/geometric.py): `sat_net/geometric.py`
- [Traffic regions](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/traffic_region.py): `sat_net/traffic_region.py`

### Routing and learning

- [Solver factory](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/__init__.py): `sat_net/solver/__init__.py`
- [Solver callbacks](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/base_solver.py): `sat_net/solver/base_solver.py`
- [PRIMAL-CVaR](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/primal_cvar.py): `sat_net/solver/primal_cvar.py`
- [PRIMAL-Avg](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/primal_avg.py): `sat_net/solver/primal_avg.py`
- [Multi-agent IQN](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/iqn.py): `sat_net/solver/iqn.py`
- [Multi-agent DQN](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/dqn.py): `sat_net/solver/dqn.py`
- [Multi-agent SAC](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/sac.py): `sat_net/solver/sac.py`
- [Shortest-path routing](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/solver/spf.py): `sat_net/solver/spf.py`
- [RL networks and buffer](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/nn.py): `sat_net/nn.py`

### Results and visualization

- [Run statistics](https://github.com/skypitcher/risk_aware_marl/blob/main/sat_net/stats.py): `sat_net/stats.py`
- [Evaluation plots](https://github.com/skypitcher/risk_aware_marl/blob/main/plot_eval.py): `plot_eval.py`
- [Interactive network viewer](https://github.com/skypitcher/risk_aware_marl/blob/main/satnet_viewer/renderer.py): `satnet_viewer/renderer.py`
- [Viewer application](https://github.com/skypitcher/risk_aware_marl/blob/main/satnet_viewer/app.py): `satnet_viewer/app.py`

### Other components

- **Experiment operator**
- [Training runner](https://github.com/skypitcher/risk_aware_marl/blob/main/run_train.py): `run_train.py`
- [Evaluation runner](https://github.com/skypitcher/risk_aware_marl/blob/main/run_eval.py): `run_eval.py`

## Connections

- Experiment operator → Training runner: starts training (evidence: `README.md`)
- Experiment operator → Evaluation runner: starts evaluation (evidence: `README.md`)
- Training runner → Event simulation: runs simulation (evidence: `run_train.py`)
- Evaluation runner → Event simulation: runs simulation (evidence: `run_eval.py`)
- Training runner → Solver factory: creates solver (evidence: `run_train.py`)
- Evaluation runner → Solver factory: creates solver (evidence: `run_eval.py`)
- Event simulation → Event scheduler: schedules events (evidence: `sat_net/routing_env.py`)
- Event simulation → Constellation network: updates topology (evidence: `sat_net/routing_env.py`)
- Constellation network → Orbit geometry: uses calculations (evidence: `sat_net/network.py`)
- Constellation network → Satellite and station nodes: creates nodes (evidence: `sat_net/network.py`)
- Constellation network → Communication links: creates links (evidence: `sat_net/network.py`)
- Event simulation → Packet flowlets: processes packets (evidence: `sat_net/routing_env.py`)
- Event simulation → Traffic regions: uses regions (evidence: `sat_net/routing_env.py`)
- Event simulation → Communication links: transmits packets (evidence: `sat_net/routing_env.py`)
- Event simulation → Satellite and station nodes: forwards packets (evidence: `sat_net/routing_env.py`)
- Event simulation → Solver factory: selects solver
- Event simulation → Solver callbacks: invokes callbacks (evidence: `README.md`)
- Solver factory → PRIMAL-CVaR: constructs solver (evidence: `sat_net/solver/__init__.py`)
- Solver factory → PRIMAL-Avg: constructs solver (evidence: `sat_net/solver/__init__.py`)
- Solver factory → Multi-agent IQN: constructs solver (evidence: `sat_net/solver/__init__.py`)
- Solver factory → Multi-agent DQN: constructs solver (evidence: `sat_net/solver/__init__.py`)
- Solver factory → Multi-agent SAC: constructs solver (evidence: `sat_net/solver/__init__.py`)
- Solver factory → Shortest-path routing: constructs solver (evidence: `sat_net/solver/__init__.py`)
- PRIMAL-CVaR → RL networks and buffer: uses networks (evidence: `sat_net/solver/primal_cvar.py`)
- PRIMAL-Avg → RL networks and buffer: uses networks (evidence: `sat_net/solver/primal_avg.py`)
- Multi-agent IQN → RL networks and buffer: uses networks (evidence: `sat_net/solver/iqn.py`)
- Multi-agent DQN → RL networks and buffer: uses networks (evidence: `sat_net/solver/dqn.py`)
- Multi-agent SAC → RL networks and buffer: uses networks (evidence: `sat_net/solver/sac.py`)
- Event simulation → Run statistics: records metrics (evidence: `sat_net/routing_env.py`)
- Evaluation runner → Evaluation plots: supports analysis
- Experiment operator → Viewer application: opens viewer
- Viewer application → Interactive network viewer: uses renderer (evidence: `satnet_viewer/app.py`)
- Interactive network viewer → Constellation network: renders topology (evidence: `satnet_viewer/renderer.py`)
