Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
a6a0bf5
chore: new-world
ADGEfficiency Mar 15, 2025
21dfabd
feat
ADGEfficiency Mar 21, 2025
3b114f7
feat
ADGEfficiency Mar 21, 2025
a7a4baa
feat
ADGEfficiency Apr 19, 2025
7e7d17f
feat: battery env learning
ADGEfficiency Apr 19, 2025
b1bddb1
feat
ADGEfficiency Apr 19, 2025
1235aa6
feat
ADGEfficiency Apr 19, 2025
86fc228
feat
ADGEfficiency Apr 19, 2025
095fc3b
feat
ADGEfficiency Apr 19, 2025
2593cd4
feat
ADGEfficiency Apr 19, 2025
65e9a6a
feat
ADGEfficiency Apr 19, 2025
1f088ce
feat
ADGEfficiency Apr 19, 2025
5c52aaa
feat
ADGEfficiency Apr 19, 2025
f6c42dc
feat
ADGEfficiency Apr 19, 2025
584e5cb
feat
ADGEfficiency Apr 19, 2025
71ee341
feat
ADGEfficiency Apr 19, 2025
ed478c3
feat
ADGEfficiency Apr 19, 2025
bb8e35b
feat
ADGEfficiency Apr 19, 2025
cdcd9bd
feat
ADGEfficiency Apr 19, 2025
345fb09
feat
ADGEfficiency Apr 19, 2025
355f1a9
feat
ADGEfficiency Apr 19, 2025
d5d3710
feat
ADGEfficiency Apr 19, 2025
8fdec2d
feat
ADGEfficiency Apr 19, 2025
e2bce06
feat
ADGEfficiency Apr 19, 2025
dfc9036
feat
ADGEfficiency Apr 19, 2025
db4e59e
feat
ADGEfficiency Apr 19, 2025
746f321
feat
ADGEfficiency Apr 19, 2025
82e6078
feat
ADGEfficiency Apr 19, 2025
cbab42b
feat
ADGEfficiency Apr 19, 2025
c51c25c
feat
ADGEfficiency Apr 19, 2025
cd6076d
feat
ADGEfficiency Apr 19, 2025
a4a2e2e
feat
ADGEfficiency Apr 19, 2025
9c5cc86
feat
ADGEfficiency Apr 20, 2025
cbb1fa5
feat
ADGEfficiency Apr 20, 2025
7049808
feat
ADGEfficiency Apr 20, 2025
cf1d3af
feat
ADGEfficiency Apr 20, 2025
b7164aa
feat
ADGEfficiency Apr 20, 2025
342343d
feat
ADGEfficiency Apr 20, 2025
15deb7a
feat
ADGEfficiency Apr 20, 2025
84f757b
feat
ADGEfficiency Apr 20, 2025
87d6ab6
feat
ADGEfficiency Apr 20, 2025
25ed17e
feat
ADGEfficiency Apr 21, 2025
78426e9
feat
ADGEfficiency Apr 21, 2025
f913258
feat
ADGEfficiency Apr 21, 2025
e9f1c8d
feat
ADGEfficiency Apr 21, 2025
666cf65
feat
ADGEfficiency Apr 21, 2025
ae19f32
feat
ADGEfficiency Apr 21, 2025
fb53bd1
feat
ADGEfficiency Apr 21, 2025
18dc0cc
feat
ADGEfficiency Apr 21, 2025
b84c243
feat
ADGEfficiency Apr 22, 2025
7d41f72
feat
ADGEfficiency Apr 22, 2025
ec9923b
feat
ADGEfficiency Apr 22, 2025
92c9b7f
feat
ADGEfficiency Apr 22, 2025
2072782
feat
ADGEfficiency Apr 22, 2025
a6abd73
feat
ADGEfficiency Apr 22, 2025
f66707d
feat
ADGEfficiency Apr 22, 2025
e83fd66
feat
ADGEfficiency Apr 22, 2025
03e06d9
feat
ADGEfficiency Apr 22, 2025
84ee682
feat
ADGEfficiency Apr 22, 2025
311620f
feat
ADGEfficiency Apr 22, 2025
d855ebf
feat
ADGEfficiency Apr 22, 2025
af74c90
feat
ADGEfficiency Apr 22, 2025
b2d9423
feat
ADGEfficiency Apr 22, 2025
1db5c74
feat
ADGEfficiency Apr 22, 2025
505890e
feat
ADGEfficiency Apr 24, 2025
bcc26ac
feat
ADGEfficiency Apr 24, 2025
7cdb3fb
feat
ADGEfficiency Apr 24, 2025
4564fde
feat
ADGEfficiency Apr 24, 2025
d6d512e
feat
ADGEfficiency Apr 24, 2025
dd9de80
feat
ADGEfficiency Apr 25, 2025
27c85dc
feat
ADGEfficiency Apr 25, 2025
6dd191a
feat
ADGEfficiency Apr 25, 2025
a9a2f10
feat
ADGEfficiency Apr 25, 2025
41c0fe3
feat
ADGEfficiency Apr 25, 2025
0833ad1
feat
ADGEfficiency Apr 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

51 changes: 40 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,51 @@ name: test

on:
push:
branches: [main, dev]

branches: ["main"]
pull_request:
branches: [main, dev]
branches: ["main"]

jobs:
test-setup:
test-src:
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: test
run: make test

