# chimms1/lte-wifi-simulator architecture

> Architecture diagram of the GitHub repository chimms1/lte-wifi-simulator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chimms1/lte-wifi-simulator
- Repository: https://github.com/chimms1/lte-wifi-simulator

## Overview

##### Project type and purpose
- This is a Python-based network simulator for modeling LTE and WiFi coexistence scenarios in unlicensed spectrum.
- It is not a client-server or web application, but a computational engine that runs experiments, applies Q-learning, and outputs performance metrics and plots.

##### File structure
- Top-level scripts (compute7.py, rouhg.py, run500.py/sh) drive batch runs or custom experiments.
- “Simulator/” contains the core simulation engine:
- entities/ – definitions for BaseStation and UserEquipment
- Qlearning/ – implements the reinforcement learning logic
- running/ – configuration (ConstantParams.py), service methods (ServiceClass.py), and verbose/plot controls (Print.py)
- main-latest-all.py (and variants) – entry points that tie everything together.

##### Extract additional insights from the README
- main-latest-all.py is the primary driver; it loads parameters, initializes entities, loops over time/iterations, invokes service methods and Q-learning updates, and triggers logging/plotting.
- Q-learning module implements states, actions, rewards, and Q-table operations.
- Running package centralizes user-set parameters, printing flags, and service utilities.

a. Main components
1. Entry-point Scripts (main-latest-all.py, run scripts)
2. Configuration Layer (ConstantParams.py)
3. Simulation Core
– ServiceClass (orchestrates simulation steps)
– Entities (BaseStation, UserEquipment)
4. Learning Engine (Qlearning module)
5. Output/Visualization (Print.py, matplotlib, seaborn)
6. Batch Runner Scripts (compute7.py, run500.py)
b. Relationships and interactions
- Entry-point reads ConstantParams → Instantiates ServiceClass → Creates Entities
- ServiceClass calls Entities to simulate traffic/SINR → Passes state & reward to Learning Engine → Learning Engine updates Q-table
- ServiceClass uses Print module to log & plot intermediate/final results
- Batch Runner Scripts invoke multiple runs of the Entry-point with different seeds or parameter sets
c. Architectural patterns and design principles
- Modular layering: configuration, core logic, entities, learning, output
- Separation of concerns: Entities purely model network objects; ServiceClass handles orchestration; Qlearning is plugin-style algorithm; Print is orthogonal logging/visualization
d. Key technologies and libraries
- Python 3.9+
- numpy, pandas (data handling)
- matplotlib, seaborn (plots)
- tqdm, openpyxl (optional reporting)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Batch Runner Scripts"
        direction TB
        compute7["compute7.py"]:::batch
        run500_py["run500.py"]:::batch
        run500_sh["run500.sh"]:::batch
        rouhg_py_root["rouhg.py"]:::batch
        rouhg_py_sim["Simulator/rouhg.py"]:::batch
    end

    subgraph "Entry-point Scripts"
        direction TB
        main_all["main-latest-all.py"]:::entry
        main_lt["main-latest.py"]:::entry
        main["main.py"]:::entry
    end

    subgraph "Configuration Layer"
        direction TB
        params["ConstantParams.py"]:::config
    end

    subgraph "Core Simulation"
        direction TB
        service["ServiceClass.py"]:::core
        subgraph "Entities"
            direction TB
            bs["BaseStation.py"]:::core
            ue["UserEquipment.py"]:::core
        end
    end

    subgraph "Learning Engine"
        direction TB
        qlearn["learning.py"]:::learning
        qtable["Q-table"]:::data
    end

    subgraph "Output/Visualization"
        direction TB
        print_mod["Print.py"]:::output
        plots["Plots/Logs"]:::output
    end

    compute7 --> main_all
    run500_py --> main_all
    run500_sh --> main_all
    rouhg_py_root --> main_all
    rouhg_py_sim --> main_all

    params --> main_all
    main_all --> service
    service --> bs
    service --> ue
    service --> qlearn
    qlearn --> qtable
    qtable --> service
    service --> print_mod
    print_mod --> plots

    click compute7 "https://github.com/chimms1/lte-wifi-simulator/blob/main/compute7.py"
    click run500_py "https://github.com/chimms1/lte-wifi-simulator/blob/main/run500.py"
    click run500_sh "https://github.com/chimms1/lte-wifi-simulator/blob/main/run500.sh"
    click rouhg_py_root "https://github.com/chimms1/lte-wifi-simulator/blob/main/rouhg.py"
    click rouhg_py_sim "https://github.com/chimms1/lte-wifi-simulator/blob/main/Simulator/rouhg.py"
    click main_all "https://github.com/chimms1/lte-wifi-simulator/blob/main/Simulator/main-latest-all.py"
    click main_lt "https://github.com/chimms1/lte-wifi-simulator/blob/main/Simulator/main-latest.py"
    click main "https://github.com/chimms1/lte-wifi-simulator/blob/main/Simulator/main.py"
    click params "https://github.com/chimms1/lte-wifi-simulator/blob/main/Simulator/running/ConstantParams.py"
    click service "https://github.com/chimms1/lte-wifi-simulator/blob/main/Simulator/running/ServiceClass.py"
    click bs "https://github.com/chimms1/lte-wifi-simulator/blob/main/Simulator/entities/BaseStation.py"
    click ue "https://github.com/chimms1/lte-wifi-simulator/blob/main/Simulator/entities/UserEquipment.py"
    click qlearn "https://github.com/chimms1/lte-wifi-simulator/blob/main/Simulator/Qlearning/learning.py"
    click print_mod "https://github.com/chimms1/lte-wifi-simulator/blob/main/Simulator/running/Print.py"

    classDef config fill:#cce5ff,stroke:#005cbf
    classDef core fill:#d4edda,stroke:#155724
    classDef learning fill:#fff3cd,stroke:#856404
    classDef output fill:#e2e3e5,stroke:#6c757d
    classDef batch fill:#f8f9fa,stroke:#6c757d
    classDef entry fill:#f8f9fa,stroke:#6c757d
    classDef data fill:#ffe6e6,stroke:#cc0000
```
