# adaptive-intelligent-robotics/qdax architecture

> Architecture diagram of the GitHub repository adaptive-intelligent-robotics/qdax, 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/adaptive-intelligent-robotics/qdax
- Repository: https://github.com/adaptive-intelligent-robotics/qdax

## Overview

##### Main Components

a) Core Components Layer:
- QD Algorithms Module (map_elites.py, mome.py, etc.)
- Neuroevolution Module (containing networks, buffers, losses)
- Emitters Module (various emitter implementations)
- Containers Module (different types of repertoires)

b) Baseline Algorithms Layer:
- Standard RL algorithms (SAC, TD3)
- Evolutionary algorithms (NSGA2, SPEA2)
- Diversity-driven algorithms (DIAYN, DADS)

c) Environment Layer:
- Brax environments
- Custom environments (pointmaze, humanoidtrap)
- Environment wrappers
- Behavior descriptor extractors

d) Tasks Layer:
- QD Suite tasks
- Standard benchmark functions
- Custom task implementations

e) Utils Layer:
- Metrics computation
- Plotting utilities
- Sampling methods
- Training utilities

##### Component Relationships

- Core Components → Tasks (algorithms use tasks for evaluation)
- Core Components → Environments (algorithms interact with environments)
- Baseline Algorithms → Environments (similar interaction)
- Utils → All Components (utility functions support all modules)
- Environments → Tasks (tasks utilize environments)

##### Implementation Details to Highlight

- Modular emitter system
- Repertoire management system
- Points of parallelization
- Integration with external libraries (Brax, JAX)

##### Key Features to Emphasize

- Hardware acceleration capabilities
- Massive parallelization points
- Flexibility in algorithm implementation
- Extensibility through modular design

##### Additional Elements

- Component types
- Special symbols used

Remember to highlight the system's unique selling points:
- Hardware acceleration capabilities
- Massive parallelization
- Flexibility and extensibility
- Rich algorithm ecosystem

This will create a comprehensive visualization that helps understand both the structure and the capabilities of the QDax framework.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Core Components"]
        QD["QD Algorithms"]:::core
        NE["Neuroevolution"]:::core
        EM["Emitters"]:::core
        CN["Containers"]:::core
    end

    subgraph Tasks["Tasks & Environments"]
        BE["Brax Environments"]:::tasks
        QS["QD Suite Tasks"]:::tasks
        CT["Custom Tasks"]:::tasks
        EW["Environment Wrappers"]:::tasks
    end

    subgraph Baselines["Baseline Algorithms"]
        RL["Standard RL<br/>SAC, TD3"]:::baselines
        EA["Evolutionary<br/>NSGA2, SPEA2"]:::baselines
        DM["Diversity Methods<br/>DADS, DIAYN"]:::baselines
    end

    subgraph Utils["Utilities"]
        MT["Metrics"]:::utils
        PL["Plotting"]:::utils
        SP["Sampling"]:::utils
        PF["Pareto Front"]:::utils
    end

    subgraph External["External Dependencies"]
        JAX["JAX"]:::external
        BRAX["Brax"]:::external
    end

    %% Core relationships
    QD --> BE
    QD --> QS
    QD --> CT
    NE --> QD
    EM --> QD
    CN --> QD

    %% Task relationships
    BE --> EW
    QS --> EW
    CT --> EW
    EW --> QD

    %% Baseline relationships
    RL --> EW
    EA --> EW
    DM --> EW

    %% Utils relationships
    MT --> QD
    PL --> QD
    SP --> QD
    PF --> QD

    %% External relationships
    JAX --> QD
    BRAX --> BE

    %% Click events
    click QD "https://github.com/adaptive-intelligent-robotics/QDax/blob/main/qdax/core/map_elites.py"
    click NE "https://github.com/adaptive-intelligent-robotics/QDax/tree/main/qdax/core/neuroevolution/"
    click EM "https://github.com/adaptive-intelligent-robotics/QDax/tree/main/qdax/core/emitters/"
    click CN "https://github.com/adaptive-intelligent-robotics/QDax/tree/main/qdax/core/containers/"
    click BE "https://github.com/adaptive-intelligent-robotics/QDax/blob/main/qdax/tasks/brax_envs.py"
    click QS "https://github.com/adaptive-intelligent-robotics/QDax/tree/main/qdax/tasks/qd_suite/"
    click CT "https://github.com/adaptive-intelligent-robotics/QDax/blob/main/qdax/tasks/arm.py"
    click EW "https://github.com/adaptive-intelligent-robotics/QDax/tree/main/qdax/environments/"
    click RL "https://github.com/adaptive-intelligent-robotics/QDax/blob/main/qdax/baselines/sac.py"
    click EA "https://github.com/adaptive-intelligent-robotics/QDax/blob/main/qdax/baselines/nsga2.py"
    click DM "https://github.com/adaptive-intelligent-robotics/QDax/blob/main/qdax/baselines/dads.py"
    click MT "https://github.com/adaptive-intelligent-robotics/QDax/blob/main/qdax/utils/metrics.py"
    click PL "https://github.com/adaptive-intelligent-robotics/QDax/blob/main/qdax/utils/plotting.py"
    click SP "https://github.com/adaptive-intelligent-robotics/QDax/blob/main/qdax/utils/sampling.py"
    click PF "https://github.com/adaptive-intelligent-robotics/QDax/blob/main/qdax/utils/pareto_front.py"

    %% Styling
    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef tasks fill:#57a773,stroke:#57a773,color:#fff
    classDef baselines fill:#ff8c42,stroke:#ff8c42,color:#fff
    classDef utils fill:#808080,stroke:#808080,color:#fff
    classDef external fill:#6c4b7b,stroke:#6c4b7b,color:#fff

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Tasks & Environments"]:::tasks
        L3["Baseline Algorithms"]:::baselines
        L4["Utilities"]:::utils
        L5["External Dependencies"]:::external
    end
```
