# google/sbsim architecture

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

- Interactive diagram: https://gitdiagram.com/google/sbsim
- Repository: https://github.com/google/sbsim

## Overview

Smart Buildings Control combines real-building datasets, a calibrated HVAC/building simulator, and reinforcement-learning control. The principal workflow is to construct a controllable environment, observe building state, choose setpoints, apply them, and receive reward feedback; agents can be trained through the RL scripts. Dataset partitioning and visual observation are additional capabilities. The source index supports several module relationships, while some implementation details—especially script orchestration and simulator wiring—were not excerpted, so those links are omitted or marked unverified.

Main entry points: [`smart_control/environment/environment.py`](https://github.com/google/sbsim/blob/copybara_push/smart_control/environment/environment.py) (RL Environment), [`smart_control/reinforcement_learning/agents/sac_agent.py`](https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/agents/sac_agent.py) (SAC Agent), [`smart_control/reinforcement_learning/observers/rendering_observer.py`](https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/observers/rendering_observer.py) (Environment Renderer), [`smart_control/dataset/dataset.py`](https://github.com/google/sbsim/blob/copybara_push/smart_control/dataset/dataset.py) (Building Dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Real-World Data"]
  node_dataset["Building Dataset<br/>[dataset.py]"]
  node_partition["Dataset Partitioning<br/>[partition.py]"]
end

subgraph group_simulation["Building Simulation"]
  node_sim_building["Thermal Building Model<br/>[building.py]"]
  node_radiation["Radiation Model"]
  node_solar["Solar Radiation<br/>[solar_radiation.py]"]
  node_weather["Weather Control"]
  node_tf_sim["TF Simulator<br/>[tf_simulator.py]"]
  node_air_handler["Air Handler<br/>[air_handler.py]"]
end

subgraph group_control["Control Environment"]
  node_building_contract["Building Interface<br/>[base_building.py]"]
  node_environment["RL Environment<br/>[environment.py]"]
  node_reward["Energy-Carbon Reward"]
  node_regret["Regret Reward"]
end

subgraph group_learning["Reinforcement Learning"]
  node_train["Training Script<br/>[train.py]"]
  node_agent["SAC Agent<br/>[sac_agent.py]"]
  node_networks["SAC Networks<br/>[sac_networks.py]"]
  node_schedule["Schedule Policy<br/>[schedule_policy.py]"]
  node_replay["Replay Buffer<br/>[replay_buffer.py]"]
end

subgraph group_analysis["Logs and Visualization"]
  node_data_processing["RL Data Processing<br/>[data_processing.py]"]
  node_rendering["Environment Renderer"]
  node_reader["Controller Reader"]
  node_writer["Controller Writer"]
  node_histogram["Histogram Reduction"]
end

node_engineer(("Engineer / Trainer"))

node_engineer -->|"uses data"| node_dataset
node_engineer -->|"starts training"| node_train
node_dataset -->|"provides records"| node_partition
node_train -.->|"trains"| node_agent
node_agent -->|"uses networks"| node_networks
node_agent -.->|"stores experience"| node_replay
node_agent -.->|"controls"| node_environment
node_schedule -.->|"provides actions"| node_environment
node_environment -->|"calls building API"| node_building_contract
node_environment -->|"evaluates reward"| node_reward
node_regret -->|"extends reward"| node_reward
node_sim_building -->|"uses model"| node_radiation
node_radiation -->|"uses model"| node_solar
node_air_handler -->|"queries weather"| node_weather
node_tf_sim -.->|"simulates building"| node_sim_building
node_environment -->|"writes metrics"| node_writer
node_reader -->|"supplies observations"| node_histogram
node_rendering -->|"renders environment"| node_environment
node_rendering -->|"plots timeseries"| node_data_processing

click node_dataset "https://github.com/google/sbsim/blob/copybara_push/smart_control/dataset/dataset.py"
click node_partition "https://github.com/google/sbsim/blob/copybara_push/smart_control/dataset/partition.py"
click node_sim_building "https://github.com/google/sbsim/blob/copybara_push/smart_control/simulator/building.py"
click node_radiation "https://github.com/google/sbsim/blob/copybara_push/smart_control/simulator/building_radiation_utils.py"
click node_solar "https://github.com/google/sbsim/blob/copybara_push/smart_control/simulator/solar_radiation.py"
click node_weather "https://github.com/google/sbsim/blob/copybara_push/smart_control/simulator/weather_controller.py"
click node_tf_sim "https://github.com/google/sbsim/blob/copybara_push/smart_control/simulator/tf_simulator.py"
click node_air_handler "https://github.com/google/sbsim/blob/copybara_push/smart_control/simulator/air_handler.py"
click node_building_contract "https://github.com/google/sbsim/blob/copybara_push/smart_control/models/base_building.py"
click node_environment "https://github.com/google/sbsim/blob/copybara_push/smart_control/environment/environment.py"
click node_reward "https://github.com/google/sbsim/blob/copybara_push/smart_control/reward/base_setpoint_energy_carbon_reward.py"
click node_regret "https://github.com/google/sbsim/blob/copybara_push/smart_control/reward/setpoint_energy_carbon_regret.py"
click node_train "https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/scripts/train.py"
click node_agent "https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/agents/sac_agent.py"
click node_networks "https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/agents/networks/sac_networks.py"
click node_schedule "https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/policies/schedule_policy.py"
click node_replay "https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/replay_buffer/replay_buffer.py"
click node_data_processing "https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/utils/data_processing.py"
click node_rendering "https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/observers/rendering_observer.py"
click node_reader "https://github.com/google/sbsim/blob/copybara_push/smart_control/utils/controller_reader.py"
click node_writer "https://github.com/google/sbsim/blob/copybara_push/smart_control/utils/controller_writer.py"
click node_histogram "https://github.com/google/sbsim/blob/copybara_push/smart_control/utils/histogram_reducer.py"

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_dataset,node_partition toneBlue
class node_sim_building,node_radiation,node_solar,node_weather,node_tf_sim,node_air_handler toneAmber
class node_building_contract,node_environment,node_reward,node_regret toneMint
class node_train,node_agent,node_networks,node_schedule,node_replay toneRose
class node_data_processing,node_rendering,node_reader,node_writer,node_histogram,node_engineer toneIndigo
```

## Components

### Real-World Data

- [Building Dataset](https://github.com/google/sbsim/blob/copybara_push/smart_control/dataset/dataset.py): `smart_control/dataset/dataset.py`
- [Dataset Partitioning](https://github.com/google/sbsim/blob/copybara_push/smart_control/dataset/partition.py): `smart_control/dataset/partition.py`

### Building Simulation

- [Thermal Building Model](https://github.com/google/sbsim/blob/copybara_push/smart_control/simulator/building.py): `smart_control/simulator/building.py`
- [Radiation Model](https://github.com/google/sbsim/blob/copybara_push/smart_control/simulator/building_radiation_utils.py): `smart_control/simulator/building_radiation_utils.py`
- [Solar Radiation](https://github.com/google/sbsim/blob/copybara_push/smart_control/simulator/solar_radiation.py): `smart_control/simulator/solar_radiation.py`
- [Weather Control](https://github.com/google/sbsim/blob/copybara_push/smart_control/simulator/weather_controller.py): `smart_control/simulator/weather_controller.py`
- [TF Simulator](https://github.com/google/sbsim/blob/copybara_push/smart_control/simulator/tf_simulator.py): `smart_control/simulator/tf_simulator.py`
- [Air Handler](https://github.com/google/sbsim/blob/copybara_push/smart_control/simulator/air_handler.py): `smart_control/simulator/air_handler.py`

### Control Environment

- [Building Interface](https://github.com/google/sbsim/blob/copybara_push/smart_control/models/base_building.py): `smart_control/models/base_building.py`
- [RL Environment](https://github.com/google/sbsim/blob/copybara_push/smart_control/environment/environment.py): `smart_control/environment/environment.py`
- [Energy-Carbon Reward](https://github.com/google/sbsim/blob/copybara_push/smart_control/reward/base_setpoint_energy_carbon_reward.py): `smart_control/reward/base_setpoint_energy_carbon_reward.py`
- [Regret Reward](https://github.com/google/sbsim/blob/copybara_push/smart_control/reward/setpoint_energy_carbon_regret.py): `smart_control/reward/setpoint_energy_carbon_regret.py`

### Reinforcement Learning

- [Training Script](https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/scripts/train.py): `smart_control/reinforcement_learning/scripts/train.py`
- [SAC Agent](https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/agents/sac_agent.py): `smart_control/reinforcement_learning/agents/sac_agent.py`
- [SAC Networks](https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/agents/networks/sac_networks.py): `smart_control/reinforcement_learning/agents/networks/sac_networks.py`
- [Schedule Policy](https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/policies/schedule_policy.py): `smart_control/reinforcement_learning/policies/schedule_policy.py`
- [Replay Buffer](https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/replay_buffer/replay_buffer.py): `smart_control/reinforcement_learning/replay_buffer/replay_buffer.py`

### Logs and Visualization

- [RL Data Processing](https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/utils/data_processing.py): `smart_control/reinforcement_learning/utils/data_processing.py`
- [Environment Renderer](https://github.com/google/sbsim/blob/copybara_push/smart_control/reinforcement_learning/observers/rendering_observer.py): `smart_control/reinforcement_learning/observers/rendering_observer.py`
- [Controller Reader](https://github.com/google/sbsim/blob/copybara_push/smart_control/utils/controller_reader.py): `smart_control/utils/controller_reader.py`
- [Controller Writer](https://github.com/google/sbsim/blob/copybara_push/smart_control/utils/controller_writer.py): `smart_control/utils/controller_writer.py`
- [Histogram Reduction](https://github.com/google/sbsim/blob/copybara_push/smart_control/utils/histogram_reducer.py): `smart_control/utils/histogram_reducer.py`

### Other components

- **Engineer / Trainer**

## Connections

- Engineer / Trainer → Building Dataset: uses data (evidence: `README.md`)
- Engineer / Trainer → Training Script: starts training (evidence: `README.md`)
- Building Dataset → Dataset Partitioning: provides records (evidence: `smart_control/dataset/partition.py`)
- Training Script → SAC Agent: trains
- SAC Agent → SAC Networks: uses networks (evidence: `smart_control/reinforcement_learning/agents/sac_agent.py`)
- SAC Agent → Replay Buffer: stores experience
- SAC Agent → RL Environment: controls
- Schedule Policy → RL Environment: provides actions
- RL Environment → Building Interface: calls building API (evidence: `smart_control/environment/environment.py`)
- RL Environment → Energy-Carbon Reward: evaluates reward (evidence: `smart_control/environment/environment.py`)
- Regret Reward → Energy-Carbon Reward: extends reward (evidence: `smart_control/reward/setpoint_energy_carbon_regret.py`)
- Thermal Building Model → Radiation Model: uses model (evidence: `smart_control/simulator/building.py`)
- Radiation Model → Solar Radiation: uses model (evidence: `smart_control/simulator/building_radiation_utils.py`)
- Air Handler → Weather Control: queries weather (evidence: `smart_control/simulator/air_handler.py`)
- TF Simulator → Thermal Building Model: simulates building
- RL Environment → Controller Writer: writes metrics (evidence: `smart_control/environment/environment.py`)
- Controller Reader → Histogram Reduction: supplies observations (evidence: `smart_control/utils/histogram_reducer.py`)
- Environment Renderer → RL Environment: renders environment (evidence: `smart_control/reinforcement_learning/observers/rendering_observer.py`)
- Environment Renderer → RL Data Processing: plots timeseries (evidence: `smart_control/reinforcement_learning/observers/rendering_observer.py`)
