Skip to content

Commit

Permalink
prepare assume-framework for first release (#177)
Browse files Browse the repository at this point in the history
This prepares the first release 0.1.0 of assume-framework
  • Loading branch information
maurerle authored Sep 12, 2023
1 parent f18442d commit 5a2f8ed
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 22 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/lint-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ jobs:
# stop the build if there are Python syntax errors or undefined names
black --check assume examples tests
isort --check assume examples tests
- name: Test with pytest
- name: Test with pytest & integration tests
run: |
pytest --cov --cov-report=xml --junitxml="result.xml" -m "not require_learning"
pytest -m "not require_learning"
- name: Install torch dependencies
run: |
python -m pip install -e .[learning]
- name: Run Learning with assume cli in in-memory db
- name: Test pytest with torch & integration tests
run: |
assume -s example_01_rl -db "sqlite:///"
pytest --cov --cov-report=xml --junitxml="result.xml"
- name: Upload tests results
uses: actions/upload-artifact@v3
Expand Down
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ focus on the German market setup. As a newly developed open-source
model its priority is to ensure usability and customisability
for a variety of users and use cases in the energy system modelling community.

The unique feature of the ASSUME tool-box is the integration of **deep reinforcement
The unique feature of the ASSUME toolbox is the integration of **deep reinforcement
learning** methods into the behavioural strategies of market agents.
The model comes with different predefined agent representations for the demand and
generation side that can be used as plug-and-play modules,
Expand All @@ -17,7 +17,7 @@ This setup enables a research of new market designs and dynamics in the energy m

The project is developed by [developers](https://assume.readthedocs.io/en/latest/developers.html) from INATECH at University of Freiburg, IISM at KIT, Fraunhofer ISI, FH Aachen.
The project ASSUME is funded by the Federal Ministry for Economic
Affairs and Energy (BMWK).
Affairs and Climate Action (BMWK).

Documentation
=============
Expand All @@ -30,6 +30,23 @@ Documentation
Installation
============


Using pip
---------

The project is available on [PyPi](https://pypi.org/) and can be simply installed:

```
pip install assume-framework
```

if you want to install it with testin capabilities run:

```
pip install assume-framework[test]
```


Using conda
-----------

Expand Down
14 changes: 8 additions & 6 deletions assume/common/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(
db_engine=None,
export_csv_path: str = "",
save_frequency_hours: int = 24,
learning_mode: bool = False,
):
super().__init__()

Expand All @@ -55,13 +56,14 @@ def __init__(
shutil.rmtree(self.p, ignore_errors=True)
self.p.mkdir(parents=True)
self.db = db_engine
self.learning_mode = learning_mode

# learning
episode = self.simulation_id.split("_")[-1]
if episode.isdigit():
self.episode = int(episode)
else:
self.episode = None
self.episode = None
if self.learning_mode:
episode = self.simulation_id.split("_")[-1]
if episode.isdigit():
self.episode = int(episode)

# contruct all timeframe under which hourly values are written to excel and db
self.start = start
Expand Down Expand Up @@ -339,7 +341,7 @@ async def on_stop(self):
logger.error(f"No scenario run Yet {e}")

def learning_queries(self):
if not self.episode:
if not self.learning_mode:
return []

queries = [
Expand Down
2 changes: 1 addition & 1 deletion assume/common/scenario_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ async def load_scenario_folder_async(

index = pd.date_range(
start=start,
end=end + pd.Timedelta(hours=24),
end=end,
freq=config["time_step"],
)
# get extra parameters for bidding strategies
Expand Down
1 change: 1 addition & 0 deletions assume/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ async def setup_output_agent(self, simulation_id: str, save_frequency_hours: int
db_engine=self.db,
export_csv_path=self.export_csv_path,
save_frequency_hours=save_frequency_hours,
learning_mode=self.learning_mode,
)
if self.same_process:
output_agent = RoleAgent(
Expand Down
45 changes: 45 additions & 0 deletions examples/inputs/example_01_rl/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,48 @@ base:
minimum_bid_price: -500
price_unit: EUR/MWh
market_mechanism: pay_as_clear


tiny:
start_date: 2019-01-01 00:00
end_date: 2019-01-02 00:00
time_step: 1h
save_frequency_hours: 24

learning_config:
observation_dimension: 50
action_dimension: 2
continue_learning: False
load_model_path: None
max_bid_price: 100
learning_mode: True
algorithm: matd3
learning_rate: 0.001
training_episodes: 2
collecting_initial_experience: 1
train_freq: 24
gradient_steps: -1
batch_size: 128
gamma: 0.99
device: cpu
noise_sigma: 0.1
noise_scale: 1
noise_dt: 1
validation_episodes_interval: 10

markets_config:
EOM:
operator: EOM_operator
product_type: energy
products:
- duration: 1h
count: 1
first_delivery: 1h
opening_frequency: 1h
opening_duration: 1h
volume_unit: MWh
maximum_bid_volume: 100000
maximum_bid_price: 3000
minimum_bid_price: -500
price_unit: EUR/MWh
market_mechanism: pay_as_clear
22 changes: 22 additions & 0 deletions examples/inputs/example_01a/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ base:
price_unit: EUR/MWh
market_mechanism: pay_as_clear

tiny:
start_date: 2019-01-01 00:00
end_date: 2019-01-02 00:00
time_step: 1h
save_frequency_hours: 24
markets_config:
EOM:
operator: EOM_operator
product_type: energy
products:
- duration: 1h
count: 1
first_delivery: 1h
opening_frequency: 1h
opening_duration: 1h
volume_unit: MWh
maximum_bid_volume: 100000
maximum_bid_price: 3000
minimum_bid_price: -500
price_unit: EUR/MWh
market_mechanism: pay_as_clear

dam:
start_date: 2019-01-01 00:00
end_date: 2019-04-01 00:00
Expand Down
15 changes: 7 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tool.poetry]
name = "assume_framework"
version = "0.0.1"
description = "ASSUME - Agent based energy market modeling using mango agents"
authors = ["ASSUME developers <[email protected].de>"]
name = "assume-framework"
version = "0.1.0"
description = "ASSUME - Agent-Based Electricity Markets Simulation Toolbox"
authors = ["ASSUME Developers <contact@assume-project.de>"]
license = "LICENSE"
readme = "README.md"

Expand All @@ -14,10 +14,9 @@ keywords = ["agent based simulation", "energy market", "reinforcement learning",
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3 (AGPLv3)",
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
"Operating System :: OS Independent",
"Framework :: asyncio",
"Framework :: mango-agents",
"Framework :: AsyncIO",
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Libraries :: Python Modules",
]
Expand All @@ -29,7 +28,7 @@ packages = [
[tool.poetry.dependencies]
python = "^3.10"
paho-mqtt = "^1.5.1"
mango-agents = {git = "https://gitlab.com/maurerle/mango"}
mango-agents = "^1.1.1"
tqdm = "^4.64.1"
python-dateutil = "^2.8.2"
sqlalchemy = "^2.0.9"
Expand Down
9 changes: 8 additions & 1 deletion tests/test_integration_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@

@pytest.mark.slow
def test_cli():
args = "-s example_01a -c base -db sqlite:///./examples/local_db/test_mini.db"
args = "-s example_01a -c tiny -db sqlite:///./examples/local_db/test_mini.db"
cli(args.split(" "))


@pytest.mark.slow
@pytest.mark.require_learning
def test_cli_learning():
args = "-s example_01_rl -c tiny -db sqlite:///./examples/local_db/test_mini_rl.db"
cli(args.split(" "))

0 comments on commit 5a2f8ed

Please sign in to comment.