# geminilight/virne architecture

> Architecture diagram of the GitHub repository geminilight/virne, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/geminilight/virne
- Repository: https://github.com/geminilight/virne

## Overview

##### Project Type and Purpose
- Virne is a simulator and benchmarking framework for resource allocation in network function virtualization (NFV), covering problems like Virtual Network Embedding, VNF Placement, and Service Function Chain deployment.
- The project supports multiple simulation scenarios (from cloud-edge to admission control), a rich variety of solvers (exact, heuristic, meta-heuristic, and learning-based), and customizable network topologies.
- Key use cases include testing and comparing algorithms under various scenarios, offering an extensible and unified interface for reinforcement learning experiments.

##### File Structure
- Top-Level Files: Files like main.py, install.sh, and test.py indicate entry points and utility scripts.
- Documentation Files: The docs folder (with its various reStructuredText files) and the resource folder (with figures and supplementary code) provide user and developer guidance.
- Settings and Configuration: Folders like “settings” and configurations under “virne/settings” hold YAML files for simulation parameters.
- Core Package (“virne”): Contains subdirectories “base”, “data”, “solver”, “utils”, etc. This is the heart of the simulation framework.
- Solver Structure: Under “virne/solver” you see clear separations of solver types (exact, heuristic, meta-heuristic, learning-based) arranged in their dedicated subdirectories. This indicates the framework uses a registry (see virne/solver/registry.py) to look up and run these different algorithms.
- Testing Infrastructure: The “tester” folder provides unit and integration tests, demonstrating a focus on verifying core simulation and solver logic.

##### Components
a. Main Components:
- Configuration & Entry Point: Represent main.py, the Config class (in virne/config.py), and the configuration files (settings/p_net_setting.yaml, etc.).
- Data & Network Modeling: Include the “data” component housed under virne/data. This “network” layer includes generators, network attribute models, and physical/virtual network representations.
- Solver Registry & Solver Modules: Clearly denote the “solver” component with submodules:
– Exact Solvers (mip, d_rounding, r_rounding)
– Heuristic Solvers (nrm_rank, pl_rank, etc.)
– Meta-heuristic Solvers (ga, ts, etc.)
– Learning-based Solvers (a3c_gcn_seq2seq, ddpg_attention, mcts, etc.)
- Utilities and Common Services: Utilities (virne/utils) that assist with logging, data manipulation, settings management, and stats.
- Dataset Generator: Illustrate the “Generator” in charge of dataset generation (invoked in the Minimal Example).
- External Resources: Show external dependencies like the libraries for reinforcement learning (gym.Env style environments), and integration with external research artifacts (e.g., GitHub links in the README).

b. Relationships and Interactions:
- That the Simulation Engine uses the “Data Modeling” layer to set up the virtual and physical network topologies.
- That each solver (exact, heuristic, meta-heuristic, learning-based) interacts with the “Data” layer (for network attributes and node/link properties) and the “Environment” (virne/base/environment.py) for simulation state updates.
- That “Utilities” and “Settings” are supporting components invoked by almost every module to manage configuration, logging, and stats aggregation.

c. Architectural Patterns and Design Principles
- Modular design: Each major function area (configuration, simulation, data, and solvers) is encapsulated in its own package.
- Registry Pattern: Utilized for managing and dynamically dispatching solver implementations.
- Extensible and pluggable architecture: New solver and simulation approaches can be easily added as additional modules since the project emphasizes extensibility.
- Separation of Concerns: Front-end (CLI/script level configuration and execution) is kept separate from the simulation logic, solver algorithms, and data handling.

d. Relevant Technologies, Frameworks, or Libraries
- Python is the primary language with use of YAML for configuration.
- Documentation is managed via reStructuredText and Sphinx (seen in docs/).
- Integration with reinforcement learning libraries (OpenAI Gym style environments) is evident.
- Standard scientific libraries may be employed in solver implementations (though not detailed in the file tree, expect NumPy, PyTorch/TensorFlow within learning solvers).

