# templierpaul/qdax_es architecture

> Architecture diagram of the GitHub repository templierpaul/qdax_es, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/templierpaul/qdax_es
- Repository: https://github.com/templierpaul/qdax_es

## Overview

##### High-Level Components

a) Core Framework Layer:
- Core containers and emitters as sub-components

b) Algorithm Layer:
- This above the core layer
- Implemented algorithms (JEDi, ES, MEES, CMAME)
- Connections to their respective emitters

c) Environment Integration Layer:
- This on the right side
- Brax and Kheperax integration points
- To the core framework

d) Configuration & Pipeline Layer:
- This on the left side
- Hydra configuration system
- Weights & Biases (W&B) integration

##### Component Relationships

a) Data Flow:
- Configuration → Core Framework
- Core Framework → Environments
- Emitters → Containers
- Algorithms → Emitters

b) Dependencies:

##### Specific Implementation Details

Key architectural elements:

a) Core Components:
**Containers/**
- Count Repertoire
- GP Repertoire
- MAE Repertoire
- Novelty Archive

**Emitters/**
- CMA-ME
- JEDi
- MEES
- Base Emitter

b) Factory Pattern:
- Factories (cmame.py, es.py, jedi.py, etc.) as intermediaries
- Them to their respective algorithms

##### Important Notes

- Modular nature of the emitter system
- Extensibility points for new algorithms
- Configuration system's role in experiment management
- Integration points with external libraries (Evosax, Brax, Kheperax)

##### Technical Details

- Python-based implementation
- Hydra configuration management
- W&B integration for experiment tracking
- Support for various environment types
- Multiple algorithm implementations

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Configuration["Configuration & Pipeline Layer"]
        direction TB
        HC["Hydra Config"]:::config
        WB["Weights & Biases"]:::config
        MC["Main Config"]:::config
        TC["Task Configs"]:::config
    end

    subgraph Algorithms["Algorithm Layer"]
        direction TB
        CMAME["CMA-ME"]:::algo
        JEDI["JEDi"]:::algo
        ES["ES"]:::algo
        MEES["MEES"]:::algo
        PGAME["PGA-ME"]:::algo
    end

    subgraph Core["Core Framework Layer"]
        direction TB
        subgraph Containers["Containers"]
            direction TB
            CR["Count Repertoire"]:::core
            GPR["GP Repertoire"]:::core
            MAER["MAE Repertoire"]:::core
            NA["Novelty Archive"]:::core
        end

        subgraph Emitters["Emitters"]
            direction TB
            BE["Base ES Emitter"]:::core
            CME["CMA-ME Emitter\n(extends Base ES)"]:::core
            JE["JEDi Emitter\n(extends Base ES)"]:::core
            MEE["MEES Emitter\n(extends Base ES)"]:::core
        end

        subgraph Factories["Algorithm Factories"]
            direction TB
            CMF["CMA-ME Factory"]:::factory
            ESF["ES Factory"]:::factory
            JF["JEDi Factory"]:::factory
            MEF["ME Factory"]:::factory
            PGF["PGA-ME Factory"]:::factory
        end
    end

    BE --> CME
    BE --> JE
    BE --> MEE

    subgraph Environment["Environment Integration Layer"]
        direction TB
        EM["Environment Module"]:::env
        EC["Environment Configs"]:::env
        BD["Behavior Descriptors"]:::env
    end

    subgraph Utils["Utilities"]
        direction TB
        PU["Plotting Utils"]:::util
        GP["Gaussian Process"]:::util
        EI["Evosax Interface"]:::util
    end

    %% Relationships
    HC --> MC
    MC --> Core
    TC --> Environment
    WB --> Core

    CMAME --> CMF
    JEDI --> JF
    ES --> ESF
    MEES --> MEF
    PGAME --> PGF

    CMF --> CME
    JF --> JE
    ESF --> BE
    MEF --> MEE

    Emitters --> Containers
    Core --> Environment
    Environment --> Utils

    %% Click Events
    click CR "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/core/containers/count_repertoire.py"
    click GPR "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/core/containers/gp_repertoire.py"
    click MAER "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/core/containers/mae_repertoire.py"
    click NA "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/core/containers/novelty_archive.py"
    click BE "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/core/emitters/evosax_base_emitter.py"
    click CME "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/core/emitters/cma_me_emitter.py"
    click JE "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/core/emitters/jedi_emitter.py"
    click MEE "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/core/emitters/mees_emitter.py"
    click CMF "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/factories/cmame.py"
    click ESF "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/factories/es.py"
    click JF "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/factories/jedi.py"
    click MEF "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/factories/me.py"
    click PGF "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/factories/pga_me.py"
    click MC "https://github.com/TemplierPaul/QDax_ES/blob/main/configs/config.yaml"
    click EM "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/environments/__init__.py"
    click EC "https://github.com/TemplierPaul/QDax_ES/tree/main/configs/task"
    click BD "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/utils/env_bd.py"
    click PU "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/utils/plotting.py"
    click GP "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/utils/gaussian_process.py"
    click EI "https://github.com/TemplierPaul/QDax_ES/blob/main/qdax_es/utils/evosax_interface.py"

    %% Styling
    classDef core fill:#2374ab
    classDef algo fill:#7a306c
    classDef env fill:#28a745
    classDef config fill:#ffa62b
    classDef factory fill:#636363
    classDef util fill:#6c757d
```
