# satcom-telma/ma-drl_routing_simulator architecture

> Architecture diagram of the GitHub repository satcom-telma/ma-drl_routing_simulator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/satcom-telma/ma-drl_routing_simulator
- Repository: https://github.com/satcom-telma/ma-drl_routing_simulator

## Overview

##### Project Type & Purpose
- This is a research‐grade, full-stack simulation and post-processing pipeline, not a web or mobile app.
- Core purpose: simulate block transmissions through dynamic satellite constellations (non-RL and RL modes) and then analyze results (latency, throughput, model performance).

##### Main Components
A. Configuration & Input Loader
- Files: Gateways.csv, input.csv, inputRL.csv, Population Map TIFFs/PDFs
- Function: parse gateway locations, simulation parameters, population data
B. Simulation Engine
- Non-RL core: Simulation.py
- RL core: SimulationRL.py (loads Q-Learning & Deep-Q networks/tables from pre_trained_NNs/)
- Underlying framework: Simpy event scheduler
C. Network Model
- Gateway objects (with transmit queues)
- Satellite objects (with inter-satellite link queues)
- Constellation updater (discrete movement, link re-builds)
D. Routing Logic
- Non-RL: Dijkstra shortest-path (uses metrics: latency, dataRate, slant_range, hop)
- RL: Q-Learning / Deep Q-Learning agents decide next hop at runtime
E. Data Generation & Propagation
- Blocks per gateway → placed into Simpy queues → propagate via link processes → arrival events
F. Telemetry Output & Storage
- Results folders (.csv, .npy): per-simulation logs (latency, DataRate, Q-values, epsilons)
- Population Map outputs (PDFs/TIFFs)
G. Post-Processing Pipeline
- Post-Processing/Post-Results.ipynb (Jupyter)
- Python scripts under Post-Processing/* generate CDFs, performance (CKA), throughput, rotation tests, figures
H. Visualization & Video
- Video scripts (Video/MA-DRL_Movement.mp4, change_name.py) for demo animations
I. Dependencies & External Libraries
- Python 3.9, Simpy, NumPy, Pandas, NetworkX (shortest path), Keras/TensorFlow (Deep Q-Networks), Matplotlib, Jupyter

##### Component Interactions & Data Flow
- Input Loader → populates Simulation Engine parameters
- Simulation Engine (Simpy) invokes Network Model & Routing Logic
- Blocks flow through queues → Telemetry Writer writes to file system
- RL mode loads pre_trained_NNs from disk → agents interact with Simpy events
- Post-Processing scripts read telemetry files (.csv, .npy) → compute metrics → store analysis results
- Visualization: notebook or scripts read post-processed data → generate plots, animations

##### Architectural Patterns & Principles
- Modular separation: Simulation core decoupled from post-processing
- Plugin-style routing: switch easily between non-RL (Dijkstra) and RL agents
- Data-driven configuration: all parameters externalized in CSV files
- Event-driven simulation (Simpy)
- Pipeline pattern: raw simulation → telemetry → analysis → visualization

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layer 1: Inputs
    subgraph "Layer 1: Inputs"
        style Layer1 fill:#f9f,stroke:#333,stroke-width:1
        CSVs["Gateways.csv, input.csv, inputRL.csv"]:::storage
        PopMap["Population Map"]:::storage
    end

    %% Layer 2: Simulation
    subgraph "Layer 2: Simulation Core"
        Simpy["Simpy Event Loop"]:::sim
        SimNonRL["Simulation.py (Non-RL)"]:::sim
        SimRL["SimulationRL.py (RL)"]:::sim
        Pretrained["pre_trained_NNs/"]:::storage
        NetworkModel["Network Model"]:::sim
        Routing["Routing Logic"]:::sim
        Dijkstra["Dijkstra Module"]:::sim
        RLAgent["RL Agent"]:::sim
        Telemetry["Telemetry Writer"]:::sim
    end

    %% Layer 3: Results Storage
    subgraph "Layer 3: Telemetry Storage"
        Results["Results/Telemetry (.csv, .npy)"]:::storage
    end

    %% Layer 4: Post-Processing
    subgraph "Layer 4: Post-Processing"
        Notebook["Post-Results.ipynb"]:::analysis
        PPScripts["Post-Processing Scripts"]:::analysis
        subgraph "Analysis Outputs"
            DET["deterministic/"]:::analysis
            OFF["2GTsOffline/"]:::analysis
            EXPLORE["8GTs_Explore/"]:::analysis
            EXPLOIT["8GTs_Exploit/"]:::analysis
            CDF["CDF/"]:::analysis
            FL["FL/"]:::analysis
            THR["Throughput/"]:::analysis
            PERF["Performance/"]:::analysis
        end
    end

    %% Layer 5: Visualization
    subgraph "Layer 5: Visualization"
        VideoFile["MA-DRL_Movement.mp4"]:::viz
        ChangeName["change_name.py"]:::viz
    end

    %% Dependencies
    subgraph "Environment & Dependencies"
        Req["requirements.txt"]:::dep
        Readme["README.md"]:::dep
    end

    %% Connections
    CSVs -->|provides config| SimNonRL
    CSVs -->|provides config| SimRL
    PopMap -->|provides data| SimNonRL
    PopMap -->|provides data| SimRL

    SimNonRL -->|schedules events| Simpy
    SimRL -->|schedules events| Simpy
    Simpy -->|orchestrates| NetworkModel

    NetworkModel -->|uses| Routing
    Routing -->|non-RL| Dijkstra
    Routing -->|RL| RLAgent
    RLAgent -->|loads models| Pretrained

    SimNonRL -->|writes| Telemetry
    SimRL -->|writes| Telemetry
    Telemetry -->|stores| Results

    Results -->|input| Notebook
    Results -->|input| PPScripts

    PPScripts -->|generates| DET
    PPScripts -->|generates| OFF
    PPScripts -->|generates| EXPLORE
    PPScripts -->|generates| EXPLOIT
    PPScripts -->|generates| CDF
    PPScripts -->|generates| FL
    PPScripts -->|generates| THR
    PPScripts -->|generates| PERF

    DET -->|read by| VideoFile
    OFF -->|read by| VideoFile
    EXPLORE -->|read by| VideoFile
    EXPLOIT -->|read by| VideoFile
    PERF -->|read by| ChangeName

    %% Click Events
    click CSVs "https://github.com/satcom-telma/ma-drl_routing_simulator/blob/main/Gateways.csv"
    click PopMap "https://github.com/satcom-telma/ma-drl_routing_simulator/tree/main/Population Map/"
    click SimNonRL "https://github.com/satcom-telma/ma-drl_routing_simulator/blob/main/Simulation.py"
    click SimRL "https://github.com/satcom-telma/ma-drl_routing_simulator/blob/main/SimulationRL.py"
    click Pretrained "https://github.com/satcom-telma/ma-drl_routing_simulator/tree/main/pre_trained_NNs/"
    click Notebook "https://github.com/satcom-telma/ma-drl_routing_simulator/blob/main/Post-Processing/Post-Results.ipynb"
    click PPScripts "https://github.com/satcom-telma/ma-drl_routing_simulator/tree/main/Post-Processing/"
    click DET "https://github.com/satcom-telma/ma-drl_routing_simulator/tree/main/Post-Processing/deterministic/"
    click OFF "https://github.com/satcom-telma/ma-drl_routing_simulator/tree/main/Post-Processing/2GTsOffline/"
    click EXPLORE "https://github.com/satcom-telma/ma-drl_routing_simulator/tree/main/Post-Processing/8GTs_Explore/"
    click EXPLOIT "https://github.com/satcom-telma/ma-drl_routing_simulator/tree/main/Post-Processing/8GTs_Exploit/"
    click CDF "https://github.com/satcom-telma/ma-drl_routing_simulator/tree/main/Post-Processing/CDF/"
    click FL "https://github.com/satcom-telma/ma-drl_routing_simulator/tree/main/Post-Processing/FL/"
    click THR "https://github.com/satcom-telma/ma-drl_routing_simulator/tree/main/Post-Processing/Throughput/"
    click PERF "https://github.com/satcom-telma/ma-drl_routing_simulator/tree/main/Post-Processing/Performance/"
    click VideoFile "https://github.com/satcom-telma/ma-drl_routing_simulator/blob/main/Video/MA-DRL_Movement.mp4"
    click ChangeName "https://github.com/satcom-telma/ma-drl_routing_simulator/blob/main/Video/change_name.py"
    click Req "https://github.com/satcom-telma/ma-drl_routing_simulator/blob/main/requirements.txt"
    click Readme "https://github.com/satcom-telma/ma-drl_routing_simulator/blob/main/README.md"

    %% Styles
    classDef sim fill:#bbdefb,stroke:#0d47a1,stroke-width:1
    classDef storage fill:#c8e6c9,stroke:#1b5e20,stroke-width:1
    classDef analysis fill:#ffe0b2,stroke:#ef6c00,stroke-width:1
    classDef viz fill:#e1bee7,stroke:#6a1b9a,stroke-width:1
    classDef dep fill:#eeeeee,stroke:#757575,stroke-width:1
```