##### Final Detailed Steps for the Principal Software Engineer
- That every component is annotated with its primary responsibilities and key interactions.
- Review the README’s “workflow.jpg” and the structure of various scenario and solver implementations to capture any additional runtime interactions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configuration & Entry Point
    subgraph "Configuration & Entry Point"
        C1["Entry Point (main.py)"]:::config
        C2["Config Manager (virne/config.py)"]:::config
        C3["Settings (settings/ & virne/settings/)"]:::config
    end

    %% Simulation Core
    subgraph "Simulation Core"
        SE1["Scenario Engine (virne/base/scenario.py)"]:::sim
        SE2["Environment (virne/base/environment.py)"]:::sim
    end

    %% Data Layer
    subgraph "Data Layer"
        D1["Network Modeling (virne/data/network/)"]:::data
        DG["Dataset Generator (virne/data/generator.py)"]:::data
    end

    %% Solver Framework
    subgraph "Solver Framework"
        SR["Solver Registry (virne/solver/registry.py)"]:::solver
        SExact["Exact Solvers (virne/solver/exact/)"]:::exact
        SHeuristic["Heuristic Solvers (virne/solver/heuristic/)"]:::heuristic
        SMeta["Meta-Heuristic Solvers (virne/solver/meta_heuristic/)"]:::meta
        SLearning["Learning-Based Solvers (virne/solver/learning/)"]:::learning
    end

    %% Utilities
    subgraph "Utilities"
        U1["Utilities & Common Services (virne/utils)"]:::utils
    end

    %% Connections
    C1 -->|"triggers"| SE1
    C1 -->|"initiates"| DG

    SE1 -->|"executes"| SE2
    SE1 -->|"fetches network data from"| D1
    SE1 -->|"calls"| SR

    SR -->|"dispatches to"| SExact
    SR -->|"dispatches to"| SHeuristic
    SR -->|"dispatches to"| SMeta
    SR -->|"dispatches to"| SLearning

    SExact -.->|"accesses"| D1
    SHeuristic -.->|"accesses"| D1
    SMeta -.->|"accesses"| D1
    SLearning -.->|"accesses"| D1

    %% Utilities support (dashed lines)
    C1 -.->|"uses"| U1
    SE1 -.->|"uses"| U1
    D1 -.->|"uses"| U1
    SR -.->|"uses"| U1

    %% Styles
    classDef config fill:#FAD7A0,stroke:#D35400,stroke-width:2px,color:#000;
    classDef sim fill:#AED6F1,stroke:#2874A6,stroke-width:2px,color:#000;
    classDef data fill:#A9DFBF,stroke:#27AE60,stroke-width:2px,color:#000;
    classDef solver fill:#F9E79F,stroke:#B7950B,stroke-width:2px,color:#000;
    classDef utils fill:#F5B7B1,stroke:#C0392B,stroke-width:2px,color:#000;
    classDef exact fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px,color:#000;
    classDef heuristic fill:#D6EAF8,stroke:#3498DB,stroke-width:2px,color:#000;
    classDef meta fill:#D5F5E3,stroke:#28B463,stroke-width:2px,color:#000;
    classDef learning fill:#D0ECE7,stroke:#1ABC9C,stroke-width:2px,color:#000;

    %% Click Events
    click C1 "https://github.com/geminilight/virne/blob/main/main.py"
    click C2 "https://github.com/geminilight/virne/blob/main/virne/config.py"
    click C3 "https://github.com/geminilight/virne/tree/main/settings/"
    click SE1 "https://github.com/geminilight/virne/blob/main/virne/base/scenario.py"
    click SE2 "https://github.com/geminilight/virne/blob/main/virne/base/environment.py"
    click D1 "https://github.com/geminilight/virne/tree/main/virne/data/network/"
    click DG "https://github.com/geminilight/virne/blob/main/virne/data/generator.py"
    click SR "https://github.com/geminilight/virne/blob/main/virne/solver/registry.py"
    click SExact "https://github.com/geminilight/virne/tree/main/virne/solver/exact/"
    click SHeuristic "https://github.com/geminilight/virne/tree/main/virne/solver/heuristic/"
    click SMeta "https://github.com/geminilight/virne/tree/main/virne/solver/meta_heuristic/"
    click SLearning "https://github.com/geminilight/virne/tree/main/virne/solver/learning/"
    click U1 "https://github.com/geminilight/virne/tree/main/virne/utils"
```
