Skip to main content

Sinergym provides a Gymnasium-based interface to interact with building simulations. This allows control in simulation time through custom controllers, including reinforcement learning agents

Project description



Github latest release Github last commit pypi version pypi downloads GitHub Contributors Github issues GitHub pull requests Github license pypi Python version DockerHub last version



About Sinergym

Sinergym provides a Gymnasium-based interface to interact with simulation engines such as EnergyPlus. This allows control in simulation time through custom controllers, including reinforcement learning agents.

For more information about Sinergym, refer to its documentation.

Main features

⚙️ Simulation engines compatibility. Sinergym is currently compatible with the EnergyPlus Python API for controller-building communication.

📊 Benchmark environments. Similar to Atari or Mujoco, Sinergym allows the use of benchmarking environments to test and compare RL algorithms or custom control strategies.

🛠️ Custom experimentation. Sinergym enables effortless customization of experimental settings. Users can create their own environments or customize pre-configured ones within Sinergym. Select your preferred reward functions, wrappers, controllers, and more!

🏠 Automatic building model adaptation. Automatic adaptation of building models to align with user-defined settings.

🪛 Automatic actuator control. Seamless management of building actuators via the Gymnasium interface. Users only need to specify actuator names, and Sinergym will do the rest.

🤖 Stable Baselines 3 integration. Sinergym is highly integrated with Stable Baselines 3 algorithms, wrappers and callbacks.

Controller-agnostic. Any controller compatible with the Gymnasium interface can be integrated with Sinergym.

☁️ Google Cloud execution. Sinergym provides several features to execute experiments in Google Cloud.

📈 Weights & Biases logging. Automate the logging of training and evaluation data, and record your models in the cloud. Sinergym facilitates reproducibility and cloud data storage through Weights and Biases integration.

📒 Notebook examples. Learn how to get the most out of Sinergym through our notebooks examples.

📚 Extensive documentation, unit tests, and GitHub actions workflows. Sinergym follows proper development practices facilitating community contributions.



Project structure

This repository is organized into the following directories:

  • sinergym/: the source code of Sinergym.
  • docs/: Sinergym's documentation sources.
  • examples/: notebooks with several examples illustrating how to use Sinergym.
  • tests/: Sinergym tests code.
  • scripts/: auxiliar and help scripts.

Available environments

For a complete and up-to-date list of available environments, please refer to our documentation.

Installation

Read INSTALL.md for detailed installation instructions.

Usage example

This is a simple script using Sinergym:

import gymnasium as gym
import sinergym

# Create environment
env = gym.make('Eplus-datacenter-mixed-continuous-stochastic-v1')

# Initialization
obs, info = env.reset()
truncated = terminated = False

# Run episode
while not (terminated or truncated):
    action = env.action_space.sample() # random action selection
    obs, reward, terminated, truncated, info = env.step(action)

env.close()

Several usage examples can be consulted here.

Contributing

To report questions and issues, open an issue following the provided templates. We appreciate your feedback!

Check out CONTRIBUTING.md for specific details on how to contribute.

Projects using Sinergym

The following are some of the projects using Sinergym:

📝 If you want to appear in this list, feel free to open a pull request and include the following badge in your repository:

Repository activity

Alt

Citing Sinergym

If you use Sinergym in your work, please cite our paper:

