# rsoumyadeep/activerl_validation architecture

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

- Interactive diagram: https://gitdiagram.com/rsoumyadeep/activerl_validation
- Repository: https://github.com/rsoumyadeep/activerl_validation

## Overview

1. **Project role and overall shape**
   - This is a Python research repo for validating ActiveRL sample-complexity theory.
   - The architecture is organized as a pipeline: **collect trajectories in an environment → estimate uncertainty/information gain → compute theoretical curves/bounds → compare against offline RL performance → generate plots/tables**.

2. **Experiment drivers are the orchestration entry points**
   - The `experiments/` directory contains separate scripts for each study:
     - scaling laws
     - variance vs. information gain
     - discount-factor ablation
     - GP vs. ensemble comparison
     - coverage ablation
   - These scripts likely coordinate the full workflow for each paper figure/result, rather than containing core logic themselves.

3. **Active data collection is one core subsystem**
   - `src/active_collection/` contains the machinery for gathering data under an exploration strategy:
     - `initial_state_selector.py` chooses starting states or reset conditions
     - `exploration_policy.py` defines how the agent explores
     - `trajectory_collector.py` executes rollouts and records trajectories
   - This subsystem is the bridge between the environment and the rest of the analysis pipeline.

4. **Environment adapters isolate the collection code from raw env details**
   - `src/envs/wrappers.py` suggests a boundary layer that normalizes environment behavior for the experiments.
   - This likely handles state/action formatting, episode bookkeeping, or other environment-specific adjustments so the rest of the system can stay environment-agnostic.

5. **Uncertainty estimation is a second major subsystem**
   - `src/uncertainty/` provides two alternative uncertainty models:
     - `ensemble.py` for ensemble-based uncertainty
     - `gp_proxy.py` for a Gaussian-process-style proxy
     - `metrics.py` for derived uncertainty statistics
   - This layer turns collected experience into uncertainty signals used by theory validation and comparison experiments.

6. **Theory and prediction logic are kept separate from data collection**
   - `src/theory/` contains the mathematical side of the project:
     - `bounds.py` for sample-complexity or performance bounds
     - `information_gain.py` for theoretical information-gain calculations
     - `complexity_curve.py` for predicted scaling behavior
   - This separation makes the theory layer reusable across experiments and easy to compare against empirical results.

7. **Offline RL baseline is isolated as its own module**
   - `src/offline_rl/td3bc.py` implements TD3+BC, the offline RL baseline used for evaluation.
   - This is the main downstream consumer of collected data: trajectories produced by the active collection subsystem are used to train or evaluate the baseline.

8. **Analysis is split from experiment execution**
   - The `analysis/` directory contains post-processing scripts:
     - `plot_scaling.py`
     - `plot_variance_sum.py`
     - `tables.py`
   - These scripts consume experiment outputs and theory values to produce publication-style figures and tables, keeping visualization out of the core logic.

9. **Configuration is centralized**
   - `config/defaults.yaml` appears to hold default experiment and model settings.
   - This suggests the repo is meant to support repeated controlled runs across multiple ablations, with configuration driving behavior instead of hard-coded values.

10. **Tests focus on the mathematical and uncertainty core**
   - `tests/test_bounds.py`, `tests/test_ensemble.py`, and `tests/test_gp_proxy.py` indicate that correctness checks are concentrated around the theoretical and uncertainty-estimation components.
   - That fits the repo’s purpose: the most critical risk is not UI or integration, but whether the underlying theory and proxies are implemented correctly.

11. **Likely data flow across the repository**
   - A typical run seems to move through these boundaries:
     - environment wrapper sets up the task
     - active collection gathers trajectories using an exploration policy
     - uncertainty module computes ensemble/GP-based statistics
     - theory module computes bounds or complexity predictions
     - offline RL module provides empirical performance baselines
     - analysis scripts compare the two and render plots/tables

12. **Architectural takeaway**
   - The repo is organized as a **research validation stack** with clear separation between:
     - **interaction/data collection**
     - **uncertainty estimation**
     - **theory computation**
     - **baseline RL training**
     - **analysis/reporting**
   - That structure is well suited for reproducible experiments and for swapping uncertainty estimators or theoretical assumptions without rewriting the whole pipeline.

