# pedrovic12/repopulation-with-elite-set architecture

> Architecture diagram of the GitHub repository pedrovic12/repopulation-with-elite-set, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pedrovic12/repopulation-with-elite-set
- Repository: https://github.com/pedrovic12/repopulation-with-elite-set

## Overview

##### Project Type and Purpose
- The project is a research-oriented framework that combines an evolutionary algorithm (using DEAP) with a power system simulation engine (Pandapower). It is applied to solve power grid scheduling issues (such as the IEEE14 network) and includes a “Repopulation with Elite Set” strategy.

##### Analyzing the File Structure
- Several top-level areas can be distinguished:
- The PANDA_POWER folder that encompasses the primary simulation codes, embedded system integrations (Arduino, Python scripts, and notebooks), and the Pandapower-based electric network simulation logic.
- The “app” directory includes components for the evolutionary algorithm (AlgEvolutivoRCE) and the electric grid module (RedeEletrica) with templates for dashboards and multiple main scripts.
- The “evolution_rce_master” directory is extensive, covering notebooks, backend scripts, database files, frontend (both Dash and React) and models. It suggests an evolution or extended version of the base methodology and indicates a separation between experimental code (notebooks), backend processing, front-end visualization, and even some database management.
- Support files like JSON parameter configuration (parameters.json), Excel outputs, and scripts for PDF generation or additional data visualizations indicate integration points between simulation, data capture, and reporting.

##### Key Components to Highlight
a. Core Evolutionary Algorithm Engine:
- Components for setting up the evolutionary process: “Setup”, “AlgoritimoEvolutivoRCE”, and “DataExploration”.
- Workflow: receiving decision variables, applying the fitness function (which in this case often involves simulation via a Pandapower network), and generating evolved populations.

b. Electric Network Simulation Module:
- “RedeEletricaPandaPower” class and its integration with Pandapower.
- Components such as network loading, scenario evaluation, load flow computations (e.g., using the Newton-Raphson method), and fitness violation calculations.
- Point out how this module interacts with the evolutionary algorithm (i.e., it serves as the evaluation engine for the objective function).

c. Dashboard & Visualization Layer:
- Dashboards (built with Dash and templates in the “app/templates” folder) that showcase results from the evolutionary algorithm.
- Front-end compilation details from “evolution_rce_master/src/front_end” (noting that there is a React-based client and additional Dash servers).
- How visualization components allow users to interact with both simulation results and parameter configurations.

d. Embedded Systems & Microcontroller Integration:
- “embbed_systems” folder components (Arduino sketches, Python integrations, and C++ servers) that suggest hardware interfacing.
- Separate “circuito_RC” for Arduino code which likely handles the hardware-level operations.

e. Data Storage and I/O:
- Notebooks and PDF generation files that handle exploratory data analysis and reporting.

##### Architectural Patterns & Design Principles
- A different one for simulation (RedeEletricaPandaPower, pandapower calls).
- A separate style for front-end/dashboard components.
- And a unique symbol for hardware/embedded systems.
- Usage of abstraction in the simulation module — encapsulating detailed electric network analysis methods and their interplay with the objective function evaluation.
- Integration of data analytics elements (notebooks) and configuration management (parameters.json and Excel/DB files).

##### Specific Elements
- “Evolutionary Algorithm (DEAP Framework)”
- “Electric Network Simulator (Pandapower & RedeEletricaPandaPower)”
- “Dashboard & Visualization (Dash, Streamlit, React Frontend)”
- “Embedded Systems / Hardware Integration (Arduino, C++ Server, Python Scripts)”
- “Data I/O and Persistence (JSON, Excel, SQLite DB)”

## Diagram (Mermaid)

