An open source Farama Foundation Gymnasium environment for benchmarking distributed energy resource control algorithms to provide energy flexibility in a district of buildings.
Project description
CityLearn
CityLearn is an open source Farama Foundation Gymnasium environment for the implementation of Multi-Agent Reinforcement Learning (RL) for building energy coordination and demand response in cities. A major challenge for RL in demand response is the ability to compare algorithm performance. Thus, CityLearn facilitates and standardizes the evaluation of RL agents such that different algorithms can be easily compared with each other.
Environment Overview
CityLearn includes energy models of buildings and distributed energy resources (DER) including air-to-water heat pumps, electric heaters and batteries. A collection of building energy models makes up a virtual district (a.k.a neighborhood or community). In each building, space cooling, space heating and domestic hot water end-use loads may be independently satisfied through air-to-water heat pumps. Alternatively, space heating and domestic hot water loads can be satisfied through electric heaters.
Installation
Install latest release in PyPi with pip:
pip install softcpsrecsimulator
Python import path remains:
from citylearn.citylearn import CityLearnEnv
Developer Commands
Use the repository virtual environment when available:
.venv/bin/pytest -q
Critical lint checks used in CI:
.venv/bin/python -m ruff check citylearn tests scripts/manual scripts/ci --select E9,F821
Manual utility scripts live in scripts/manual and are excluded from default pytest collection:
python scripts/manual/demo_ev_rbc.py
python scripts/manual/demo_ev_rbc_export_end.py
Runtime benchmark (main training resolutions 5s/60s):
python scripts/manual/bench_runtime.py --seconds 5 60 --render-modes none end --episode-steps 1200
CI performance smoke check command:
python scripts/ci/perf_smoke.py --episode-steps 600 --seconds 60 --baseline-file scripts/ci/perf_baseline.json
Publish This Fork to PyPI
This fork is configured to publish the distribution name softcpsrecsimulator.
- Create the package on PyPI (project name:
softcpsrecsimulator). - In GitHub repo settings, add secret
PYPI_API_TOKENwith a PyPI token that can publish this project. - Bump
citylearn/__init__.pyversion. - Push commit and create a GitHub Release (or run
Publish Python Packageworkflow manually). - Workflow
.github/workflows/pypi_deploy.ymlbuildsdist/*and uploads to PyPI.
Optional local build check:
python -m pip install --upgrade pip build twine
python -m build
python -m twine check dist/*
Internal Architecture
Public APIs remain in CityLearnEnv and Building, while internal orchestration is split into service modules under citylearn/internal:
loading.py: schema-driven loading/build assembly (_load*, metadata processing).runtime.py: episode runtime orchestration (step, action parsing, time progression, EV/charger association).building_ops.py: building observation/action orchestration.kpi.py: KPI/evaluation pipeline.
Export and Render Modes
CityLearnEnv keeps export off by default:
render_mode='none': no CSV export and minimal runtime overhead.render_mode='during': writes CSV rows at each environment step.render_mode='end': keeps the rollout fast and writes full episode CSVs when the episode ends.
Optional location controls:
render_directory: base folder for exports.render_session_name: session subfolder name underrender_directory(orrender_directory_name).render_directory_name: legacy fallback folder under project root whenrender_directoryis not set.render: legacy boolean flag; still supported for compatibility.
Examples:
from citylearn.citylearn import CityLearnEnv
# Fast training/no export
env = CityLearnEnv(schema, render_mode='none')
# Stream CSVs every step
env = CityLearnEnv(
schema,
render_mode='during',
render_directory='outputs',
render_session_name='run_during'
)
# Export once at episode end
env = CityLearnEnv(
schema,
render_mode='end',
render_directory='outputs',
render_session_name='run_end'
)
Documentation
Refer to the docs.
CityLearn UI
CityLearn UI is a visual dashboard for exploring simulation data generated by the CityLearn framework. It was developed to simplify the analysis of results from smart energy communities, district energy coordination, demand response (among other applications), allowing users to visually inspect building-level components, compare simulation KPIs, and create simulation schemas with ease.
The interface is available in two options:
- Web app: https://citylearnui.netlify.app/ (free hosted version — not recommended for sensitive/personal data)
- Open-source code: https://github.com/Soft-CPS-Research-Group/citylearn-ui
You can check a tutorial at the official CityLearn website, in the CityLearn UI repository README, or at the help tooltip of the oficial webapp.
Compatibility: This version of the UI currently supports CityLearn v2.5.0 simulation data.
Developed by: José, a member of the SoftCPS, Software for Cyber-Physical Systems research group (ISEP, Portugal) in collaboration with the Intelligent Environments Lab, University of Texas at Austin.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file softcpsrecsimulator-0.1.0.tar.gz.
File metadata
- Download URL: softcpsrecsimulator-0.1.0.tar.gz
- Upload date:
- Size: 412.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff3eedd7f684b7061a1dbbb426a7d175fe67fe2530f47da883317b62feb715f7
|
|
| MD5 |
f97c6f62e8e38504ae87a375a7370511
|
|
| BLAKE2b-256 |
e28330bc9705547cc81646336c7646abd3890455235cf24d936c27b639a8ac2a
|
File details
Details for the file softcpsrecsimulator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: softcpsrecsimulator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 415.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a553a710f744805d8f5f5a8c7c6d74ae600ae3df43fcac7494e66abe5965cfc
|
|
| MD5 |
1453777d743ef8448ad86b9fdf9ff469
|
|
| BLAKE2b-256 |
f05377e6ba8d8953a01ffbdc426be59bd0a0e8a4fc8ce239434129650c51fae3
|