# vermouth1992/mbrl-hvac architecture

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

- Interactive diagram: https://gitdiagram.com/vermouth1992/mbrl-hvac
- Repository: https://github.com/vermouth1992/mbrl-hvac

## Overview

- Environment → Agent (State information)
- Agent → Environment (Control actions)
- Model → Agent (Predictions)
- Environment → Dataset (Training data collection)

- Training Systems → Agent (Training signals)
- Agent → Model (Model updates)

##### Detailed Subcomponents

a. Environment Layer:
- EnergyPlus Integration
- Gym Wrapper
- Environment Models
- 2ZoneDataCenterHVAC Base
- Temperature Control
- Fan Control
- IO Handling

b. Agent Layer:
- Agent Framework
- Model-based Components
- World Model
- Planner
- Policy
- Policy Gradient Components
- A2C
- PPO
- PID Controller

##### Technical Details

- City configuration options (SF, Golden, Chicago, Sterling)
- MPC horizon settings
- Training parameters
- Data flow between components

##### Important Notes

- Version information for critical components (e.g., EnergyPlus 9.1.0)
- Data collection flow to the 'runs' folder
- Log file generation paths
- Configuration points for different cities and training modes

Remember to include a small section showing the file structure organization, particularly highlighting the relationship between the agent, gym_energyplus, and torchlib directories, as these form the core of the implementation.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Training["Training Systems"]
        direction TB
        PID["PID Controller Training"]:::training
        PPO["PPO Training"]:::training
        MBT["Model-based Training"]:::training
    end

    subgraph Core["Core Components"]
        direction TB
        EP["EnergyPlus Simulation"]:::core
        GYM["Gym Environment Wrapper"]:::core
        AF["Agent Framework"]:::core
        MF["Model Framework"]:::core
        DRL["Deep RL Algorithm Suite"]:::core
    end

    subgraph EnvModels["Environment Models"]
        direction TB
        Base["2ZoneDataCenterHVAC Base"]:::env
        Temp["Temperature Control"]:::env
        Fan["Fan Control"]:::env
    end

    subgraph AgentLayer["Agent Components"]
        direction TB
        WM["World Model"]:::agent
        PL["Planner"]:::agent
        POL["Policy"]:::agent
        A2C["A2C"]:::agent
        PPOC["PPO Component"]:::agent
        PIDC["PID Controller"]:::agent
    end

    subgraph Support["Supporting Libraries"]
        direction TB
        DH["Dataset Handlers"]:::support
        US["Utility Services"]:::support
        RB["Replay Buffer"]:::support
    end

    %% Relationships
    EP --> GYM
    GYM --> AF
    AF --> MF
    MF --> DRL

    EnvModels --> GYM
    AgentLayer --> AF

    PID --> AF
    PPO --> AF
    MBT --> AF

    AF --> Support
    MF --> Support

    %% Click Events
    click EP "https://github.com/vermouth1992/mbrl-hvac/tree/master/EnergyPlus/Model/"
    click GYM "https://github.com/vermouth1992/mbrl-hvac/blob/master/gym_energyplus/envs/energyplus_env.py"
    click AF "https://github.com/vermouth1992/mbrl-hvac/blob/master/agent/agent.py"
    click MF "https://github.com/vermouth1992/mbrl-hvac/tree/master/torchlib/deep_rl/models/"
    click DRL "https://github.com/vermouth1992/mbrl-hvac/tree/master/torchlib/deep_rl/algorithm/"
    click Base "https://github.com/vermouth1992/mbrl-hvac/blob/master/gym_energyplus/envs/energyplus_model_2ZoneDataCenterHVAC_wEconomizer.py"
    click Temp "https://github.com/vermouth1992/mbrl-hvac/blob/master/gym_energyplus/envs/energyplus_model_2ZoneDataCenterHVAC_wEconomizer_Temp.py"
    click Fan "https://github.com/vermouth1992/mbrl-hvac/blob/master/gym_energyplus/envs/energyplus_model_2ZoneDataCenterHVAC_wEconomizer_Temp_Fan.py"
    click WM "https://github.com/vermouth1992/mbrl-hvac/blob/master/torchlib/deep_rl/algorithm/model_based/world_model.py"
    click PL "https://github.com/vermouth1992/mbrl-hvac/blob/master/agent/planner.py"
    click POL "https://github.com/vermouth1992/mbrl-hvac/blob/master/torchlib/deep_rl/models/policy.py"
    click A2C "https://github.com/vermouth1992/mbrl-hvac/blob/master/torchlib/deep_rl/algorithm/policy_gradient/a2c.py"
    click PPOC "https://github.com/vermouth1992/mbrl-hvac/blob/master/torchlib/deep_rl/algorithm/policy_gradient/ppo.py"
    click DH "https://github.com/vermouth1992/mbrl-hvac/tree/master/torchlib/dataset/"
    click US "https://github.com/vermouth1992/mbrl-hvac/tree/master/torchlib/utils/"
    click RB "https://github.com/vermouth1992/mbrl-hvac/blob/master/torchlib/deep_rl/utils/replay/replay_buffer.py"
    click PID "https://github.com/vermouth1992/mbrl-hvac/blob/master/train_pid.py"
    click PPO "https://github.com/vermouth1992/mbrl-hvac/blob/master/train_ppo.py"
    click MBT "https://github.com/vermouth1992/mbrl-hvac/blob/master/train_model_based.py"

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef env fill:#2ecc71,stroke:#27ae60,color:white
    classDef agent fill:#e67e22,stroke:#d35400,color:white
    classDef training fill:#9b59b6,stroke:#8e44ad,color:white
    classDef support fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Environment Components"]:::env
        L3["Agent Components"]:::agent
        L4["Training Systems"]:::training
        L5["Support Components"]:::support
    end
```