```mermaid
flowchart TB

    %% Dashboard & Visualization Layer
    subgraph "Dashboard & Visualization"
        DT["Dashboard Template"]:::dash
        RC["React Client"]:::dash
        DS["Dash Server"]:::dash
    end

    %% Evolutionary Algorithm Engine
    subgraph "Evolutionary Algorithm Engine"
        EASetup["Setup"]:::evo
        EAEngine["AlgEvolutivoRCE"]:::evo
        EAAlgo["AlgoritimoEvolutivoRCE"]:::evo
    end

    %% Electric Network Simulation Module
    subgraph "Electric Network Simulation Module"
        Sim1["RedeEletricaPandaPower (PandaPower)"]:::sim
        Sim2["RedeEletrica Adapter"]:::sim
    end

    %% Data I/O & Persistence
    subgraph "Data I/O & Persistence"
        Config["Configuration (parameters.json)"]:::data
        Excel["Excel Outputs"]:::data
        DBMgr["Database Manager"]:::data
        DBFile["SQLite Database"]:::data
    end

    %% Embedded Systems & Hardware Integration
    subgraph "Embedded Systems & Hardware Integration"
        EmbSys["Embedded Systems Integration"]:::embed
        Circuito["Arduino Sketches"]:::embed
        CppServer["C++ Server"]:::embed
    end

    %% Relationships and Data Flows
    DS -->|"triggers"| EAEngine
    EASetup --> EAEngine
    EAEngine --> EAAlgo

    EAEngine -->|"calls simulation"| Sim1
    Sim2 -->|"returns fitness"| EAEngine

    EAEngine -->|"saves results"| DBMgr
    EAEngine -->|"exports data"| Excel
    Config -->|"loads configuration"| EAEngine

    DS ---|"updates UI"| RC
    RC ---|"displays outcome"| DT

    EmbSys -->|"interfaces hardware"| Sim1
    Circuito --> EmbSys
    CppServer --> EmbSys

    %% Classes for styling
    classDef evo fill:#D1E8E2,stroke:#333,stroke-width:2px;
    classDef sim fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef dash fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef embed fill:#F5B7B1,stroke:#333,stroke-width:2px;
    classDef data fill:#D7BDE2,stroke:#333,stroke-width:2px;

    %% Click Events for Evolutionary Algorithm Engine components
    click EASetup "https://github.com/pedrovic12/repopulation-with-elite-set/blob/main/app/AlgEvolutivoRCE/Setup.py"
    click EAEngine "https://github.com/pedrovic12/repopulation-with-elite-set/blob/main/app/AlgEvolutivoRCE/alg_evolutivo_rce.py"
    click EAAlgo "https://github.com/pedrovic12/repopulation-with-elite-set/blob/main/evolution_rce_master/src/models/AlgoritimoEvolutivoRCE.py"

    %% Click Events for Electric Network Simulation Module components
    click Sim1 "https://github.com/pedrovic12/repopulation-with-elite-set/blob/main/PANDA_POWER/src/RedeEletrica.py"
    click Sim2 "https://github.com/pedrovic12/repopulation-with-elite-set/blob/main/app/RedeEletrica/rede_eletrica.py"

    %% Click Events for Dashboard & Visualization components
    click DT "https://github.com/pedrovic12/repopulation-with-elite-set/tree/main/app/templates"
    click RC "https://github.com/pedrovic12/repopulation-with-elite-set/tree/main/evolution_rce_master/src/front_end/client"
    click DS "https://github.com/pedrovic12/repopulation-with-elite-set/blob/main/evolution_rce_master/src/front_end/dash_server.py"

    %% Click Events for Embedded Systems & Hardware Integration components
    click EmbSys "https://github.com/pedrovic12/repopulation-with-elite-set/tree/main/PANDA_POWER/embbed_systems"
    click Circuito "https://github.com/pedrovic12/repopulation-with-elite-set/tree/main/PANDA_POWER/circuito_RC"
    click CppServer "https://github.com/pedrovic12/repopulation-with-elite-set/blob/main/PANDA_POWER/embbed_systems/server_arduino.cpp"

    %% Click Events for Data I/O & Persistence components
    click Config "https://github.com/pedrovic12/repopulation-with-elite-set/blob/main/evolution_rce_master/src/db/parameters.json"
    click Excel "https://github.com/pedrovic12/repopulation-with-elite-set/tree/main/evolution_rce_master/src/assets/output"
    click DBMgr "https://github.com/pedrovic12/repopulation-with-elite-set/blob/main/evolution_rce_master/src/db/database_manager.py"
    click DBFile "https://github.com/pedrovic12/repopulation-with-elite-set/blob/main/evolution_rce_master/src/db/rce_database.db"
```
