# fzohra-ux/code-organisee architecture

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

- Interactive diagram: https://gitdiagram.com/fzohra-ux/code-organisee
- Repository: https://github.com/fzohra-ux/code-organisee

## Overview

#### Purpose and Execution Surfaces
This is a Python building-energy project that identifies room thermal RC models, adds ML residual correction, and simulates HVAC load-shedding (“effacement”) control. It is organized as several related experiment pipelines rather than one packaged service. Primary runnable surfaces are `RC_model_identification/main_train.py`, `RC_model_identification/main_validation.py`, and `pilotage/main.py`; alternative identification and corrector implementations live in `Identification 2R2C/` and `corrector*/`.

#### Input Data Boundary
The system operates offline on historical CSV telemetry: room temperature, CO₂, airflow, HVAC/radiator measurements, AHU signals, and outdoor weather. Room-specific sources are under `data/rooms/4A014/`, `data/rooms/4A015/`, etc.; weather is under `data/weather/`. The data-loading boundary is centralized per pipeline, notably `RC_model_identification/data_loading.py` and `pilotage/data_loading.py`. There is no indicated live BMS, database, API, or cloud integration.

#### RC Thermal Model and Parameter Identification
The core physics model is an R4C3 resistance-capacitance thermal network, implemented independently in `RC_model_identification/R4C3.py` and `pilotage/R4C3.py`. Identification trains model parameters against measured building trajectories through `RC_model_identification/identification.py`, then persists learned 2022 parameters in `RC_model_identification/theta_identified_2022.json`. `Identification 2R2C/parameters_identification.py` and `Identification 2R2C/model_validation.py` represent a separate 2R2C-oriented identification path.

#### Simulation and Validation
Identified RC parameters and aligned telemetry feed forward thermal simulation. `RC_model_identification/simulation.py` performs the model trajectory computation, while `RC_model_identification/main_validation.py` evaluates the resulting fit and `RC_model_identification/plotting.py` produces analysis outputs. This establishes the key boundary between calibrated physical dynamics and observed measurements.

#### Occupancy and Internal Gains
Occupancy is estimated as a derived input to thermal/load models, with implementations in `RC_model_identification/occupancy_estimation.py` and `pilotage/occupancy_estimation.py`. Supporting occupancy labels or estimates are stored as `RC_model_identification/occupants_number.csv` and `Identification 2R2C/occupants_number.csv`. Occupancy contributes to internal-gain assumptions rather than being an external runtime service.

#### Hybrid ML Corrector
The `corrector/` and `corrector_multi_output/` pipelines learn corrections around RC-model behavior. Their central stages are RC-informed feature construction (`corrector/rc_features.py`), training (`corrector/Training.py`), and evaluation (`corrector/evaluation.py`). `corrector_multi_output/Training.py` provides a multi-output variant. The control pipeline consumes serialized per-room hybrid Ridge models from `pilotage/models/hybrid_ridge_model_4A014.pkl` through `pilotage/models/hybrid_ridge_model_4A019.pkl`.

#### Load-Shedding Control Pipeline
`pilotage/main.py` is the operational experiment entry point. It assembles dynamics in `pilotage/model_builder.py` and `pilotage/thermal_dynamics.py`, creates RC loads via `pilotage/rc_load_creation.py`, applies ML correction through `pilotage/ml_correction.py`, and solves/extracts the control result in `pilotage/solve_extract.py`. Inputs include identified parameter snapshots (`pilotage/theta_identified_2022.json`, `pilotage/theta_identified_2023.json`) and room models. Outputs are persisted CSV artifacts such as `pilotage/results/HVAC value baseline.csv`, `pilotage/results/HVAC value.csv`, and `pilotage/results/effacement_summary.csv`.

#### Runtime and Dependencies
The repository is Python-based, with dependencies declared in `requirements.txt`. It relies on local filesystem data/model artifacts and likely scientific computing, optimization, plotting, and scikit-learn-compatible pickle loading, but no deployment infrastructure or external service is represented in the tree.

Main entry points: [`RC_model_identification/data_loading.py`](https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/data_loading.py) (Identification loader), [`RC_model_identification/simulation.py`](https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/simulation.py) (Thermal simulation), [`RC_model_identification/identification.py`](https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/identification.py) (Parameter identification), [`pilotage/model_builder.py`](https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/model_builder.py) (Control dynamics assembly)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Offline telemetry"]
  node_room_data[("Room telemetry<br/>CSV data")]
  node_weather_data[("Weather telemetry<br/>CSV data")]
