Skip to content

Commit f2035d6

Browse files
committed
Merge remote-tracking branch 'origin/main' into electricitymarket2
2 parents 8ab0828 + b17c358 commit f2035d6

22 files changed

+173
-271
lines changed

CONTRIBUTING.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
# Contributing code
22

33
1. Install [miniconda3](https://docs.conda.io/en/latest/miniconda.html).
4-
2. Create conda environment. Replace `XX` below with the name of the SustainGym environment you want to work on.
4+
2. (Optional, but recommended) If you are using a conda version `<=23.9.0`, set the conda solver to libmamba for faster dependency solving. Starting from conda version [`23.10.0`](https://github.com/conda/conda/releases/tag/23.10.0), libmamba is the default solver.
55
```bash
6-
conda env update --file env_XX.yml --prune
6+
conda config --set solver libmamba
77
```
8-
9-
If you are using RLLib with a GPU, you will also need to [configure TensorFlow for GPU](https://www.tensorflow.org/install/pip#4_gpu_setup):
8+
3. Clone the SustainGym repo, and enter the `sustaingym` directory.
109
```bash
11-
mkdir -p $CONDA_PREFIX/etc/conda/activate.d
12-
echo 'CUDNN_PATH=$(dirname $(python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)"))' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
13-
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/:$CUDNN_PATH/lib' >> $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh
10+
git clone https://github.com/chrisyeh96/sustaingym.git
11+
cd sustaingym
1412
```
15-
16-
3. Make code modifications in a separate git branch
13+
4. Create conda environment. Replace `XX` below with the name of the SustainGym environment you want to work on. By default, the `env_XX.yml` environment files assume that you have a NVIDIA GPU. If you do not have a NVIDIA GPU, you may need to modify the `env_XX.yml` file.
14+
```bash
15+
conda env update --file env_XX.yml --prune
16+
```
17+
5. Make code modifications in a separate git branch
1718
```bash
1819
git checkout -b new_feature
1920
```
20-
4. From repo root folder, run mypy type checker and fix any errors.
21+
6. From repo root folder, run mypy type checker and fix any errors.
2122
```bash
2223
mypy sustaingym
2324
```
24-
5. From repo root folder, run code linter and fix any linting errors.
25+
7. From repo root folder, run code linter and fix any linting errors.
2526
```bash
2627
flake8 sustaingym
2728
```
28-
6. Commit changes in git and push.
29-
7. Submit pull request on GitHub.
29+
8. Commit changes in git and push.
30+
9. Submit pull request on GitHub.
3031

3132

3233
## Unit tests
3334

34-
First, set your terminal directory to this repo's root directory. Next, make sure you have activated the appropriate conda environment for the SustainGym environment you want to test (e.g., `conda activate sustaingym_ev`). Finally, run the unit tests for the desired SustainGym environment:
35+
First, set your terminal directory to this repo's root directory. Next, make sure you have activated the appropriate conda environment for the SustainGym environment you want to test (_e.g._, `conda activate sustaingym_ev`). Finally, run the unit tests for the desired SustainGym environment:
3536
3637
```bash
3738
python -m unittest -v tests/test_evcharging.py

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# SustainGym: Reinforcement learning environments for sustainability applications
1+
# SustainGym: Reinforcement Learning Environments for Sustainable Energy Systems
22

33
The lack of standardized benchmarks for reinforcement learning (RL) in sustainability applications has made it difficult to both track progress on specific domains and identify bottlenecks for researchers to focus their efforts on. We present SustainGym, a suite of environments designed to test the performance of RL algorithms on realistic sustainability tasks. These environments highlight challenges in introducing RL to real-world sustainability tasks, including physical constraints and distribution shift.
44

5-
[**Paper**](https://drive.google.com/file/d/1wrLGu2FCVOT_BvtDoudsz05zFG89r7dI/view?usp=drive_link)
5+
[**Paper**](https://openreview.net/forum?id=vZ9tA3o3hr)
66
| [**Website**](https://chrisyeh96.github.io/sustaingym/)
77

88
SustainGym contains both single-agent and multi-agent RL environments.

docs/buildingenv.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
BuildingEnv considers the control of the heat flow in a multi-zone building so as to maintain a desired temperature setpoint. Building temperature simulation uses first-principled physics models. Users can either choose from a pre-defined list of buildings (Office small, School primary, Apartment midrise, and Office large) and three climate types and cities (San Diego, Tucson, New York) provided by the Building Energy Codes Program or define a customized BuildingEnv environment by importing any self-defined EnergyPlus building models. Each episode runs for 1 day, with 5-minute time intervals ($H = 288$, $\tau = 5/60$ hours).
44

55
## Observation Space
6-
For a building with $M$ indoor zones, the state $s(t) \in \R^{3M+2}$ contains observable properties of the building environment at timestep $t$:
6+
For a building with $M$ indoor zones, the state $s(t) \in \R^{M+4}$ contains observable properties of the building environment at timestep $t$:
77

88
$$
9-
s(t) = (T_1(t), ...,T_{M}(t), N_1(t), ..., N_{M}(t), Q_{1}^{GHI}(t), ..., Q_{M}^{GHI}(t), T_G(t), T_{E}(t)),
9+
s(t) = (T_1(t), \dotsc, T_M(t), T_\mathrm{E}(t), T_\mathrm{G}(t), Q^\mathrm{GHI}(t), \bar{Q}^\mathrm{p}(t)),
1010
$$
1111

12-
where $T_i(t)$ is zone $i$'s temperature at time step $t$, $N_i(t)$ is the number of occupants, $Q_{i}^{GHI}(t)$ is the heat gain from the solar irradiance, and $T_G(t)$ and $T_E(t)$ denote the ground and outdoor environment temperature. In practice, the agent may have access to all or part of the state variables for decision-making depending on the sensor setup. Note that the outdoor/ground temperature, room occupancy, and heat gain from solar radiance are time-varying uncontrolled variables from the environment.
12+
where $T_i(t)$ is zone $i$'s temperature at time step $t$, $\bar{Q}^\mathrm{p}(t)$ is the heat acquisition from occupant's activities, $Q^\mathrm{GHI}(t)$ is the heat gain from the solar irradiance, and $T_\mathrm{G}(t)$ and $T_\mathrm{E}(t)$ denote the ground and outdoor environment temperature. In practice, the agent may have access to all or part of the state variables for decision-making depending on the sensor setup. Note that the outdoor/ground temperature, room occupancy, and heat gain from solar radiance are time-varying uncontrolled variables from the environment.
1313

1414
## Action Space
1515
The action $a(t) \in [-1, 1]^M$ sets the controlled heating supplied to each of the $M$ zones, scaled to $[-1, 1]$.
@@ -18,13 +18,13 @@ The action $a(t) \in [-1, 1]^M$ sets the controlled heating supplied to each of
1818
The objective is to reduce energy consumption while keeping the temperature within a given comfort range. The default reward function is a weighted $\ell_2$ reward, defined as
1919

2020
$$
21-
r(t) = - (1-\beta) \|a(t)\|_2 - \beta \|T^{obj}(t)-T(t)\|_2
21+
r(t) = - (1-\beta) \|a(t)\|_2 - \beta \|T^\mathrm{target}(t)-T(t)\|_2
2222
$$
2323

24-
where $T^{obj}(t)=[T^{obj}_{1}(t),...,T^{obj}_{M}(t)]$ are the target temperatures and $T(t)=[T_{1}(t),...,T_{M}(t)]$ are the actual zonal temperature. BuildingEnv also allows users to customize reward functions using environment states $s(t)$, actions $a(t)$, target values $T^{obj}(t)$, and a weight term $\beta$. Users can also customize the reward function to take CO<sub>2</sub> emissions into consideration.
24+
where $T^\mathrm{target}(t)=[T^\mathrm{target}_{1}(t),\cdots,T^\mathrm{target}_{M}(t)]$ are the target temperatures and $T(t)=[T_1(t),\cdots,T_M(t)]$ are the actual zonal temperature. BuildingEnv also allows users to customize reward functions by changing the weight term $\beta$ or the parameter $p$ defining the $\ell_p$ norm. Users can also customize the reward function to take CO<sub>2</sub> emissions into consideration.
2525

2626
## Distribution Shift
27-
BuildingEnv features distribution shifts in the ambient outdoor temperature profile $T_E$ which varies with different seasons.
27+
BuildingEnv features distribution shifts in the ambient outdoor temperature profile $T_\mathrm{E}$ which varies with different seasons.
2828

2929
## Multiagent Setting
3030
In the multiagent setting for BuildingEnv, we treat each building as an independent agent whose action is the building's heat control decisions. It must coordinate with other building agents to maximize overall reward, which is the summation of each agent's reward. Each agent obtains either the global observation or individual building states.
@@ -33,11 +33,25 @@ In the multiagent setting for BuildingEnv, we treat each building as an independ
3333

3434
### Installation
3535

36-
Coming soon!
36+
SustainGym is designed for Linux machines. SustainGym is hosted on [PyPI](https://pypi.org/project/sustaingym/) and can be installed with `pip`:
37+
38+
```bash
39+
pip install sustaingym[building]
40+
```
3741

3842
### Using our training script
3943

40-
Coming soon!
44+
1. Install [miniconda3](https://docs.conda.io/en/latest/miniconda-other-installer-links.html).
45+
2. (Optional, but recommended) If you are using a conda version `<=23.9.0`, set the conda solver to libmamba for faster dependency solving. Starting from conda version [`23.10.0`](https://github.com/conda/conda/releases/tag/23.10.0), libmamba is the default solver.
46+
```bash
47+
conda config --set solver libmamba
48+
```
49+
3. Install the libraries necessary for runnning the BuildingEnv environment.
50+
```bash
51+
conda env update --file env_building.yml --prune
52+
```
53+
54+
More instructions coming soon!
4155

4256
### Custom RL Loop
4357

docs/cogenenv.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ while not terminated:
6161
### Using our training script
6262

6363
1. Install [miniconda3](https://docs.conda.io/en/latest/miniconda-other-installer-links.html).
64-
2. (Optional) Set the conda solver to libmamba for faster dependency solving.
64+
2. (Optional, but recommended) If you are using a conda version `<=23.9.0`, set the conda solver to libmamba for faster dependency solving. Starting from conda version [`23.10.0`](https://github.com/conda/conda/releases/tag/23.10.0), libmamba is the default solver.
6565
```bash
6666
conda config --set solver libmamba
6767
```

docs/electricitymarketenv.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ElectricityMarketEnv considers temporal distribution shifts, specifically in the
3434
### Installation
3535

3636
1. Install [miniconda3](https://docs.conda.io/en/latest/miniconda-other-installer-links.html).
37-
2. (Optional) Set the conda solver to libmamba for faster dependency solving.
37+
2. (Optional, but recommended) If you are using a conda version `<=23.9.0`, set the conda solver to libmamba for faster dependency solving. Starting from conda version [`23.10.0`](https://github.com/conda/conda/releases/tag/23.10.0), libmamba is the default solver.
3838
```bash
3939
conda config --set solver libmamba
4040
```

docs/evchargingenv.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ The reward function is a sum of three components: $r(t) = p(t) - c_V(t) - c_C(t)
1919

2020
### Installation
2121

22-
SustainGym is hosted on [PyPI](https://pypi.org/project/sustaingym/) and can be installed with `pip`:
22+
SustainGym is designed for Linux machines. SustainGym is hosted on [PyPI](https://pypi.org/project/sustaingym/) and can be installed with `pip`:
2323

2424
```bash
2525
pip install sustaingym[ev]
2626
```
2727

28+
Specifically for `EVChargingEnv`, you also need to have a MOSEK license. You may either request a free [personal academic license](https://www.mosek.com/products/academic-licenses/), or a free 30-day [commercial trial license](https://www.mosek.com/products/trial/). The license file should be placed inside a folder called "mosek" under your home directory. Typically, that will be `~/mosek/mosek.lic`.
29+
2830
### Custom RL Loop
2931

3032
```python
@@ -48,7 +50,7 @@ while not terminated:
4850
### Using our training script
4951

5052
1. Install [miniconda3](https://docs.conda.io/en/latest/miniconda-other-installer-links.html).
51-
2. (Optional) Set the conda solver to libmamba for faster dependency solving.
53+
2. (Optional, but recommended) If you are using a conda version `<=23.9.0`, set the conda solver to libmamba for faster dependency solving. Starting from conda version [`23.10.0`](https://github.com/conda/conda/releases/tag/23.10.0), libmamba is the default solver.
5254
```bash
5355
conda config --set solver libmamba
5456
```
@@ -90,4 +92,4 @@ optional arguments:
9092
9193
## References
9294
93-
[1] Z. J. Lee et al., "Adaptive Charging Networks: A Framework for Smart Electric Vehicle Charging," in _IEEE Transactions on Smart Grid_, vol. 12, no. 5, pp. 4339-4350, Sept. 2021, doi: 10.1109/TSG.2021.3074437. URL [https://ieeexplore.ieee.org/document/9409126](https://ieeexplore.ieee.org/document/9409126).
95+
[1] Z. J. Lee et al., "Adaptive Charging Networks: A Framework for Smart Electric Vehicle Charging," in _IEEE Transactions on Smart Grid_, vol. 12, no. 5, pp. 4339-4350, Sept. 2021, doi: 10.1109/TSG.2021.3074437. URL [https://ieeexplore.ieee.org/document/9409126](https://ieeexplore.ieee.org/document/9409126).

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A suite of environments designed to test the performance of RL algorithms on rea
1111
The lack of standardized benchmarks for reinforcement learning (RL) in sustainability applications has made it difficult to both track progress on specific domains and identify bottlenecks for researchers to focus their efforts on. We present **SustainGym**, a suite of environments designed to test the performance of RL algorithms on realistic sustainability tasks. These environments highlight challenges in introducing RL to real-world sustainability tasks, including physical constraints and distribution shift.
1212

1313
<p>
14-
<a href="https://drive.google.com/file/d/1wrLGu2FCVOT_BvtDoudsz05zFG89r7dI/view?usp=drive_link" class="btn btn-blue fs-5 mb-4 mb-md-0 mr-2">Read the Paper</a>
14+
<a href="https://openreview.net/forum?id=vZ9tA3o3hr" class="btn btn-blue fs-5 mb-4 mb-md-0 mr-2">Read the Paper</a>
1515
<a href="https://github.com/chrisyeh96/sustaingym/" class="btn fs-5 mb-4 mb-md-0">View it on GitHub</a>
1616
</p>
1717

env_building.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,41 @@
55
# conda remove --name sustaingym_building --all
66
#
77
# Notes
8-
# - last updated: September 27, 2023
8+
# - Ray 2.8:
9+
# - officially only supports up to Python 3.10 (see https://docs.ray.io/en/latest/ray-overview/installation.html)
10+
# - only supports gymnasium 0.28.1 (see https://github.com/ray-project/ray/blob/ray-2.8.0/python/setup.py#L305)
11+
# - officially seems to only supports pettingzoo 1.23.1 (see https://github.com/ray-project/ray/blob/ray-2.7.1/python/requirements/ml/rllib-test-requirements.txt),
12+
# but empirically seems to work with pettingzoo 1.24.*
13+
#
14+
# last updated: November 13, 2023
915
name: sustaingym_building
1016
channels:
17+
- pytorch
18+
- nvidia
1119
- conda-forge
1220
dependencies:
13-
- python=3.11
14-
- cvxpy # for MPC controller
15-
- flake8 # Optional, for code linting
16-
- ipympl # Optional, for Jupyter / VSCode notebooks
17-
- ipykernel # Optional, for Jupyter / VSCode notebooks
21+
- python=3.10.*
22+
- cvxpy=1.4.* # for MPC controller
23+
- flake8 # Optional, for code linting
24+
- ipympl # Optional, for Jupyter / VSCode notebooks
25+
- ipykernel # Optional, for Jupyter / VSCode notebooks
1826
- matplotlib
19-
- mypy # Optional, for type checking
27+
- mypy # Optional, for type checking
2028
- numpy
2129
- pandas
2230
- pip
2331
- pvlib
32+
- pytorch=2.1.*
2433
- scikit-learn
2534
- scipy
2635
- seaborn
27-
- tqdm # Optional, for progress bars
36+
- tqdm # Optional, for progress bars
37+
38+
# for GPU. comment out for CPU-only.
39+
- pytorch-cuda=11.8 # for PyTorch 2
2840

2941
- pip:
3042
- gymnasium==0.28.1
3143
- pettingzoo==1.24.1
32-
- ray[rllib]==2.7.0
33-
- stable_baselines3>=2.0.0
44+
- ray[rllib]==2.8.*
45+
- stable_baselines3>=2

env_cogen.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,49 @@
55
# conda remove --name sustaingym_cogen --all
66
#
77
# Notes
8-
# - ray[rllib]==2.7 only supports gymnasium 0.28.1, pettingzoo 0.24.*
9-
# - last updated: October 30, 2023
8+
# - TensorFlow 2.14:
9+
# - the GPU version only works with Python <=3.10 (see https://github.com/tensorflow/tensorflow/issues/61986)
10+
# - TensorFlow 2.15 should fix this issue
11+
# - Ray 2.8:
12+
# - officially only supports up to Python 3.10 (see https://docs.ray.io/en/latest/ray-overview/installation.html)
13+
# - only supports gymnasium 0.28.1 (see https://github.com/ray-project/ray/blob/ray-2.8.0/python/setup.py#L305)
14+
# - officially seems to only supports pettingzoo 1.23.1 (see https://github.com/ray-project/ray/blob/ray-2.8.0/python/requirements/ml/rllib-test-requirements.txt),
15+
# but empirically seems to work with pettingzoo 1.24.*
16+
#
17+
# last updated: November 16, 2023
1018
name: sustaingym_cogen
1119
channels:
1220
- pytorch # for pytorch
1321
- nvidia # for pytorch-cuda
1422
- conda-forge
1523
dependencies:
16-
- python=3.11
24+
- python=3.10.*
1725
- flake8
1826
- ipympl # for Jupyter / VSCode notebooks
1927
- ipykernel # for Jupyter / VSCode notebooks
2028
- matplotlib
2129
- mypy
22-
- numpy
30+
- numpy=1.26.*
2331
- openpyxl # for reading Excel files
2432
- pandas
2533
- pip
26-
- pytorch=2.0.1
34+
- pytorch=2.1.*
2735
- pytz=2023.3
2836
- seaborn
2937
- tqdm
3038
- xlrd # for reading Excel files
3139

32-
# for GPU
33-
- cudatoolkit=11.8.0 # for TensorFlow 2.12
34-
- pytorch-cuda=11.8 # for PyTorch 2.0
35-
40+
# for GPU. comment out for CPU-only.
41+
- pytorch-cuda=11.8 # for PyTorch 2
3642

3743
- pip:
3844
- gymnasium==0.28.1
3945
- pettingzoo==1.24.1
40-
- "ray[rllib]==2.7.1"
41-
- tensorflow==2.14.*
46+
- ray[rllib]==2.8.*
47+
- onnxruntime==1.16.* # the ONNX model for CogenEnv is small and runs sufficiently fast on CPU
4248

4349
# uncomment for CPU-only
44-
# - onnxruntime
50+
# - tensorflow==2.14.*
4551

46-
# for GPU
47-
- nvidia-cudnn-cu11==8.6.0.163 # for TensorFlow 2.12
48-
- onnxruntime-gpu
52+
# for GPU. comment out for CPU-only.
53+
- tensorflow[and-cuda]==2.14.*

env_ev.yml

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,54 @@
55
# conda remove --name sustaingym_ev --all
66
#
77
# Notes
8-
# - the 2 main bottlenecks are acnportal and ray
9-
# 1) acnportal v0.3.2 only supports up to Pandas 1.1,
10-
# and Pandas 1.1 only supports up to Python 3.9
11-
# 2) ray[rllib]==2.7.0 only supports gymnasium 0.28.1, pettingzoo 0.24.*
12-
# - technically, ray(2.7.0) needs Pandas >= 1.3, but we can bypass this requirement by installing
13-
# it through pip instead of conda
14-
# - last updated: September 27, 2023
8+
# - TensorFlow 2.14:
9+
# - the GPU version only works with Python <=3.10 (see https://github.com/tensorflow/tensorflow/issues/61986)
10+
# - TensorFlow 2.15 should fix this issue
11+
# - Ray 2.8:
12+
# - officially only supports up to Python 3.10 (see https://docs.ray.io/en/latest/ray-overview/installation.html)
13+
# - only supports gymnasium 0.28.1 (see https://github.com/ray-project/ray/blob/ray-2.8.0/python/setup.py#L305)
14+
# - officially seems to only supports pettingzoo 1.23.1 (see https://github.com/ray-project/ray/blob/ray-2.8.0/python/requirements/ml/rllib-test-requirements.txt),
15+
# but empirically seems to work with pettingzoo 1.24.*
16+
#
17+
# last updated: November 25, 2023
1518
name: sustaingym_ev
1619
channels:
1720
- pytorch # for pytorch
1821
- nvidia # for pytorch-cuda
1922
- mosek # for mosek
2023
- conda-forge
2124
dependencies:
22-
- python=3.9.16
23-
- cudatoolkit=11.8.0 # for TensorFlow 2.12
24-
- cvxpy=1.3.1
25-
- flake8=6.0.0
25+
- python=3.10.*
26+
- cvxpy=1.4.*
27+
- flake8=6.1.*
2628
- ipympl=0.9.3 # for Jupyter / VSCode notebooks
2729
- ipykernel # for Jupyter / VSCode notebooks
28-
- matplotlib=3.7.1
29-
- mosek=10.0.44
30-
- mypy=1.3.0
31-
- numpy=1.24.3
32-
- pandas=1.1.5 # acnportal 0.3.2 only works with Pandas 1.1
30+
- matplotlib=3.8.*
31+
- mosek=10.1.*
32+
- mypy=1.3.*
33+
- numpy=1.26.*
34+
- pandas=2.1.*
3335
- pip
34-
- pytorch=2.0.1
35-
- pytorch-cuda=11.8 # for PyTorch 2.0
36+
- pytorch=2.1.*
3637
- pytz=2023.3
37-
- requests=2.31.0
38-
- scikit-learn=1.1.1
39-
- scipy=1.10.1
40-
- seaborn=0.12.2
41-
- tqdm=4.65.0
38+
- requests=2.31.*
39+
- scikit-learn=1.1.*
40+
- scipy=1.11.*
41+
- seaborn=0.13.*
42+
- tqdm=4.66.*
43+
44+
# for GPU. comment out for CPU-only.
45+
- pytorch-cuda=11.8 # for PyTorch 2
4246

4347
- pip:
44-
- acnportal==0.3.2
48+
- acnportal>=0.3.3
4549
- gymnasium==0.28.1
4650
- pettingzoo==1.24.1
47-
- "ray[rllib]==2.7.0"
48-
- tensorflow==2.12.0
49-
- nvidia-cudnn-cu11==8.6.0.163 # for TensorFlow 2.12
51+
- ray[rllib]==2.8.*
52+
- stable_baselines3>=2
53+
54+
# uncomment for CPU-only
55+
# - tensorflow==2.14.*
56+
57+
# for GPU. comment out for CPU-only.
58+
- tensorflow[and-cuda]==2.14.*

0 commit comments

Comments
 (0)