Skip to content

Commit

Permalink
Merge pull request #76 from jajimer/documentation
Browse files Browse the repository at this point in the history
Rebranding Energym to Sinergym - version 1.3.0
  • Loading branch information
jajimer authored Sep 29, 2021
2 parents 91d29f2 + d6a3cd0 commit 9b49b9c
Show file tree
Hide file tree
Showing 137 changed files with 453 additions and 449 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "energym",
"name": "sinergym",
"build": {
"args": {"ENERGYPLUS_VERSION":"9.5.0", "ENERGYPLUS_INSTALL_VERSION":"9-5-0", "ENERGYPLUS_SHA":"de239b2e5f"},
},
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/create_release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
uses: abatilo/[email protected]
with:
owner: jajimer
repo: energym
repo: sinergym
- name: Build container image with release tag
env:
TAG: ${{ steps.tag_version.outputs.latest_tag }}
#TAG_DATE: ${{ steps.tag_version.outputs.latest_tag_published_at }}
run: docker build . --file Dockerfile --build-arg ENERGYM_EXTRAS=[extras] --tag $DOCKER_USER/energym:$TAG
run: docker build . --file Dockerfile --build-arg SINERGYM_EXTRAS=[extras] --tag $DOCKER_USER/sinergym:$TAG
- name: Login Docker Hub
run: docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Push container built with release tag
env:
TAG: ${{ steps.tag_version.outputs.latest_tag }}
run: docker push $DOCKER_USER/energym:$TAG
run: docker push $DOCKER_USER/sinergym:$TAG
6 changes: 3 additions & 3 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Build the latest Docker image
run: docker build . --file Dockerfile --build-arg ENERGYM_EXTRAS=[DRL,test] --tag $DOCKER_USER/energym:latest
run: docker build . --file Dockerfile --build-arg SINERGYM_EXTRAS=[DRL,test] --tag $DOCKER_USER/sinergym:latest
- name: Execute tests from container
run: docker run -t $DOCKER_USER/energym:latest /bin/bash -c 'pytest tests/ -vv'
run: docker run -t $DOCKER_USER/sinergym:latest /bin/bash -c 'pytest tests/ -vv'
- name: Login in Docker Hub account
run: docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Push container used with test
run: docker push $DOCKER_USER/energym:latest
run: docker push $DOCKER_USER/sinergym:latest
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ services:
- docker

before_script:
- docker build -t $DOCKER_USER/energym --build-arg ENERGYM_EXTRAS=[DRL,test] .
- docker build -t $DOCKER_USER/sinergym --build-arg SINERGYM_EXTRAS=[DRL,test] .

script:
- docker run -it $DOCKER_USER/energym /bin/bash -c 'pytest tests -vv'
- docker run -it $DOCKER_USER/sinergym /bin/bash -c 'pytest tests -vv'

after_success:
- docker login -u $DOCKER_USER -p $DOCKER_PASSWORD #Previusly set up in our own travis account
- docker tag $DOCKER_USER/energym $DOCKER_USER/energym:latest
- docker push $DOCKER_USER/energym:latest
- docker tag $DOCKER_USER/sinergym $DOCKER_USER/sinergym:latest
- docker push $DOCKER_USER/sinergym:latest



14 changes: 7 additions & 7 deletions DRL_battery.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import gym
import energym
import sinergym
import argparse
import uuid
import mlflow

import numpy as np

from energym.utils.callbacks import LoggerCallback, LoggerEvalCallback
from energym.utils.wrappers import MultiObsWrapper, NormalizeObservation, LoggerWrapper
from energym.utils.rewards import *
from sinergym.utils.callbacks import LoggerCallback, LoggerEvalCallback
from sinergym.utils.wrappers import MultiObsWrapper, NormalizeObservation, LoggerWrapper
from sinergym.utils.rewards import *


