# qlt315/ucmec-mmwave-fronthaul architecture

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

- Interactive diagram: https://gitdiagram.com/qlt315/ucmec-mmwave-fronthaul
- Repository: https://github.com/qlt315/ucmec-mmwave-fronthaul

## Overview

##### Project type and purpose
- This is a multi-agent deep reinforcement learning (MADRL) evaluation framework for “User-Centric Mobile Edge Computing” (UCMEC).
- Its goal is to simulate decentralized task offloading and resource allocation in a user-centric MEC architecture, compare MADRL algorithms (MAPPO, IPPO, IQL, MADDPG) and convex optimization, and generate performance figures.

##### File structure
Top-level directories and files:
- algorithms/
– Contains MADRL algorithm implementations and helper modules.
– Subdirectories: algorithm/ (core policy classes: rMAPPOPolicy, r_actor_critic, r_mappo), utils/ (network modules: cnn, mlp, rnn; action/distribution classes; normalization).
- envs/
– Custom multi-agent environments for UCMEC under combinations of stat/dyna and coop/non-coop for different scenarios.
– Core env interface: env_core.py, with wrappers env_discrete.py and env_continuous.py.
- runner/
– Two runner styles: separated (each agent trained separately) and shared (agents share networks).
– base_runner.py and env_runner.py in each.
- train/
– train.py orchestrates experiment launch, parses --num_agents, chooses discrete vs continuous environment.
- utils/
– Shared utilities: replay buffers (separated_buffer, shared_buffer), normalizers, general util.
- scripts/
– data_process.py (post-processing), figure_generate.m (Matlab plots), render subdir with render_mpe.py and train_mpe.sh.
- config.py
– Hyperparameter and environment configuration.
- results/
– Output directory for logs, model checkpoints, metrics, and figures.

##### README for additional insights
- The README confirms the ENV abstraction (EnvCore, reset(), step()), continuous vs discrete action handling in algorithms/utils/act.py and runner/shared/env_runner.py.
- It points out how to switch scenarios by editing env files (N_sim, M_sim) and train.py flags.

##### Elements
– Config → train.py → Runner → Env (reset/step)
– Runner → Algorithm (action selection, learning updates)
– Algorithm → Utils (network forward/backward, buffers)
– Runner → Results (logging) → Scripts → Figures