end

subgraph group_identification["RC identification"]
  node_id_loader["Identification loader<br/>data loading<br/>[data_loading.py]"]
  node_occupancy["Occupancy estimation<br/>derived inputs"]
  node_r4c3_id{{"R4C3 thermal model<br/>physics model<br/>[R4C3.py]"}}
  node_identification_train["Parameter identification<br/>training pipeline<br/>[identification.py]"]
  node_theta_2022["Identified parameters<br/>parameter snapshot"]
  node_simulation["Thermal simulation<br/>trajectory simulation<br/>[simulation.py]"]
  node_validation["Fit validation<br/>experiment entry point<br/>[main_validation.py]"]
end

subgraph group_hybrid["Hybrid correction"]
  node_rc_features["RC-informed features<br/>feature engineering<br/>[rc_features.py]"]
  node_corrector_training["Residual corrector training<br/>ML training<br/>[Training.py]"]
  node_corrector_evaluation["Corrector evaluation<br/>ML evaluation<br/>[evaluation.py]"]
end

subgraph group_control["Load-shedding control"]
  node_pilotage_loader["Pilotage loader<br/>data loading<br/>[data_loading.py]"]
  node_control_dynamics["Control dynamics assembly<br/>model assembly<br/>[model_builder.py]"]
  node_pilotage_r4c3{{"Pilotage R4C3 model<br/>physics model<br/>[R4C3.py]"}}
  node_hybrid_models["Per-room hybrid models<br/>serialized ML models"]
  node_solver["Solve and extract<br/>optimization solver<br/>[solve_extract.py]"]
  node_pilotage_main["Load-shedding experiment<br/>runtime entry point<br/>[main.py]"]
  node_control_results["Control result CSVs<br/>output artifacts"]
end

node_room_data -->|"load telemetry"| node_id_loader
node_weather_data -->|"load weather"| node_id_loader
node_id_loader -->|"measurements"| node_occupancy
node_id_loader -->|"aligned trajectories"| node_identification_train
node_occupancy -->|"internal gains"| node_identification_train
node_r4c3_id -->|"model structure"| node_identification_train
node_identification_train -->|"persist parameters"| node_theta_2022
node_theta_2022 -->|"calibration"| node_simulation
node_id_loader -->|"forcing and observations"| node_simulation
node_r4c3_id -->|"dynamics"| node_simulation
node_simulation -->|"predicted trajectory"| node_validation
node_id_loader -->|"telemetry"| node_rc_features
node_simulation -->|"RC behavior"| node_rc_features
node_rc_features -->|"features"| node_corrector_training
node_corrector_training -->|"trained corrector"| node_corrector_evaluation
node_room_data -->|"load telemetry"| node_pilotage_loader
node_weather_data -->|"load weather"| node_pilotage_loader
node_pilotage_loader -->|"scenario inputs"| node_control_dynamics
node_theta_2022 -.->|"RC parameters"| node_control_dynamics
node_pilotage_r4c3 -->|"thermal equations"| node_control_dynamics
node_control_dynamics -->|"optimization model"| node_solver
node_hybrid_models -->|"ML correction"| node_solver
node_pilotage_main -->|"run experiment"| node_solver
node_solver -->|"write results"| node_control_results