from stable_baselines3.common.noise import NormalActionNoise, OrnsteinUhlenbeckActionNoise
Expand All @@ -25,7 +25,7 @@
required=True,
type=str,
dest='environment',
help='Environment name of simulation (see energym/__init__.py).')
help='Environment name of simulation (see sinergym/__init__.py).')
parser.add_argument(
'--episodes',
'-ep',
Expand Down Expand Up @@ -64,7 +64,7 @@
'-log',
action='store_true',
dest='logger',
help='Apply Energym CSVLogger class if this flag is specified.')
help='Apply Sinergym CSVLogger class if this flag is specified.')
parser.add_argument(
'--tensorboard',
'-tens',
Expand Down Expand Up @@ -249,7 +249,7 @@
callbacks.append(eval_callback)

if args.tensorboard:
log_callback = LoggerCallback(energym_logger=bool(args.logger))
log_callback = LoggerCallback(sinergym_logger=bool(args.logger))
callbacks.append(log_callback)

callback = CallbackList(callbacks)
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ARG ENERGYPLUS_VERSION=9.5.0
ARG ENERGYPLUS_INSTALL_VERSION=9-5-0
ARG ENERGYPLUS_SHA=de239b2e5f

# Argument for Energym extras libraries
ARG ENERGYM_EXTRAS=[extras]
# Argument for Sinergym extras libraries
ARG SINERGYM_EXTRAS=[extras]

ENV ENERGYPLUS_VERSION=$ENERGYPLUS_VERSION
ENV ENERGYPLUS_TAG=v$ENERGYPLUS_VERSION
Expand Down Expand Up @@ -60,13 +60,13 @@ WORKDIR /code
COPY requirements.txt .
COPY setup.py .
COPY DRL_battery.py .
COPY energym /code/energym
COPY sinergym /code/sinergym
COPY tests /code/tests
COPY examples /code/examples
COPY check_run_times.py .
RUN pip3 install -e .${ENERGYM_EXTRAS}
RUN pip3 install -e .${SINERGYM_EXTRAS}

CMD ["/bin/bash"]

# Build: docker build -t energym:1.1.0 --build-arg ENERGYPLUS_VERSION=9.5.0 --build-arg ENERGYPLUS_INSTALL_VERSION=9-5-0 --build-arg ENERGYPLUS_SHA=de239b2e5f .
# Run: docker run -it --rm -p 5005:5005 energym:1.1.0
# Build: docker build -t sinergym:1.1.0 --build-arg ENERGYPLUS_VERSION=9.5.0 --build-arg ENERGYPLUS_INSTALL_VERSION=9-5-0 --build-arg ENERGYPLUS_SHA=de239b2e5f .
# Run: docker run -it --rm -p 5005:5005 sinergym:1.1.0
36 changes: 17 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# energym

> :warning: **We are in the process of rebranding this project. Stay tuned for new updates!**
# sinergym

<div align="center">
<img src="images/logo.png" width=40%><br><br>
</div>

**Welcome to energym!**
**Welcome to sinergym!**

This is a project based on Zhiang Zhang and Khee Poh Lam [Gym-Eplus](https://github.com/zhangzhizza/Gym-Eplus).

The goal of this project is to create an environment following OpenAI Gym interface for wrapping simulation engines for building control using **deep reinforcement learning**.

The main functionalities of Energym are the following :
The main functionalities of Sinergym are the following :

- **Benchmark environments**. Similarly to Atari or Mujoco environments for RL community, we are designing a set of environments for benchmarking and testing deep RL algorithms. These environments may include different buildings, weathers or action spaces.
- **Develop different experimental settings**. We aim to provide a package that allows to modify experimental settings in an easy manner. For example, several reward functions or observation variables may be defined.
Expand Down Expand Up @@ -60,26 +58,26 @@ _This is a work in progress project. Stay tuned for upcoming releases._

## Installation process

To install energym, follow these steps.
To install sinergym, follow these steps.

First, it is recommended to create a virtual environment. You can do so by:

```sh
$ sudo apt-get install python-virtualenv virtualenv
$ virtualenv env_energym --python=python3.7
$ source env_energym/bin/activate
$ virtualenv env_sinergym --python=python3.7
$ source env_sinergym/bin/activate
```

Then, clone this repository using this command:
```
$ git clone https://github.com/jajimer/energym.git
$ git clone https://github.com/jajimer/sinergym.git
```

### Docker container

We include a **Dockerfile** for installing all dependencies and setting up the image for running energym. If you use [Visual Studio Code](https://code.visualstudio.com/), by simply opening the root directory and clicking on the pop-up button "_Reopen in container_", dependencies will be installed automatically and you will be able to run energym in an isolated environment.
We include a **Dockerfile** for installing all dependencies and setting up the image for running sinergym. If you use [Visual Studio Code](https://code.visualstudio.com/), by simply opening the root directory and clicking on the pop-up button "_Reopen in container_", dependencies will be installed automatically and you will be able to run sinergym in an isolated environment.

You can also use our [Docker Hub repository](https://hub.docker.com/repository/docker/alejandrocn7/energym) with the desired version directly.
You can also use our [Docker Hub repository](https://hub.docker.com/repository/docker/alejandrocn7/sinergym) with the desired version directly.

However, if you prefer installing it manually, follow the steps below.

Expand All @@ -88,9 +86,9 @@ However, if you prefer installing it manually, follow the steps below.
#### 1. Install Energy Plus 9.5.0

Firstly, install EnergyPlus. Currently it has been update compability to 9.5.0 and it has
been tested, but code may also work with other versions. Energym ensure this support:
been tested, but code may also work with other versions. Sinergym ensure this support:

| Energym Version | EnergyPlus version |
| Sinergym Version | EnergyPlus version |
|------------------|--------------------|
| 1.0.0 | 8.6.0 |
| 1.1.0 | 9.5.0 |
Expand All @@ -111,34 +109,34 @@ Two environment variables must be set: ``EPLUS_PATH`` and ``BCVTB_PATH``, with t

#### 4. Install the package

Finally, energym can be installed by running this command at the repo root folder:
Finally, sinergym can be installed by running this command at the repo root folder:

```sh
pip install -e .
```

Extra libraries can be installed by typing ``pip install -e .[extras]``. They are intended for running and analyzing DRL algorithms over energym, but they are
Extra libraries can be installed by typing ``pip install -e .[extras]``. They are intended for running and analyzing DRL algorithms over sinergym, but they are
not a requirement of the package.

And that's all!

## Check Installation

This project is automatically supervised using tests developed specifically for it. If you want to check energym has been installed successfully, run next command:
This project is automatically supervised using tests developed specifically for it. If you want to check sinergym has been installed successfully, run next command:

```sh
$ pytest tests/ -vv
```
Anyway, every time energym repository is updated, the tests will run automatically in a remote container using the Dockerfile to build it. `Github Action <https://docs.github.com/es/actions/>`__ will do that job (see our documentation for more information).
Anyway, every time sinergym repository is updated, the tests will run automatically in a remote container using the Dockerfile to build it. `Github Action <https://docs.github.com/es/actions/>`__ will do that job (see our documentation for more information).

## Usage example

Energym uses the standard OpenAI gym API. So basic loop should be something like:
Sinergym uses the standard OpenAI gym API. So basic loop should be something like:

```python

import gym
import energym
import sinergym

env = gym.make('Eplus-demo-v1')
obs = env.reset()
Expand Down
4 changes: 2 additions & 2 deletions check_run_times.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gym
from energym.utils.wrappers import NormalizeObservation, LoggerWrapper, MultiObsWrapper
from sinergym.utils.wrappers import NormalizeObservation, LoggerWrapper, MultiObsWrapper
from datetime import datetime
import argparse
import os
Expand Down Expand Up @@ -49,6 +49,6 @@
shutil.rmtree(directory)

# Deleting new random weather files once it has been checked
files = glob('energym/data/weather/*Random*.epw')
files = glob('sinergym/data/weather/*Random*.epw')
for file in files:
os.remove(file)
10 changes: 5 additions & 5 deletions cloud_manager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
from time import sleep
from pprint import pprint
import energym.utils.gcloud as gcloud
import sinergym.utils.gcloud as gcloud

parser = argparse.ArgumentParser(
description='Process for run experiments in Google Cloud')
Expand All @@ -22,14 +22,14 @@
'--template_name',
'-tem',
type=str,
default='energym-template',
default='sinergym-template',
dest='template_name',
help='Name of template previously created in gcloud account to generate VM copies.')
parser.add_argument(
'--group_name',
'-group',
type=str,
default='energym-group',
default='sinergym-group',
dest='group_name',
help='Name of instance group(MIG) will be created during experimentation.')
parser.add_argument(
Expand Down Expand Up @@ -110,8 +110,8 @@
print('All VM\'s are working correctly, see Google Cloud Platform Console.')
# Close VM when finished with google cloud alerts?

# python cloud_manager.py --project_id energym-314709
# python cloud_manager.py --project_id sinergym
# --experiments_commands
# 'python 3 DRL_battery.py --environment Eplus-5Zone-hot-discrete-v1 --episodes 3 --algorithm DQN --logger log_interval 1 --seed 54'
# 'python3 DRL_battery.py --environment Eplus-5Zone-hot-continuous-stochastic-v1 --episodes 3 --algorithm PPO --logger --log_interval 1 --tensorboard --normalization --seed 54'
# --template_name energym_template --group_name sinergym-vm
# --template_name sinergym_template --group_name sinergym-vm
12 changes: 6 additions & 6 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ steps:
# Write in cache for quick updates
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'bash'
args: ['-c', 'docker pull gcr.io/${PROJECT_ID}/energym:latest || exit 0']
args: ['-c', 'docker pull gcr.io/${PROJECT_ID}/sinergym:latest || exit 0']
# Build image (using cache if it's possible)
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'docker'
args: [
'build',
'-t', 'gcr.io/${PROJECT_ID}/energym:latest',
'--cache-from', 'gcr.io/${PROJECT_ID}/energym:latest',
'--build-arg', 'ENERGYM_EXTRAS=[DRL]',
'-t', 'gcr.io/${PROJECT_ID}/sinergym:latest',
'--cache-from', 'gcr.io/${PROJECT_ID}/sinergym:latest',
'--build-arg', 'SINERGYM_EXTRAS=[DRL]',
'.'
]

# Push image built to container registry
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'docker'
args: ['push', 'gcr.io/${PROJECT_ID}/energym:latest']
args: ['push', 'gcr.io/${PROJECT_ID}/sinergym:latest']

# This container is going to be public (Change command in other case)
- name: 'gcr.io/cloud-builders/gsutil'
Expand All @@ -27,6 +27,6 @@ options:
diskSizeGb: '10'
machineType: 'E2_HIGHCPU_8'
timeout: 86400s
images: ['gcr.io/${PROJECT_ID}/energym:latest']
images: ['gcr.io/${PROJECT_ID}/sinergym:latest']


6 changes: 3 additions & 3 deletions doc/modules.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
energym
=======
sinergym
=========

.. toctree::
:maxdepth: 4

energym
sinergym
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# -- Project information -----------------------------------------------------

project = 'energym'
project = 'sinergym'
copyright = '2021, J. Jiménez, J. Gómez, M. Molina, A. Manjavacas, A. Campoy'
author = 'J. Jiménez, J. Gómez, M.l Molina, A. Manjavacas, A. Campoy'

Expand Down
4 changes: 2 additions & 2 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Welcome to **energym**!
=======================
Welcome to **sinergym**!
========================

.. include:: pages/introduction.rst

Expand Down
6 changes: 3 additions & 3 deletions doc/source/pages/API-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ API reference
:template: custom-module-template.rst
:recursive:

energym.utils
energym.envs
energym.simulators
sinergym.utils
sinergym.envs
sinergym.simulators

6 changes: 3 additions & 3 deletions doc/source/pages/controllers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Controllers
############

Energym has a section to implement your own controllers. Currently, we have developed a **random agent** and a **rule-based agent**.
You can find this code in `energym/energym/utils/controllers.py <https://github.com/jajimer/energym/blob/main/energym/utils/controllers.py>`__.
Sinergym has a section to implement your own controllers. Currently, we have developed a **random agent** and a **rule-based agent**.
You can find this code in `sinergym/sinergym/utils/controllers.py <https://github.com/jajimer/sinergym/blob/main/sinergym/utils/controllers.py>`__.
it is very useful in order to perform benchmarks as a reference point to study DRL algorithms:

.. literalinclude:: ../../../energym/utils/controllers.py
.. literalinclude:: ../../../sinergym/utils/controllers.py
:language: python

The functionality is very simple; given an environment observation, these instances return an action to interact with the environment. You can develop your own
Expand Down
Loading

0 comments on commit 9b49b9c

Please sign in to comment.