OpenModelica Microgrid Gym
Project description
OpenModelica Microgrid Gym
The OpenModelica Microgrid Gym (OMG) package is a software toolbox for the simulation and control optimization of microgrids based on energy conversion by power electronic converters.
The main characteristics of the toolbox are the plug-and-play grid design and simulation in OpenModelica as well as the ready-to-go approach of intuitive reinfrocement learning (RL) approaches through a Python interface.
The OMG toolbox is built upon the OpenAI Gym environment definition framework. Therefore, the toolbox is specifically designed for running reinforcement learning algorithms to train agents controlling power electronic converters in microgrids. Nevertheless, also arbritary classical control approaches can be combined and tested using the OMG interface.
Free software: GNU General Public License v3
Documentation: https://upb-lea.github.io/openmodelica-microgrid-gym
Installation
Install Python Environment
Since it is not possible to install PyFMI, a package which is necessary for the communication between the python interface and the environment, via pip, we recommend to install this package in advance in a conda environment.
If conda is NOT installed on your PC, install miniconda for python 3.8
Create a new conda environment (e.g. in PyCharm)
Install PyFMI from the conda-forge channel in the terminal:
$ conda install -c conda-forge pyfmi
Install OpenModelica MicrogridGym from PyPI (recommended):
$ pip install openmodelica_microgrid_gym
Installation of OpenModelica
OMG was create by using OMEdit v1.16
In case of installation issues you can resort to their pre-built virtual machine.
Getting started
The environment is initialized and run like any other OpenAI Gym
import gym
if __name__ == '__main__':
env = gym.make('openmodelica_microgrid_gym:ModelicaEnv-v1',
model_input=['i1p1', 'i1p2', 'i1p3'],
model_output=dict(lc1=['inductor1.i', 'inductor2.i', 'inductor3.i']),
model_path='grid.network.fmu')
env.reset()
for _ in range(1000):
env.render()
env.step(env.action_space.sample()) # pick three continous control actions randomly
env.close()
OMG uses the FMI standard for the exchange of the model between OpenModelica and Python.
An example network consisting out of two inverters, three filters and an inductive load.
You can either use one of the provided FMUs (Windows and Linux, 64-bit, both included in the grid.network.fmu) or create your own by running:
openmodelica_microgrid_gym\fmu> omc create_fmu.mos
Running the staticctrl.py starts a simulation with a manually tuned cascaded PIPI controller
A save Bayesian approach of a reinforcement learning agent is provided under examples/berkamkamp.py.
Citation & white paper
Please find a white paper on the OMG toolbox including an exemplary usage scenario here:
Please use the following BibTeX entry for citing us:
@misc{OMG2020, title={Towards a Scalable and Flexible Simulation and Testing Environment Toolbox for Intelligent Microgrid Control}, author={Henrik Bode and Stefan Heid and Daniel Weber and Eyke Hüllermeier and Oliver Wallscheid}, year={2020}, eprint={http://arxiv.org/abs/2005.04869}, archivePrefix={arXiv}, primaryClass={eess.SY} }
Contributing
Please refer to the contribution guide.
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.2.0 (2020-05-27)
API
- ModelicaEnv:
reward function parameter
vis_cols now also supports Plotting templates
EmptyHistory and descendant: update(), append()
Agent: added properties
StaticControlAgent and descendant: small changes in constructor params, specifically obs_template, added properties
SafeOptAgent: added properties
Runner: plotting can be disabled
Examples
added example for plotting
Performance
6.6× speedup
Dependencies
Increased Language Level to Python 3.8
0.1.3 (2020-05-13)
best parameter set output after termination of SafeOpt agent (#7)
proper action and observation space (#14)
resolved problem related to environment
model_params
(#21)
documentation improvements (more examples, installation)
0.1.2 (2020-05-04)
corrected pip install requirements
0.1.1 (2020-04-22)
First release on PyPI.
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
Built Distribution
Hashes for openmodelica_microgrid_gym-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4924887d4dc926553adc7d3e60bc67dc1101c5f96b4171cfd82ec0ee31649fb0 |
|
MD5 | 1c95631749044f4f24e6e0eff55c4758 |
|
BLAKE2b-256 | 92edcd5c5eb7e957dcc616275aff2056b8df2afb6748e5fe25a5caa4156a56fa |
Hashes for openmodelica_microgrid_gym-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0847f5da30dfa3ab02d2e62182c8324f07f793f6e82dc8bfd397551c682c827d |
|
MD5 | d1c6bd277544754bff62cee793a78ab0 |
|
BLAKE2b-256 | 6677dbcc936e521517b96eac2dcef735e3053d6bc596e7b5c2514018b581831d |