click node_id_loader "https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/data_loading.py"
click node_occupancy "https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/occupancy_estimation.py"
click node_r4c3_id "https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/R4C3.py"
click node_identification_train "https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/identification.py"
click node_theta_2022 "https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/theta_identified_2022.json"
click node_simulation "https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/simulation.py"
click node_validation "https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/main_validation.py"
click node_rc_features "https://github.com/fzohra-ux/code-organisee/blob/main/corrector/rc_features.py"
click node_corrector_training "https://github.com/fzohra-ux/code-organisee/blob/main/corrector/Training.py"
click node_corrector_evaluation "https://github.com/fzohra-ux/code-organisee/blob/main/corrector/evaluation.py"
click node_pilotage_loader "https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/data_loading.py"
click node_control_dynamics "https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/model_builder.py"
click node_pilotage_r4c3 "https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/R4C3.py"
click node_hybrid_models "https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/models/hybrid_ridge_model_4A014.pkl"
click node_solver "https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/solve_extract.py"
click node_pilotage_main "https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/main.py"
click node_control_results "https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/results/effacement_summary.csv"

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_room_data,node_weather_data toneBlue
class node_id_loader,node_occupancy,node_r4c3_id,node_identification_train,node_theta_2022,node_simulation,node_validation toneAmber
class node_rc_features,node_corrector_training,node_corrector_evaluation toneMint
class node_pilotage_loader,node_control_dynamics,node_pilotage_r4c3,node_hybrid_models,node_solver,node_pilotage_main,node_control_results toneRose
```

## Components

### Offline telemetry

Historical room and weather CSV inputs.

- **Room telemetry**: CSV data · Temperature, CO₂, airflow, and HVAC measurements by room.
- **Weather telemetry**: CSV data

### RC identification

Physics calibration and validation experiments.

- [Identification loader](https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/data_loading.py): data loading · `RC_model_identification/data_loading.py`
- [Occupancy estimation](https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/occupancy_estimation.py): derived inputs · Estimates internal-gain occupancy inputs. · `RC_model_identification/occupancy_estimation.py`
- [R4C3 thermal model](https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/R4C3.py): physics model · `RC_model_identification/R4C3.py`
- [Parameter identification](https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/identification.py): training pipeline · `RC_model_identification/identification.py`
- [Identified parameters](https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/theta_identified_2022.json): parameter snapshot · Learned 2022 R4C3 parameters. · `RC_model_identification/theta_identified_2022.json`
- [Thermal simulation](https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/simulation.py): trajectory simulation · `RC_model_identification/simulation.py`
- [Fit validation](https://github.com/fzohra-ux/code-organisee/blob/main/RC_model_identification/main_validation.py): experiment entry point · `RC_model_identification/main_validation.py`

### Hybrid correction

Residual-learning experiment pipelines.

- [RC-informed features](https://github.com/fzohra-ux/code-organisee/blob/main/corrector/rc_features.py): feature engineering · `corrector/rc_features.py`
- [Residual corrector training](https://github.com/fzohra-ux/code-organisee/blob/main/corrector/Training.py): ML training · `corrector/Training.py`
- [Corrector evaluation](https://github.com/fzohra-ux/code-organisee/blob/main/corrector/evaluation.py): ML evaluation · `corrector/evaluation.py`

### Load-shedding control

Pilotage simulation and optimization pipeline.

- [Pilotage loader](https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/data_loading.py): data loading · `pilotage/data_loading.py`
- [Control dynamics assembly](https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/model_builder.py): model assembly · Builds thermal dynamics and RC loads for optimization. · `pilotage/model_builder.py`
- [Pilotage R4C3 model](https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/R4C3.py): physics model · `pilotage/R4C3.py`
- [Per-room hybrid models](https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/models/hybrid_ridge_model_4A014.pkl): serialized ML models · `pilotage/models/hybrid_ridge_model_4A014.pkl`
- [Solve and extract](https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/solve_extract.py): optimization solver · `pilotage/solve_extract.py`
- [Load-shedding experiment](https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/main.py): runtime entry point · `pilotage/main.py`
- [Control result CSVs](https://github.com/fzohra-ux/code-organisee/blob/main/pilotage/results/effacement_summary.csv): output artifacts · Baseline, controlled HVAC values, and effacement summary. · `pilotage/results/effacement_summary.csv`

## Connections

- Room telemetry → Identification loader: load telemetry
- Weather telemetry → Identification loader: load weather
- Identification loader → Occupancy estimation: measurements
- Identification loader → Parameter identification: aligned trajectories
- Occupancy estimation → Parameter identification: internal gains
- R4C3 thermal model → Parameter identification: model structure
- Parameter identification → Identified parameters: persist parameters
- Identified parameters → Thermal simulation: calibration
- Identification loader → Thermal simulation: forcing and observations
- R4C3 thermal model → Thermal simulation: dynamics
- Thermal simulation → Fit validation: predicted trajectory
- Identification loader → RC-informed features: telemetry
- Thermal simulation → RC-informed features: RC behavior
- RC-informed features → Residual corrector training: features
- Residual corrector training → Corrector evaluation: trained corrector
- Room telemetry → Pilotage loader: load telemetry
- Weather telemetry → Pilotage loader: load weather
- Pilotage loader → Control dynamics assembly: scenario inputs
- Identified parameters → Control dynamics assembly: RC parameters
- Pilotage R4C3 model → Control dynamics assembly: thermal equations
- Control dynamics assembly → Solve and extract: optimization model
- Per-room hybrid models → Solve and extract: ML correction
- Load-shedding experiment → Solve and extract: run experiment
- Solve and extract → Control result CSVs: write results
