GithubHelp home page GithubHelp logo

00mjk / openmodelica-microgrid-gym Goto Github PK

View Code? Open in Web Editor NEW

This project forked from upb-lea/openmodelica-microgrid-gym

0.0 0.0 0.0 40.13 MB

OpenModelica Microgrid Gym (OMG): An OpenAI Gym Environment for Microgrids

License: GNU General Public License v3.0

Makefile 0.63% Modelica 70.79% Python 28.58%

openmodelica-microgrid-gym's Introduction

OpenModelica Microgrid Gym

build cov     python pypi download     license
https://github.com/upb-lea/openmodelica-microgrid-gym/raw/develop/docs/pictures/omg_flow.png

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.

Installation

Install Python Environment

This is the short installation guide for Windows and Linux. OpenModelica is hardly supported for Mac, they suggest to install in a Linux VM. For this reason, running OMG in a Linux VM is strongly recommended for Mac users!

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. As of now, only Windows and Linux are supported officially.

  • 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',
                   max_episode_steps=None,
                   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.

https://github.com/upb-lea/openmodelica-microgrid-gym/raw/master/docs/pictures/omedit.jpg

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

https://github.com/upb-lea/openmodelica-microgrid-gym/raw/master/docs/pictures/control.jpg

A save Bayesian approach of a reinforcement learning agent is provided under examples/berkamkamp.py.

https://github.com/upb-lea/openmodelica-microgrid-gym/raw/master/docs/pictures/kp_kp_J.png

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:

@article{OMG-code2020,
    title = {OMG: A Scalable and Flexible Simulation and Testing Environment Toolbox for Intelligent Microgrid Control},
    author = {Stefan Heid and Daniel Weber and Henrik Bode and Eyke Hüllermeier and Oliver Wallscheid},
    year = {2020},
    doi = {10.21105/joss.02435},
    url = {https://doi.org/10.21105/joss.02435},
    publisher = {The Open Journal},
    volume = {5},
    number = {54},
    pages = {2435},
    journal = {Journal of Open Source Software}
}

@article{OMG-whitepaper2020,
    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.

openmodelica-microgrid-gym's People

Contributors

dhhagan avatar h-bode avatar wallscheid avatar webbah avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.