##### Final advice
- Be exhaustive: represent every subcomponent (e.g., rMAPPOPolicy, shared_buffer).
- Branching logic: continuous vs discrete, shared vs separated training.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Environment Layer"
        EC["EnvCore\n(env_core.py)"]:::env
        ED["Discrete Wrapper\n(env_discrete.py)"]:::env
        ECN["Continuous Wrapper\n(env_continuous.py)"]:::env
        subgraph "Scenarios"
            S1["MA_UCMEC_stat_coop.py"]:::env
            S2["MA_UCMEC_stat_noncoop.py"]:::env
            S3["MA_UCMEC_dyna_coop.py"]:::env
            S4["MA_UCMEC_dyna_noncoop.py"]:::env
        end
    end

    subgraph "Runner Layer"
        SRB["Shared Base Runner\n(base_runner.py)"]:::runner
        SRER["Shared Env Runner\n(env_runner.py)"]:::runner
        SEB["Separated Base Runner\n(base_runner.py)"]:::runner
        SEER["Separated Env Runner\n(env_runner.py)"]:::runner
    end

    subgraph "Algorithm Layer"
        MAPPO["rMAPPOPolicy\n(rMAPPOPolicy.py)"]:::algo
        AC["r_actor_critic\n(r_actor_critic.py)"]:::algo
        RM["r_mappo\n(r_mappo.py)"]:::algo
        NN1["MLP\n(mlp.py)"]:::algo
        NN2["CNN\n(cnn.py)"]:::algo
        NN3["RNN\n(rnn.py)"]:::algo
        ACT["act.py\n(discrete/continuous)"]:::algo
        DIS["distributions.py"]:::algo
        POP["popart.py"]:::algo
        UTIL_ALGO["util.py"]:::algo
    end

    subgraph "Utils & Buffers"
        SB["shared_buffer.py"]:::util
        SeB["separated_buffer.py"]:::util
        VN["valuenorm.py"]:::util
        UTIL["util.py"]:::util
    end

    subgraph "Scripts & Results"
        DP["data_process.py"]:::script
        FG["figure_generate.m"]:::script
        RN["render_mpe.py"]:::script
        TS["train_mpe.sh"]:::script
        RES["results/"]:::result
    end

    CFG["config.py"]:::config
    TRAIN["train.py"]:::config

    CFG --> TRAIN
    TRAIN --> SRER
    TRAIN --> SEER
    TRAIN --> EC
    EC --> ED
    EC --> ECN
    ED --> S1
    ED --> S2
    ED --> S3
    ED --> S4
    SRER --> EC
    SEER --> EC
    SRER --> MAPPO
    SEER --> MAPPO
    MAPPO --> AC
    MAPPO --> RM
    RM --> NN1
    RM --> NN2
    RM --> NN3
    MAPPO --> ACT
    ACT --> DIS
    DIS --> POP
    RM --> UTIL_ALGO
    SRER --> SB
    SEER --> SeB
    SB --> UTIL
    SeB --> UTIL
    SRER --> RES
    SEER --> RES
    RES --> DP
    RES --> FG
    RES --> RN
    RES --> TS

    click EC "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/envs/env_core.py"
    click ED "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/envs/env_discrete.py"
    click ECN "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/envs/env_continuous.py"
    click S1 "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/envs/MA_UCMEC_stat_coop.py"
    click S2 "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/envs/MA_UCMEC_stat_noncoop.py"
    click S3 "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/envs/MA_UCMEC_dyna_coop.py"
    click S4 "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/envs/MA_UCMEC_dyna_noncoop.py"
    click MAPPO "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/algorithms/algorithm/rMAPPOPolicy.py"
    click AC "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/algorithms/algorithm/r_actor_critic.py"
    click RM "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/algorithms/algorithm/r_mappo.py"
    click NN1 "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/algorithms/utils/mlp.py"
    click NN2 "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/algorithms/utils/cnn.py"
    click NN3 "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/algorithms/utils/rnn.py"
    click ACT "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/algorithms/utils/act.py"
    click DIS "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/algorithms/utils/distributions.py"
    click POP "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/algorithms/utils/popart.py"
    click UTIL_ALGO "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/algorithms/utils/util.py"
    click SRB "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/runner/shared/base_runner.py"
    click SRER "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/runner/shared/env_runner.py"
    click SEB "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/runner/separated/base_runner.py"
    click SEER "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/runner/separated/env_runner.py"
    click TRAIN "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/train/train.py"
    click CFG "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/config.py"
    click SeB "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/utils/separated_buffer.py"
    click SB "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/utils/shared_buffer.py"
    click VN "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/utils/valuenorm.py"
    click UTIL "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/utils/util.py"
    click DP "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/scripts/data_process.py"
    click FG "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/scripts/figure_generate.m"
    click RN "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/scripts/render/render_mpe.py"
    click TS "https://github.com/qlt315/ucmec-mmwave-fronthaul/blob/main/scripts/train_mpe.sh"
    click RES "https://github.com/qlt315/ucmec-mmwave-fronthaul/tree/main/results/"

    classDef env fill:#D0E8FF,stroke:#1E90FF
    classDef runner fill:#D0FFD8,stroke:#28A745
    classDef algo fill:#FFF7C2,stroke:#FFCA28
    classDef util fill:#E0E0E0,stroke:#6C6C6C
    classDef script fill:#FFE0CC,stroke:#FF8C00
    classDef config fill:#F0D0FF,stroke:#A32CC4
    classDef result fill:#FFD1D1,stroke:#DC3545
```