- name: Setup Python
uses: actions/setup-python@v2
test-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: python
uses: actions/setup-python@v5
with:
python-version: 3.8.10
python-version: '3.11'
- name: test examples
run: make test-examples

- name: Run Tests
run: make test
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: check
run: make check

static:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: static checks
run: make static
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

49 changes: 23 additions & 26 deletions Makefile
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
.PHONY: test pushs3

setup:
pip install -q -r requirements.txt
pip install .

test: setup
pytest tests -m "not pybox2d" --tb=line --disable-pytest-warnings
curl -LsSf https://astral.sh/uv/0.6.3/install.sh | sh
uv venv
uv sync

test-with-pybox2d:
pytest tests --tb=line --disable-pytest-warnings

tensorboard:
tensorboard --logdir experiments
clean:
rm -rf ./data/tensorboard/

TB_DIR=./data/tensorboard/
monitor:
jupyter lab
uv run tensorboard --logdir $(TB_DIR) --bind_all

setup-test: setup
uv sync --group test

pulls3:
make pulls3-dataset
make pulls3-nem
test: setup-test
# TODO - test coverage up to 100 %
uv run pytest tests --tb=short -p no:warnings --disable-warnings --cov=src --cov-report=term-missing --cov-report=html:htmlcov --cov-fail-under=50

pulls3-dataset:
aws --no-sign-request --region ap-southeast-2 s3 cp s3://energy-py/public/dataset.zip dataset.zip
unzip dataset.zip
test-examples: setup-test
uv run examples/battery.py
uv run examples/battery_arbitrage_experiments.py

pulls3-nem:
aws --no-sign-request --region ap-southeast-2 s3 cp s3://energy-py/public/nem.zip nem.zip
unzip nem.zip; mv nem-data ~
# TODO - include the tests dir
SRC_DIRS=src examples
static: setup-test
uv run basedpyright $(SRC_DIRS) --level error

setup-pybox2d-macos:
brew install swig
git clone https://github.com/pybox2d/pybox2d
cd pybox2d_dev; python setup.py build; python setup.py install
RUFF_ARGS=
check: setup-test
uv run ruff check $(SRC_DIRS) $(RUFF_ARGS)
74 changes: 20 additions & 54 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,72 +1,38 @@
# energy-py
# energypy

[![Build Status](https://travis-ci.org/ADGEfficiency/energy-py.svg?branch=master)](https://travis-ci.org/ADGEfficiency/energy-py)
![Tests](https://github.com/ADGEfficiency/energy-py/actions/workflows/test.yml/badge.svg?branch=main)

energy-py is a framework for running reinforcement learning experiments on energy environments.
A framework for running reinforcement learning experiments on energy environments - starting with electric battery storage.

The library is focused on electric battery storage, and offers a implementation of a many batteries operating in parallel.

energy-py includes an implementation of the Soft Actor-Critic reinforcement learning agent, implementated in Tensorflow 2:

- test & train episodes based on historical Australian electricity price data,
- checkpoints & restarts,
- logging in Tensorboard.

energy-py is built and maintained by Adam Green - adam.green@adgefficiency.com.
## Features

- Electric battery storage environment for energy arbitrage
- Integration with [Gymnasium](https://gymnasium.farama.org/) as a custom Gymnasium environment
- Integration with [Stable Baselines 3](https://stable-baselines3.readthedocs.io/) for reinforcement learning agents
- Historical electricity price data for realistic training scenarios
- Experiment framework for training and evaluation on separate datasets
- Tensorboard logging for experiment tracking

## Setup

```bash
```shell-session
$ make setup
```

## Examples

## Test

```bash
$ make test
```


## Running experiments

`energypy` has a high level API to run a specific run of an experiment from a `JSON` config file.

The most interesting experiment is to run battery storage for price arbitrage in the Australian electricity market. This requires grabbing some data from S3. The command below will download a pre-made dataset and unzip it to `./dataset`:

```bash
$ make pulls3-dataset
```

You can then run the experiment from a JSON file:

```bash
$ energypy benchmarks/nem-battery.json
```shell-session
$ uv run examples/battery.py
```

Results are saved into `./experiments/{env_name}/{run_name}`:
Or run a more extensive experiment with real electricity price data:

```bash
$ tree -L 3 experiments
experiments/
└── battery
├── nine
│   ├── checkpoints
│   ├── hyperparameters.json
│   ├── logs
│   └── tensorboard
└── random.pkl
```shell-session
$ uv run examples/battery_arbitrage_experiments.py
```

Also provide wrappers around two `gym` environments - Pendulum and Lunar Lander:

```bash
$ energypy benchmarks/pendulum.json
```

Running the Lunar Lander experiment has a dependency on Swig and pybox2d - which can require a bit of elbow-grease to setup depending on your environment.
## Test

```bash
$ energypy benchmarks/lunar.json
```shell-session
$ make test
```
22 changes: 0 additions & 22 deletions benchmarks/battery.json

This file was deleted.

21 changes: 0 additions & 21 deletions benchmarks/lunar.json

This file was deleted.

21 changes: 0 additions & 21 deletions benchmarks/pendulum.json

This file was deleted.

3 changes: 0 additions & 3 deletions energypy/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions energypy/agent/__init__.py

This file was deleted.

40 changes: 0 additions & 40 deletions energypy/agent/alpha.py

This file was deleted.

Loading