@article{Campoy2025sinergym,
  title = {Sinergym – A virtual testbed for building energy optimization with Reinforcement Learning},
  author = {Alejandro Campoy-Nieves and Antonio Manjavacas and Javier Jiménez-Raboso and Miguel Molina-Solana and Juan Gómez-Romero},
  journal   = {Energy and Buildings},
  volume = {327},
  articleno = {115075},
  year = {2025},
  issn = {0378-7788},
  doi = {10.1016/j.enbuild.2024.115075},
  url = {https://www.sciencedirect.com/science/article/pii/S0378778824011915},
}

For detailed information, please refer to the documentation.

Installation

Sinergym relies on several dependencies, the specifics of which vary by version.

The table below provides a summary of the dependencies versions supported by Sinergym across its releases:

Sinergym version Ubuntu version Python version EnergyPlus version Building model file
0.0 18.04 LTS 3.6 8.3.0 IDF
1.1.0 18.04 LTS 3.6 9.5.0 IDF
1.7.0 18.04 LTS 3.9 9.5.0 IDF
1.9.5 22.04 LTS 3.10.6 9.5.0 IDF
2.4.0 22.04 LTS 3.10.6 9.5.0 epJSON
2.5.0 22.04 LTS 3.10.6 23.1.0 epJSON
3.3.6 24.04 LTS 3.12.3 23.1.0 epJSON
3.5.8 24.04 LTS 3.12.3 24.1.0 epJSON

We recommend to always use the latest version of Sinergym that is supported by the container. This will help you to avoid the complexities of manual installation. However, if you prefer to manually install Sinergym on your computer, we provide the necessary documentation in the subsequent sections.

Docker container

We provide a Dockerfile to install all dependencies and prepare the image for running Sinergym. This is the recommended option, since it ensures that all dependencies and versions are correctly installed and configured.

This Dockerfile installs the compatible operating system, EnergyPlus, Python, and Sinergym, along with the necessary dependencies for its proper functioning.

If you have cloned the repository, run the following command:

$ docker build -t <tag_name> .

Sinergym has a set of optional dependencies that enhance its usage. These dependencies can be installed in the following way when building the image:

$ docker build -t <tag_name> --build-arg SINERGYM_EXTRAS="drl notebooks gcloud" .

These optional dependencies allow you to use stable-baselines3, wandb, notebooks and gcloud. For more information, please refer to the pyproject.toml file at the root of the repository ([tool.poetry.extras] section).

If you want to install all optional packages, use extras in the SINERGYM_EXTRAS argument.

:memo: Note: the container can also be directly installed from the Docker Hub repository. It contains all the project's releases with secondary dependencies or lite versions.

Once the container image is ready, you can execute any command as follows:

$ docker run -it --rm <tag_name> <command>

By default, the command executed is python scripts/try_env.py, which is a minimal working example.

If you want to run a DRL experiment, for example, you can do it like this:

$ docker build -t example/sinergym:latest --build-arg SINERGYM_EXTRAS="drl" .
$ docker run -e WANDB_API_KEY=$WANDB_API_KEY -it --rm example/sinergym:latest python scripts/train/train_agent.py -conf scripts/train/train_agent_PPO.json

If the script you want to use requires a Weights and Biases account, remember to include the corresponding API token in a container environment variable.

It is also possible to keep an open session in the image. For more information, please refer to the official Docker documentation. This may help to run your own scripts in the container.

$ docker run -it <tag_name> /bin/bash

:memo: Note: For Visual Studio Code users, simply open the root directory and click the Reopen in container pop-up button. This will automatically install all dependencies and enable you to run Sinergym in an isolated environment. For more details about this feature, refer to the VSCode Containers extension documentation.

Manual installation

If you prefer not to use containers and install it natively on your system, we provide some guidance on how to do it.

First, ensure that your system meets the previously specified software compatibility requirements. Without this, we cannot provide support or guarantees of functionality.

Configure Python Environment

Start by installing the desired version of Python and pip. It is recommended to set up a working environment for Python. Finally, install the necessary dependencies of Sinergym in that environment:

$ pip install sinergym

You can also install the optional packages by running:

$ pip install sinergym[extras]

To directly install Sinergym from the cloned repository, run:

$ poetry install --no-interaction --only main --extras <optional_extras>
# or
$ pip install .[<optional_extras>]

Now the correct Python version and the necessary modules to run Sinergym will be installed.

Let's now proceed with the installation of external software.

Install EnergyPlus

We have tested and confirmed compatibility with EnergyPlus version 24.1.0. Sinergym might not work with other non-tested versions.

Follow the instructions detailed here to install it in Linux (we only guarantee proper testing and support for Ubuntu).

After installation, the folder Energyplus-24-1-0 should appear in the selected location.

Include EnergyPlus Python API in Python path

Sinergym relies on the Energyplus Python API. The modules of this API are located in the EnergyPlus folder that was created in the previous step. You must add this installation path to the PYTHONPATH environment variable so that the interpreter can access these modules.

Develop in Sinergym

Whether you have chosen to use Docker or a manual installation, we offer facilities for developing and contributing to Sinergym.

  • If you have used a container, Visual Studio Code will set up a development environment with all the necessary packages automatically configured, including documentation, tests, etc.

  • If you have decided to use a container without Visual Studio Code, you can use the Dockerfile available in the .devcontainer folder instead of the one in the root of the repository. If you create your own Dockerfile, make sure to perform the following installation so that all development modules are available:

RUN poetry install --no-interaction

The default installation includes all development packages. To avoid this, you should specify --only main or --without <develop_groups>. The development groups can also be found in pyproject.toml.

If you have manually installed the project, you can install the development packages from poetry in the same way. Once the repository is cloned, run:

$ poetry install --no-interaction

The command is similar to the one shown in the manual installation section, but without specifying groups or extras, so that all development packages are installed. In this case, it is not possible to use pip because it does not include information about development dependencies (except those listed in extras).

:memo: For more information about how poetry dependencies work, visit its official documentation.

Verify Installation

This project is automatically monitored using tests. To verify that Sinergym has been installed correctly, execute pytest tests/ -vv from the repository root directory. Tests dependencies should have been previously installed.

Each time the Sinergym repository is updated, the tests are automatically executed in a remote container built using the Dockerfile. This task is performed via Github actions (refer to the Github actions documentation section for additional details).

Cloud Computing

We provide some features to execute experiments in Google Cloud. For more information visit the Google Cloud integration section of the documentation.

Contributor Covenant Code of Conduct

Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

Our Standards

Examples of behavior that contributes to a positive environment for our community include:

  • Demonstrating empathy and kindness toward other people
  • Being respectful of differing opinions, viewpoints, and experiences
  • Giving and gracefully accepting constructive feedback
  • Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
  • Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

  • The use of sexualized language or imagery, and sexual attention or advances of any kind
  • Trolling, insulting or derogatory comments, and personal or political attacks
  • Public or private harassment
  • Publishing others' private information, such as a physical or email address, without their explicit permission
  • Other conduct which could reasonably be considered inappropriate in a professional setting

Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

1. Correction

Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

2. Warning

Community Impact: A violation through a single incident or series of actions.

Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

3. Temporary Ban

Community Impact: A serious violation of community standards, including sustained inappropriate behavior.

Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

4. Permanent Ban

Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

Consequence: A permanent ban from any sort of public interaction within the community.

Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by Mozilla's code of conduct enforcement ladder.

For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

MIT License

Copyright (c) 2025, A. Campoy, A. Manjavacas, J. Jiménez, M. Molina, J. Gómez

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sinergym-3.8.1.tar.gz (3.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sinergym-3.8.1-py3-none-any.whl (3.4 MB view details)

Uploaded Python 3

File details

Details for the file sinergym-3.8.1.tar.gz.

File metadata

  • Download URL: sinergym-3.8.1.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sinergym-3.8.1.tar.gz
Algorithm Hash digest
SHA256 8efe9f3b9b7b5adcdb990e81b262a5af6bdf1169a36b1b4a7a1333b050202a92
MD5 a48dd5884bafe3236dde94b78882e211
BLAKE2b-256 d83702629eedf22761a71f59f4c7cd4feefbdee0ede686796c8544e108b08e49

See more details on using hashes here.

Provenance

The following attestation bundles were made for sinergym-3.8.1.tar.gz:

Publisher: create_release.yml on ugr-sail/sinergym

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sinergym-3.8.1-py3-none-any.whl.

File metadata

  • Download URL: sinergym-3.8.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sinergym-3.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce25220b6c76b96b5fccd1227c0156acf419f8d72b9f1e3ee89b8ad089bd8c9a
MD5 be226d64637bcb16c245d93b2bdc36a2
BLAKE2b-256 fe45777b1da6398a1b7f741572b85bc1304d01dab6660e23c4973014ff03b85e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sinergym-3.8.1-py3-none-any.whl:

Publisher: create_release.yml on ugr-sail/sinergym

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page