├── .gitattributes ├── .github └── workflows │ ├── build.yml │ ├── documentation-links.yaml │ └── garage-compat.yml ├── .gitignore ├── .readthedocs.yaml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── MANIFEST.in ├── README.md ├── docs ├── Makefile ├── make.bat ├── requirements.txt └── source │ ├── _templates │ └── autosummary │ │ ├── base.rst │ │ └── class.rst │ ├── conf.py │ ├── examples │ ├── index.rst │ ├── mpc-example.nblink │ ├── quick-start.nblink │ ├── rbc-example.nblink │ └── rl-example.nblink │ ├── getting_started.rst │ ├── index.rst │ └── reference │ ├── algos │ └── index.rst │ ├── envs │ └── index.rst │ ├── forecast │ └── index.rst │ ├── general │ └── index.rst │ ├── index.rst │ ├── microgrid.rst │ └── modules │ └── index.rst ├── notebooks ├── mpc-example.ipynb ├── quick-start.ipynb ├── rbc-example.ipynb └── rl-example.ipynb ├── pymgrid 25 - benchmarks.xlsx ├── pyproject.toml ├── requirements.txt ├── setup.cfg ├── setup.py ├── src ├── __init__.py └── pymgrid │ ├── MicrogridGenerator.py │ ├── __init__.py │ ├── _deprecated │ ├── Environments │ │ ├── Environment.py │ │ ├── Preprocessing.py │ │ ├── __init__.py │ │ ├── pymgrid_csca.py │ │ ├── pymgrid_csca_old.py │ │ ├── pymgrid_csda.py │ │ └── pymgrid_cspla.py │ ├── __init__.py │ └── non_modular_microgrid.py │ ├── algos │ ├── Control.py │ ├── __init__.py │ ├── example.log │ ├── mpc │ │ ├── __init__.py │ │ └── mpc.py │ ├── priority_list │ │ ├── __init__.py │ │ ├── priority_list.py │ │ └── priority_list_element.py │ ├── rbc │ │ ├── __init__.py │ │ ├── _nonmodular_rbc.py │ │ └── rbc.py │ └── saa │ │ ├── __init__.py │ │ └── saa.py │ ├── convert │ ├── __init__.py │ ├── convert.py │ ├── get_module.py │ └── to_nonmodular_ops.py │ ├── data │ ├── __init__.py │ ├── co2 │ │ ├── __init__.py │ │ ├── co2_caiso.csv │ │ └── co2_duke.csv │ ├── load │ │ ├── RefBldgFullServiceRestaurantNew2004_v1.3_7.1_6A_USA_MN_MINNEAPOLIS.csv │ │ ├── RefBldgHospitalNew2004_7.1_5.0_3C_USA_CA_SAN_FRANCISCO.csv │ │ ├── RefBldgLargeHotelNew2004_v1.3_7.1_4A_USA_MD_BALTIMORE.csv │ │ ├── RefBldgLargeOfficeNew2004_v1.3_7.1_5A_USA_IL_CHICAGO-OHARE.csv │ │ ├── RefBldgPrimarySchoolNew2004_v1.3_7.1_2A_USA_TX_HOUSTON.csv │ │ └── __init__.py │ ├── pv │ │ ├── Houston_722430TYA.csv │ │ ├── Minneapolis_726580TYA.csv │ │ ├── NewYork_744860TYA.csv │ │ ├── Raleigh_723060TYA.csv │ │ ├── SanFrancisco_724940TYA.csv │ │ └── __init__.py │ └── scenario │ │ ├── __init__.py │ │ ├── pymgrid25.pkl │ │ └── pymgrid25 │ │ ├── microgrid_0 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_0.yaml │ │ ├── microgrid_1 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_1.yaml │ │ ├── microgrid_10 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_10.yaml │ │ ├── microgrid_11 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_11.yaml │ │ ├── microgrid_12 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_12.yaml │ │ ├── microgrid_13 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_13.yaml │ │ ├── microgrid_14 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_14.yaml │ │ ├── microgrid_15 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_15.yaml │ │ ├── microgrid_16 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_16.yaml │ │ ├── microgrid_17 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_17.yaml │ │ ├── microgrid_18 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_18.yaml │ │ ├── microgrid_19 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_19.yaml │ │ ├── microgrid_2 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_2.yaml │ │ ├── microgrid_20 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_20.yaml │ │ ├── microgrid_21 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_21.yaml │ │ ├── microgrid_22 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_22.yaml │ │ ├── microgrid_23 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_23.yaml │ │ ├── microgrid_24 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_24.yaml │ │ ├── microgrid_3 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_3.yaml │ │ ├── microgrid_4 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_4.yaml │ │ ├── microgrid_5 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_5.yaml │ │ ├── microgrid_6 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_6.yaml │ │ ├── microgrid_7 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_7.yaml │ │ ├── microgrid_8 │ │ ├── data │ │ │ └── cls_params │ │ │ │ ├── GridModule │ │ │ │ └── time_series.csv.gz │ │ │ │ ├── LoadModule │ │ │ │ └── time_series.csv.gz │ │ │ │ └── RenewableModule │ │ │ │ └── time_series.csv.gz │ │ └── microgrid_8.yaml │ │ └── microgrid_9 │ │ ├── data │ │ └── cls_params │ │ │ ├── GridModule │ │ │ └── time_series.csv.gz │ │ │ ├── LoadModule │ │ │ └── time_series.csv.gz │ │ │ └── RenewableModule │ │ │ └── time_series.csv.gz │ │ └── microgrid_9.yaml │ ├── envs │ ├── __init__.py │ ├── base │ │ ├── __init__.py │ │ ├── base.py │ │ └── skip_init.py │ ├── continuous │ │ ├── __init__.py │ │ └── continuous.py │ └── discrete │ │ ├── __init__.py │ │ └── discrete.py │ ├── forecast │ ├── __init__.py │ └── forecaster.py │ ├── microgrid │ ├── __init__.py │ ├── microgrid.py │ ├── reward_shaping │ │ ├── __init__.py │ │ ├── base.py │ │ ├── battery_discharge_shaper.py │ │ └── pv_curtailment_shaper.py │ ├── trajectory │ │ ├── __init__.py │ │ ├── base.py │ │ ├── deterministic.py │ │ └── stochastic.py │ └── utils │ │ ├── __init__.py │ │ └── step.py │ ├── modules │ ├── __init__.py │ ├── base │ │ ├── __init__.py │ │ ├── base_module.py │ │ └── timeseries │ │ │ ├── __init__.py │ │ │ └── base_timeseries_module.py │ ├── battery_module.py │ ├── genset_module.py │ ├── grid_module.py │ ├── load_module.py │ ├── module_container.py │ ├── renewable_module.py │ └── unbalanced_energy_module.py │ ├── utils │ ├── DataGenerator.py │ ├── __init__.py │ ├── logger.py │ ├── ray.py │ ├── serialize.py │ └── space.py │ └── version.py └── tests ├── __init__.py ├── conftest.py ├── control ├── __init__.py ├── data_generation │ ├── __init__.py │ └── test_data_generator.py ├── test_control.py ├── test_mpc.py └── test_rbc.py ├── envs ├── __init__.py ├── test_discrete.py └── test_trajectory.py ├── helpers ├── __init__.py ├── genset_module_testing_utils.py ├── modular_microgrid.py └── test_case.py ├── microgrid ├── __init__.py ├── modules │ ├── __init__.py │ ├── container_tests │ │ ├── __init__.py │ │ └── test_container.py │ ├── conversion_test │ │ ├── __init__.py │ │ └── test_modular_conversion.py │ ├── forecaster_tests │ │ ├── __init__.py │ │ └── test_forecaster.py │ └── module_tests │ │ ├── test_genset_long_status_changes.py │ │ ├── test_genset_module.py │ │ ├── test_genset_module_start_up_1_wind_down_1.py │ │ ├── test_load_module.py │ │ ├── test_renewable_module.py │ │ └── timeseries_modules.py ├── serialize │ └── test_microgrid_serialization.py └── test_microgrid.py ├── test_microgridgenerator.py └── test_nonmodular_microgrid.py /.gitattributes: -------------------------------------------------------------------------------- 1 | *.ipynb linguist-vendored -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # This workflow will install Python dependencies, run tests and lint with a variety of Python versions 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 3 | 4 | name: build 5 | 6 | on: 7 | push: 8 | branches: [ "master" ] 9 | pull_request: 10 | branches: [ "master" ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | python-version: ["3.8", "3.9", "3.10"] 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | - name: Set up Python ${{ matrix.python-version }} 24 | uses: actions/setup-python@v3 25 | with: 26 | python-version: ${{ matrix.python-version }} 27 | - name: Install dependencies 28 | run: | 29 | python -m pip install --upgrade pip 30 | python -m pip install flake8 pytest 31 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 32 | pip install -e .'[dev]' 33 | - name: Lint with flake8 34 | run: | 35 | # stop the build if there are Python syntax errors or undefined names 36 | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics 37 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide 38 | flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics 39 | - name: Test with pytest 40 | run: | 41 | pip install pytest 42 | pip install pytest-cov 43 | pip install pytest-subtests 44 | pytest tests/ --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html 45 | -------------------------------------------------------------------------------- /.github/workflows/documentation-links.yaml: -------------------------------------------------------------------------------- 1 | # .github/workflows/documentation-links.yaml 2 | 3 | name: Read the Docs Pull Request Preview 4 | on: 5 | pull_request_target: 6 | types: 7 | - opened 8 | 9 | permissions: 10 | pull-requests: write 11 | 12 | jobs: 13 | documentation-links: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: readthedocs/actions/preview@v1 17 | with: 18 | project-slug: "pymgrid" 19 | -------------------------------------------------------------------------------- /.github/workflows/garage-compat.yml: -------------------------------------------------------------------------------- 1 | # This workflow will install Python dependencies, run tests and lint with a variety of Python versions 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 3 | 4 | name: garage-compat 5 | 6 | on: 7 | push: 8 | branches: [ "master" ] 9 | pull_request: 10 | branches: [ "master" ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | python-version: ["3.8", "3.9"] 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | - name: Set up Python ${{ matrix.python-version }} 24 | uses: actions/setup-python@v3 25 | with: 26 | python-version: ${{ matrix.python-version }} 27 | - name: Install dependencies 28 | run: | 29 | python -m pip install --upgrade pip 30 | python -m pip install flake8 pytest 31 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 32 | pip install -e .'[dev]' 33 | - name: Get garage VERSION 34 | uses: wei/wget@v1 35 | with: 36 | args: -O VERSION https://raw.githubusercontent.com/rlworkgroup/garage/master/VERSION 37 | - name: Get garage README.md 38 | uses: wei/wget@v1 39 | with: 40 | args: -O README.md https://raw.githubusercontent.com/rlworkgroup/garage/master/README.md 41 | - name: Get garage setup.py 42 | uses: wei/wget@v1 43 | with: 44 | args: -O garage_setup.py https://raw.githubusercontent.com/rlworkgroup/garage/master/setup.py 45 | - name: Extract garage dependencies 46 | run: | 47 | python -m garage_setup egg_info 48 | in_all=false 49 | while IFS= read -r line; do 50 | if [[ "$line" == *"[all]"* ]]; then 51 | in_all=true 52 | elif [[ "$line" == \[* ]]; then 53 | in_all=false 54 | elif [[ $in_all == true ]]; then 55 | echo $"$line" >> src/garage.egg-info/requires_all.txt 56 | fi 57 | done < "src/garage.egg-info/requires.txt" 58 | - name: Install garage dependencies 59 | run: | 60 | sudo apt install libopenmpi-dev 61 | cat src/garage.egg-info/requires_all.txt 62 | python -m pip install -r src/garage.egg-info/requires_all.txt 63 | - name: Lint with flake8 64 | run: | 65 | # stop the build if there are Python syntax errors or undefined names 66 | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics 67 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide 68 | flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics 69 | - name: Test with pytest 70 | run: | 71 | pip install pytest 72 | pip install pytest-cov 73 | pip install pytest-subtests 74 | pytest tests/ --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html 75 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #Ignore what is not python code 2 | notebooks/ 3 | .DS_STORE 4 | .idea 5 | *.pkl 6 | pymgrid/__pycache__/ 7 | *.ipynb 8 | .ipynb_checkpoints 9 | __pycache__/ 10 | 11 | .Python 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | docs/source/reference/api/ 25 | pip-wheel-metadata/ 26 | share/python-wheels/ 27 | *.egg-info/ 28 | .installed.cfg 29 | *.egg 30 | MANIFEST 31 | *sandbox.py 32 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yaml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Set the version of Python and other tools you might need 9 | build: 10 | os: ubuntu-20.04 11 | tools: 12 | python: "3.8" 13 | 14 | sphinx: 15 | configuration: docs/source/conf.py 16 | 17 | python: 18 | install: 19 | - method: pip 20 | path: . 21 | extra_requirements: 22 | - all 23 | 24 | formats: 25 | - pdf -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | global-include *.csv 2 | global-include *.pkl 3 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | 13 | %SPHINXBUILD% >NUL 2>NUL 14 | if errorlevel 9009 ( 15 | echo. 16 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 17 | echo.installed, then set the SPHINXBUILD environment variable to point 18 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 19 | echo.may add the Sphinx directory to PATH. 20 | echo. 21 | echo.If you don't have Sphinx installed, grab it from 22 | echo.https://www.sphinx-doc.org/ 23 | exit /b 1 24 | ) 25 | 26 | if "%1" == "" goto help 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | nbsphinx==0.8.10 2 | nbsphinx-link==1.3.0 3 | numpydoc==1.5.0 4 | pydata_sphinx_theme==0.12.0 5 | Sphinx==5.3.0 6 | -------------------------------------------------------------------------------- /docs/source/_templates/autosummary/base.rst: -------------------------------------------------------------------------------- 1 | {{ objname | escape | underline }} 2 | 3 | .. currentmodule:: {{ module }} 4 | 5 | .. auto{{ objtype }}:: {{ objname }} 6 | -------------------------------------------------------------------------------- /docs/source/_templates/autosummary/class.rst: -------------------------------------------------------------------------------- 1 | {{ fullname | escape | underline}} 2 | 3 | .. currentmodule:: {{ module }} 4 | 5 | .. autoclass:: {{ objname }} 6 | 7 | {% block methods %} 8 | 9 | {% if methods %} 10 | .. rubric:: {{ _('Methods') }} 11 | 12 | .. autosummary:: 13 | :toctree: generated/ 14 | 15 | {% for item in methods %} 16 | {% if item != "__init__" %} 17 | ~{{ name }}.{{ item }} 18 | {% endif %} 19 | {%- endfor %} 20 | {% endif %} 21 | {% endblock %} 22 | 23 | {% block attributes %} 24 | {% if attributes %} 25 | .. rubric:: {{ _('Attributes') }} 26 | 27 | .. autosummary:: 28 | :toctree: generated/ 29 | 30 | {% for item in attributes %} 31 | ~{{ name }}.{{ item }} 32 | {%- endfor %} 33 | {% endif %} 34 | {% endblock %} 35 | -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # For the full list of built-in configuration values, see the documentation: 4 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 5 | 6 | import inspect 7 | import os 8 | import sys 9 | 10 | from copy import deepcopy 11 | from builtins import object 12 | 13 | import pymgrid 14 | 15 | 16 | # -- Project information ----------------------------------------------------- 17 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information 18 | 19 | project = 'pymgrid' 20 | copyright = '2022, TotalEnergies' 21 | author = 'Avishai Halev' 22 | release = pymgrid.__version__ 23 | version = pymgrid.__version__ 24 | 25 | # -- General configuration --------------------------------------------------- 26 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration 27 | 28 | extensions = [ 29 | 'sphinx.ext.duration', 30 | 'sphinx.ext.autodoc', 31 | 'sphinx.ext.coverage', 32 | 'sphinx.ext.autosummary', 33 | 'sphinx.ext.doctest', 34 | 'sphinx.ext.linkcode', 35 | 'sphinx.ext.intersphinx', 36 | 'sphinx.ext.mathjax', 37 | 'nbsphinx', 38 | 'nbsphinx_link', 39 | 'IPython.sphinxext.ipython_console_highlighting' 40 | ] 41 | 42 | templates_path = ['_templates'] 43 | exclude_patterns = [] 44 | 45 | 46 | # -- Options for HTML output ------------------------------------------------- 47 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output 48 | 49 | html_theme = 'pydata_sphinx_theme' 50 | 51 | html_theme_options = { 52 | "primary_sidebar_end": ["indices.html", "sidebar-ethical-ads.html"], 53 | 54 | "logo": { 55 | "image_light": "logo-light.png", 56 | "image_dark": "logo-dark.png", 57 | }, 58 | 59 | "icon_links": [ 60 | { 61 | "name": "GitHub", 62 | "url": "https://github.com/Total-RD/pymgrid", 63 | "icon": "fa-brands fa-github", 64 | }, 65 | { 66 | "name": "PyPI", 67 | "url": "https://pypi.org/project/pymgrid/", 68 | "icon": "fa-solid fa-box", 69 | } 70 | ] 71 | } 72 | 73 | 74 | html_static_path = ['_static'] 75 | 76 | 77 | # These are attributes that don't have a __doc__ attribute to read ':meta private:' from. 78 | skip_members = [ 79 | 'yaml_flow_style', 80 | 'metadata', 81 | 'render_mode', 82 | 'reward_range', 83 | 'spec' 84 | ] 85 | 86 | 87 | def autodoc_skip_member(app, what, name, obj, skip, options): 88 | if name in skip_members: 89 | return True 90 | 91 | try: 92 | doc = obj.__doc__ 93 | except AttributeError: 94 | return None 95 | 96 | if doc is not None and ':meta private:' in doc: 97 | return True 98 | return None 99 | 100 | 101 | def autodoc_process_signature(app, what, name, obj, options, signature, return_annotation): 102 | """ 103 | If a class signature is being read from cls.__new__, we want to replace it with the signature from cls.__init__. 104 | """ 105 | if what == 'class' and signature[1:] in str(inspect.signature(obj.__new__)): 106 | obj_copy = deepcopy(obj) 107 | obj_copy.__new__ = object.__new__ 108 | signature = str(inspect.signature(obj_copy)) 109 | return signature, return_annotation 110 | 111 | 112 | def linkcode_resolve(domain, info): 113 | """ 114 | Determine the URL corresponding to Python object 115 | """ 116 | if domain != "py": 117 | return None 118 | 119 | modname = info["module"] 120 | fullname = info["fullname"] 121 | 122 | submod = sys.modules.get(modname) 123 | if submod is None: 124 | return None 125 | 126 | obj = submod 127 | for part in fullname.split("."): 128 | try: 129 | obj = getattr(obj, part) 130 | except AttributeError: 131 | return None 132 | 133 | try: 134 | fn = inspect.getsourcefile(inspect.unwrap(obj)) 135 | except TypeError: 136 | try: # property 137 | fn = inspect.getsourcefile(inspect.unwrap(obj.fget)) 138 | except (AttributeError, TypeError): 139 | fn = None 140 | if not fn: 141 | return None 142 | 143 | try: 144 | source, lineno = inspect.getsourcelines(obj) 145 | except TypeError: 146 | try: # property 147 | source, lineno = inspect.getsourcelines(obj.fget) 148 | except (AttributeError, TypeError): 149 | lineno = None 150 | except OSError: 151 | lineno = None 152 | 153 | if lineno: 154 | linespec = f"#L{lineno}-L{lineno + len(source) - 1}" 155 | else: 156 | linespec = "" 157 | 158 | fn = os.path.relpath(fn, start=os.path.dirname(pymgrid.__file__)) 159 | 160 | return f'https://github.com/Total-RD/pymgrid/tree/v{pymgrid.__version__}/src/pymgrid/{fn}{linespec}' 161 | 162 | 163 | intersphinx_mapping = { 164 | 'gym': ('https://www.gymlibrary.dev/', None) 165 | } 166 | 167 | 168 | def setup(app): 169 | app.connect('autodoc-skip-member', autodoc_skip_member) 170 | app.connect('autodoc-process-signature', autodoc_process_signature) 171 | -------------------------------------------------------------------------------- /docs/source/examples/index.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | To run the examples, clone the repository: 5 | 6 | .. code-block:: bash 7 | 8 | $ git clone https://github.com/Total-RD/pymgrid.git 9 | 10 | and use `Jupyter `_ to open any notebook in 11 | the :code:`notebooks` directory. 12 | 13 | .. toctree:: 14 | :maxdepth: 2 15 | 16 | quick-start 17 | rbc-example 18 | mpc-example 19 | rl-example -------------------------------------------------------------------------------- /docs/source/examples/mpc-example.nblink: -------------------------------------------------------------------------------- 1 | { 2 | "path": "../../../notebooks/mpc-example.ipynb" 3 | } -------------------------------------------------------------------------------- /docs/source/examples/quick-start.nblink: -------------------------------------------------------------------------------- 1 | { 2 | "path": "../../../notebooks/quick-start.ipynb" 3 | } 4 | -------------------------------------------------------------------------------- /docs/source/examples/rbc-example.nblink: -------------------------------------------------------------------------------- 1 | { 2 | "path": "../../../notebooks/rbc-example.ipynb" 3 | } 4 | -------------------------------------------------------------------------------- /docs/source/examples/rl-example.nblink: -------------------------------------------------------------------------------- 1 | { 2 | "path": "../../../notebooks/rl-example.ipynb" 3 | } 4 | -------------------------------------------------------------------------------- /docs/source/getting_started.rst: -------------------------------------------------------------------------------- 1 | Getting Started 2 | =============== 3 | 4 | .. _installation: 5 | 6 | Installation 7 | ------------ 8 | 9 | The easiest way to install *pymgrid* is with pip: 10 | 11 | .. code-block:: console 12 | 13 | $ pip install -U pymgrid 14 | 15 | Alternatively, you can install from source. First clone the repo: 16 | 17 | .. code-block:: bash 18 | 19 | $ git clone https://github.com/Total-RD/pymgrid.git 20 | 21 | Then navigate to the root directory of pymgrid and call 22 | 23 | .. code-block:: bash 24 | 25 | $ pip install . 26 | 27 | Advanced Installation 28 | --------------------- 29 | 30 | To use the included model predictive control algorithm on microgrids containing gensets, 31 | additional dependencies are required as the optimization problem becomes mixed integer. 32 | 33 | The packages MOSEK and CVXOPT can both handle this case; you can install both by calling 34 | 35 | .. code-block:: bash 36 | 37 | $ pip install pymgrid[genset_mpc] 38 | 39 | Note that MOSEK requires a license; see https://www.mosek.com/ for details. 40 | Academic and trial licenses are available. 41 | 42 | Simple Example 43 | -------------- 44 | See :doc:`examples/quick-start` for a simple example to get started. 45 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | .. pymgrid documentation master file, created by 2 | sphinx-quickstart on Sat Nov 19 12:49:18 2022. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | ********************* 7 | pymgrid documentation 8 | ********************* 9 | 10 | Important Notice 11 | ---------------- 12 | 13 | **The person that has been maintaining pymgrid since 2020 has moved future development to** 14 | `python-microgrid `__ 15 | **for the foreseeable future, a drop in replacement for pymgrid, and pymgrid may not be receiving any future updates.** 16 | **Please open any new issues in python-microgrid. You can also view python-microgrid's documentation** 17 | `at this link `__. 18 | 19 | **Version**: |version| 20 | 21 | *pymgrid* is a Python library to simulate tertiary control of electrical microgrids. *pymgrid* allows 22 | users to create and customize microgrids of their choosing. These microgrids can then be controlled using a user-defined 23 | algorithm or one of the control algorithms contained in *pymgrid*: rule-based control and model predictive control. 24 | 25 | Environments corresponding to the OpenAI-Gym API are also provided, with both continuous and discrete action space 26 | environments available. These environments can be used with your choice of reinforcement learning algorithm to train 27 | a control algorithm. 28 | 29 | *pymgrid* attempts to offer the simplest and most intuitive API possible, allowing the user to 30 | focus on their particular application. 31 | 32 | See the :doc:`getting_started` section for further information, including instructions on how to 33 | :ref:`install ` the project. 34 | 35 | **Useful links**: 36 | `Binary Installers `__ | 37 | `Source Repository `__ 38 | 39 | 40 | .. note:: 41 | 42 | This project is under active development. 43 | 44 | Contents 45 | ======== 46 | 47 | .. toctree:: 48 | :maxdepth: 2 49 | 50 | getting_started 51 | examples/index 52 | reference/index 53 | 54 | Indices and tables 55 | ================== 56 | 57 | * :ref:`genindex` 58 | * :ref:`modindex` 59 | * :ref:`search` 60 | -------------------------------------------------------------------------------- /docs/source/reference/algos/index.rst: -------------------------------------------------------------------------------- 1 | .. _api.control: 2 | 3 | Control Algorithms 4 | ================== 5 | 6 | .. currentmodule:: pymgrid.algos 7 | 8 | Control algorithms built into pymgrid, as well as references for external algorithms that can be deployed 9 | 10 | Rule Based Control 11 | ------------------ 12 | 13 | Heuristic Algorithm that deploys modules via a priority list. 14 | 15 | .. autosummary:: 16 | :toctree: ../api/algos/ 17 | 18 | RuleBasedControl 19 | 20 | 21 | Model Predictive Control 22 | ------------------------ 23 | 24 | Algorithm that depends on a future forecast as well as a model of state transitions to determine optimal controls. 25 | 26 | 27 | .. autosummary:: 28 | :toctree: ../api/algos/ 29 | 30 | ModelPredictiveControl 31 | 32 | 33 | Reinforcement Learning 34 | ---------------------- 35 | 36 | Algorithms that treat a microgrid as a Markov process, and train a black-box policy by repeated interactions with 37 | the environment. See :doc:`here <../../examples/rl-example>` for an example of using 38 | reinforcement learning to train such an algorithm. 39 | 40 | 41 | 42 | .. 43 | HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages. 44 | Copied from pandas docs. 45 | 46 | .. currentmodule:: pymgrid.algos.priority_list 47 | 48 | .. autosummary:: 49 | :toctree: ../api/algos/priority_list/ 50 | PriorityListElement -------------------------------------------------------------------------------- /docs/source/reference/envs/index.rst: -------------------------------------------------------------------------------- 1 | .. _api.envs: 2 | 3 | Reinforcement Learning (RL) Environments 4 | ====================== 5 | 6 | .. currentmodule:: pymgrid.envs 7 | 8 | Environment classes using the `OpenAI Gym API `_ for reinforcement learning. 9 | 10 | Discrete 11 | -------- 12 | 13 | Environment with a discrete action space. 14 | 15 | 16 | .. autosummary:: 17 | :toctree: ../api/envs/ 18 | 19 | DiscreteMicrogridEnv 20 | 21 | Continuous 22 | ---------- 23 | 24 | Environment with a discrete action space. 25 | 26 | 27 | .. autosummary:: 28 | :toctree: ../api/envs/ 29 | 30 | ContinuousMicrogridEnv 31 | -------------------------------------------------------------------------------- /docs/source/reference/forecast/index.rst: -------------------------------------------------------------------------------- 1 | .. _api.forecast: 2 | 3 | Forecasting 4 | =========== 5 | 6 | .. currentmodule:: pymgrid.forecast 7 | 8 | Classes available to use for time-series forecasting, as well a class that allows users to define their own forecaster. 9 | 10 | .. autosummary:: 11 | :toctree: ../api/forecast/ 12 | 13 | get_forecaster 14 | OracleForecaster 15 | GaussianNoiseForecaster 16 | UserDefinedForecaster 17 | NoForecaster 18 | 19 | -------------------------------------------------------------------------------- /docs/source/reference/general/index.rst: -------------------------------------------------------------------------------- 1 | .. _api.general: 2 | 3 | General functions and objects 4 | ============================= 5 | 6 | .. currentmodule:: pymgrid.modules 7 | 8 | ModuleContainer 9 | --------------- 10 | 11 | Object that store's a microgrid's modules. 12 | 13 | .. autosummary:: 14 | :toctree: ../api/general/ 15 | 16 | ModuleContainer 17 | 18 | ModuleSpace 19 | ----------- 20 | 21 | Object for module action and observation spaces. 22 | 23 | .. currentmodule:: pymgrid.utils.space 24 | 25 | .. autosummary:: 26 | :toctree: ../api/general/ 27 | 28 | ModuleSpace 29 | -------------------------------------------------------------------------------- /docs/source/reference/index.rst: -------------------------------------------------------------------------------- 1 | API reference 2 | ============= 3 | 4 | This page contains an overview of all public *pymgrid* objects and functions. 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | microgrid 10 | modules/index 11 | forecast/index 12 | envs/index 13 | algos/index 14 | general/index -------------------------------------------------------------------------------- /docs/source/reference/microgrid.rst: -------------------------------------------------------------------------------- 1 | .. _api.microgrid: 2 | 3 | 4 | Microgrid 5 | ================= 6 | 7 | .. currentmodule:: pymgrid 8 | 9 | Constructor 10 | ----------- 11 | .. autosummary:: 12 | :toctree: api/microgrid/ 13 | 14 | Microgrid 15 | 16 | Methods 17 | ------- 18 | .. autosummary:: 19 | 20 | :toctree: api/microgrid/ 21 | 22 | Microgrid.run 23 | Microgrid.reset 24 | Microgrid.sample_action 25 | Microgrid.get_log 26 | Microgrid.get_forecast_horizon 27 | Microgrid.get_empty_action 28 | 29 | Serialization/IO/Conversion 30 | --------------------------- 31 | .. autosummary:: 32 | 33 | :toctree: api/microgrid/ 34 | 35 | Microgrid.load 36 | Microgrid.dump 37 | Microgrid.from_nonmodular 38 | Microgrid.from_scenario 39 | Microgrid.to_nonmodular -------------------------------------------------------------------------------- /docs/source/reference/modules/index.rst: -------------------------------------------------------------------------------- 1 | .. _api.modules: 2 | 3 | Modules 4 | ======= 5 | 6 | .. currentmodule:: pymgrid.modules 7 | 8 | The modules defined here are commonly found in microgrids. 9 | Pass any combination of modules to :ref:`Microgrid ` to define and run a microgrid. 10 | 11 | Timeseries Modules 12 | ------------------ 13 | 14 | Modules that are temporal in nature. 15 | 16 | 17 | 18 | .. autosummary:: 19 | :toctree: ../api/modules/ 20 | 21 | GridModule 22 | LoadModule 23 | RenewableModule 24 | 25 | Non-temporal Modules 26 | -------------------- 27 | 28 | Modules that do not depend on an underlying timeseries. 29 | 30 | .. autosummary:: 31 | :toctree: ../api/modules/ 32 | 33 | BatteryModule 34 | GensetModule 35 | 36 | Helper Module 37 | -------------- 38 | 39 | A module that cleans up after all the other modules are deployed. 40 | 41 | .. autosummary:: 42 | :toctree: ../api/modules/ 43 | 44 | UnbalancedEnergyModule -------------------------------------------------------------------------------- /notebooks/mpc-example.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "c9464f3b", 6 | "metadata": {}, 7 | "source": [ 8 | "### Model Predictive Control\n", 9 | "\n", 10 | "Coming Soon." 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "id": "25adf05f", 17 | "metadata": {}, 18 | "outputs": [], 19 | "source": [] 20 | } 21 | ], 22 | "metadata": { 23 | "kernelspec": { 24 | "display_name": "Python 3 (ipykernel)", 25 | "language": "python", 26 | "name": "python3" 27 | }, 28 | "language_info": { 29 | "codemirror_mode": { 30 | "name": "ipython", 31 | "version": 3 32 | }, 33 | "file_extension": ".py", 34 | "mimetype": "text/x-python", 35 | "name": "python", 36 | "nbconvert_exporter": "python", 37 | "pygments_lexer": "ipython3", 38 | "version": "3.9.13" 39 | } 40 | }, 41 | "nbformat": 4, 42 | "nbformat_minor": 5 43 | } 44 | -------------------------------------------------------------------------------- /pymgrid 25 - benchmarks.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/pymgrid 25 - benchmarks.xlsx -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.pytest.ini_options] 2 | log_cli = true 3 | log_cli_level = "INFO" 4 | log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)" 5 | log_cli_date_format = "%Y-%m-%d %H:%M:%S" -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | cufflinks>=0.17.3 2 | cvxpy>=1.1.4 3 | gym>=0.15.7 4 | matplotlib>=3.1.1 5 | numpy>=1.19.5 6 | pandas>=1.0.3 7 | plotly>=4.9.0 8 | scipy>=1.5.3 9 | statsmodels>=0.11.1 10 | tqdm>=4.1.0 11 | pyyaml>=1.5 -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.md 3 | 4 | [tool:pytest] 5 | norecursedirs=tests/helpers -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | from setuptools import setup, find_packages 3 | 4 | v = {} 5 | exec(open('src/pymgrid/version.py').read(), v) # read __version__ 6 | VERSION = v['__version__'] 7 | DESCRIPTION = "A simulator for tertiary control of electrical microgrids" 8 | DOWNLOAD_URL = f"https://github.com/Total-RD/pymgrid/archive/refs/tags/v{VERSION}.tar.gz" 9 | MAINTAINER = "Avishai Halev" 10 | MAINTAINER_EMAIL = "avishaihalev@gmail.com" 11 | LICENSE = "GNU LGPL 3.0" 12 | PROJECT_URLS = {"Source Code": "https://github.com/Total-RD/pymgrid", 13 | "Documentation": "https://pymgrid.readthedocs.io/en/latest/"} 14 | 15 | EXTRAS = dict() 16 | EXTRAS["genset_mpc"] = ["Mosek", "cvxopt"] 17 | EXTRAS["dev"] = [ 18 | "pytest", 19 | "pytest-subtests", 20 | "flake8", 21 | "sphinx", 22 | "pydata_sphinx_theme", 23 | "numpydoc", 24 | "nbsphinx", 25 | "nbsphinx-link", 26 | *EXTRAS["genset_mpc"]] 27 | 28 | EXTRAS["rtd"] = ["ipython"] 29 | 30 | EXTRAS["all"] = list(set(sum(EXTRAS.values(), []))) 31 | 32 | 33 | setup( 34 | name="pymgrid", 35 | package_dir={"": "src"}, 36 | packages=find_packages("src"), 37 | python_requires=">=3.6", 38 | version=VERSION, 39 | maintainer=MAINTAINER, 40 | maintainer_email=MAINTAINER_EMAIL, 41 | download_url=DOWNLOAD_URL, 42 | project_urls=PROJECT_URLS, 43 | description=DESCRIPTION, 44 | license=LICENSE, 45 | long_description=(Path(__file__).parent / "README.md").read_text(), 46 | long_description_content_type="text/markdown", 47 | include_package_data=True, 48 | install_requires=[ 49 | "pandas", 50 | "numpy", 51 | "cvxpy", 52 | "statsmodels", 53 | "matplotlib", 54 | "plotly", 55 | "cufflinks", 56 | "gym", 57 | "tqdm", 58 | "pyyaml" 59 | ], 60 | extras_require=EXTRAS 61 | ) 62 | -------------------------------------------------------------------------------- /src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/__init__.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | from .version import __version__ 3 | 4 | PROJECT_PATH = Path(__file__).parent 5 | 6 | from ._deprecated.non_modular_microgrid import NonModularMicrogrid 7 | from .microgrid import Microgrid 8 | from .MicrogridGenerator import MicrogridGenerator 9 | 10 | from .utils import add_pymgrid_yaml_representers 11 | 12 | import pymgrid.envs 13 | 14 | __all__ = [ 15 | 'Microgrid', 16 | 'MicrogridGenerator', 17 | 'NonModularMicrogrid', 18 | 'envs' 19 | ] -------------------------------------------------------------------------------- /src/pymgrid/_deprecated/Environments/Preprocessing.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | 3 | def normalize_environment_states(mg): 4 | max_values = {} 5 | for keys in mg._df_record_state: 6 | if keys == 'hour': 7 | max_values[keys] = 24 8 | elif keys == 'capa_to_charge' or keys == 'capa_to_discharge' : 9 | max_values[keys] = mg.parameters.battery_capacity.values[0] 10 | elif keys == 'grid_status' or keys == 'battery_soc': 11 | max_values[keys] = 1 12 | elif keys == 'grid_co2': 13 | max_values[keys] = max(mg._grid_co2.values[0]) 14 | elif keys == 'grid_price_import': 15 | max_values[keys] = max(mg._grid_price_import.values[0]) 16 | elif keys == 'grid_price_export': 17 | max_values[keys] = max(mg._grid_price_import.values[0]) 18 | elif keys == 'load': 19 | max_values[keys] = mg.parameters.load.values[0] 20 | elif keys == 'pv': 21 | max_values[keys] = mg.parameters.PV_rated_power.values[0] 22 | else: 23 | max_values[keys] = mg.parameters[keys].values[0] 24 | 25 | return max_values 26 | 27 | def sample_reset(has_grid, saa, microgrid, sampling_args=None): 28 | """ 29 | Generates a new sample using an instance of SampleAverageApproximation and 30 | :param has_grid: bool, whether the microgrid has a grid. 31 | :param saa:, SampleAverageApproximation 32 | :param microgrid: Microgrid 33 | :param sampling_args: arguments to be passed to saa.sample_from_forecasts(). 34 | :return: 35 | """ 36 | if sampling_args is None: 37 | sampling_args = dict() 38 | 39 | sample = saa.sample_from_forecasts(n_samples=1, **sampling_args) 40 | sample = sample[0] 41 | 42 | microgrid._load_ts = pd.DataFrame(sample['load']) 43 | microgrid._pv_ts = pd.DataFrame(sample['pv']) 44 | microgrid._df_record_state['load'] = [sample['load'].iloc[0].squeeze()] 45 | microgrid._df_record_state['pv'] = [sample['pv'].iloc[0].squeeze()] 46 | if has_grid: 47 | microgrid._grid_status_ts = pd.DataFrame(sample['grid']) 48 | microgrid._df_record_state['grid_status'] = [sample['grid'].iloc[0].squeeze()] -------------------------------------------------------------------------------- /src/pymgrid/_deprecated/Environments/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/pymgrid/_deprecated/Environments/pymgrid_csca_old.py: -------------------------------------------------------------------------------- 1 | from pymgrid.Environments.Environment import Environment 2 | import numpy as np 3 | import gym 4 | from gym.utils import seeding 5 | from gym.spaces import Space, Discrete, Box 6 | 7 | 8 | class MicroGridEnv(Environment): 9 | """ 10 | Markov Decision Process associated to the microgrid. 11 | 12 | Parameters 13 | ---------- 14 | microgrid: microgrid, mandatory 15 | The controlled microgrid. 16 | random_seed: int, optional 17 | Seed to be used to generate the needed random numbers to size microgrids. 18 | 19 | """ 20 | def __init__(self, env_config, seed=42): 21 | super().__init__(env_config, seed) 22 | self.Na = 4 + self.mg.architecture['grid'] * 3 + self.mg.architecture['genset'] * 1 23 | 24 | action_limits = [int(self.mg._pv_ts.max().values[0]), 25 | int(self.mg.parameters['battery_power_charge'].values[0]), 26 | int(self.mg.parameters['battery_power_discharge'].values[0]), 27 | 2, 28 | ] 29 | if self.mg.architecture['genset'] ==1: 30 | action_limits.append(int(self.mg.parameters['genset_rated_power'].values[0]* self.mg.parameters['genset_pmax'].values[0])) 31 | 32 | if self.mg.architecture['grid'] == 1: 33 | action_limits.append(int(self.mg.parameters['grid_power_import'].values[0])) 34 | action_limits.append(int(self.mg.parameters['grid_power_export'].values[0])) 35 | action_limits.append(2) 36 | 37 | self.action_space = gym.spaces.Tuple([gym.spaces.Discrete(x) for x in action_limits]) 38 | 39 | 40 | def get_action(self, action): 41 | return self.get_action_continuous(action) -------------------------------------------------------------------------------- /src/pymgrid/_deprecated/Environments/pymgrid_csda.py: -------------------------------------------------------------------------------- 1 | from pymgrid.Environments.Environment import Environment 2 | import numpy as np 3 | import gym 4 | from gym.utils import seeding 5 | from gym.spaces import Space, Discrete, Box 6 | 7 | 8 | class MicroGridEnv(Environment): 9 | """ 10 | Markov Decision Process associated to the microgrid. 11 | 12 | Parameters 13 | ---------- 14 | microgrid: microgrid, mandatory 15 | The controlled microgrid. 16 | random_seed: int, optional 17 | Seed to be used to generate the needed random numbers to size microgrids. 18 | 19 | """ 20 | def __init__(self, env_config, seed=42): 21 | super().__init__(env_config, seed) 22 | self.Na = 4 + self.mg.architecture['grid'] * 3 + self.mg.architecture['genset'] * 1 23 | 24 | action_limits = [int(self.mg._pv_ts.max().values[0]), 25 | int(self.mg.parameters['battery_power_charge'].values[0]), 26 | int(self.mg.parameters['battery_power_discharge'].values[0]), 27 | 2, 28 | ] 29 | if self.mg.architecture['genset'] ==1: 30 | action_limits.append(int(self.mg.parameters['genset_rated_power'].values[0]* self.mg.parameters['genset_pmax'].values[0])) 31 | 32 | if self.mg.architecture['grid'] == 1: 33 | action_limits.append(int(self.mg.parameters['grid_power_import'].values[0])) 34 | action_limits.append(int(self.mg.parameters['grid_power_export'].values[0])) 35 | action_limits.append(2) 36 | 37 | self.action_space = gym.spaces.Tuple([gym.spaces.Discrete(x) for x in action_limits]) 38 | 39 | 40 | def get_action(self, action): 41 | return self.get_action_discrete(action) -------------------------------------------------------------------------------- /src/pymgrid/_deprecated/Environments/pymgrid_cspla.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2020 Total S.A 3 | Authors:Gonzague Henri 4 | Permission to use, modify, and distribute this software is given under the 5 | terms of the pymgrid License. 6 | NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. 7 | $Date: 2020/10/21 07:43 $ 8 | Gonzague Henri 9 | """ 10 | 11 | """ 12 | 13 | Copyright (C) <2020> 14 | 15 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . 20 | 21 | """ 22 | from pymgrid.Environments.Environment import Environment 23 | import numpy as np 24 | import gym 25 | from gym.utils import seeding 26 | from gym.spaces import Space, Discrete, Box 27 | 28 | class MicroGridEnv(Environment): 29 | """ 30 | Markov Decision Process associated to the microgrid. 31 | 32 | Parameters 33 | ---------- 34 | microgrid: microgrid, mandatory 35 | The controlled microgrid. 36 | random_seed: int, optional 37 | Seed to be used to generate the needed random numbers to size microgrids. 38 | 39 | """ 40 | 41 | def __init__(self, env_config, seed=42): 42 | super().__init__(env_config, seed) 43 | self.Na = 2 + self.mg.architecture['grid'] * 3 + self.mg.architecture['genset'] * 1 44 | if self.mg.architecture['grid'] == 1 and self.mg.architecture['genset'] == 1: 45 | self.Na += 1 46 | self.action_space = Discrete(self.Na) 47 | 48 | 49 | 50 | def get_action(self, action): 51 | return self.get_action_priority_list(action) 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/pymgrid/_deprecated/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/_deprecated/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/algos/__init__.py: -------------------------------------------------------------------------------- 1 | from .mpc.mpc import ModelPredictiveControl 2 | from .rbc.rbc import RuleBasedControl 3 | -------------------------------------------------------------------------------- /src/pymgrid/algos/example.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/algos/example.log -------------------------------------------------------------------------------- /src/pymgrid/algos/mpc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/algos/mpc/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/algos/priority_list/__init__.py: -------------------------------------------------------------------------------- 1 | from .priority_list_element import PriorityListElement 2 | from .priority_list import PriorityListAlgo 3 | -------------------------------------------------------------------------------- /src/pymgrid/algos/priority_list/priority_list_element.py: -------------------------------------------------------------------------------- 1 | from dataclasses import dataclass 2 | from functools import total_ordering 3 | from typing import Tuple, Optional 4 | 5 | 6 | @total_ordering 7 | @dataclass(frozen=True) 8 | class PriorityListElement: 9 | """ 10 | A dataclass that acts as a representation of a module's position in a deployment order. 11 | 12 | Used in :class:`.RuleBasedControl` and :class:`.DiscreteMicrogridEnv` to define actions given a specific order 13 | of module deployment. 14 | 15 | In :class:`.RuleBasedControl`, one list of these elements is used at every step to define actions. 16 | 17 | In :class:`.DiscreteMicrogridEnv`, each action in the environment's action space corresponds to a distinct priority 18 | list. 19 | 20 | See :attr:`.PriorityListElement.module_actions` and :attr:`.PriorityListElement.action` for further details 21 | of how these elements are incorporated in algorithms. 22 | 23 | """ 24 | 25 | module: Tuple[str, int] 26 | """ 27 | Module name. 28 | """ 29 | 30 | module_actions: int 31 | """ 32 | Number of possible action classes. 33 | 34 | * If one, actions generated with this element will be scalar. 35 | 36 | * If greater than one, actions generated this element will be a length-2 array. The first element 37 | is the action number (defined by `action`) and the second is a float corresponding to the scalar case. 38 | 39 | See :attr:`.PriorityListElement.action` for additional details. 40 | 41 | """ 42 | 43 | action: int 44 | """ 45 | Action number in {0, ..., :attr:`.PriorityListElement.module_actions`-1}. 46 | 47 | This is most relevant to :class:`GensetModule` and other elements with an action space 48 | with more than one dimension. 49 | 50 | Specifically, :class:`GensetModules` have a two-dimensional action space: 51 | the first element defines whether to turn the module on or off, and the second is an amount of energy to draw -- 52 | assuming the module is on. See :meth:`.GensetModule.step` and :meth:`.GensetModule.update_status` for details. 53 | """ 54 | 55 | marginal_cost: Optional[float] = None 56 | """ 57 | Marginal cost of using the module. 58 | 59 | Defines an ordering on elements. 60 | """ 61 | 62 | def __eq__(self, other): 63 | if type(self) != type(other): 64 | return NotImplemented 65 | 66 | return ( 67 | self.module == other.module and 68 | self.module_actions == other.module_actions and 69 | self.action == other.action and 70 | self.marginal_cost == other.marginal_cost 71 | ) 72 | 73 | def __lt__(self, other): 74 | if type(self) != type(other) or self.marginal_cost is None or other.marginal_cost is None: 75 | return NotImplemented 76 | 77 | return ( 78 | self.marginal_cost < other.marginal_cost or 79 | (self.marginal_cost == other.marginal_cost and self.action > other.action) 80 | ) 81 | -------------------------------------------------------------------------------- /src/pymgrid/algos/rbc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/algos/rbc/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/algos/rbc/rbc.py: -------------------------------------------------------------------------------- 1 | from copy import deepcopy 2 | from tqdm import tqdm 3 | 4 | from pymgrid.algos.priority_list import PriorityListAlgo 5 | 6 | 7 | class RuleBasedControl(PriorityListAlgo): 8 | """ 9 | 10 | Run a rule-based (heuristic) control algorithm on a microgrid. 11 | 12 | In rule-based control, modules are deployed in a preset order. You can either define this order by passing a 13 | priority list or the order will be defined automatically from the module with the lowest marginal cost to the 14 | highest. 15 | 16 | Parameters 17 | ---------- 18 | microgrid : :class:`pymgrid.Microgrid` 19 | Microgrid on which to run rule-based control. 20 | 21 | priority_list : list of :class:`.PriorityListElement` or None, default None. 22 | Priority list to use. If None, the order will be defined automatically from the module with the lowest marginal 23 | cost to the highest. 24 | 25 | """ 26 | def __init__(self, microgrid, priority_list=None, remove_redundant_gensets=True): 27 | super().__init__() 28 | self._microgrid = deepcopy(microgrid) 29 | self._priority_list = self._get_priority_list(priority_list, remove_redundant_gensets) 30 | 31 | def _get_priority_list(self, priority_list, remove_redundant_gensets): 32 | """ 33 | Given a microgrid, return the optimal order of module deployment. 34 | """ 35 | priority_lists = self.get_priority_lists(remove_redundant_gensets=remove_redundant_gensets) 36 | 37 | if priority_list is None: 38 | return sorted(priority_lists[0]) 39 | 40 | if priority_list not in priority_lists: 41 | raise ValueError('Invalid priority list. Use RuleBasedControl.get_priority_lists to view all ' 42 | 'valid priority lists.') 43 | 44 | return priority_list 45 | 46 | def _get_action(self): 47 | """ 48 | Given the priority list, define an action. 49 | """ 50 | return self._populate_action(self._priority_list) 51 | 52 | def reset(self): 53 | """ 54 | Reset the underlying microgrid. 55 | 56 | Returns 57 | ------- 58 | obs : dict[str, list[float]] 59 | Observations from resetting the modules as well as the flushed balance log. 60 | 61 | """ 62 | return self._microgrid.reset() 63 | 64 | def run(self, max_steps=None, verbose=False): 65 | """ 66 | Get the priority list and then deploy on the microgrid for some number of steps. 67 | 68 | Parameters 69 | --------- 70 | max_steps : int or None, default None 71 | Maximum number of RBC steps. If None, run until the microgrid terminates. 72 | 73 | verbose : bool, default False 74 | Whether to display a progress bar. 75 | 76 | Returns 77 | ------- 78 | log : pd.DataFrame 79 | Results of running the rule-based control algorithm. 80 | 81 | """ 82 | if max_steps is None: 83 | max_steps = len(self.microgrid) 84 | 85 | self.reset() 86 | 87 | for _ in tqdm(range(max_steps), desc="RBC Progress", disable=(not verbose)): 88 | action = self._get_action() 89 | _, _, done, _ = self._microgrid.run(action, normalized=False) 90 | if done: 91 | break 92 | 93 | return self._microgrid.get_log(as_frame=True) 94 | 95 | def get_empty_action(self): 96 | """ 97 | :meta private: 98 | """ 99 | return self._microgrid.get_empty_action() 100 | 101 | @property 102 | def microgrid(self): 103 | """ 104 | View of the microgrid. 105 | 106 | Returns 107 | ------- 108 | microgrid : :class:`pymgrid.Microgrid` 109 | The microgrid that RBC is being run on. 110 | 111 | """ 112 | return self._microgrid 113 | 114 | @property 115 | def fixed(self): 116 | """:meta private:""" 117 | return self._microgrid.fixed 118 | 119 | @property 120 | def flex(self): 121 | """:meta private:""" 122 | return self._microgrid.flex 123 | 124 | @property 125 | def modules(self): 126 | """:meta private:""" 127 | return self._microgrid.modules 128 | 129 | @property 130 | def priority_list(self): 131 | """ 132 | Order in which to deploy controllable modules. 133 | 134 | Returns 135 | ------- 136 | priority_list: list of :class:`.PriorityListElement` 137 | Priority list. 138 | 139 | """ 140 | return self._priority_list 141 | -------------------------------------------------------------------------------- /src/pymgrid/algos/saa/__init__.py: -------------------------------------------------------------------------------- 1 | from .saa import SampleAverageApproximation -------------------------------------------------------------------------------- /src/pymgrid/convert/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/convert/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/convert/convert.py: -------------------------------------------------------------------------------- 1 | from pymgrid._deprecated.non_modular_microgrid import NonModularMicrogrid 2 | from pymgrid.microgrid.microgrid import Microgrid 3 | from pymgrid.convert.get_module import get_module 4 | from pymgrid.convert.to_nonmodular_ops import check_viability, add_params_from_module, get_empty_params, finalize_params 5 | 6 | 7 | def to_modular(nonmodular, raise_errors=False): 8 | modules = [('load', get_module('load', nonmodular, raise_errors)), 9 | ('unbalanced_energy', get_module('unbalanced_energy', nonmodular, raise_errors))] 10 | for component, exists in nonmodular.architecture.items(): 11 | if exists: 12 | module = get_module(component, nonmodular, raise_errors) 13 | modules.append((component, module)) 14 | return Microgrid(modules, add_unbalanced_module=False) 15 | 16 | 17 | def to_nonmodular(modular): 18 | """ 19 | microgrid_params needs to contain the following: 20 | parameters: ('DataFrame', (1, 16)) 21 | df_actions: ('dict', {'load': [], 'pv_consummed': [], 'pv_curtailed': [], 'pv': [], 'battery_charge': [], 'battery_discharge': [], 'grid_import': [], 'grid_export': []}) 22 | architecture: ('dict', {'PV': 1, 'battery': 1, 'genset': 0, 'grid': 1}) 23 | df_status: ('dict', {'load': [304.4], 'hour': [0], 'pv': [0.0], 'battery_soc': [0.2], 'capa_to_charge': [1290.7], 'capa_to_discharge': [0.0], 'grid_status': [1.0], 'grid_co2': [0.23975790800000002], 'grid_price_import': [0.22], 'grid_price_export': [0.0]}) 24 | df_actual_generation: ('dict', {'loss_load': [], 'overgeneration': [], 'pv_consummed': [], 'pv_curtailed': [], 'battery_charge': [], 'battery_discharge': [], 'grid_import': [], 'grid_export': []}) 25 | grid_spec: ('int', 0) 26 | df_cost: ('dict', {'loss_load': [], 'overgeneration': [], 'co2': [], 'battery': [], 'grid_import': [], 'grid_export': [], 'total_cost': []}) 27 | df_co2: ('dict', {'co2': []}) 28 | pv: ('DataFrame', (8760, 1)) 29 | load: ('DataFrame', (8760, 1)) 30 | grid_ts: ('DataFrame', (8760, 1)) 31 | control_dict: ('list', ['load', 'pv_consummed', 'pv_curtailed', 'pv', 'battery_charge', 'battery_discharge', 'grid_import', 'grid_export']) 32 | grid_price_import: ('DataFrame', (8760, 1)) 33 | grid_price_export: ('DataFrame', (8760, 1)) 34 | grid_co2: ('DataFrame', (8760, 1)) 35 | :param modular: 36 | :return: 37 | """ 38 | check_viability(modular) 39 | microgrid_params = get_empty_params() 40 | for _, module_list in modular.modules.iterdict(): 41 | add_params_from_module(module_list[0], microgrid_params) 42 | finalize_params(microgrid_params) 43 | return NonModularMicrogrid(parameters=microgrid_params, horizon=modular.get_forecast_horizon() + 1) 44 | -------------------------------------------------------------------------------- /src/pymgrid/convert/get_module.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from pymgrid.modules import LoadModule, RenewableModule, BatteryModule, GridModule, GensetModule, UnbalancedEnergyModule 3 | 4 | 5 | def get_module(component, nonmodular, raise_errors): 6 | if component == 'load': 7 | return get_load_module(nonmodular, raise_errors) 8 | elif component == 'PV': 9 | return get_pv_module(nonmodular, raise_errors) 10 | elif component == 'battery': 11 | return get_battery_module(nonmodular, raise_errors) 12 | elif component == 'genset': 13 | return get_genset_module(nonmodular, raise_errors) 14 | elif component == 'grid': 15 | return get_grid_module(nonmodular, raise_errors) 16 | elif component == 'unbalanced_energy': 17 | return get_unbalanced_energy_module(nonmodular, raise_errors) 18 | else: 19 | raise ValueError(f'Cannot parse component {component}.') 20 | 21 | 22 | def get_load_module(nonmodular, raise_errors): 23 | time_series = nonmodular._load_ts 24 | return LoadModule(time_series=time_series, 25 | forecaster='oracle', 26 | forecast_horizon=nonmodular.horizon-1, 27 | raise_errors=raise_errors) 28 | 29 | 30 | def get_pv_module(nonmodular, raise_errors): 31 | time_series = nonmodular._pv_ts 32 | return RenewableModule(time_series=time_series, 33 | raise_errors=raise_errors, 34 | forecaster='oracle', 35 | forecast_horizon=nonmodular.horizon-1 36 | ) 37 | 38 | 39 | def get_battery_module(nonmodular, raise_errors): 40 | battery = nonmodular.battery 41 | max_capacity = battery.capacity 42 | min_capacity = max_capacity*battery.soc_min 43 | max_charge = battery.p_charge_max 44 | max_discharge = battery.p_discharge_max 45 | efficiency = battery.efficiency 46 | battery_cost_cycle = battery.cost_cycle 47 | init_soc = battery.soc 48 | return BatteryModule(min_capacity=min_capacity, 49 | max_capacity=max_capacity, 50 | max_charge=max_charge, 51 | max_discharge=max_discharge, 52 | efficiency=efficiency, 53 | battery_cost_cycle=battery_cost_cycle, 54 | init_soc=init_soc, 55 | raise_errors=raise_errors) 56 | 57 | 58 | def get_genset_module(nonmodular, raise_errors): 59 | genset = nonmodular.genset 60 | min_production = genset.p_min*genset.rated_power 61 | max_production = genset.p_max*genset.rated_power 62 | genset_cost = genset.fuel_cost 63 | co2_per_unit = nonmodular.parameters.genset_co2.item() 64 | cost_per_unit_co2 = nonmodular.parameters.cost_co2.item() 65 | return GensetModule(running_min_production=min_production, 66 | running_max_production=max_production, 67 | genset_cost=genset_cost, 68 | co2_per_unit=co2_per_unit, 69 | cost_per_unit_co2=cost_per_unit_co2, 70 | start_up_time=0, 71 | wind_down_time=0, 72 | raise_errors=raise_errors) 73 | 74 | 75 | def get_grid_module(nonmodular, raise_errors): 76 | max_import = nonmodular.grid.power_import 77 | max_export = nonmodular.grid.power_export 78 | cost_per_unit_co2 = nonmodular.parameters.cost_co2.item() 79 | 80 | cost_import = nonmodular._grid_price_import.squeeze() 81 | cost_import.name = 'cost_import' 82 | cost_export = nonmodular._grid_price_export.squeeze() 83 | cost_export.name = 'cost_export' 84 | co2_per_unit = nonmodular._grid_co2.squeeze() 85 | co2_per_unit.name = 'co2_per_unit_production' 86 | grid_status = nonmodular._grid_status_ts.squeeze() 87 | grid_status.name = 'grid_status' 88 | time_series = pd.concat([cost_import, cost_export, co2_per_unit, grid_status], axis=1) 89 | 90 | return GridModule(max_import=max_import, 91 | max_export=max_export, 92 | time_series=time_series, 93 | forecaster='oracle', 94 | forecast_horizon=nonmodular.horizon - 1, 95 | cost_per_unit_co2=cost_per_unit_co2, 96 | raise_errors=raise_errors) 97 | 98 | 99 | def get_unbalanced_energy_module(nonmodular, raise_errors): 100 | return UnbalancedEnergyModule(raise_errors=raise_errors, 101 | loss_load_cost=nonmodular.parameters['cost_loss_load'].item(), 102 | overgeneration_cost=nonmodular.parameters['cost_overgeneration'].item() 103 | ) -------------------------------------------------------------------------------- /src/pymgrid/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/data/co2/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/pymgrid/data/load/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/load/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/data/pv/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/pv/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25.pkl -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_0/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_0/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_0/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_0/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_0/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_0/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_0/microgrid_0.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - battery 51 | - !BatteryModule 52 | cls_params: 53 | battery_cost_cycle: 0.02 54 | battery_transition_model: null 55 | efficiency: 0.9 56 | init_charge: null 57 | init_soc: 0.2 58 | initial_step: 0 59 | max_capacity: 1452 60 | max_charge: 363 61 | max_discharge: 363 62 | min_capacity: 290.40000000000003 63 | raise_errors: false 64 | name: 65 | - battery 66 | - 0 67 | state: 68 | _current_step: 0 69 | current_charge: 290.40000000000003 70 | soc: 0.2 71 | - - grid 72 | - !GridModule 73 | cls_params: 74 | cost_per_unit_co2: 0.1 75 | final_step: 8759 76 | forecast_horizon: 23 77 | forecaster: oracle 78 | forecaster_increase_uncertainty: false 79 | forecaster_relative_noise: false 80 | initial_step: 0 81 | max_export: 1920 82 | max_import: 1920 83 | raise_errors: false 84 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 85 | name: 86 | - grid 87 | - 0 88 | state: 89 | _current_step: 0 90 | trajectory_func: null 91 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_1/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_1/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_1/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_1/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_1/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_1/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_1/microgrid_1.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 60363.0 62 | running_min_production: 3353.5 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 91274 84 | max_charge: 22819 85 | max_discharge: 22819 86 | min_capacity: 18254.8 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 18254.8 94 | soc: 0.19999999999999998 95 | - - grid 96 | - !GridModule 97 | cls_params: 98 | cost_per_unit_co2: 0.1 99 | final_step: 8759 100 | forecast_horizon: 23 101 | forecaster: oracle 102 | forecaster_increase_uncertainty: false 103 | forecaster_relative_noise: false 104 | initial_step: 0 105 | max_export: 120726 106 | max_import: 120726 107 | raise_errors: false 108 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 109 | name: 110 | - grid 111 | - 0 112 | state: 113 | _current_step: 0 114 | trajectory_func: null 115 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_10/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_10/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_10/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_10/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_10/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_10/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_10/microgrid_10.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 60144.3 62 | running_min_production: 3341.3500000000004 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 219201 84 | max_charge: 54801 85 | max_discharge: 54801 86 | min_capacity: 43840.200000000004 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 43840.200000000004 94 | soc: 0.2 95 | - - grid 96 | - !GridModule 97 | cls_params: 98 | cost_per_unit_co2: 0.1 99 | final_step: 8759 100 | forecast_horizon: 23 101 | forecaster: oracle 102 | forecaster_increase_uncertainty: false 103 | forecaster_relative_noise: false 104 | initial_step: 0 105 | max_export: 120288 106 | max_import: 120288 107 | raise_errors: false 108 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 109 | name: 110 | - grid 111 | - 0 112 | state: 113 | _current_step: 0 114 | trajectory_func: null 115 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_11/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_11/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_11/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_11/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_11/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_11/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_11/microgrid_11.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - battery 51 | - !BatteryModule 52 | cls_params: 53 | battery_cost_cycle: 0.02 54 | battery_transition_model: null 55 | efficiency: 0.9 56 | init_charge: null 57 | init_soc: 1 58 | initial_step: 0 59 | max_capacity: 69594 60 | max_charge: 17399 61 | max_discharge: 17399 62 | min_capacity: 13918.800000000001 63 | raise_errors: false 64 | name: 65 | - battery 66 | - 0 67 | state: 68 | _current_step: 0 69 | current_charge: 69594 70 | soc: 1.0 71 | - - grid 72 | - !GridModule 73 | cls_params: 74 | cost_per_unit_co2: 0.1 75 | final_step: 8759 76 | forecast_horizon: 23 77 | forecaster: oracle 78 | forecaster_increase_uncertainty: false 79 | forecaster_relative_noise: false 80 | initial_step: 0 81 | max_export: 55230 82 | max_import: 55230 83 | raise_errors: false 84 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 85 | name: 86 | - grid 87 | - 0 88 | state: 89 | _current_step: 0 90 | trajectory_func: null 91 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_12/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_12/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_12/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_12/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_12/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_12/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_12/microgrid_12.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - battery 51 | - !BatteryModule 52 | cls_params: 53 | battery_cost_cycle: 0.02 54 | battery_transition_model: null 55 | efficiency: 0.9 56 | init_charge: null 57 | init_soc: 0.2 58 | initial_step: 0 59 | max_capacity: 143726 60 | max_charge: 35932 61 | max_discharge: 35932 62 | min_capacity: 28745.2 63 | raise_errors: false 64 | name: 65 | - battery 66 | - 0 67 | state: 68 | _current_step: 0 69 | current_charge: 28745.2 70 | soc: 0.2 71 | - - grid 72 | - !GridModule 73 | cls_params: 74 | cost_per_unit_co2: 0.1 75 | final_step: 8759 76 | forecast_horizon: 23 77 | forecaster: oracle 78 | forecaster_increase_uncertainty: false 79 | forecaster_relative_noise: false 80 | initial_step: 0 81 | max_export: 96428 82 | max_import: 96428 83 | raise_errors: false 84 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 85 | name: 86 | - grid 87 | - 0 88 | state: 89 | _current_step: 0 90 | trajectory_func: null 91 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_13/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_13/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_13/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_13/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_13/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_13/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_13/microgrid_13.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 19941.3 62 | running_min_production: 1107.8500000000001 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 47556 84 | max_charge: 11889 85 | max_discharge: 11889 86 | min_capacity: 9511.2 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 9511.2 94 | soc: 0.2 95 | - - grid 96 | - !GridModule 97 | cls_params: 98 | cost_per_unit_co2: 0.1 99 | final_step: 8759 100 | forecast_horizon: 23 101 | forecaster: oracle 102 | forecaster_increase_uncertainty: false 103 | forecaster_relative_noise: false 104 | initial_step: 0 105 | max_export: 39882 106 | max_import: 39882 107 | raise_errors: false 108 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 109 | name: 110 | - grid 111 | - 0 112 | state: 113 | _current_step: 0 114 | trajectory_func: null 115 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_14/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_14/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_14/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_14/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_14/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_14/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_14/microgrid_14.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - battery 51 | - !BatteryModule 52 | cls_params: 53 | battery_cost_cycle: 0.02 54 | battery_transition_model: null 55 | efficiency: 0.9 56 | init_charge: null 57 | init_soc: 0.2 58 | initial_step: 0 59 | max_capacity: 162570 60 | max_charge: 40643 61 | max_discharge: 40643 62 | min_capacity: 32514.0 63 | raise_errors: false 64 | name: 65 | - battery 66 | - 0 67 | state: 68 | _current_step: 0 69 | current_charge: 32514.0 70 | soc: 0.2 71 | - - grid 72 | - !GridModule 73 | cls_params: 74 | cost_per_unit_co2: 0.1 75 | final_step: 8759 76 | forecast_horizon: 23 77 | forecaster: oracle 78 | forecaster_increase_uncertainty: false 79 | forecaster_relative_noise: false 80 | initial_step: 0 81 | max_export: 197286 82 | max_import: 197286 83 | raise_errors: false 84 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 85 | name: 86 | - grid 87 | - 0 88 | state: 89 | _current_step: 0 90 | trajectory_func: null 91 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_15/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_15/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_15/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_15/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_15/microgrid_15.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 17296.2 62 | running_min_production: 960.9000000000001 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 1 82 | initial_step: 0 83 | max_capacity: 26153 84 | max_charge: 6539 85 | max_discharge: 6539 86 | min_capacity: 5230.6 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 26153 94 | soc: 1.0 95 | trajectory_func: null 96 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_16/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_16/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_16/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_16/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_16/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_16/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_16/microgrid_16.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - battery 51 | - !BatteryModule 52 | cls_params: 53 | battery_cost_cycle: 0.02 54 | battery_transition_model: null 55 | efficiency: 0.9 56 | init_charge: null 57 | init_soc: 0.534118811938557 58 | initial_step: 0 59 | max_capacity: 60099 60 | max_charge: 15025 61 | max_discharge: 15025 62 | min_capacity: 12019.800000000001 63 | raise_errors: false 64 | name: 65 | - battery 66 | - 0 67 | state: 68 | _current_step: 0 69 | current_charge: 32100.00647869534 70 | soc: 0.534118811938557 71 | - - grid 72 | - !GridModule 73 | cls_params: 74 | cost_per_unit_co2: 0.1 75 | final_step: 8759 76 | forecast_horizon: 23 77 | forecaster: oracle 78 | forecaster_increase_uncertainty: false 79 | forecaster_relative_noise: false 80 | initial_step: 0 81 | max_export: 97244 82 | max_import: 97244 83 | raise_errors: false 84 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 85 | name: 86 | - grid 87 | - 0 88 | state: 89 | _current_step: 0 90 | trajectory_func: null 91 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_17/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_17/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_17/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_17/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_17/microgrid_17.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 31257.0 62 | running_min_production: 1736.5 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 38636 84 | max_charge: 9659 85 | max_discharge: 9659 86 | min_capacity: 7727.200000000001 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 7727.200000000001 94 | soc: 0.2 95 | trajectory_func: null 96 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_18/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_18/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_18/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_18/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_18/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_18/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_18/microgrid_18.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 34418.700000000004 62 | running_min_production: 1912.15 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 1 82 | initial_step: 0 83 | max_capacity: 82080 84 | max_charge: 20520 85 | max_discharge: 20520 86 | min_capacity: 16416.0 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 82080 94 | soc: 1.0 95 | - - grid 96 | - !GridModule 97 | cls_params: 98 | cost_per_unit_co2: 0.1 99 | final_step: 8759 100 | forecast_horizon: 23 101 | forecaster: oracle 102 | forecaster_increase_uncertainty: false 103 | forecaster_relative_noise: false 104 | initial_step: 0 105 | max_export: 68836 106 | max_import: 68836 107 | raise_errors: false 108 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 109 | name: 110 | - grid 111 | - 0 112 | state: 113 | _current_step: 0 114 | trajectory_func: null 115 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_19/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_19/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_19/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_19/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_19/microgrid_19.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 1529.1000000000001 62 | running_min_production: 84.95 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 2506 84 | max_charge: 627 85 | max_discharge: 627 86 | min_capacity: 501.20000000000005 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 501.20000000000005 94 | soc: 0.2 95 | trajectory_func: null 96 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_2/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_2/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_2/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_2/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_2/microgrid_2.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 43725.6 62 | running_min_production: 2429.2000000000003 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 66116 84 | max_charge: 16529 85 | max_discharge: 16529 86 | min_capacity: 13223.2 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 13223.2 94 | soc: 0.2 95 | trajectory_func: null 96 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_20/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_20/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_20/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_20/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_20/microgrid_20.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 79186.5 62 | running_min_production: 4399.25 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 129765 84 | max_charge: 32442 85 | max_discharge: 32442 86 | min_capacity: 25953.0 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 25953.0 94 | soc: 0.2 95 | trajectory_func: null 96 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_21/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_21/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_21/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_21/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_21/microgrid_21.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 95435.1 62 | running_min_production: 5301.950000000001 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 170694 84 | max_charge: 42674 85 | max_discharge: 42674 86 | min_capacity: 34138.8 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 34138.8 94 | soc: 0.2 95 | trajectory_func: null 96 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_22/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_22/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_22/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_22/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_22/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_22/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_22/microgrid_22.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 80372.7 62 | running_min_production: 4465.150000000001 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 292924 84 | max_charge: 73231 85 | max_discharge: 73231 86 | min_capacity: 58584.8 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 58584.8 94 | soc: 0.2 95 | - - grid 96 | - !GridModule 97 | cls_params: 98 | cost_per_unit_co2: 0.1 99 | final_step: 8759 100 | forecast_horizon: 23 101 | forecaster: oracle 102 | forecaster_increase_uncertainty: false 103 | forecaster_relative_noise: false 104 | initial_step: 0 105 | max_export: 160744 106 | max_import: 160744 107 | raise_errors: false 108 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 109 | name: 110 | - grid 111 | - 0 112 | state: 113 | _current_step: 0 114 | trajectory_func: null 115 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_23/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_23/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_23/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_23/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_23/microgrid_23.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 9453.6 62 | running_min_production: 525.2 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 14294 84 | max_charge: 3574 85 | max_discharge: 3574 86 | min_capacity: 2858.8 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 2858.8 94 | soc: 0.2 95 | trajectory_func: null 96 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_24/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_24/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_24/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_24/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_24/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_24/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_24/microgrid_24.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 50157.0 62 | running_min_production: 2786.5 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 103328 84 | max_charge: 25832 85 | max_discharge: 25832 86 | min_capacity: 20665.600000000002 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 20665.600000000002 94 | soc: 0.2 95 | - - grid 96 | - !GridModule 97 | cls_params: 98 | cost_per_unit_co2: 0.1 99 | final_step: 8759 100 | forecast_horizon: 23 101 | forecaster: oracle 102 | forecaster_increase_uncertainty: false 103 | forecaster_relative_noise: false 104 | initial_step: 0 105 | max_export: 100314 106 | max_import: 100314 107 | raise_errors: false 108 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 109 | name: 110 | - grid 111 | - 0 112 | state: 113 | _current_step: 0 114 | trajectory_func: null 115 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_3/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_3/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_3/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_3/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_3/microgrid_3.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 78147.0 62 | running_min_production: 4341.5 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 102450 84 | max_charge: 25613 85 | max_discharge: 25613 86 | min_capacity: 20490.0 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 20490.0 94 | soc: 0.2 95 | trajectory_func: null 96 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_4/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_4/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_4/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_4/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_4/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_4/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_4/microgrid_4.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - battery 51 | - !BatteryModule 52 | cls_params: 53 | battery_cost_cycle: 0.02 54 | battery_transition_model: null 55 | efficiency: 0.9 56 | init_charge: null 57 | init_soc: 0.2 58 | initial_step: 0 59 | max_capacity: 65305 60 | max_charge: 16327 61 | max_discharge: 16327 62 | min_capacity: 13061.0 63 | raise_errors: false 64 | name: 65 | - battery 66 | - 0 67 | state: 68 | _current_step: 0 69 | current_charge: 13061.0 70 | soc: 0.2 71 | - - grid 72 | - !GridModule 73 | cls_params: 74 | cost_per_unit_co2: 0.1 75 | final_step: 8759 76 | forecast_horizon: 23 77 | forecaster: oracle 78 | forecaster_increase_uncertainty: false 79 | forecaster_relative_noise: false 80 | initial_step: 0 81 | max_export: 99625 82 | max_import: 99625 83 | raise_errors: false 84 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 85 | name: 86 | - grid 87 | - 0 88 | state: 89 | _current_step: 0 90 | trajectory_func: null 91 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_5/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_5/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_5/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_5/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_5/microgrid_5.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 28560.600000000002 62 | running_min_production: 1586.7 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 1 82 | initial_step: 0 83 | max_capacity: 57581 84 | max_charge: 14396 85 | max_discharge: 14396 86 | min_capacity: 11516.2 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 57581 94 | soc: 1.0 95 | trajectory_func: null 96 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_6/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_6/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_6/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_6/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_6/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_6/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_6/microgrid_6.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - battery 51 | - !BatteryModule 52 | cls_params: 53 | battery_cost_cycle: 0.02 54 | battery_transition_model: null 55 | efficiency: 0.9 56 | init_charge: null 57 | init_soc: 0.960305168086668 58 | initial_step: 0 59 | max_capacity: 179373 60 | max_charge: 44844 61 | max_discharge: 44844 62 | min_capacity: 35874.6 63 | raise_errors: false 64 | name: 65 | - battery 66 | - 0 67 | state: 68 | _current_step: 0 69 | current_charge: 172252.8189152099 70 | soc: 0.960305168086668 71 | - - grid 72 | - !GridModule 73 | cls_params: 74 | cost_per_unit_co2: 0.1 75 | final_step: 8759 76 | forecast_horizon: 23 77 | forecaster: oracle 78 | forecaster_increase_uncertainty: false 79 | forecaster_relative_noise: false 80 | initial_step: 0 81 | max_export: 98432 82 | max_import: 98432 83 | raise_errors: false 84 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 85 | name: 86 | - grid 87 | - 0 88 | state: 89 | _current_step: 0 90 | trajectory_func: null 91 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_7/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_7/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_7/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_7/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_7/microgrid_7.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 11798.1 62 | running_min_production: 655.45 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 1 82 | initial_step: 0 83 | max_capacity: 19334 84 | max_charge: 4834 85 | max_discharge: 4834 86 | min_capacity: 3866.8 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 19334 94 | soc: 1.0 95 | trajectory_func: null 96 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_8/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_8/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_8/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_8/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_8/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_8/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_8/microgrid_8.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 64065.6 62 | running_min_production: 3559.2000000000003 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.2 82 | initial_step: 0 83 | max_capacity: 105583 84 | max_charge: 26396 85 | max_discharge: 26396 86 | min_capacity: 21116.600000000002 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 21116.600000000002 94 | soc: 0.2 95 | - - grid 96 | - !GridModule 97 | cls_params: 98 | cost_per_unit_co2: 0.1 99 | final_step: 8759 100 | forecast_horizon: 23 101 | forecaster: oracle 102 | forecaster_increase_uncertainty: false 103 | forecaster_relative_noise: false 104 | initial_step: 0 105 | max_export: 128130 106 | max_import: 128130 107 | raise_errors: false 108 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 109 | name: 110 | - grid 111 | - 0 112 | state: 113 | _current_step: 0 114 | trajectory_func: null 115 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_9/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_9/data/cls_params/GridModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_9/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_9/data/cls_params/LoadModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_9/data/cls_params/RenewableModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/data/scenario/pymgrid25/microgrid_9/data/cls_params/RenewableModule/time_series.csv.gz -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_9/microgrid_9.yaml: -------------------------------------------------------------------------------- 1 | !Microgrid 2 | final_step: 8759 3 | initial_step: 0 4 | modules: 5 | - - load 6 | - !LoadModule 7 | cls_params: 8 | final_step: 8759 9 | forecast_horizon: 23 10 | forecaster: oracle 11 | forecaster_increase_uncertainty: false 12 | forecaster_relative_noise: false 13 | initial_step: 0 14 | raise_errors: false 15 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 16 | name: 17 | - load 18 | - 0 19 | state: 20 | _current_step: 0 21 | - - pv 22 | - !RenewableModule 23 | cls_params: 24 | final_step: 8759 25 | forecast_horizon: 23 26 | forecaster: oracle 27 | forecaster_increase_uncertainty: false 28 | forecaster_relative_noise: false 29 | initial_step: 0 30 | provided_energy_name: renewable_used 31 | raise_errors: false 32 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 33 | name: 34 | - pv 35 | - 0 36 | state: 37 | _current_step: 0 38 | - - unbalanced_energy 39 | - !UnbalancedEnergyModule 40 | cls_params: 41 | initial_step: 0 42 | loss_load_cost: 10 43 | overgeneration_cost: 1 44 | raise_errors: false 45 | name: 46 | - unbalanced_energy 47 | - 0 48 | state: 49 | _current_step: 0 50 | - - genset 51 | - !Genset 52 | cls_params: 53 | allow_abortion: true 54 | co2_per_unit: 2 55 | cost_per_unit_co2: 0.1 56 | genset_cost: 0.4 57 | init_start_up: true 58 | initial_step: 0 59 | provided_energy_name: genset_production 60 | raise_errors: false 61 | running_max_production: 98996.40000000001 62 | running_min_production: 5499.8 63 | start_up_time: 0 64 | wind_down_time: 0 65 | name: 66 | - genset 67 | - 0 68 | state: 69 | _current_status: true 70 | _current_step: 0 71 | _goal_status: true 72 | _steps_until_down: 0 73 | _steps_until_up: 0 74 | - - battery 75 | - !BatteryModule 76 | cls_params: 77 | battery_cost_cycle: 0.02 78 | battery_transition_model: null 79 | efficiency: 0.9 80 | init_charge: null 81 | init_soc: 0.5374787046064285 82 | initial_step: 0 83 | max_capacity: 199587 84 | max_charge: 49897 85 | max_discharge: 49897 86 | min_capacity: 39917.4 87 | raise_errors: false 88 | name: 89 | - battery 90 | - 0 91 | state: 92 | _current_step: 0 93 | current_charge: 107273.76221628326 94 | soc: 0.5374787046064285 95 | - - grid 96 | - !GridModule 97 | cls_params: 98 | cost_per_unit_co2: 0.1 99 | final_step: 8759 100 | forecast_horizon: 23 101 | forecaster: oracle 102 | forecaster_increase_uncertainty: false 103 | forecaster_relative_noise: false 104 | initial_step: 0 105 | max_export: 197992 106 | max_import: 197992 107 | raise_errors: false 108 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 109 | name: 110 | - grid 111 | - 0 112 | state: 113 | _current_step: 0 114 | trajectory_func: null 115 | -------------------------------------------------------------------------------- /src/pymgrid/envs/__init__.py: -------------------------------------------------------------------------------- 1 | from .discrete.discrete import DiscreteMicrogridEnv 2 | from .continuous.continuous import ContinuousMicrogridEnv 3 | -------------------------------------------------------------------------------- /src/pymgrid/envs/base/__init__.py: -------------------------------------------------------------------------------- 1 | from .base import BaseMicrogridEnv 2 | -------------------------------------------------------------------------------- /src/pymgrid/envs/base/skip_init.py: -------------------------------------------------------------------------------- 1 | def skip_init(cls, init): 2 | """ 3 | Skip init once on cls, and then revert to original init. 4 | 5 | Parameters 6 | ---------- 7 | cls : Type 8 | Class to skip init on. 9 | init : callable 10 | Original init. 11 | 12 | Returns 13 | ------- 14 | skip_init : callable 15 | Callable that skips init once. 16 | 17 | """ 18 | def reset_init(*args, **kwargs): 19 | cls.__init__ = init 20 | return reset_init 21 | -------------------------------------------------------------------------------- /src/pymgrid/envs/continuous/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/envs/continuous/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/envs/continuous/continuous.py: -------------------------------------------------------------------------------- 1 | from gym.spaces import Dict, Tuple, flatten_space 2 | from warnings import warn 3 | 4 | from pymgrid.envs.base import BaseMicrogridEnv 5 | 6 | 7 | class ContinuousMicrogridEnv(BaseMicrogridEnv): 8 | """ 9 | Microgrid environment with a continuous action space. 10 | 11 | Implements the `OpenAI Gym API `_ for a microgrid; 12 | inherits from both :class:`.Microgrid` and :class:`gym.Env`. 13 | 14 | Parameters 15 | ---------- 16 | modules : list, Microgrid, NonModularMicrogrid, or int. 17 | The constructor can be called in three ways: 18 | 19 | 1. Passing a list of microgrid modules. This is identical to the :class:`.Microgrid` constructor. 20 | 21 | 2. Passing a :class:`.Microgrid` or :class:`.NonModularMicrogrid` instance. 22 | This will effectively wrap the microgrid instance with the Gym API. 23 | 24 | 3. Passing an integer in [0, 25). 25 | This will be result in loading the corresponding `pymgrid25` benchmark microgrids. 26 | 27 | add_unbalanced_module : bool, default True. 28 | Whether to add an unbalanced energy module to your microgrid. Such a module computes and attributes 29 | costs to any excess supply or demand. 30 | Set to True unless ``modules`` contains an :class:`.UnbalancedEnergyModule`. 31 | 32 | loss_load_cost : float, default 10.0 33 | Cost per unit of unmet demand. Ignored if ``add_unbalanced_module=False``. 34 | 35 | overgeneration_cost : float, default 2.0 36 | Cost per unit of excess generation. Ignored if ``add_unbalanced_module=False``. 37 | 38 | flat_spaces : bool, default True 39 | Whether the environment's spaces should be flat. 40 | 41 | If True, all continuous spaces are :class:`gym:gym.spaces.Box`. 42 | 43 | Otherwise, they are nested :class:`gym:gym.spaces.Dict` of :class:`gym:gym.spaces.Tuple` 44 | of :class:`gym:gym.spaces.Box`, corresponding to the structure of the ``control`` arg of :meth:`.Microgrid.run`. 45 | 46 | trajectory_func : callable or None, default None 47 | Callable that sets an initial and final step for an episode. ``trajectory_func`` must take two inputs: 48 | :attr:`.initial_step` and :attr:`.final_step`, and return two integers: the initial and final step for 49 | that particular episode, respectively. This function will be called every time :meth:`.reset` is called. 50 | 51 | If None, :attr:`.initial_step` and :attr:`.final_step` are used to define every episode. 52 | 53 | """ 54 | _nested_action_space = None 55 | 56 | def _get_nested_action_space(self): 57 | return Dict({name: Tuple([module.action_space['normalized'] for module in modules_list]) 58 | for name, modules_list in self.fixed.iterdict() if modules_list[0].is_source}) 59 | 60 | def _get_action_space(self): 61 | self._nested_action_space = self._get_nested_action_space() 62 | return flatten_space(self._nested_action_space) if self._flat_spaces else self._nested_action_space 63 | 64 | def _get_action(self, action): 65 | # Action does not have fixed sinks (loads); add those values. 66 | assert action in self._nested_action_space, 'Action is not in action space.' 67 | action = action.copy() 68 | for name, module_list in self.fixed.sinks.iterdict(): 69 | action[name] = [module.to_normalized(-1 * module.max_consumption, act=True) for module in module_list] 70 | return action 71 | 72 | def step(self, action): 73 | action = self._get_action(action) 74 | return super().run(action) 75 | 76 | def run(self, action, normalized=True): 77 | warn('run() should not be called directly in environments.') 78 | return super().run(action, normalized=normalized) 79 | -------------------------------------------------------------------------------- /src/pymgrid/envs/discrete/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/envs/discrete/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/forecast/__init__.py: -------------------------------------------------------------------------------- 1 | from .forecaster import get_forecaster, OracleForecaster, GaussianNoiseForecaster, UserDefinedForecaster, NoForecaster 2 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/__init__.py: -------------------------------------------------------------------------------- 1 | DEFAULT_HORIZON = 23 2 | 3 | from .microgrid import Microgrid 4 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/reward_shaping/__init__.py: -------------------------------------------------------------------------------- 1 | from .pv_curtailment_shaper import PVCurtailmentShaper 2 | from .battery_discharge_shaper import BatteryDischargeShaper 3 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/reward_shaping/base.py: -------------------------------------------------------------------------------- 1 | import yaml 2 | 3 | from abc import abstractmethod 4 | 5 | 6 | class BaseRewardShaper(yaml.YAMLObject): 7 | yaml_dumper = yaml.SafeDumper 8 | yaml_loader = yaml.SafeLoader 9 | 10 | @staticmethod 11 | def sum_module_val(info, module_name, module_attr): 12 | try: 13 | module_info = info[module_name] 14 | return sum([d[module_attr] for d in module_info]) 15 | except KeyError: 16 | return 0.0 17 | 18 | @abstractmethod 19 | def __call__(self, step_info, cost_info): 20 | pass 21 | 22 | def __repr__(self): 23 | return f'{self.__class__.__name__}()' 24 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/reward_shaping/battery_discharge_shaper.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pymgrid.microgrid.reward_shaping.base import BaseRewardShaper 4 | 5 | 6 | class BatteryDischargeShaper(BaseRewardShaper): 7 | """ 8 | Reward is the percentage of load that is met by battery discharging. 9 | 10 | Return a value in [-1, 1]. Value of -1 implies that all load was loss load. Value of 1 implies all load 11 | was met by battery. 12 | 13 | Use in a config with 14 | 15 | microgrid: 16 | attributes: 17 | reward_shaping_func: !BatteryDischargeShaper {} 18 | 19 | """ 20 | yaml_tag = u"!BatteryDischargeShaper" 21 | 22 | def __call__(self, step_info, cost_info): 23 | battery_discharge = self.sum_module_val(step_info, 'battery', 'provided_energy') 24 | load = self.sum_module_val(step_info, 'load', 'absorbed_energy') 25 | loss_load = self.sum_module_val(step_info, 'unbalanced_energy', 'provided_energy') 26 | 27 | # battery_discharge is in [0, load-loss_load]; loss_load is in [0, load]. 28 | try: 29 | percent_battery = (battery_discharge - loss_load) / load 30 | except ZeroDivisionError: 31 | return 0.0 32 | 33 | assert -1 <= percent_battery <= 1 or np.isclose(percent_battery, 1) or np.isclose(percent_battery, 0) 34 | return percent_battery 35 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/reward_shaping/pv_curtailment_shaper.py: -------------------------------------------------------------------------------- 1 | from pymgrid.microgrid.reward_shaping.base import BaseRewardShaper 2 | 3 | 4 | class PVCurtailmentShaper(BaseRewardShaper): 5 | """ 6 | Use in a config with 7 | 8 | microgrid: 9 | attributes: 10 | reward_shaping_func: !PVCurtailmentShaper {} 11 | """ 12 | 13 | yaml_tag = u"!PVCurtailmentShaper" 14 | 15 | def __call__(self, step_info, cost_info): 16 | pv_curtailment = self.sum_module_val(step_info, 'pv', 'curtailment') 17 | return -1.0 * pv_curtailment 18 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/trajectory/__init__.py: -------------------------------------------------------------------------------- 1 | from .deterministic import DeterministicTrajectory 2 | from .stochastic import StochasticTrajectory, FixedLengthStochasticTrajectory 3 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/trajectory/base.py: -------------------------------------------------------------------------------- 1 | import inspect 2 | import yaml 3 | 4 | from abc import abstractmethod 5 | 6 | 7 | class BaseTrajectory(yaml.YAMLObject): 8 | yaml_dumper = yaml.SafeDumper 9 | yaml_loader = yaml.SafeLoader 10 | 11 | @abstractmethod 12 | def __call__(self, initial_step, final_step): 13 | pass 14 | 15 | def __repr__(self): 16 | params = inspect.signature(self.__init__).parameters 17 | formatted_params = ', '.join([f'{p}={getattr(self, p)}' for p in params]) 18 | return f'{self.__class__.__name__}({formatted_params})' 19 | 20 | def __eq__(self, other): 21 | if type(self) != type(other): 22 | return NotImplemented 23 | return repr(self) == repr(other) 24 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/trajectory/deterministic.py: -------------------------------------------------------------------------------- 1 | from pymgrid.microgrid.trajectory.base import BaseTrajectory 2 | 3 | 4 | class DeterministicTrajectory(BaseTrajectory): 5 | yaml_tag = u"!DeterministicTrajectory" 6 | 7 | def __init__(self, initial_step, final_step): 8 | self.initial_step = initial_step 9 | self.final_step = final_step 10 | 11 | def __call__(self, initial_step, final_step): 12 | return self.initial_step, self.final_step 13 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/trajectory/stochastic.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pymgrid.microgrid.trajectory.base import BaseTrajectory 4 | 5 | 6 | class StochasticTrajectory(BaseTrajectory): 7 | yaml_tag = u"!StochasticTrajectory" 8 | 9 | def __call__(self, initial_step, final_step): 10 | 11 | initial = np.random.randint(initial_step, final_step-2) 12 | final = np.random.randint(initial, final_step) 13 | 14 | return initial, final 15 | 16 | 17 | class FixedLengthStochasticTrajectory(BaseTrajectory): 18 | yaml_tag = u"!FixedLengthStochasticTrajectory" 19 | 20 | def __init__(self, trajectory_length): 21 | self.trajectory_length = trajectory_length 22 | 23 | def __call__(self, initial_step, final_step): 24 | if final_step - initial_step < self.trajectory_length: 25 | raise ValueError(f'Cannot create a trajectory of length {self.trajectory_length}' 26 | f'between initial_step ({initial_step}) and final_step ({final_step})') 27 | 28 | initial = np.random.randint(initial_step, final_step-self.trajectory_length) 29 | 30 | return initial, initial + self.trajectory_length 31 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/microgrid/utils/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/microgrid/utils/step.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | class MicrogridStep: 5 | def __init__(self, reward_shaping_func=None, cost_info=None): 6 | self._reward_shaping_func = reward_shaping_func 7 | self.cost_info = cost_info 8 | self._obs = dict() 9 | self._reward = 0.0 10 | self._done = False 11 | self._info = dict(absorbed_energy=[], provided_energy=[]) 12 | 13 | def append(self, module_name, obs, reward, done, info): 14 | try: 15 | self._obs[module_name].append(obs) 16 | except KeyError: 17 | self._obs[module_name] = [obs] 18 | self._reward += reward 19 | if done: 20 | self._done = True 21 | 22 | try: 23 | self._info[module_name].append(info) 24 | except KeyError: 25 | self._info[module_name] = [info] 26 | 27 | for key, value in info.items(): 28 | try: 29 | self._info[key].append(value) 30 | except KeyError: 31 | pass 32 | 33 | def balance(self): 34 | provided_energy = np.sum(self._info['provided_energy']) 35 | absorbed_energy = np.sum(self._info['absorbed_energy']) 36 | return provided_energy, absorbed_energy, self._reward, self.shaped_reward() 37 | 38 | def output(self): 39 | return self._obs, self.shaped_reward(), self._done, self._output_info() 40 | 41 | def shaped_reward(self): 42 | if self._reward_shaping_func is not None: 43 | assert isinstance(self.cost_info, dict) 44 | return self._reward_shaping_func(self._output_info(), self.cost_info) 45 | 46 | return self._reward 47 | 48 | def _output_info(self): 49 | return {k: v for k, v in self._info.items() if k not in ('absorbed_energy', 'provided_energy')} 50 | 51 | @property 52 | def obs(self): 53 | return self._obs 54 | 55 | @property 56 | def reward(self): 57 | return self._reward 58 | 59 | @property 60 | def done(self): 61 | return self._done 62 | 63 | @property 64 | def info(self): 65 | return self._info -------------------------------------------------------------------------------- /src/pymgrid/modules/__init__.py: -------------------------------------------------------------------------------- 1 | from .battery_module import BatteryModule 2 | from .genset_module import GensetModule 3 | from .grid_module import GridModule 4 | from .load_module import LoadModule 5 | from .renewable_module import RenewableModule 6 | from .unbalanced_energy_module import UnbalancedEnergyModule 7 | 8 | from .module_container import ModuleContainer 9 | -------------------------------------------------------------------------------- /src/pymgrid/modules/base/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_module import BaseMicrogridModule 2 | from .timeseries.base_timeseries_module import BaseTimeSeriesMicrogridModule 3 | -------------------------------------------------------------------------------- /src/pymgrid/modules/base/timeseries/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/src/pymgrid/modules/base/timeseries/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/modules/load_module.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import yaml 3 | 4 | from pymgrid.microgrid import DEFAULT_HORIZON 5 | from pymgrid.modules.base import BaseTimeSeriesMicrogridModule 6 | 7 | 8 | class LoadModule(BaseTimeSeriesMicrogridModule): 9 | """ 10 | A renewable energy module. 11 | 12 | The classic examples of renewables are photovoltaics (PV) and wind turbines. 13 | 14 | Parameters 15 | ---------- 16 | time_series : array-like, shape (n_steps, ) 17 | Time series of load demand. 18 | 19 | forecaster : callable, float, "oracle", or None, default None. 20 | Function that gives a forecast n-steps ahead. 21 | 22 | * If ``callable``, must take as arguments ``(val_c: float, val_{c+n}: float, n: int)``, where 23 | 24 | * ``val_c`` is the current value in the time series: ``self.time_series[self.current_step]`` 25 | 26 | * ``val_{c+n}`` is the value in the time series n steps in the future 27 | 28 | * n is the number of steps in the future at which we are forecasting. 29 | 30 | The output ``forecast = forecaster(val_c, val_{c+n}, n)`` must have the same sign 31 | as the inputs ``val_c`` and ``val_{c+n}``. 32 | 33 | * If ``float``, serves as a standard deviation for a mean-zero gaussian noise function 34 | that is added to the true value. 35 | 36 | * If ``"oracle"``, gives a perfect forecast. 37 | 38 | * If ``None``, no forecast. 39 | 40 | forecast_horizon : int. 41 | Number of steps in the future to forecast. If forecaster is None, ignored and 0 is returned. 42 | 43 | forecaster_increase_uncertainty : bool, default False 44 | Whether to increase uncertainty for farther-out dates if using a GaussianNoiseForecaster. Ignored otherwise.. 45 | 46 | raise_errors : bool, default False 47 | Whether to raise errors if bounds are exceeded in an action. 48 | If False, actions are clipped to the limit possible. 49 | 50 | """ 51 | module_type = ('load', 'fixed') 52 | yaml_tag = u"!LoadModule" 53 | yaml_dumper = yaml.SafeDumper 54 | yaml_loader = yaml.SafeLoader 55 | 56 | state_components = np.array(["load"], dtype=object) 57 | 58 | def __init__(self, 59 | time_series, 60 | forecaster=None, 61 | forecast_horizon=DEFAULT_HORIZON, 62 | forecaster_increase_uncertainty=False, 63 | forecaster_relative_noise=False, 64 | initial_step=0, 65 | final_step=-1, 66 | raise_errors=False): 67 | super().__init__( 68 | time_series, 69 | raise_errors=raise_errors, 70 | forecaster=forecaster, 71 | forecast_horizon=forecast_horizon, 72 | forecaster_increase_uncertainty=forecaster_increase_uncertainty, 73 | forecaster_relative_noise=forecaster_relative_noise, 74 | initial_step=initial_step, 75 | final_step=final_step, 76 | provided_energy_name=None, 77 | absorbed_energy_name='load_met' 78 | ) 79 | 80 | self.name = ('load', None) 81 | 82 | def _get_bounds(self): 83 | _min_obs, _max_obs, _, _ = super()._get_bounds() 84 | return _min_obs, _max_obs, np.array([]), np.array([]) 85 | 86 | def update(self, external_energy_change, as_source=False, as_sink=False): 87 | assert as_sink, f'Class {self.__class__.__name__} is a sink.' 88 | 89 | info = {'absorbed_energy': self.current_load} 90 | 91 | return 0.0, self._done(), info 92 | 93 | def sample_action(self, strict_bound=False): 94 | return np.array([]) 95 | 96 | @property 97 | def max_consumption(self): 98 | return self.current_load 99 | 100 | @property 101 | def current_load(self): 102 | """ 103 | Current load. 104 | 105 | Returns 106 | ------- 107 | load : float 108 | Current load demand. 109 | 110 | """ 111 | return -1 * self._time_series[self._current_step].item() 112 | 113 | @property 114 | def is_sink(self): 115 | return True 116 | -------------------------------------------------------------------------------- /src/pymgrid/modules/renewable_module.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import yaml 3 | 4 | from pymgrid.microgrid import DEFAULT_HORIZON 5 | from pymgrid.modules.base import BaseTimeSeriesMicrogridModule 6 | 7 | 8 | class RenewableModule(BaseTimeSeriesMicrogridModule): 9 | """ 10 | A renewable energy module. 11 | 12 | The classic examples of renewables are photovoltaics (PV) and wind turbines. 13 | 14 | Parameters 15 | ---------- 16 | time_series : array-like, shape (n_steps, ) 17 | Time series of renewable production. 18 | 19 | forecaster : callable, float, "oracle", or None, default None. 20 | Function that gives a forecast n-steps ahead. 21 | 22 | * If ``callable``, must take as arguments ``(val_c: float, val_{c+n}: float, n: int)``, where 23 | 24 | * ``val_c`` is the current value in the time series: ``self.time_series[self.current_step]`` 25 | 26 | * ``val_{c+n}`` is the value in the time series n steps in the future 27 | 28 | * n is the number of steps in the future at which we are forecasting. 29 | 30 | The output ``forecast = forecaster(val_c, val_{c+n}, n)`` must have the same sign 31 | as the inputs ``val_c`` and ``val_{c+n}``. 32 | 33 | * If ``float``, serves as a standard deviation for a mean-zero gaussian noise function 34 | that is added to the true value. 35 | 36 | * If ``"oracle"``, gives a perfect forecast. 37 | 38 | * If ``None``, no forecast. 39 | 40 | forecast_horizon : int. 41 | Number of steps in the future to forecast. If forecaster is None, ignored and 0 is returned. 42 | 43 | forecaster_increase_uncertainty : bool, default False 44 | Whether to increase uncertainty for farther-out dates if using a GaussianNoiseForecaster. Ignored otherwise. 45 | 46 | provided_energy_name: str, default "renewable_used" 47 | Name of the energy provided by this module, to be used in logging. 48 | 49 | raise_errors : bool, default False 50 | Whether to raise errors if bounds are exceeded in an action. 51 | If False, actions are clipped to the limit possible. 52 | 53 | """ 54 | module_type = ('renewable', 'flex') 55 | yaml_tag = u"!RenewableModule" 56 | yaml_loader = yaml.SafeLoader 57 | yaml_dumper = yaml.SafeDumper 58 | 59 | state_components = np.array(["renewable"], dtype=object) 60 | 61 | def __init__(self, 62 | time_series, 63 | raise_errors=False, 64 | forecaster=None, 65 | forecast_horizon=DEFAULT_HORIZON, 66 | forecaster_increase_uncertainty=False, 67 | forecaster_relative_noise=False, 68 | initial_step=0, 69 | final_step=-1, 70 | provided_energy_name='renewable_used'): 71 | super().__init__( 72 | time_series, 73 | raise_errors, 74 | forecaster=forecaster, 75 | forecast_horizon=forecast_horizon, 76 | forecaster_increase_uncertainty=forecaster_increase_uncertainty, 77 | forecaster_relative_noise=forecaster_relative_noise, 78 | initial_step=initial_step, 79 | final_step=final_step, 80 | provided_energy_name=provided_energy_name, 81 | absorbed_energy_name=None 82 | ) 83 | 84 | self.name = ('renewable', None) 85 | 86 | def update(self, external_energy_change, as_source=False, as_sink=False): 87 | assert as_source, f'Class {self.__class__.__name__} can only be used as a source.' 88 | assert external_energy_change <= self.current_renewable, f'Cannot provide more than {self.current_renewable}' 89 | 90 | info = {'provided_energy': external_energy_change, 91 | 'curtailment': self.current_renewable-external_energy_change} 92 | 93 | return 0.0, self._done(), info 94 | 95 | @property 96 | def max_production(self): 97 | return self.current_renewable 98 | 99 | @property 100 | def current_renewable(self): 101 | """ 102 | Current renewable production. 103 | 104 | Returns 105 | ------- 106 | renewable : float 107 | Renewable production. 108 | 109 | """ 110 | return self._time_series[self._current_step].item() 111 | 112 | @property 113 | def is_source(self): 114 | return True 115 | -------------------------------------------------------------------------------- /src/pymgrid/modules/unbalanced_energy_module.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import yaml 3 | 4 | from pymgrid.modules.base import BaseMicrogridModule 5 | 6 | 7 | class UnbalancedEnergyModule(BaseMicrogridModule): 8 | module_type = ('balancing', 'flex') 9 | yaml_tag = u"!UnbalancedEnergyModule" 10 | yaml_dumper = yaml.SafeDumper 11 | yaml_loader = yaml.SafeLoader 12 | 13 | def __init__(self, 14 | raise_errors, 15 | initial_step=0, 16 | loss_load_cost=10, 17 | overgeneration_cost=2.0 18 | ): 19 | 20 | super().__init__(raise_errors, 21 | initial_step=initial_step, 22 | provided_energy_name='loss_load', 23 | absorbed_energy_name='overgeneration') 24 | 25 | self.loss_load_cost, self.overgeneration_cost = loss_load_cost, overgeneration_cost 26 | self.name = ('unbalanced_energy', None) 27 | 28 | def update(self, external_energy_change, as_source=False, as_sink=False): 29 | assert as_source + as_sink == 1, 'Must act as either source or sink but not both or neither.' 30 | 31 | info_key = 'provided_energy' if as_source else 'absorbed_energy' 32 | reward = -1.0 * self.get_cost(external_energy_change, as_source, as_sink) 33 | assert reward <= 0 34 | info = {info_key: external_energy_change} 35 | 36 | return reward, False, info 37 | 38 | def get_cost(self, energy_amount, as_source, as_sink): 39 | """ 40 | Get the cost of unmet load or excess production. 41 | 42 | Parameters 43 | ---------- 44 | energy_amount : float>=0 45 | Amount of unmet load or excess production. 46 | 47 | as_source : bool 48 | Whether the energy is unmet load. 49 | 50 | as_sink : bool 51 | Whether the energy is excess production. 52 | 53 | Returns 54 | ------- 55 | cost : float 56 | 57 | Raises 58 | ------ 59 | TypeError 60 | If both as_source and as_sink are True or neither are. 61 | 62 | """ 63 | if as_source and as_sink: 64 | raise TypeError("as_source and as_sink cannot both be True.") 65 | if as_source: # loss load 66 | return self.loss_load_cost*energy_amount 67 | elif as_sink: 68 | return self.overgeneration_cost*energy_amount 69 | else: 70 | raise TypeError("One of as_source or as_sink must be True.") 71 | 72 | def _state_dict(self): 73 | return dict() 74 | 75 | @property 76 | def state(self): 77 | return np.array([]) 78 | 79 | @property 80 | def min_obs(self): 81 | return np.array([]) 82 | 83 | @property 84 | def max_obs(self): 85 | return np.array([]) 86 | 87 | @property 88 | def min_act(self): 89 | return -np.inf 90 | 91 | @property 92 | def max_act(self): 93 | return np.inf 94 | 95 | @property 96 | def max_production(self): 97 | return np.inf 98 | 99 | @property 100 | def max_consumption(self): 101 | return np.inf 102 | 103 | @property 104 | def is_source(self): 105 | return True 106 | 107 | @property 108 | def is_sink(self): 109 | return True 110 | 111 | @property 112 | def production_marginal_cost(self): 113 | return self.loss_load_cost 114 | 115 | @property 116 | def absorption_marginal_cost(self): 117 | return self.overgeneration_cost 118 | -------------------------------------------------------------------------------- /src/pymgrid/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .serialize import add_pymgrid_yaml_representers 2 | -------------------------------------------------------------------------------- /src/pymgrid/utils/logger.py: -------------------------------------------------------------------------------- 1 | from collections import UserDict 2 | 3 | import numpy as np 4 | import pandas as pd 5 | 6 | 7 | class ModularLogger(UserDict): 8 | def __init__(self, *args, **kwargs): 9 | super().__init__(*args, **kwargs) 10 | self._log_length = max(len(v) for _, v in self.items()) if len(self.data) else 0 11 | 12 | def flush(self): 13 | d = self.data.copy() 14 | self.clear() 15 | self._log_length = 0 16 | return d 17 | 18 | def log(self, **log_dict): 19 | for key, value in log_dict.items(): 20 | try: 21 | self[key].append(value.item()) 22 | except AttributeError: 23 | self[key].append(value) 24 | except KeyError: 25 | self[key] = [np.nan]*self._log_length 26 | self[key].append(value) 27 | 28 | self._log_length += 1 29 | 30 | def to_dict(self): 31 | return self.data.copy() 32 | 33 | def raw(self): 34 | return {k: list(map(float, v)) for k, v in self.data.items()} 35 | 36 | def to_frame(self): 37 | return pd.DataFrame(self.data) 38 | 39 | def serialize(self, key): 40 | return {key: self.to_frame()} if len(self) > 0 else {} 41 | 42 | def __len__(self): 43 | return self._log_length 44 | 45 | @classmethod 46 | def from_raw(cls, raw): 47 | if raw is None: 48 | return cls() 49 | elif isinstance(raw, str): 50 | raw = pd.read_csv(raw).to_dict() 51 | return cls(raw) 52 | -------------------------------------------------------------------------------- /src/pymgrid/utils/ray.py: -------------------------------------------------------------------------------- 1 | import functools 2 | from copy import copy 3 | 4 | 5 | def ray_decorator(func): 6 | """ 7 | ray raises an error when assigning values after ray.get to variables defined before ray.get. 8 | Easiest solution is to copy the values and try again. 9 | 10 | :meta private: 11 | 12 | """ 13 | @functools.wraps(func) 14 | def wrapper(*args, **kwargs): 15 | try: 16 | return func(*args, **kwargs) 17 | except ValueError as e: 18 | if 'assignment destination is read-only' not in e.args[0]: 19 | raise 20 | else: 21 | return func(*(copy(a) for a in args), **{k: copy(v) for k, v in kwargs.items()}) 22 | return wrapper 23 | -------------------------------------------------------------------------------- /src/pymgrid/utils/serialize.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pandas as pd 3 | import yaml 4 | 5 | from pathlib import Path 6 | 7 | TO_CSV_TYPES = np.ndarray, pd.core.generic.NDFrame 8 | 9 | 10 | def add_pymgrid_yaml_representers(): 11 | add_numpy_pandas_representers() 12 | from pymgrid.microgrid.trajectory import ( 13 | DeterministicTrajectory, 14 | StochasticTrajectory, 15 | FixedLengthStochasticTrajectory 16 | ) 17 | 18 | from pymgrid.microgrid.reward_shaping import ( 19 | PVCurtailmentShaper, 20 | BatteryDischargeShaper 21 | ) 22 | 23 | 24 | def dump_data(data_dict, stream, yaml_tag): 25 | if not hasattr(stream, "name"): 26 | return data_dict 27 | 28 | path = Path(stream.name).parent / "data" 29 | return add_path_to_arr_like(data_dict, path, yaml_tag) 30 | 31 | 32 | def add_path_to_arr_like(data_dict, path, yaml_tag): 33 | for key, value in data_dict.items(): 34 | if isinstance(value, dict): 35 | data_dict[key] = add_path_to_arr_like(value, path / key, yaml_tag) 36 | elif isinstance(value, TO_CSV_TYPES): 37 | if isinstance(value, np.ndarray): 38 | value = NDArraySubclass(value) 39 | value.path = path / f'{yaml_tag.lstrip("!")}/{key}.csv.gz' 40 | data_dict[key] = value 41 | 42 | return data_dict 43 | 44 | 45 | def add_numpy_pandas_representers(): 46 | yaml.SafeDumper.add_representer(pd.DataFrame, _pandas_df_representer) 47 | yaml.SafeDumper.add_multi_representer(np.ndarray, _numpy_arr_representer) 48 | yaml.SafeDumper.add_multi_representer(np.floating, _numpy_represent_floating) 49 | yaml.SafeDumper.add_multi_representer(np.integer, _numpy_represent_int) 50 | 51 | 52 | def add_numpy_pandas_constructors(): 53 | yaml.SafeLoader.add_constructor('!NDArray', _numpy_arr_constructor) 54 | yaml.SafeLoader.add_constructor('!DataFrame', _pandas_df_constructor) 55 | 56 | 57 | def _numpy_represent_floating(dumper, data): 58 | return dumper.represent_float(data.item()) 59 | 60 | 61 | def _numpy_represent_int(dumper, data): 62 | return dumper.represent_int(data.item()) 63 | 64 | 65 | def _numpy_arr_representer(dumper, data): 66 | return _arr_representer(dumper, data, 'NDArray') 67 | 68 | 69 | def _pandas_df_representer(dumper, data): 70 | return _arr_representer(dumper, data, 'DataFrame') 71 | 72 | 73 | def _arr_representer(dumper, data, r_type): 74 | if hasattr(data, "path"): 75 | rel_path = _dump_representation(data, data.path, Path(dumper.stream.name).parent) 76 | return dumper.represent_scalar(f'!{r_type}', rel_path) 77 | 78 | try: 79 | return dumper.represent_mapping(f'!{r_type}', data.to_dict()) 80 | except AttributeError: 81 | return dumper.represent_sequence(f'!{r_type}', data.tolist()) 82 | 83 | 84 | def _dump_representation(data, path, stream_loc): 85 | if not path.exists(): 86 | path.parent.mkdir(parents=True, exist_ok=True) 87 | pd.DataFrame(data).to_csv(path) 88 | return str(path.relative_to(stream_loc)) 89 | 90 | 91 | def _pandas_df_constructor(loader, node): 92 | if isinstance(node, yaml.MappingNode): 93 | return pd.DataFrame(loader.construct_mapping(node)) 94 | 95 | data_path = Path(loader.construct_scalar(node)) 96 | 97 | if not data_path.is_absolute(): 98 | try: 99 | stream_name = loader.stream.name 100 | except AttributeError: 101 | raise ValueError(f"Path {data_path} must be absolute if yaml stream has no 'name'.") 102 | 103 | data_path = Path(stream_name).parent / data_path 104 | 105 | return pd.read_csv(data_path, index_col=0) 106 | 107 | 108 | def _numpy_arr_constructor(loader, node): 109 | if isinstance(node, yaml.SequenceNode): 110 | return np.array(loader.construct_sequence(node)) 111 | 112 | return _pandas_df_constructor(loader, node).values 113 | 114 | 115 | class NDArraySubclass(np.ndarray): 116 | """ 117 | A simple python class that allows a 'path' attribute for serialization. 118 | `path` may be lost if object is manipulated. 119 | """ 120 | def __new__(cls, input_array, path=None): 121 | obj = np.asarray(input_array).view(cls) 122 | obj.path = path 123 | return obj 124 | 125 | def __array_finalize__(self, obj): 126 | if obj is None: 127 | return 128 | self.path = getattr(obj, 'path', None) 129 | -------------------------------------------------------------------------------- /src/pymgrid/version.py: -------------------------------------------------------------------------------- 1 | __version__ = '1.2.2' 2 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/tests/__init__.py -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/tests/conftest.py -------------------------------------------------------------------------------- /tests/control/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/tests/control/__init__.py -------------------------------------------------------------------------------- /tests/control/data_generation/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/tests/control/data_generation/__init__.py -------------------------------------------------------------------------------- /tests/control/test_control.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | -------------------------------------------------------------------------------- /tests/control/test_mpc.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from tests.helpers.test_case import TestCase 4 | from tests.helpers.modular_microgrid import get_modular_microgrid 5 | 6 | from pymgrid.algos import ModelPredictiveControl 7 | 8 | 9 | class TestMPC(TestCase): 10 | def test_init(self): 11 | microgrid = get_modular_microgrid() 12 | mpc = ModelPredictiveControl(microgrid) 13 | self.assertTrue(mpc.is_modular) 14 | self.assertEqual(mpc.horizon, 1) 15 | 16 | def test_run_with_load_pv_battery_grid(self): 17 | from pymgrid.modules import RenewableModule, LoadModule 18 | 19 | max_steps = 10 20 | pv_const = 50 21 | load_const = 60 22 | pv = RenewableModule(time_series=pv_const*np.ones(100)) 23 | load = LoadModule(time_series=load_const*np.ones(100)) 24 | 25 | microgrid = get_modular_microgrid(remove_modules=["renewable", "load", "genset"], additional_modules=[pv, load]) 26 | 27 | mpc = ModelPredictiveControl(microgrid) 28 | mpc_output = mpc.run(max_steps=max_steps) 29 | self.assertEqual(mpc_output.shape[0], max_steps) 30 | self.assertEqual(mpc_output[("grid", 0, "grid_import")].values + 31 | mpc_output[("battery", 0, "discharge_amount")].values + 32 | mpc_output[("renewable", 0, "renewable_used")].values, 33 | [load_const] * mpc_output.shape[0] 34 | ) 35 | 36 | def test_run_with_load_pv_battery_genset(self): 37 | from pymgrid.modules import RenewableModule, LoadModule 38 | 39 | max_steps = 10 40 | pv_const = 50 41 | load_const = 60 42 | pv = RenewableModule(time_series=pv_const*np.ones(100)) 43 | load = LoadModule(time_series=load_const*np.ones(100)) 44 | 45 | microgrid = get_modular_microgrid(remove_modules=["renewable", "load", "grid"], additional_modules=[pv, load]) 46 | 47 | mpc = ModelPredictiveControl(microgrid) 48 | mpc_output = mpc.run(max_steps=max_steps) 49 | self.assertEqual(mpc_output.shape[0], max_steps) 50 | 51 | self.assertEqual(mpc_output[("load", 0, "load_met")].values, [60.]*mpc_output.shape[0]) 52 | self.assertEqual(mpc_output[("genset", 0, "genset_production")].values + 53 | mpc_output[("battery", 0, "discharge_amount")].values, 54 | [10.] * mpc_output.shape[0]) 55 | 56 | def test_run_twice_with_load_pv_battery_genset(self): 57 | from pymgrid.modules import RenewableModule, LoadModule 58 | 59 | max_steps = 10 60 | pv_const = 50 61 | load_const = 60 62 | pv = RenewableModule(time_series=pv_const*np.ones(100)) 63 | load = LoadModule(time_series=load_const*np.ones(100)) 64 | 65 | microgrid = get_modular_microgrid(remove_modules=["renewable", "load", "grid"], additional_modules=[pv, load]) 66 | 67 | mpc = ModelPredictiveControl(microgrid) 68 | mpc_output = mpc.run(max_steps=max_steps) 69 | 70 | self.assertEqual(mpc_output.shape[0], max_steps) 71 | self.assertEqual(mpc_output[("load", 0, "load_met")].values, [60.] * mpc_output.shape[0]) 72 | self.assertEqual(mpc_output[("genset", 0, "genset_production")].values + 73 | mpc_output[("battery", 0, "discharge_amount")].values, 74 | [10.] * mpc_output.shape[0]) 75 | 76 | mpc_output = mpc.run(max_steps=max_steps) 77 | 78 | self.assertEqual(mpc_output.shape[0], max_steps) 79 | self.assertEqual(mpc_output[("load", 0, "load_met")].values, [60.] * mpc_output.shape[0]) 80 | self.assertEqual(mpc_output[("genset", 0, "genset_production")].values, [10.] * mpc_output.shape[0]) 81 | 82 | def test_run_with_load_pv_battery_grid_different_names(self): 83 | from pymgrid.modules import RenewableModule, LoadModule 84 | 85 | max_steps = 10 86 | pv_const = 50 87 | load_const = 60 88 | pv = RenewableModule(time_series=pv_const*np.ones(100)) 89 | load = LoadModule(time_series=load_const*np.ones(100)) 90 | 91 | microgrid = get_modular_microgrid(remove_modules=["renewable", "load", "genset"], 92 | additional_modules=[("pv_with_name", pv), ("load_with_name", load)]) 93 | 94 | mpc = ModelPredictiveControl(microgrid) 95 | mpc_output = mpc.run(max_steps=max_steps) 96 | self.assertEqual(mpc_output.shape[0], max_steps) 97 | self.assertEqual(mpc_output[("load_with_name", 0, "load_met")].values, [load_const]*mpc_output.shape[0]) 98 | self.assertEqual(mpc_output[("grid", 0, "grid_import")].values + 99 | mpc_output[("battery", 0, "discharge_amount")].values + 100 | mpc_output[("pv_with_name", 0, "renewable_used")].values, 101 | [load_const] * mpc_output.shape[0] 102 | ) 103 | self.assertEqual(mpc_output[("load_with_name", 0, "load_met")].values, [load_const]*mpc_output.shape[0]) -------------------------------------------------------------------------------- /tests/control/test_rbc.py: -------------------------------------------------------------------------------- 1 | from copy import deepcopy 2 | 3 | from tests.helpers.test_case import TestCase 4 | from tests.helpers.modular_microgrid import get_modular_microgrid 5 | 6 | from pymgrid.algos import RuleBasedControl 7 | 8 | 9 | class TestRBC(TestCase): 10 | def setUp(self) -> None: 11 | self.rbc = RuleBasedControl(get_modular_microgrid()) 12 | 13 | def test_init(self): 14 | microgrid = get_modular_microgrid() 15 | self.assertEqual(microgrid, self.rbc.microgrid) 16 | self.assertEqual(microgrid, deepcopy(self.rbc).microgrid) 17 | 18 | def test_priority_list(self): 19 | rbc = deepcopy(self.rbc) 20 | 21 | for j, (element_1, element_2) in enumerate(zip(rbc.priority_list[:-1], rbc.priority_list[1:])): 22 | with self.subTest(testing=f'element_{j}<=element_{j+1}'): 23 | self.assertLessEqual(element_1.marginal_cost, element_2.marginal_cost) 24 | 25 | def test_run_once(self): 26 | rbc = deepcopy(self.rbc) 27 | 28 | self.assertEqual(len(rbc.microgrid.log), 0) 29 | 30 | n_steps = 10 31 | 32 | log = rbc.run(n_steps) 33 | 34 | self.assertEqual(len(log), n_steps) 35 | self.assertEqual(log, rbc.microgrid.log) 36 | return rbc 37 | 38 | def test_reset_after_run(self): 39 | rbc = self.test_run_once() 40 | rbc.reset() 41 | self.assertEqual(len(rbc.microgrid.log), 0) -------------------------------------------------------------------------------- /tests/envs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/tests/envs/__init__.py -------------------------------------------------------------------------------- /tests/helpers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/tests/helpers/__init__.py -------------------------------------------------------------------------------- /tests/helpers/genset_module_testing_utils.py: -------------------------------------------------------------------------------- 1 | from pymgrid.modules import GensetModule 2 | 3 | 4 | default_params = dict(running_min_production=10, 5 | running_max_production=100, 6 | genset_cost=1, 7 | start_up_time=0, 8 | wind_down_time=0, 9 | allow_abortion=True, 10 | init_start_up=True, 11 | raise_errors=True) 12 | 13 | 14 | def get_genset(default_parameters=None, **new_params): 15 | params = default_parameters.copy() if default_parameters is not None else default_params.copy() 16 | params.update(new_params) 17 | return GensetModule(**params), params 18 | 19 | 20 | def normalize_production(production, max_production=None): 21 | max_production = max_production if max_production else default_params['running_max_production'] 22 | return production/max_production 23 | -------------------------------------------------------------------------------- /tests/helpers/modular_microgrid.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pymgrid import Microgrid 4 | 5 | from pymgrid.modules import ( 6 | BatteryModule, 7 | GensetModule, 8 | GridModule, 9 | LoadModule, 10 | RenewableModule 11 | ) 12 | 13 | 14 | def get_modular_microgrid(remove_modules=(), 15 | retain_only=None, 16 | additional_modules=None, 17 | add_unbalanced_module=True, 18 | timeseries_length=100, 19 | modules_only=False): 20 | 21 | modules = dict( 22 | genset=GensetModule(running_min_production=10, running_max_production=50, genset_cost=0.5), 23 | 24 | battery=BatteryModule(min_capacity=0, 25 | max_capacity=100, 26 | max_charge=50, 27 | max_discharge=50, 28 | efficiency=1.0, 29 | init_soc=0.5), 30 | 31 | renewable=RenewableModule(time_series=50*np.ones(timeseries_length)), 32 | 33 | load=LoadModule(time_series=60*np.ones(timeseries_length)), 34 | 35 | grid=GridModule(max_import=100, max_export=0, time_series=np.ones((timeseries_length, 3)), raise_errors=True) 36 | ) 37 | 38 | if retain_only is not None: 39 | modules = {k: v for k, v in modules.items() if k in retain_only} 40 | if remove_modules: 41 | raise RuntimeError('Can pass either remove_modules or retain_only, but not both.') 42 | else: 43 | for module in remove_modules: 44 | try: 45 | modules.pop(module) 46 | except KeyError: 47 | raise NameError(f"Module {module} not one of default modules {list(modules.keys())}.") 48 | 49 | modules = list(modules.values()) 50 | modules.extend(additional_modules if additional_modules else []) 51 | 52 | if modules_only: 53 | return modules 54 | 55 | return Microgrid(modules, add_unbalanced_module=add_unbalanced_module) 56 | -------------------------------------------------------------------------------- /tests/helpers/test_case.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import numpy as np 3 | from warnings import warn 4 | 5 | 6 | class TestCase(unittest.TestCase): 7 | def assertEqual(self, first, second, msg=None) -> None: 8 | try: 9 | super().assertEqual(first, second, msg=msg) 10 | except (ValueError, AssertionError): 11 | # array-like or pandas obj 12 | try: 13 | # convert pandas obj 14 | first, second = first.values, second.values 15 | except AttributeError: 16 | # not a pandas obj 17 | pass 18 | 19 | try: 20 | np.testing.assert_equal(first, second, err_msg=msg if msg else '') 21 | except AssertionError as e: 22 | try: 23 | np.testing.assert_allclose(first, second, rtol=1e-7, atol=1e-10, err_msg=msg if msg else '') 24 | except TypeError: 25 | raise e 26 | -------------------------------------------------------------------------------- /tests/microgrid/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/tests/microgrid/__init__.py -------------------------------------------------------------------------------- /tests/microgrid/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/tests/microgrid/modules/__init__.py -------------------------------------------------------------------------------- /tests/microgrid/modules/container_tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/tests/microgrid/modules/container_tests/__init__.py -------------------------------------------------------------------------------- /tests/microgrid/modules/container_tests/test_container.py: -------------------------------------------------------------------------------- 1 | from tests.helpers.modular_microgrid import get_modular_microgrid 2 | from tests.helpers.test_case import TestCase 3 | 4 | 5 | class TestContainer(TestCase): 6 | def test_container_init(self): 7 | microgrid = get_modular_microgrid() 8 | self.assertTrue(len(microgrid.controllable.sources)) 9 | self.assertTrue(len(microgrid.controllable.source_and_sinks)) 10 | action = microgrid.sample_action() 11 | -------------------------------------------------------------------------------- /tests/microgrid/modules/conversion_test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/tests/microgrid/modules/conversion_test/__init__.py -------------------------------------------------------------------------------- /tests/microgrid/modules/conversion_test/test_modular_conversion.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from tests.helpers.test_case import TestCase 4 | 5 | 6 | class TestToModular(TestCase): 7 | def setUp(self) -> None: 8 | from pymgrid.MicrogridGenerator import MicrogridGenerator 9 | mgen = MicrogridGenerator() 10 | mgen.generate_microgrid(modular=False) 11 | self.weak_grids = [microgrid for microgrid in mgen.microgrids if self.is_weak_grid(microgrid)] 12 | self.genset_only = [microgrid for microgrid in mgen.microgrids if not microgrid.architecture["grid"]] 13 | self.strong_grid_only = [microgrid for microgrid in mgen.microgrids if 14 | (not microgrid.architecture["genset"]) and self.is_strong_grid(microgrid)] 15 | self.strong_grid_and_genset = [microgrid for microgrid in mgen.microgrids if 16 | microgrid.architecture["genset"] and self.is_strong_grid(microgrid)] 17 | 18 | @staticmethod 19 | def is_weak_grid(microgrid): 20 | return microgrid.architecture["grid"] and microgrid._grid_status_ts.min().item() < 1 21 | 22 | @staticmethod 23 | def is_strong_grid(microgrid): 24 | return microgrid.architecture["grid"] and microgrid._grid_status_ts.min().item() == 1 25 | 26 | def test_weak_grid_conversion_success(self): 27 | for microgrid in self.weak_grids: 28 | modular_microgrid = microgrid.to_modular() 29 | self.assertTrue(modular_microgrid.grid.item().weak_grid) 30 | 31 | def test_genset_only(self): 32 | for microgrid in self.genset_only: 33 | modular = microgrid.to_modular() 34 | self.assertTrue(len(modular.genset) == 1) 35 | 36 | genset_module = modular.genset[0] 37 | self.assertEqual(microgrid.genset.fuel_cost, genset_module.genset_cost) 38 | self.assertEqual(microgrid.genset.co2, genset_module.co2_per_unit) 39 | self.assertEqual(microgrid.genset.rated_power*microgrid.genset.p_max, genset_module.max_production) 40 | 41 | with self.assertRaises(AttributeError): 42 | _ = modular.grid -------------------------------------------------------------------------------- /tests/microgrid/modules/forecaster_tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Total-RD/pymgrid/7bf39516e1e91b6fe5dbe22ea2eb6caeb5ac6fb8/tests/microgrid/modules/forecaster_tests/__init__.py -------------------------------------------------------------------------------- /tests/microgrid/modules/module_tests/test_load_module.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pymgrid.modules import LoadModule 4 | 5 | from tests.microgrid.modules.module_tests.timeseries_modules import ( 6 | TestTimeseriesModuleForecasting, 7 | TestTimeseriesModuleNoForecasting, 8 | TestTimeSeriesModuleForecastingNegativeVals, 9 | TestTimeSeriesModuleNoForecastingNegativeVals 10 | ) 11 | 12 | 13 | class TestLoadModuleNoForecasting(TestTimeseriesModuleNoForecasting): 14 | __test__ = True 15 | negative_time_series = True 16 | action_space_dim = 0 17 | 18 | 19 | def get_module(self): 20 | return LoadModule(self.module_time_series) 21 | 22 | def test_init_current_load(self): 23 | load_module = self.get_module() 24 | self.assertEqual(load_module.current_load, -1 * self.time_series[0]) 25 | 26 | def test_step(self): 27 | load_module = self.get_module() 28 | self.assertEqual(load_module.current_load, -1 * self.time_series[0]) 29 | 30 | obs, reward, done, info = load_module.step(np.array([])) 31 | obs = load_module.from_normalized(obs, obs=True) 32 | self.assertEqual(obs, self.time_series[1]) 33 | self.assertEqual(reward, 0) 34 | self.assertFalse(done) 35 | self.assertEqual(info["absorbed_energy"], -1 * self.time_series[0]) 36 | 37 | 38 | class TestLoadModuleForecasting(TestTimeseriesModuleForecasting): 39 | __test__ = True 40 | negative_time_series = True 41 | action_space_dim = 0 42 | 43 | def get_module(self): 44 | return LoadModule(self.module_time_series, forecaster="oracle", forecast_horizon=self.forecast_horizon) 45 | 46 | def test_step(self): 47 | load_module = self.get_module() 48 | self.assertEqual(load_module.current_load, -1 * self.time_series[0]) 49 | 50 | action = load_module.to_normalized(np.array([]), act=True) 51 | obs, reward, done, info = load_module.step(action) 52 | obs = load_module.from_normalized(obs, obs=True) 53 | self.assertEqual(obs, self.time_series[1:self.forecast_horizon+2]) 54 | self.assertEqual(reward, 0) 55 | self.assertFalse(done) 56 | self.assertEqual(info["absorbed_energy"], -1 * self.time_series[0]) 57 | 58 | 59 | class TestLoadModuleForecastingNegativeVals(TestTimeSeriesModuleForecastingNegativeVals, 60 | TestLoadModuleForecasting): 61 | pass 62 | 63 | 64 | class TestLoadModuleNoForecastingNegativeVals(TestTimeSeriesModuleNoForecastingNegativeVals, 65 | TestLoadModuleNoForecasting): 66 | pass 67 | 68 | -------------------------------------------------------------------------------- /tests/microgrid/modules/module_tests/test_renewable_module.py: -------------------------------------------------------------------------------- 1 | 2 | from pymgrid.modules import RenewableModule 3 | 4 | from tests.microgrid.modules.module_tests.timeseries_modules import ( 5 | TestTimeseriesModuleForecasting, 6 | TestTimeseriesModuleNoForecasting, 7 | TestTimeSeriesModuleForecastingNegativeVals, 8 | TestTimeSeriesModuleNoForecastingNegativeVals 9 | ) 10 | 11 | 12 | class TestRenewableModuleNoForecasting(TestTimeseriesModuleNoForecasting): 13 | __test__ = True 14 | action_space_dim = 1 15 | 16 | def get_module(self): 17 | return RenewableModule(self.module_time_series) 18 | 19 | def test_init_current_renewable(self): 20 | renewable_module = self.get_module() 21 | self.assertEqual(renewable_module.current_renewable, self.time_series[0]) 22 | 23 | def test_step(self): 24 | renewable_module = self.get_module() 25 | self.assertEqual(renewable_module.current_renewable, self.time_series[0]) 26 | 27 | unnormalized_action = 1 28 | action = renewable_module.to_normalized(unnormalized_action, act=True) 29 | obs, reward, done, info = renewable_module.step(action) 30 | obs = renewable_module.from_normalized(obs, obs=True) 31 | self.assertEqual(obs, self.time_series[1]) 32 | self.assertEqual(reward, 0) 33 | self.assertFalse(done) 34 | self.assertEqual(info["provided_energy"], unnormalized_action) 35 | self.assertEqual(info["curtailment"], 0) 36 | 37 | 38 | class TestRenewableModuleForecasting(TestTimeseriesModuleForecasting): 39 | __test__ = True 40 | action_space_dim = 1 41 | 42 | def get_module(self): 43 | return RenewableModule(self.module_time_series, forecaster="oracle", forecast_horizon=self.forecast_horizon) 44 | 45 | def test_step(self): 46 | renewable_module = self.get_module() 47 | self.assertEqual(renewable_module.current_renewable, self.time_series[0]) 48 | 49 | unnormalized_action = 1 50 | action = renewable_module.to_normalized(unnormalized_action, act=True) 51 | obs, reward, done, info = renewable_module.step(action) 52 | obs = renewable_module.from_normalized(obs, obs=True) 53 | self.assertEqual(obs, self.time_series[1:self.forecast_horizon+2]) 54 | self.assertEqual(reward, 0) 55 | self.assertFalse(done) 56 | self.assertEqual(info["provided_energy"], unnormalized_action) 57 | self.assertEqual(info["curtailment"], 0) 58 | 59 | 60 | class TestRenewableModuleForecastingNegativeVals(TestTimeSeriesModuleForecastingNegativeVals, 61 | TestRenewableModuleForecasting): 62 | pass 63 | 64 | 65 | class TestRenewableModuleNoForecastingNegativeVals(TestTimeSeriesModuleNoForecastingNegativeVals, 66 | TestRenewableModuleNoForecasting): 67 | pass 68 | -------------------------------------------------------------------------------- /tests/microgrid/modules/module_tests/timeseries_modules.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from abc import abstractmethod 3 | from gym.spaces import Box 4 | 5 | from pymgrid.utils.space import ModuleSpace 6 | 7 | from tests.helpers.test_case import TestCase 8 | 9 | 10 | class TestTimeseriesModule(TestCase): 11 | __test__ = False 12 | negative_time_series = False 13 | forecast_horizon: int 14 | action_space_dim: int 15 | 16 | def setUp(self) -> None: 17 | self.module_time_series = self._get_module_time_series() 18 | self.time_series = self._get_time_series() 19 | 20 | def _get_module_time_series(self): 21 | return self._get_time_series() 22 | 23 | def _get_time_series(self): 24 | sign = -1 if self.negative_time_series else 1 25 | return sign * (2 - np.cos(np.pi * np.arange(100) / 2)) 26 | 27 | @abstractmethod 28 | def get_module(self): 29 | return NotImplemented 30 | 31 | def test_action_space(self): 32 | module = self.get_module() 33 | normalized_action_space = module.action_space["normalized"] 34 | unnormalized_action_space = module.action_space["unnormalized"] 35 | 36 | self.assertEqual(normalized_action_space, Box(low=0, high=1, shape=(self.action_space_dim, ))) 37 | self.assertEqual(unnormalized_action_space, Box(low=min(0, self.time_series.min()), 38 | high=max(0, self.time_series.max()), 39 | shape=(self.action_space_dim, ))) 40 | 41 | def test_observation_space(self): 42 | module = self.get_module() 43 | normalized_obs_space = module.observation_space["normalized"] 44 | unnormalized_obs_space = module.observation_space["unnormalized"] 45 | 46 | self.assertEqual(normalized_obs_space, Box(low=0, high=1, shape=(1+self.forecast_horizon,))) 47 | self.assertEqual(unnormalized_obs_space, Box(low=min(0, self.time_series.min()), 48 | high=max(0, self.time_series.max()), 49 | shape=(1+self.forecast_horizon,))) 50 | 51 | 52 | def test_observations_in_observation_space(self): 53 | module = self.get_module() 54 | 55 | observation_space = ModuleSpace( 56 | unnormalized_low=min(0, self.time_series.min()), 57 | unnormalized_high=max(0, self.time_series.max()), 58 | shape=(1 + module.forecast_horizon,) 59 | ) 60 | 61 | self.assertEqual(module.observation_space, observation_space) 62 | 63 | done = False 64 | while not done: 65 | obs, reward, done, info = module.step(module.action_space.sample(), normalized=False) 66 | if np.isscalar(obs): 67 | obs = np.array([obs]) 68 | self.assertIn(obs, observation_space['normalized']) 69 | self.assertIn(module.state, observation_space['unnormalized']) 70 | 71 | 72 | class TestTimeseriesModuleNoForecasting(TestTimeseriesModule): 73 | forecast_horizon = 0 74 | 75 | def test_init(self): 76 | module = self.get_module() 77 | self.assertIsNone(module.forecast()) 78 | self.assertEqual(module.state, self.time_series[0]) 79 | self.assertEqual(len(module.state_dict()), 1+self.forecast_horizon) 80 | 81 | 82 | class TestTimeseriesModuleForecasting(TestTimeseriesModule): 83 | forecast_horizon = 24 84 | 85 | def test_init(self): 86 | module = self.get_module() 87 | self.assertIsNotNone(module.forecast()) 88 | self.assertEqual(module.forecast(), self.time_series[1:1 + self.forecast_horizon].reshape((-1, 1))) 89 | self.assertEqual(module.state, self.time_series[:1 + self.forecast_horizon]) 90 | self.assertEqual(len(module.state_dict()), 1 + self.forecast_horizon) 91 | 92 | 93 | class TestTimeSeriesModuleNoForecastingNegativeVals(TestTimeseriesModuleNoForecasting): 94 | def _get_module_time_series(self): 95 | return -1 * self._get_time_series() 96 | 97 | 98 | class TestTimeSeriesModuleForecastingNegativeVals(TestTimeseriesModuleForecasting): 99 | def _get_module_time_series(self): 100 | return -1 * self._get_time_series() 101 | -------------------------------------------------------------------------------- /tests/microgrid/serialize/test_microgrid_serialization.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pymgrid import Microgrid 4 | 5 | from tests.helpers.modular_microgrid import get_modular_microgrid 6 | from tests.helpers.test_case import TestCase 7 | 8 | 9 | class TestMicrogridSerialization(TestCase): 10 | def test_serialize_no_modules(self): 11 | microgrid = Microgrid([], add_unbalanced_module=False) 12 | dump = microgrid.dump() 13 | loaded = Microgrid.load(dump) 14 | 15 | self.assertEqual(microgrid, loaded) 16 | 17 | def test_serialize_with_renewable(self): 18 | microgrid = get_modular_microgrid(remove_modules=["genset", "battery", "load", "grid"], 19 | add_unbalanced_module=False) 20 | 21 | self.assertEqual(len(microgrid.modules), 1) 22 | self.assertEqual(microgrid, Microgrid.load(microgrid.dump())) 23 | -------------------------------------------------------------------------------- /tests/test_microgridgenerator.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2020 Total S.A. 3 | Authors:Gonzague Henri 4 | Permission to use, modify, and distribute this software is given under the 5 | terms of the pymgrid License. 6 | NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. 7 | $Date: 2020/08/27 08:04 $ 8 | Gonzague Henri 9 | """ 10 | 11 | import numpy as np 12 | import pandas as pd 13 | from numpy.testing import assert_allclose 14 | 15 | 16 | import os, sys 17 | sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) 18 | 19 | from pymgrid.MicrogridGenerator import MicrogridGenerator 20 | 21 | import unittest 22 | 23 | 24 | class TestMicogridGenerator(unittest.TestCase): 25 | 26 | def setUp(self): 27 | self.mgen = MicrogridGenerator() 28 | 29 | def test_get_random_file(self): 30 | import inspect, pymgrid 31 | from pathlib import Path 32 | 33 | path = Path(inspect.getfile(pymgrid)).parent 34 | path = path / 'data/pv' 35 | data = self.mgen._get_random_file(path) 36 | 37 | self.assertEqual(len(data), 8760) 38 | 39 | def test_scale_ts(self): 40 | ts = pd.DataFrame( [i for i in range(10)]) 41 | factor = 4 42 | scaled = self.mgen._scale_ts(ts, factor) 43 | assert_allclose(ts/ts.sum()*factor, scaled) 44 | 45 | def test_get_genset(self): 46 | genset = self.mgen._get_genset() 47 | self.assertEqual (1000, genset['rated_power']) 48 | 49 | 50 | def test_get_battery(self): 51 | battery = self.mgen._get_battery() 52 | self.assertEqual (1000, battery['capa']) 53 | 54 | def test_get_grid_price_ts(self): 55 | price = self.mgen._get_grid_price_ts(10, price=0.2) 56 | self.assertTrue(all([p == 0.2 for p in price])) 57 | 58 | def test_get_grid(self): 59 | grid = self.mgen._get_grid() 60 | self.assertEqual(1000, grid['grid_power_import']) 61 | 62 | def test_size_mg(self): 63 | ts = pd.DataFrame([i for i in range(10)]) 64 | mg = self.mgen._size_mg(ts, 10) 65 | 66 | self.assertEqual(18, mg['grid']) 67 | 68 | def test_size_genset(self): 69 | self.assertEqual(int(np.ceil(10/0.9)), self.mgen._size_genset([10, 10, 10])) 70 | 71 | def test_size_battery(self): 72 | size = self.mgen._size_battery([10, 10, 10]) 73 | self.assertLessEqual(30, size) 74 | self.assertGreaterEqual(50, size) 75 | 76 | def test_generate_microgrid(self): 77 | microgrids = self.mgen.generate_microgrid().microgrids 78 | 79 | self.assertEqual(self.mgen.nb_microgrids, len(microgrids)) 80 | 81 | def test_create_microgrid(self): 82 | mg = self.mgen._create_microgrid() 83 | 84 | self.assertEqual(1, mg.architecture['battery']) 85 | 86 | if __name__ == '__main__': 87 | unittest.main() 88 | -------------------------------------------------------------------------------- /tests/test_nonmodular_microgrid.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright 2020 Total S.A. 3 | Authors:Gonzague Henri 4 | Permission to use, modify, and distribute this software is given under the 5 | terms of the pymgrid License. 6 | NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. 7 | $Date: 2020/08/27 08:04 $ 8 | Gonzague Henri 9 | """ 10 | import unittest 11 | import numpy as np 12 | 13 | from pymgrid.MicrogridGenerator import MicrogridGenerator 14 | 15 | 16 | class TestNonmodularMicrogrid(unittest.TestCase): 17 | def setUp(self): 18 | mgen = MicrogridGenerator() 19 | self.mg = mgen._create_microgrid() 20 | 21 | @staticmethod 22 | def random_control(): 23 | return dict(pv_consummed=np.random.rand(), 24 | battery_charge=np.random.rand(), 25 | battery_discharge=np.random.rand(), 26 | grid_import=np.random.rand(), 27 | grid_export=np.random.rand() 28 | ) 29 | 30 | def test_set_horizon(self): 31 | self.mg.set_horizon(25) 32 | self.assertEqual(25, self.mg.horizon) 33 | 34 | def test_get_updated_values(self): 35 | mg_data = self.mg.get_updated_values() 36 | self.assertEqual(0, mg_data['pv']) 37 | 38 | def test_forecast_all(self): 39 | self.mg.set_horizon(24) 40 | forecast = self.mg.forecast_all() 41 | self.assertEqual(24, len(forecast['load'])) 42 | 43 | def test_forecast_pv(self): 44 | self.mg.set_horizon(24) 45 | forecast = self.mg.forecast_pv() 46 | self.assertEqual (24, len(forecast)) 47 | 48 | def test_forecast_load(self): 49 | self.mg.set_horizon(24) 50 | forecast = self.mg.forecast_load() 51 | self.assertEqual (24, len(forecast)) 52 | 53 | def test_run(self): 54 | pv1 = self.mg.forecast_pv()[1] 55 | self.mg.run(self.random_control()) 56 | pv2 = self.mg.pv 57 | self.assertEqual(pv1, pv2) 58 | 59 | def test_train_test_split(self): 60 | self.mg.train_test_split() 61 | self.assertEqual('training',self.mg._data_set_to_use) 62 | 63 | def test_reset(self): 64 | self.mg.run(self.random_control()) 65 | self.mg.reset() 66 | self.assertEqual (0, self.mg._tracking_timestep) 67 | 68 | 69 | if __name__ == '__main__': 70 | unittest.main() 71 | --------------------------------------------------------------------------------