Main entry points: [`src/active_collection/trajectory_collector.py`](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/active_collection/trajectory_collector.py) (Trajectory collector), [`experiments/exp1_scaling.py`](https://github.com/rsoumyadeep/activerl_validation/blob/main/experiments/exp1_scaling.py) (Scaling study), [`src/theory/bounds.py`](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/theory/bounds.py) (Bounds), [`src/uncertainty/ensemble.py`](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/uncertainty/ensemble.py) (Ensemble)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_experiments["Experiments"]
  node_node_exp_scaling["Scaling study<br/>experiment driver<br/>[exp1_scaling.py]"]
  node_node_exp_variance["Variance study<br/>experiment driver"]
  node_node_exp_discount["Discount ablation<br/>experiment driver"]
  node_node_exp_gp_ens["GP vs ensemble<br/>experiment driver"]
  node_node_exp_coverage["Coverage ablation<br/>experiment driver"]
end

subgraph group_group_core["Core pipeline"]
  node_node_env_wrappers["Env wrappers<br/>environment adapter<br/>[wrappers.py]"]
  node_node_initial_state(("State selector<br/>collection component"))
  node_node_exploration_policy(("Exploration policy<br/>collection component"))
  node_node_trajectory_collector[("Trajectory collector")]
  node_node_ensemble{{"Ensemble<br/>uncertainty model<br/>[ensemble.py]"}}
  node_node_gp_proxy{{"GP proxy<br/>uncertainty model<br/>[gp_proxy.py]"}}
  node_node_uncertainty_metrics(("Uncertainty metrics<br/>feature extraction<br/>[metrics.py]"))
  node_node_bounds["Bounds<br/>theory module<br/>[bounds.py]"]
  node_node_information_gain["Info gain<br/>theory module"]
  node_node_complexity_curve["Scaling curve<br/>theory module"]
  node_node_td3bc["TD3+BC<br/>offline RL baseline<br/>[td3bc.py]"]
end

subgraph group_group_analysis["Analysis"]
  node_node_plot_scaling["Scaling plots<br/>analysis script<br/>[plot_scaling.py]"]
  node_node_plot_variance["Variance plots<br/>analysis script"]
  node_node_tables["Result tables<br/>analysis script<br/>[tables.py]"]
end

subgraph group_group_support["Support"]
  node_node_defaults["Defaults<br/>configuration<br/>[defaults.yaml]"]
  node_node_tests["Core tests<br/>validation"]
end

node_node_exp_scaling -->|"uses"| node_node_env_wrappers
node_node_exp_scaling -->|"orchestrates"| node_node_trajectory_collector
node_node_exp_scaling -->|"evaluates"| node_node_bounds
node_node_exp_scaling -->|"predicts"| node_node_complexity_curve
node_node_exp_variance -->|"uses"| node_node_ensemble
node_node_exp_variance -->|"compares"| node_node_information_gain
node_node_exp_discount -->|"evaluates"| node_node_td3bc
node_node_exp_gp_ens -->|"compares"| node_node_gp_proxy
node_node_exp_gp_ens -->|"compares"| node_node_ensemble
node_node_exp_coverage -->|"orchestrates"| node_node_trajectory_collector
node_node_env_wrappers -->|"supports"| node_node_initial_state
node_node_initial_state -->|"feeds"| node_node_exploration_policy
node_node_exploration_policy -->|"drives"| node_node_trajectory_collector
node_node_trajectory_collector -->|"feeds"| node_node_ensemble
node_node_trajectory_collector -->|"feeds"| node_node_gp_proxy
node_node_ensemble -->|"summarizes"| node_node_uncertainty_metrics
node_node_gp_proxy -->|"summarizes"| node_node_uncertainty_metrics
node_node_uncertainty_metrics -->|"informs"| node_node_information_gain
node_node_information_gain -->|"supports"| node_node_bounds
node_node_bounds -->|"constrains"| node_node_complexity_curve
node_node_trajectory_collector -->|"trains"| node_node_td3bc
node_node_td3bc -->|"reports"| node_node_tables
node_node_bounds -->|"visualized by"| node_node_plot_scaling
node_node_uncertainty_metrics -->|"visualized by"| node_node_plot_variance
node_node_plot_scaling -->|"complements"| node_node_tables
node_node_defaults -->|"configures"| node_node_exp_scaling
node_node_defaults -->|"configures"| node_node_exp_variance
node_node_defaults -->|"configures"| node_node_exp_gp_ens
node_node_tests -->|"covers"| node_node_bounds
node_node_tests -->|"covers"| node_node_ensemble
node_node_tests -->|"covers"| node_node_gp_proxy

click node_node_exp_scaling "https://github.com/rsoumyadeep/activerl_validation/blob/main/experiments/exp1_scaling.py"
click node_node_exp_variance "https://github.com/rsoumyadeep/activerl_validation/blob/main/experiments/exp2_variance_sum.py"
click node_node_exp_discount "https://github.com/rsoumyadeep/activerl_validation/blob/main/experiments/exp3_discount_ablation.py"
click node_node_exp_gp_ens "https://github.com/rsoumyadeep/activerl_validation/blob/main/experiments/exp4_gp_vs_ensemble.py"
click node_node_exp_coverage "https://github.com/rsoumyadeep/activerl_validation/blob/main/experiments/exp5_coverage_ablation.py"
click node_node_env_wrappers "https://github.com/rsoumyadeep/activerl_validation/blob/main/src/envs/wrappers.py"
click node_node_initial_state "https://github.com/rsoumyadeep/activerl_validation/blob/main/src/active_collection/initial_state_selector.py"
click node_node_exploration_policy "https://github.com/rsoumyadeep/activerl_validation/blob/main/src/active_collection/exploration_policy.py"
click node_node_trajectory_collector "https://github.com/rsoumyadeep/activerl_validation/blob/main/src/active_collection/trajectory_collector.py"
click node_node_ensemble "https://github.com/rsoumyadeep/activerl_validation/blob/main/src/uncertainty/ensemble.py"
click node_node_gp_proxy "https://github.com/rsoumyadeep/activerl_validation/blob/main/src/uncertainty/gp_proxy.py"
click node_node_uncertainty_metrics "https://github.com/rsoumyadeep/activerl_validation/blob/main/src/uncertainty/metrics.py"
click node_node_bounds "https://github.com/rsoumyadeep/activerl_validation/blob/main/src/theory/bounds.py"
click node_node_information_gain "https://github.com/rsoumyadeep/activerl_validation/blob/main/src/theory/information_gain.py"
click node_node_complexity_curve "https://github.com/rsoumyadeep/activerl_validation/blob/main/src/theory/complexity_curve.py"
click node_node_td3bc "https://github.com/rsoumyadeep/activerl_validation/blob/main/src/offline_rl/td3bc.py"
click node_node_plot_scaling "https://github.com/rsoumyadeep/activerl_validation/blob/main/analysis/plot_scaling.py"
click node_node_plot_variance "https://github.com/rsoumyadeep/activerl_validation/blob/main/analysis/plot_variance_sum.py"
click node_node_tables "https://github.com/rsoumyadeep/activerl_validation/blob/main/analysis/tables.py"
click node_node_defaults "https://github.com/rsoumyadeep/activerl_validation/blob/main/config/defaults.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_exp_scaling,node_node_exp_variance,node_node_exp_discount,node_node_exp_gp_ens,node_node_exp_coverage toneBlue
class node_node_env_wrappers,node_node_initial_state,node_node_exploration_policy,node_node_trajectory_collector,node_node_ensemble,node_node_gp_proxy,node_node_uncertainty_metrics,node_node_bounds,node_node_information_gain,node_node_complexity_curve,node_node_td3bc toneAmber
class node_node_plot_scaling,node_node_plot_variance,node_node_tables toneMint
class node_node_defaults,node_node_tests toneRose
```

## Components

### Experiments

Study drivers that orchestrate end-to-end runs for different ablations and comparisons.

- [Scaling study](https://github.com/rsoumyadeep/activerl_validation/blob/main/experiments/exp1_scaling.py): experiment driver · Coordinates the scaling-law validation run. · `experiments/exp1_scaling.py`
- [Variance study](https://github.com/rsoumyadeep/activerl_validation/blob/main/experiments/exp2_variance_sum.py): experiment driver · Drives the variance versus information-gain experiment. · `experiments/exp2_variance_sum.py`
- [Discount ablation](https://github.com/rsoumyadeep/activerl_validation/blob/main/experiments/exp3_discount_ablation.py): experiment driver · Runs discount-factor ablation experiments. · `experiments/exp3_discount_ablation.py`
- [GP vs ensemble](https://github.com/rsoumyadeep/activerl_validation/blob/main/experiments/exp4_gp_vs_ensemble.py): experiment driver · Compares Gaussian-process proxy and ensemble uncertainty. · `experiments/exp4_gp_vs_ensemble.py`
- [Coverage ablation](https://github.com/rsoumyadeep/activerl_validation/blob/main/experiments/exp5_coverage_ablation.py): experiment driver · Runs coverage-focused ablation experiments. · `experiments/exp5_coverage_ablation.py`

### Core pipeline

Main source modules for interaction, uncertainty, theory, and offline RL.

- [Env wrappers](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/envs/wrappers.py): environment adapter · Normalizes environment behavior for data collection and experiments. · `src/envs/wrappers.py`
- [State selector](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/active_collection/initial_state_selector.py): collection component · Chooses initial states or reset conditions for rollouts. · `src/active_collection/initial_state_selector.py`
- [Exploration policy](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/active_collection/exploration_policy.py): collection component · Defines how the agent explores during active data collection. · `src/active_collection/exploration_policy.py`
- [Trajectory collector](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/active_collection/trajectory_collector.py): collector · Executes rollouts and records trajectories from the environment. · `src/active_collection/trajectory_collector.py`
- [Ensemble](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/uncertainty/ensemble.py): uncertainty model · Computes ensemble-based uncertainty estimates. · `src/uncertainty/ensemble.py`
- [GP proxy](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/uncertainty/gp_proxy.py): uncertainty model · Provides a Gaussian-process-style uncertainty proxy. · `src/uncertainty/gp_proxy.py`
- [Uncertainty metrics](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/uncertainty/metrics.py): feature extraction · Derives summary statistics from uncertainty signals. · `src/uncertainty/metrics.py`
- [Bounds](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/theory/bounds.py): theory module · Implements sample-complexity and performance bounds. · `src/theory/bounds.py`
- [Info gain](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/theory/information_gain.py): theory module · Computes theoretical information-gain quantities. · `src/theory/information_gain.py`
- [Scaling curve](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/theory/complexity_curve.py): theory module · Produces predicted complexity or scaling behavior. · `src/theory/complexity_curve.py`
- [TD3+BC](https://github.com/rsoumyadeep/activerl_validation/blob/main/src/offline_rl/td3bc.py): offline RL baseline · Offline RL baseline used to evaluate empirical performance. · `src/offline_rl/td3bc.py`

### Analysis

Post-processing scripts that turn experiment outputs into plots and tables.

- [Scaling plots](https://github.com/rsoumyadeep/activerl_validation/blob/main/analysis/plot_scaling.py): analysis script · Generates figures for scaling-law results. · `analysis/plot_scaling.py`
- [Variance plots](https://github.com/rsoumyadeep/activerl_validation/blob/main/analysis/plot_variance_sum.py): analysis script · Generates variance-sum comparison plots. · `analysis/plot_variance_sum.py`
- [Result tables](https://github.com/rsoumyadeep/activerl_validation/blob/main/analysis/tables.py): analysis script · Builds publication-style tables from experiment outputs. · `analysis/tables.py`

### Support

Central configuration and validation coverage for the research stack.

- [Defaults](https://github.com/rsoumyadeep/activerl_validation/blob/main/config/defaults.yaml): configuration · Central default settings for experiments and models. · `config/defaults.yaml`
- **Core tests**: validation · Covers bounds and uncertainty estimators.

## Connections

- Scaling study → Env wrappers: uses · Scaling runs start from normalized environments.
- Scaling study → Trajectory collector: orchestrates · Coordinates active data collection for the study.
- Scaling study → Bounds: evaluates · Compares empirical results with theoretical bounds.
- Scaling study → Scaling curve: predicts · Uses predicted scaling behavior for comparison.
- Variance study → Ensemble: uses · Variance study consumes ensemble uncertainty.
- Variance study → Info gain: compares · Checks variance against theoretical information gain.
- Discount ablation → TD3+BC: evaluates · Tests downstream offline RL performance under different discounts.
- GP vs ensemble → GP proxy: compares · Benchmarks the GP proxy against the ensemble model.
- GP vs ensemble → Ensemble: compares · Benchmarks the ensemble against the GP proxy.
- Coverage ablation → Trajectory collector: orchestrates · Runs collection under coverage variations.
- Env wrappers → State selector: supports · Provides standardized environment resets for initial-state selection.
- State selector → Exploration policy: feeds · Selected starts shape the exploration rollout policy.
- Exploration policy → Trajectory collector: drives · Policy determines how trajectories are gathered.
- Trajectory collector → Ensemble: feeds · Collected trajectories provide data for ensemble uncertainty.
- Trajectory collector → GP proxy: feeds · Collected trajectories provide data for GP-style uncertainty.
- Ensemble → Uncertainty metrics: summarizes · Ensemble outputs are reduced to metrics.
- GP proxy → Uncertainty metrics: summarizes · GP proxy outputs are reduced to metrics.
- Uncertainty metrics → Info gain: informs · Empirical uncertainty metrics are compared to information-gain theory.
- Info gain → Bounds: supports · Information-gain calculations underpin bound derivations.
- Bounds → Scaling curve: constrains · Bounds shape predicted scaling curves.
- Trajectory collector → TD3+BC: trains · Collected data is reused by the offline RL baseline.
- TD3+BC → Result tables: reports · Baseline outcomes are summarized in tables.
- Bounds → Scaling plots: visualized by · Bound results are turned into scaling plots.
- Uncertainty metrics → Variance plots: visualized by · Variance summaries are turned into plots.
- Scaling plots → Result tables: complements · Plots and tables are produced from the same experiment outputs.
- Defaults → Scaling study: configures · Default settings parameterize experiment execution.
- Defaults → Variance study: configures · Default settings parameterize experiment execution.
- Defaults → GP vs ensemble: configures · Default settings parameterize experiment execution.
- Core tests → Bounds: covers · Tests validate the theory implementation.
- Core tests → Ensemble: covers · Tests validate the ensemble uncertainty implementation.
- Core tests → GP proxy: covers · Tests validate the GP proxy implementation.
