├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ └── issue-template.md └── 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 │ ├── battery_transition_models │ └── index.rst │ └── index.rst ├── notebooks ├── mpc-example.ipynb ├── quick-start.ipynb ├── rbc-example.ipynb └── rl-example.ipynb ├── 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 │ ├── errors │ ├── __init__.py │ ├── env_signature.py │ ├── error.py │ └── warnings.py │ ├── forecast │ ├── __init__.py │ └── forecaster.py │ ├── microgrid │ ├── __init__.py │ ├── microgrid.py │ ├── reward_shaping │ │ ├── __init__.py │ │ ├── base.py │ │ ├── baseline_shaper.py │ │ ├── battery_discharge_shaper.py │ │ ├── pv_curtailment_shaper.py │ │ ├── rescale_shaper.py │ │ ├── sequential.py │ │ └── standardization_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 │ │ ├── __init__.py │ │ ├── battery_module.py │ │ └── transition_models │ │ │ ├── __init__.py │ │ │ ├── biased_transition_model.py │ │ │ ├── decay_transition_model.py │ │ │ └── transition_model.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 │ ├── code_link.py │ ├── deprecation.py │ ├── dry_run.py │ ├── eq.py │ ├── logger.py │ ├── ray.py │ ├── running_mean_std.py │ ├── serialize.py │ └── space │ │ ├── __init__.py │ │ ├── space.py │ │ └── utils.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_mpc_scenarios.py ├── test_rbc.py └── test_rbc_scenarios.py ├── envs ├── __init__.py ├── test_base.py ├── test_continuous_net_load.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_battery_module.py │ │ ├── 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 ├── space │ ├── __init__.py │ ├── test_microgrid_space.py │ └── test_module_space.py └── test_microgrid.py ├── test_microgridgenerator.py └── test_nonmodular_microgrid.py /.gitattributes: -------------------------------------------------------------------------------- 1 | *.ipynb linguist-vendored -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/issue-template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Issue Template 3 | about: Report a bug, ask a question, or request a new feature 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Issue Type 11 | 12 | Select one: 13 | 14 | **[] Bug report** 15 | **[] Question** 16 | **[] Feature Request** 17 | **[] Other** 18 | 19 | Fill these out: 20 | 21 | * **python version**: 22 | * **python-microgrid version**: 23 | 24 | --- 25 | 26 | ## Bug Report 27 | 28 | (Delete/skip this section if you are not submitting a bug report) 29 | 30 | * #### Bug Description: 31 | 32 | Replace this with your bug description 33 | 34 | * #### Steps to reproduce: 35 | 36 | Provide a simple example that illustrates the issue and can be run on any machine. 37 | 38 | * #### Expected behavior: 39 | 40 | Provide a clear and concise description of what you expected to happen. 41 | 42 | * #### Other context: 43 | 44 | Any other information you think would be useful. 45 | 46 | --- 47 | 48 | ## Question 49 | 50 | (Delete/skip this section if you are not submitting a question) 51 | 52 | * #### Question: 53 | 54 | Replace this with your question. 55 | 56 | * #### Other context: 57 | 58 | Motivation for your question and any other additional context that would be useful. 59 | 60 | --- 61 | 62 | ## Feature Request 63 | 64 | (Delete/skip this section if you are not submitting a feature request) 65 | 66 | * #### Problem this feature solves: 67 | 68 | Is your feature request related to a problem? Please describe. 69 | 70 | * #### Desired solution: 71 | A clear and concise description of what you want to happen. 72 | 73 | --- 74 | 75 | ## Other 76 | 77 | (Delete/skip this section if you are submitting something into the above categories) 78 | 79 | * #### Describe your issue: 80 | -------------------------------------------------------------------------------- /.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.10", "3.12"] 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: "python-microgrid" 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 | graft src/pymgrid/data -------------------------------------------------------------------------------- /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/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 | .. python-microgrid 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 | python-microgrid documentation 8 | ********************* 9 | 10 | **Version**: |version| 11 | 12 | **Maintainer**: Avishai Halev 13 | 14 | *python-microgrid* is a Python library to simulate tertiary control of electrical microgrids. 15 | It is an extension of TotalEnergies' [pymgrid](https://github.com/Total-RD/pymgrid). *python-microgrid* allows 16 | users to create and customize microgrids of their choosing. These microgrids can then be controlled using a user-defined 17 | algorithm or one of the control algorithms contained in *python-microgrid*: rule-based control and model predictive control. 18 | 19 | Environments corresponding to the OpenAI-Gym API are also provided, with both continuous and discrete action space 20 | environments available. These environments can be used with your choice of reinforcement learning algorithm to train 21 | a control algorithm. 22 | 23 | *python-microgrid* attempts to offer the simplest and most intuitive API possible, allowing the user to 24 | focus on their particular application. 25 | 26 | See the :doc:`getting_started` section for further information, including instructions on how to 27 | :ref:`install ` the project. 28 | 29 | **Useful links**: 30 | `Binary Installers `__ | 31 | `Source Repository `__ 32 | 33 | 34 | .. note:: 35 | 36 | This project is under active development. 37 | 38 | Contents 39 | ======== 40 | 41 | .. toctree:: 42 | :maxdepth: 2 43 | 44 | getting_started 45 | examples/index 46 | reference/index 47 | 48 | Indices and tables 49 | ================== 50 | 51 | * :ref:`genindex` 52 | * :ref:`modindex` 53 | * :ref:`search` 54 | -------------------------------------------------------------------------------- /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/battery_transition_models/index.rst: -------------------------------------------------------------------------------- 1 | .. _api.battery_transition_models: 2 | 3 | Battery Transition Models 4 | ========================= 5 | 6 | .. currentmodule:: pymgrid.modules.battery.transition_models 7 | 8 | Various battery transition models. 9 | 10 | .. autosummary:: 11 | :toctree: ../../api/battery_transition_models/ 12 | 13 | BatteryTransitionModel 14 | BiasedTransitionModel 15 | DecayTransitionModel 16 | 17 | -------------------------------------------------------------------------------- /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 45 | 46 | 47 | Module Functions 48 | ================ 49 | 50 | Battery Transition Models 51 | ------------------------- 52 | 53 | Various battery transition models. 54 | 55 | .. currentmodule:: pymgrid.modules.battery.transition_models 56 | 57 | .. autosummary:: 58 | :toctree: ../api/battery_transition_models/ 59 | 60 | BatteryTransitionModel 61 | BiasedTransitionModel 62 | DecayTransitionModel 63 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/ahalev/python-microgrid/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/ahalev/python-microgrid", 13 | "Documentation": "https://python-microgrid.readthedocs.io/"} 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="python-microgrid", 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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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, dry_run 11 | 12 | import pymgrid.envs 13 | import pymgrid.modules 14 | 15 | __all__ = [ 16 | 'add_pymgrid_yaml_representers', 17 | 'dry_run', 18 | 'Microgrid', 19 | 'MicrogridGenerator', 20 | 'NonModularMicrogrid', 21 | 'envs', 22 | 'modules' 23 | ] -------------------------------------------------------------------------------- /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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/src/pymgrid/algos/example.log -------------------------------------------------------------------------------- /src/pymgrid/algos/mpc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/src/pymgrid/algos/rbc/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/algos/saa/__init__.py: -------------------------------------------------------------------------------- 1 | from .saa import SampleAverageApproximation -------------------------------------------------------------------------------- /src/pymgrid/convert/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | component = component.lower() 12 | if exists: 13 | module = get_module(component, nonmodular, raise_errors) 14 | modules.append((component, module)) 15 | return Microgrid(modules, add_unbalanced_module=False) 16 | 17 | 18 | def to_nonmodular(modular): 19 | """ 20 | microgrid_params needs to contain the following: 21 | parameters: ('DataFrame', (1, 16)) 22 | df_actions: ('dict', {'load': [], 'pv_consummed': [], 'pv_curtailed': [], 'pv': [], 'battery_charge': [], 'battery_discharge': [], 'grid_import': [], 'grid_export': []}) 23 | architecture: ('dict', {'PV': 1, 'battery': 1, 'genset': 0, 'grid': 1}) 24 | 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]}) 25 | df_actual_generation: ('dict', {'loss_load': [], 'overgeneration': [], 'pv_consummed': [], 'pv_curtailed': [], 'battery_charge': [], 'battery_discharge': [], 'grid_import': [], 'grid_export': []}) 26 | grid_spec: ('int', 0) 27 | df_cost: ('dict', {'loss_load': [], 'overgeneration': [], 'co2': [], 'battery': [], 'grid_import': [], 'grid_export': [], 'total_cost': []}) 28 | df_co2: ('dict', {'co2': []}) 29 | pv: ('DataFrame', (8760, 1)) 30 | load: ('DataFrame', (8760, 1)) 31 | grid_ts: ('DataFrame', (8760, 1)) 32 | control_dict: ('list', ['load', 'pv_consummed', 'pv_curtailed', 'pv', 'battery_charge', 'battery_discharge', 'grid_import', 'grid_export']) 33 | grid_price_import: ('DataFrame', (8760, 1)) 34 | grid_price_export: ('DataFrame', (8760, 1)) 35 | grid_co2: ('DataFrame', (8760, 1)) 36 | :param modular: 37 | :return: 38 | """ 39 | check_viability(modular) 40 | microgrid_params = get_empty_params() 41 | for _, module_list in modular.modules.iterdict(): 42 | add_params_from_module(module_list[0], microgrid_params) 43 | finalize_params(microgrid_params) 44 | return NonModularMicrogrid(parameters=microgrid_params, horizon=modular.get_forecast_horizon() + 1) 45 | -------------------------------------------------------------------------------- /src/pymgrid/data/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/src/pymgrid/data/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/data/co2/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/pymgrid/data/load/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/src/pymgrid/data/load/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/data/pv/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/src/pymgrid/data/pv/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - battery 60 | - !BatteryModule 61 | cls_params: 62 | battery_cost_cycle: 0.02 63 | battery_transition_model: !BatteryTransitionModel {} 64 | efficiency: 0.9 65 | init_charge: null 66 | init_soc: 0.2 67 | initial_step: 0 68 | max_capacity: 1452 69 | max_charge: 363 70 | max_discharge: 363 71 | min_capacity: 290.40000000000003 72 | normalized_action_bounds: 73 | - 0 74 | - 1 75 | raise_errors: false 76 | name: 77 | - battery 78 | - 0 79 | state: 80 | _current_step: 0 81 | current_charge: 290.40000000000003 82 | soc: 0.2 83 | - - grid 84 | - !GridModule 85 | cls_params: 86 | cost_per_unit_co2: 0.1 87 | final_step: 8759 88 | forecast_horizon: 23 89 | forecaster: oracle 90 | forecaster_increase_uncertainty: false 91 | forecaster_relative_noise: false 92 | initial_step: 0 93 | max_export: 1920 94 | max_import: 1920 95 | normalized_action_bounds: 96 | - 0 97 | - 1 98 | raise_errors: false 99 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 100 | name: 101 | - grid 102 | - 0 103 | state: 104 | _current_step: 0 105 | trajectory_func: null 106 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_1/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 60363.0 74 | running_min_production: 3353.5 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 91274 96 | max_charge: 22819 97 | max_discharge: 22819 98 | min_capacity: 18254.8 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 18254.8 109 | soc: 0.19999999999999998 110 | - - grid 111 | - !GridModule 112 | cls_params: 113 | cost_per_unit_co2: 0.1 114 | final_step: 8759 115 | forecast_horizon: 23 116 | forecaster: oracle 117 | forecaster_increase_uncertainty: false 118 | forecaster_relative_noise: false 119 | initial_step: 0 120 | max_export: 120726 121 | max_import: 120726 122 | normalized_action_bounds: 123 | - 0 124 | - 1 125 | raise_errors: false 126 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 127 | name: 128 | - grid 129 | - 0 130 | state: 131 | _current_step: 0 132 | trajectory_func: null 133 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_10/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 60144.3 74 | running_min_production: 3341.3500000000004 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 219201 96 | max_charge: 54801 97 | max_discharge: 54801 98 | min_capacity: 43840.200000000004 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 43840.200000000004 109 | soc: 0.2 110 | - - grid 111 | - !GridModule 112 | cls_params: 113 | cost_per_unit_co2: 0.1 114 | final_step: 8759 115 | forecast_horizon: 23 116 | forecaster: oracle 117 | forecaster_increase_uncertainty: false 118 | forecaster_relative_noise: false 119 | initial_step: 0 120 | max_export: 120288 121 | max_import: 120288 122 | normalized_action_bounds: 123 | - 0 124 | - 1 125 | raise_errors: false 126 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 127 | name: 128 | - grid 129 | - 0 130 | state: 131 | _current_step: 0 132 | trajectory_func: null 133 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_11/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - battery 60 | - !BatteryModule 61 | cls_params: 62 | battery_cost_cycle: 0.02 63 | battery_transition_model: !BatteryTransitionModel {} 64 | efficiency: 0.9 65 | init_charge: null 66 | init_soc: 1 67 | initial_step: 0 68 | max_capacity: 69594 69 | max_charge: 17399 70 | max_discharge: 17399 71 | min_capacity: 13918.800000000001 72 | normalized_action_bounds: 73 | - 0 74 | - 1 75 | raise_errors: false 76 | name: 77 | - battery 78 | - 0 79 | state: 80 | _current_step: 0 81 | current_charge: 69594 82 | soc: 1.0 83 | - - grid 84 | - !GridModule 85 | cls_params: 86 | cost_per_unit_co2: 0.1 87 | final_step: 8759 88 | forecast_horizon: 23 89 | forecaster: oracle 90 | forecaster_increase_uncertainty: false 91 | forecaster_relative_noise: false 92 | initial_step: 0 93 | max_export: 55230 94 | max_import: 55230 95 | normalized_action_bounds: 96 | - 0 97 | - 1 98 | raise_errors: false 99 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 100 | name: 101 | - grid 102 | - 0 103 | state: 104 | _current_step: 0 105 | trajectory_func: null 106 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_12/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - battery 60 | - !BatteryModule 61 | cls_params: 62 | battery_cost_cycle: 0.02 63 | battery_transition_model: !BatteryTransitionModel {} 64 | efficiency: 0.9 65 | init_charge: null 66 | init_soc: 0.2 67 | initial_step: 0 68 | max_capacity: 143726 69 | max_charge: 35932 70 | max_discharge: 35932 71 | min_capacity: 28745.2 72 | normalized_action_bounds: 73 | - 0 74 | - 1 75 | raise_errors: false 76 | name: 77 | - battery 78 | - 0 79 | state: 80 | _current_step: 0 81 | current_charge: 28745.2 82 | soc: 0.2 83 | - - grid 84 | - !GridModule 85 | cls_params: 86 | cost_per_unit_co2: 0.1 87 | final_step: 8759 88 | forecast_horizon: 23 89 | forecaster: oracle 90 | forecaster_increase_uncertainty: false 91 | forecaster_relative_noise: false 92 | initial_step: 0 93 | max_export: 96428 94 | max_import: 96428 95 | normalized_action_bounds: 96 | - 0 97 | - 1 98 | raise_errors: false 99 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 100 | name: 101 | - grid 102 | - 0 103 | state: 104 | _current_step: 0 105 | trajectory_func: null 106 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_13/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 19941.3 74 | running_min_production: 1107.8500000000001 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 47556 96 | max_charge: 11889 97 | max_discharge: 11889 98 | min_capacity: 9511.2 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 9511.2 109 | soc: 0.2 110 | - - grid 111 | - !GridModule 112 | cls_params: 113 | cost_per_unit_co2: 0.1 114 | final_step: 8759 115 | forecast_horizon: 23 116 | forecaster: oracle 117 | forecaster_increase_uncertainty: false 118 | forecaster_relative_noise: false 119 | initial_step: 0 120 | max_export: 39882 121 | max_import: 39882 122 | normalized_action_bounds: 123 | - 0 124 | - 1 125 | raise_errors: false 126 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 127 | name: 128 | - grid 129 | - 0 130 | state: 131 | _current_step: 0 132 | trajectory_func: null 133 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_14/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - battery 60 | - !BatteryModule 61 | cls_params: 62 | battery_cost_cycle: 0.02 63 | battery_transition_model: !BatteryTransitionModel {} 64 | efficiency: 0.9 65 | init_charge: null 66 | init_soc: 0.2 67 | initial_step: 0 68 | max_capacity: 162570 69 | max_charge: 40643 70 | max_discharge: 40643 71 | min_capacity: 32514.0 72 | normalized_action_bounds: 73 | - 0 74 | - 1 75 | raise_errors: false 76 | name: 77 | - battery 78 | - 0 79 | state: 80 | _current_step: 0 81 | current_charge: 32514.0 82 | soc: 0.2 83 | - - grid 84 | - !GridModule 85 | cls_params: 86 | cost_per_unit_co2: 0.1 87 | final_step: 8759 88 | forecast_horizon: 23 89 | forecaster: oracle 90 | forecaster_increase_uncertainty: false 91 | forecaster_relative_noise: false 92 | initial_step: 0 93 | max_export: 197286 94 | max_import: 197286 95 | normalized_action_bounds: 96 | - 0 97 | - 1 98 | raise_errors: false 99 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 100 | name: 101 | - grid 102 | - 0 103 | state: 104 | _current_step: 0 105 | trajectory_func: null 106 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_15/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 17296.2 74 | running_min_production: 960.9000000000001 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 1 94 | initial_step: 0 95 | max_capacity: 26153 96 | max_charge: 6539 97 | max_discharge: 6539 98 | min_capacity: 5230.6 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 26153 109 | soc: 1.0 110 | trajectory_func: null 111 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_16/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - battery 60 | - !BatteryModule 61 | cls_params: 62 | battery_cost_cycle: 0.02 63 | battery_transition_model: !BatteryTransitionModel {} 64 | efficiency: 0.9 65 | init_charge: null 66 | init_soc: 0.534118811938557 67 | initial_step: 0 68 | max_capacity: 60099 69 | max_charge: 15025 70 | max_discharge: 15025 71 | min_capacity: 12019.800000000001 72 | normalized_action_bounds: 73 | - 0 74 | - 1 75 | raise_errors: false 76 | name: 77 | - battery 78 | - 0 79 | state: 80 | _current_step: 0 81 | current_charge: 32100.00647869534 82 | soc: 0.534118811938557 83 | - - grid 84 | - !GridModule 85 | cls_params: 86 | cost_per_unit_co2: 0.1 87 | final_step: 8759 88 | forecast_horizon: 23 89 | forecaster: oracle 90 | forecaster_increase_uncertainty: false 91 | forecaster_relative_noise: false 92 | initial_step: 0 93 | max_export: 97244 94 | max_import: 97244 95 | normalized_action_bounds: 96 | - 0 97 | - 1 98 | raise_errors: false 99 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 100 | name: 101 | - grid 102 | - 0 103 | state: 104 | _current_step: 0 105 | trajectory_func: null 106 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_17/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 31257.0 74 | running_min_production: 1736.5 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 38636 96 | max_charge: 9659 97 | max_discharge: 9659 98 | min_capacity: 7727.200000000001 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 7727.200000000001 109 | soc: 0.2 110 | trajectory_func: null 111 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_18/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 34418.700000000004 74 | running_min_production: 1912.15 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 1 94 | initial_step: 0 95 | max_capacity: 82080 96 | max_charge: 20520 97 | max_discharge: 20520 98 | min_capacity: 16416.0 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 82080 109 | soc: 1.0 110 | - - grid 111 | - !GridModule 112 | cls_params: 113 | cost_per_unit_co2: 0.1 114 | final_step: 8759 115 | forecast_horizon: 23 116 | forecaster: oracle 117 | forecaster_increase_uncertainty: false 118 | forecaster_relative_noise: false 119 | initial_step: 0 120 | max_export: 68836 121 | max_import: 68836 122 | normalized_action_bounds: 123 | - 0 124 | - 1 125 | raise_errors: false 126 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 127 | name: 128 | - grid 129 | - 0 130 | state: 131 | _current_step: 0 132 | trajectory_func: null 133 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_19/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 1529.1000000000001 74 | running_min_production: 84.95 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 2506 96 | max_charge: 627 97 | max_discharge: 627 98 | min_capacity: 501.20000000000005 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 501.20000000000005 109 | soc: 0.2 110 | trajectory_func: null 111 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_2/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 43725.6 74 | running_min_production: 2429.2000000000003 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 66116 96 | max_charge: 16529 97 | max_discharge: 16529 98 | min_capacity: 13223.2 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 13223.2 109 | soc: 0.2 110 | trajectory_func: null 111 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_20/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 79186.5 74 | running_min_production: 4399.25 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 129765 96 | max_charge: 32442 97 | max_discharge: 32442 98 | min_capacity: 25953.0 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 25953.0 109 | soc: 0.2 110 | trajectory_func: null 111 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_21/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 95435.1 74 | running_min_production: 5301.950000000001 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 170694 96 | max_charge: 42674 97 | max_discharge: 42674 98 | min_capacity: 34138.8 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 34138.8 109 | soc: 0.2 110 | trajectory_func: null 111 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_22/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 80372.7 74 | running_min_production: 4465.150000000001 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 292924 96 | max_charge: 73231 97 | max_discharge: 73231 98 | min_capacity: 58584.8 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 58584.8 109 | soc: 0.2 110 | - - grid 111 | - !GridModule 112 | cls_params: 113 | cost_per_unit_co2: 0.1 114 | final_step: 8759 115 | forecast_horizon: 23 116 | forecaster: oracle 117 | forecaster_increase_uncertainty: false 118 | forecaster_relative_noise: false 119 | initial_step: 0 120 | max_export: 160744 121 | max_import: 160744 122 | normalized_action_bounds: 123 | - 0 124 | - 1 125 | raise_errors: false 126 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 127 | name: 128 | - grid 129 | - 0 130 | state: 131 | _current_step: 0 132 | trajectory_func: null 133 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_23/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 9453.6 74 | running_min_production: 525.2 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 14294 96 | max_charge: 3574 97 | max_discharge: 3574 98 | min_capacity: 2858.8 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 2858.8 109 | soc: 0.2 110 | trajectory_func: null 111 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_24/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 50157.0 74 | running_min_production: 2786.5 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 103328 96 | max_charge: 25832 97 | max_discharge: 25832 98 | min_capacity: 20665.600000000002 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 20665.600000000002 109 | soc: 0.2 110 | - - grid 111 | - !GridModule 112 | cls_params: 113 | cost_per_unit_co2: 0.1 114 | final_step: 8759 115 | forecast_horizon: 23 116 | forecaster: oracle 117 | forecaster_increase_uncertainty: false 118 | forecaster_relative_noise: false 119 | initial_step: 0 120 | max_export: 100314 121 | max_import: 100314 122 | normalized_action_bounds: 123 | - 0 124 | - 1 125 | raise_errors: false 126 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 127 | name: 128 | - grid 129 | - 0 130 | state: 131 | _current_step: 0 132 | trajectory_func: null 133 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_3/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 78147.0 74 | running_min_production: 4341.5 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 102450 96 | max_charge: 25613 97 | max_discharge: 25613 98 | min_capacity: 20490.0 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 20490.0 109 | soc: 0.2 110 | trajectory_func: null 111 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_4/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - battery 60 | - !BatteryModule 61 | cls_params: 62 | battery_cost_cycle: 0.02 63 | battery_transition_model: !BatteryTransitionModel {} 64 | efficiency: 0.9 65 | init_charge: null 66 | init_soc: 0.2 67 | initial_step: 0 68 | max_capacity: 65305 69 | max_charge: 16327 70 | max_discharge: 16327 71 | min_capacity: 13061.0 72 | normalized_action_bounds: 73 | - 0 74 | - 1 75 | raise_errors: false 76 | name: 77 | - battery 78 | - 0 79 | state: 80 | _current_step: 0 81 | current_charge: 13061.0 82 | soc: 0.2 83 | - - grid 84 | - !GridModule 85 | cls_params: 86 | cost_per_unit_co2: 0.1 87 | final_step: 8759 88 | forecast_horizon: 23 89 | forecaster: oracle 90 | forecaster_increase_uncertainty: false 91 | forecaster_relative_noise: false 92 | initial_step: 0 93 | max_export: 99625 94 | max_import: 99625 95 | normalized_action_bounds: 96 | - 0 97 | - 1 98 | raise_errors: false 99 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 100 | name: 101 | - grid 102 | - 0 103 | state: 104 | _current_step: 0 105 | trajectory_func: null 106 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_5/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 28560.600000000002 74 | running_min_production: 1586.7 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 1 94 | initial_step: 0 95 | max_capacity: 57581 96 | max_charge: 14396 97 | max_discharge: 14396 98 | min_capacity: 11516.2 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 57581 109 | soc: 1.0 110 | trajectory_func: null 111 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_6/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - battery 60 | - !BatteryModule 61 | cls_params: 62 | battery_cost_cycle: 0.02 63 | battery_transition_model: !BatteryTransitionModel {} 64 | efficiency: 0.9 65 | init_charge: null 66 | init_soc: 0.960305168086668 67 | initial_step: 0 68 | max_capacity: 179373 69 | max_charge: 44844 70 | max_discharge: 44844 71 | min_capacity: 35874.6 72 | normalized_action_bounds: 73 | - 0 74 | - 1 75 | raise_errors: false 76 | name: 77 | - battery 78 | - 0 79 | state: 80 | _current_step: 0 81 | current_charge: 172252.8189152099 82 | soc: 0.960305168086668 83 | - - grid 84 | - !GridModule 85 | cls_params: 86 | cost_per_unit_co2: 0.1 87 | final_step: 8759 88 | forecast_horizon: 23 89 | forecaster: oracle 90 | forecaster_increase_uncertainty: false 91 | forecaster_relative_noise: false 92 | initial_step: 0 93 | max_export: 98432 94 | max_import: 98432 95 | normalized_action_bounds: 96 | - 0 97 | - 1 98 | raise_errors: false 99 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 100 | name: 101 | - grid 102 | - 0 103 | state: 104 | _current_step: 0 105 | trajectory_func: null 106 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_7/data/cls_params/LoadModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 11798.1 74 | running_min_production: 655.45 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 1 94 | initial_step: 0 95 | max_capacity: 19334 96 | max_charge: 4834 97 | max_discharge: 4834 98 | min_capacity: 3866.8 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 19334 109 | soc: 1.0 110 | trajectory_func: null 111 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_8/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 64065.6 74 | running_min_production: 3559.2000000000003 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.2 94 | initial_step: 0 95 | max_capacity: 105583 96 | max_charge: 26396 97 | max_discharge: 26396 98 | min_capacity: 21116.600000000002 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 21116.600000000002 109 | soc: 0.2 110 | - - grid 111 | - !GridModule 112 | cls_params: 113 | cost_per_unit_co2: 0.1 114 | final_step: 8759 115 | forecast_horizon: 23 116 | forecaster: oracle 117 | forecaster_increase_uncertainty: false 118 | forecaster_relative_noise: false 119 | initial_step: 0 120 | max_export: 128130 121 | max_import: 128130 122 | normalized_action_bounds: 123 | - 0 124 | - 1 125 | raise_errors: false 126 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 127 | name: 128 | - grid 129 | - 0 130 | state: 131 | _current_step: 0 132 | trajectory_func: null 133 | -------------------------------------------------------------------------------- /src/pymgrid/data/scenario/pymgrid25/microgrid_9/data/cls_params/GridModule/time_series.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds: 15 | - 0 16 | - 1 17 | raise_errors: false 18 | time_series: !NDArray 'data/cls_params/LoadModule/time_series.csv.gz' 19 | name: 20 | - load 21 | - 0 22 | state: 23 | _current_step: 0 24 | - - pv 25 | - !RenewableModule 26 | cls_params: 27 | final_step: 8759 28 | forecast_horizon: 23 29 | forecaster: oracle 30 | forecaster_increase_uncertainty: false 31 | forecaster_relative_noise: false 32 | initial_step: 0 33 | normalized_action_bounds: 34 | - 0 35 | - 1 36 | provided_energy_name: renewable_used 37 | raise_errors: false 38 | time_series: !NDArray 'data/cls_params/RenewableModule/time_series.csv.gz' 39 | name: 40 | - pv 41 | - 0 42 | state: 43 | _current_step: 0 44 | - - unbalanced_energy 45 | - !UnbalancedEnergyModule 46 | cls_params: 47 | initial_step: 0 48 | loss_load_cost: 10 49 | normalized_action_bounds: 50 | - 0 51 | - 1 52 | overgeneration_cost: 1 53 | raise_errors: false 54 | name: 55 | - unbalanced_energy 56 | - 0 57 | state: 58 | _current_step: 0 59 | - - genset 60 | - !Genset 61 | cls_params: 62 | allow_abortion: true 63 | co2_per_unit: 2 64 | cost_per_unit_co2: 0.1 65 | genset_cost: 0.4 66 | init_start_up: true 67 | initial_step: 0 68 | normalized_action_bounds: 69 | - 0 70 | - 1 71 | provided_energy_name: genset_production 72 | raise_errors: false 73 | running_max_production: 98996.40000000001 74 | running_min_production: 5499.8 75 | start_up_time: 0 76 | wind_down_time: 0 77 | name: 78 | - genset 79 | - 0 80 | state: 81 | _current_status: 1 82 | _current_step: 0 83 | _goal_status: 1 84 | _steps_until_down: 0 85 | _steps_until_up: 0 86 | - - battery 87 | - !BatteryModule 88 | cls_params: 89 | battery_cost_cycle: 0.02 90 | battery_transition_model: !BatteryTransitionModel {} 91 | efficiency: 0.9 92 | init_charge: null 93 | init_soc: 0.5374787046064285 94 | initial_step: 0 95 | max_capacity: 199587 96 | max_charge: 49897 97 | max_discharge: 49897 98 | min_capacity: 39917.4 99 | normalized_action_bounds: 100 | - 0 101 | - 1 102 | raise_errors: false 103 | name: 104 | - battery 105 | - 0 106 | state: 107 | _current_step: 0 108 | current_charge: 107273.76221628326 109 | soc: 0.5374787046064285 110 | - - grid 111 | - !GridModule 112 | cls_params: 113 | cost_per_unit_co2: 0.1 114 | final_step: 8759 115 | forecast_horizon: 23 116 | forecaster: oracle 117 | forecaster_increase_uncertainty: false 118 | forecaster_relative_noise: false 119 | initial_step: 0 120 | max_export: 197992 121 | max_import: 197992 122 | normalized_action_bounds: 123 | - 0 124 | - 1 125 | raise_errors: false 126 | time_series: !NDArray 'data/cls_params/GridModule/time_series.csv.gz' 127 | name: 128 | - grid 129 | - 0 130 | state: 131 | _current_step: 0 132 | trajectory_func: null 133 | -------------------------------------------------------------------------------- /src/pymgrid/envs/__init__.py: -------------------------------------------------------------------------------- 1 | from .discrete.discrete import DiscreteMicrogridEnv 2 | from .continuous.continuous import ContinuousMicrogridEnv, NetLoadContinuousMicrogridEnv 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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/src/pymgrid/envs/continuous/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/envs/discrete/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/src/pymgrid/envs/discrete/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/errors/__init__.py: -------------------------------------------------------------------------------- 1 | from .warnings import PymgridWarning, PymgridDeprecationWarning 2 | from .error import PymgridError, DeprecatedError 3 | -------------------------------------------------------------------------------- /src/pymgrid/errors/env_signature.py: -------------------------------------------------------------------------------- 1 | from pymgrid import Microgrid, NonModularMicrogrid 2 | from pymgrid.errors import DeprecatedError 3 | 4 | 5 | def environment_signature_error(cls, modules): 6 | if isinstance(modules, (Microgrid, NonModularMicrogrid)): 7 | msg = f'Initializing a {cls} with a microgrid is deprecated as of version 1.5.0. ' \ 8 | f'Use {cls}.from_microgrid() as a drop in replacement.' 9 | else: 10 | msg = f'Initializing a {cls} with a scenario integer is deprecated as of version 1.5.0. ' \ 11 | f'Use {cls}.from_scenario() as a drop in replacement.' 12 | 13 | raise DeprecatedError(msg) 14 | -------------------------------------------------------------------------------- /src/pymgrid/errors/error.py: -------------------------------------------------------------------------------- 1 | class PymgridError(Exception): 2 | """ 3 | Base pymgrid exception. 4 | """ 5 | 6 | 7 | class DeprecatedError(PymgridError): 8 | """ 9 | Code deprecation error. 10 | """ 11 | -------------------------------------------------------------------------------- /src/pymgrid/errors/warnings.py: -------------------------------------------------------------------------------- 1 | class PymgridWarning(Warning): 2 | """ 3 | Base pymgrid warning. 4 | """ 5 | 6 | 7 | class PymgridDeprecationWarning(PymgridWarning, DeprecationWarning): 8 | """ 9 | Pymgrid deprecation warning. 10 | """ -------------------------------------------------------------------------------- /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 .battery_discharge_shaper import BatteryDischargeShaper 2 | from .baseline_shaper import BaselineShaper 3 | from .pv_curtailment_shaper import PVCurtailmentShaper 4 | from .rescale_shaper import RescaleShaper, LearnedScaleRescaleShaper 5 | from .sequential import SequentialShaper 6 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/reward_shaping/base.py: -------------------------------------------------------------------------------- 1 | import inspect 2 | import yaml 3 | 4 | from warnings import warn 5 | from abc import abstractmethod 6 | 7 | 8 | class BaseRewardShaper(yaml.YAMLObject): 9 | yaml_dumper = yaml.SafeDumper 10 | yaml_loader = yaml.SafeLoader 11 | 12 | @staticmethod 13 | def sum_module_val(info, module_name, module_attr): 14 | try: 15 | module_info = info[module_name] 16 | return sum([d[module_attr] for d in module_info]) 17 | except KeyError: 18 | return 0.0 19 | 20 | @staticmethod 21 | def compute_net_load(step_info): 22 | return BaseRewardShaper.compute_total_load(step_info) - BaseRewardShaper.compute_total_renewable(step_info) 23 | 24 | @staticmethod 25 | def compute_total_load(step_info): 26 | try: 27 | load_info = step_info['load'] 28 | except KeyError: 29 | raise NameError("Microgrid has no module with name 'load'") 30 | 31 | return sum(d['absorbed_energy'] for d in load_info) 32 | 33 | @staticmethod 34 | def compute_total_renewable(step_info): 35 | try: 36 | renewable_info = step_info.get('renewable', step_info['pv']) 37 | except KeyError: 38 | raise NameError("Microgrid has no module with name 'renewable' or 'pv'.") 39 | 40 | return sum(d['provided_energy'] for d in renewable_info) 41 | 42 | @abstractmethod 43 | def __call__(self, original_reward, step_info, cost_info): 44 | pass 45 | 46 | def __repr__(self): 47 | return f'{self.__class__.__name__}()' 48 | 49 | def serializable_state_attributes(self): 50 | return [] 51 | 52 | def serialize(self): 53 | return {attr: getattr(self, attr) for attr in self.serializable_state_attributes()} 54 | 55 | @classmethod 56 | def to_yaml(cls, dumper, data): 57 | return dumper.represent_mapping(cls.yaml_tag, data.serialize(), flow_style=cls.yaml_flow_style) 58 | 59 | @classmethod 60 | def from_yaml(cls, loader, node): 61 | mapping = loader.construct_mapping(node, deep=True) 62 | instance = cls.deserialize_instance(mapping) 63 | instance.set_state_attributes(mapping) 64 | return instance 65 | 66 | @classmethod 67 | def deserialize_instance(cls, param_dict): 68 | """ 69 | Generate an instance of this module with the arguments in param_dict. 70 | 71 | Part of the ``load`` and ``yaml.safe_load`` methods. Should not be called directly. 72 | 73 | :meta private: 74 | 75 | Parameters 76 | ---------- 77 | param_dict : dict 78 | Class arguments. 79 | 80 | Returns 81 | ------- 82 | BaseMicrogridModule or child class of BaseMicrogridModule 83 | The module instance. 84 | 85 | """ 86 | param_dict = param_dict.copy() 87 | cls_params = inspect.signature(cls).parameters 88 | 89 | cls_kwargs = {} 90 | missing_params, default_params = [], [] 91 | 92 | for p_name, p_value in cls_params.items(): 93 | try: 94 | cls_kwargs[p_name] = param_dict.pop(p_name) 95 | except KeyError: 96 | if p_value.default is p_value.empty: 97 | missing_params.append(p_name) 98 | else: 99 | cls_kwargs[p_name] = p_value.default 100 | default_params.append(p_name) 101 | 102 | if len(default_params): 103 | warn(f'Missing parameter values {default_params} for {cls}. Using available default values.') 104 | 105 | if len(missing_params): 106 | raise KeyError(f"Missing parameter values {missing_params} for {cls} with no default values available.") 107 | 108 | return cls(**cls_kwargs) 109 | 110 | def set_state_attributes(self, attrs_dict): 111 | for attr in self.serializable_state_attributes(): 112 | value = attrs_dict.get(attr, getattr(self, attr)) 113 | setattr(self, attr, value) 114 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/reward_shaping/baseline_shaper.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pymgrid.microgrid.reward_shaping.base import BaseRewardShaper 4 | 5 | 6 | class BaselineShaper(BaseRewardShaper): 7 | """ 8 | Reward is the original reward minus the baseline of using one module to satisfy net load. 9 | 10 | Parameters 11 | ---------- 12 | module : tuple 13 | Module name of the form ``(, )`` from which to compute the baseline cost. 14 | 15 | relative_to : bool or tuple, default False 16 | Module to scale rewards to. If True, uses ``module``. Otherwise, expects the name of a module 17 | in the form ``(, )`` form which to compute a scale factor. 18 | 19 | """ 20 | 21 | yaml_tag = u"!BaselineShaper" 22 | 23 | def __init__(self, module=('grid', 0), relative_to=False): 24 | self.module = module 25 | self.baseline_module = self.module if relative_to is True else relative_to 26 | 27 | def compute_baseline_cost(self, step_info, cost_info, baseline_module=None): 28 | baseline_module = baseline_module or self.module 29 | net_load = self.compute_net_load(step_info) 30 | 31 | try: 32 | baseline_cost_info = cost_info[baseline_module[0]][baseline_module[1]] 33 | except (KeyError, IndexError): 34 | raise NameError(f"Microgrid has no module in position '{baseline_module}'") 35 | 36 | if net_load > 0: 37 | baseline_cost = net_load * baseline_cost_info['production_marginal_cost'] 38 | else: 39 | baseline_cost = -1 * net_load * baseline_cost_info['absorption_marginal_cost'] 40 | 41 | return baseline_cost 42 | 43 | def serializable_state_attributes(self): 44 | return 'module', 'baseline_module' 45 | 46 | def __call__(self, original_reward, step_info, cost_info): 47 | # Baseline cost is positive, original reward is negative. Equivalent to -1 * (original_cost - baseline_cost). 48 | baseline_cost = self.compute_baseline_cost(step_info, cost_info) 49 | reward = original_reward + baseline_cost 50 | 51 | if self.baseline_module: 52 | if self.baseline_module == self.module: 53 | scale = baseline_cost 54 | else: 55 | scale = self.compute_baseline_cost(step_info, cost_info, baseline_module=self.baseline_module) 56 | 57 | scale = max(scale, 1.0) 58 | 59 | return reward / scale 60 | 61 | 62 | return reward 63 | -------------------------------------------------------------------------------- /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, original_reward, 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 should be in [0, load-loss_load]; loss_load should be in [0, load]. 28 | try: 29 | percent_battery = (battery_discharge - loss_load) / load 30 | except ZeroDivisionError: 31 | return 0.0 32 | 33 | return percent_battery 34 | -------------------------------------------------------------------------------- /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, original_reward, 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/reward_shaping/rescale_shaper.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pymgrid.microgrid.reward_shaping.base import BaseRewardShaper 4 | 5 | 6 | class RescaleShaper(BaseRewardShaper): 7 | """ 8 | Reward is the original reward scaled by some scale factor. 9 | 10 | ``scaled_reward = self.scale_factor * original_reward ``. 11 | 12 | """ 13 | 14 | yaml_tag = u"!RescaleShaper" 15 | 16 | def __init__(self, scale_factor=1.0): 17 | self.scale_factor = scale_factor 18 | 19 | def serializable_state_attributes(self): 20 | return 'scale_factor', 21 | 22 | def __call__(self, original_reward, step_info, cost_info): 23 | return self.scale_factor * original_reward 24 | 25 | 26 | class LearnedScaleRescaleShaper(RescaleShaper): 27 | yaml_tag = u"!LearnedScaleRescaleShaper" 28 | 29 | def __init__(self, module=('unbalanced_energy', 0)): 30 | super().__init__(scale_factor=1.0) 31 | self.module = module 32 | 33 | self.max_load = 0.0 34 | self.max_renewable = 0.0 35 | 36 | def _update_scale(self, step_info, cost_info): 37 | total_load = self.compute_total_load(step_info) 38 | total_renewable = self.compute_total_renewable(step_info) 39 | 40 | if total_load > self.max_load: 41 | self._max_load = total_load 42 | 43 | if total_renewable > self.max_renewable: 44 | self._max_renewable = total_renewable 45 | 46 | try: 47 | baseline_cost_info = cost_info[self.module[0]][self.module[1]] 48 | except (KeyError, IndexError): 49 | raise NameError(f"Microgrid has no module in position '{self.module}'") 50 | 51 | baseline = (self.max_load - self.max_renewable) * baseline_cost_info['production_marginal_cost'] 52 | self.scale_factor = 1 / baseline if baseline else self.scale_factor 53 | 54 | def serializable_state_attributes(self): 55 | return 'module', 'max_load', 'max_renewable', 'scale_factor' 56 | 57 | def __call__(self, original_reward, step_info, cost_info): 58 | self._update_scale(step_info, cost_info) 59 | assert self.scale_factor > 0 60 | return super().__call__(original_reward, step_info, cost_info) 61 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/reward_shaping/sequential.py: -------------------------------------------------------------------------------- 1 | import functools 2 | 3 | from pymgrid.microgrid.reward_shaping.base import BaseRewardShaper 4 | 5 | 6 | class SequentialShaper(BaseRewardShaper): 7 | """ 8 | A shaper that is a composition of reward shapers. 9 | 10 | Reward is passed sequentially through passed shapers: 11 | 12 | >>> reward = original_reward 13 | >>> for shaper in self.shapers: 14 | >>> reward = shaper(reward, step_info, cost_info) 15 | 16 | 17 | """ 18 | yaml_tag = u"!SequentialShaper" 19 | 20 | def __init__(self, shapers): 21 | self.shapers = shapers 22 | 23 | def serializable_state_attributes(self): 24 | return 'shapers', 25 | 26 | def __call__(self, original_reward, step_info, cost_info): 27 | reward = functools.reduce(lambda res, f: f(res, step_info, cost_info), self.shapers, original_reward) 28 | return reward 29 | -------------------------------------------------------------------------------- /src/pymgrid/microgrid/reward_shaping/standardization_shaper.py: -------------------------------------------------------------------------------- 1 | from pymgrid.microgrid.reward_shaping.base import BaseRewardShaper 2 | from pymgrid.utils.running_mean_std import RunningMeanStd 3 | 4 | 5 | class StandardizationShaper(BaseRewardShaper): 6 | yaml_tag = u'StandardizationShaper' 7 | 8 | def __init__(self): 9 | self.reward_running_mean_std = RunningMeanStd() 10 | 11 | def __call__(self, original_reward, step_info, cost_info): 12 | self.reward_running_mean_std.update(original_reward) 13 | return (original_reward - self.reward_running_mean_std.mean) / self.reward_running_mean_std.var 14 | -------------------------------------------------------------------------------- /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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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, shape_reward=False): 34 | provided_energy = np.sum(self._info['provided_energy']) 35 | absorbed_energy = np.sum(self._info['absorbed_energy']) 36 | 37 | if shape_reward: 38 | return provided_energy, absorbed_energy, self._reward, self.shaped_reward() 39 | 40 | return provided_energy, absorbed_energy, self._reward, None 41 | 42 | def output(self): 43 | return self._obs, self.shaped_reward(), self._done, self._output_info() 44 | 45 | def shaped_reward(self): 46 | if self._reward_shaping_func is None: 47 | return self._reward 48 | elif not callable(self._reward_shaping_func): 49 | raise TypeError(f'reward_shaping_func {self._reward_shaping_func} is not callable.') 50 | 51 | assert isinstance(self.cost_info, dict) 52 | return self._reward_shaping_func(self._reward, self._output_info(), self.cost_info) 53 | 54 | 55 | def _output_info(self): 56 | return {k: v for k, v in self._info.items() if k not in ('absorbed_energy', 'provided_energy')} 57 | 58 | @property 59 | def obs(self): 60 | return self._obs 61 | 62 | @property 63 | def reward(self): 64 | return self._reward 65 | 66 | @property 67 | def done(self): 68 | return self._done 69 | 70 | @property 71 | def info(self): 72 | return self._info -------------------------------------------------------------------------------- /src/pymgrid/modules/__init__.py: -------------------------------------------------------------------------------- 1 | from .battery.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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/src/pymgrid/modules/base/timeseries/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/modules/battery/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/src/pymgrid/modules/battery/__init__.py -------------------------------------------------------------------------------- /src/pymgrid/modules/battery/transition_models/__init__.py: -------------------------------------------------------------------------------- 1 | from .transition_model import BatteryTransitionModel 2 | from .biased_transition_model import BiasedTransitionModel 3 | from .decay_transition_model import DecayTransitionModel, DecayCycleTransitionModel 4 | -------------------------------------------------------------------------------- /src/pymgrid/modules/battery/transition_models/biased_transition_model.py: -------------------------------------------------------------------------------- 1 | from pymgrid.modules.battery.transition_models import BatteryTransitionModel 2 | 3 | 4 | class BiasedTransitionModel(BatteryTransitionModel): 5 | yaml_tag = u"!BiasedTransitionModel" 6 | 7 | def __init__(self, true_efficiency=None, relative_efficiency=None): 8 | if true_efficiency is None and relative_efficiency is None: 9 | raise ValueError("Must pass one of 'true_efficiency' and 'relative_efficiency'.") 10 | 11 | self.true_efficiency = true_efficiency 12 | self.relative_efficiency = relative_efficiency 13 | self.efficiency = None 14 | 15 | def _set_efficiency(self, efficiency): 16 | if self.efficiency is not None: 17 | return 18 | 19 | if self.true_efficiency is None: 20 | self.efficiency = self.relative_efficiency * efficiency 21 | else: 22 | self.efficiency = self.true_efficiency 23 | 24 | def transition(self, external_energy_change, efficiency, **kwargs): 25 | self._set_efficiency(efficiency) 26 | return super().transition(external_energy_change=external_energy_change, 27 | efficiency=self.efficiency) 28 | -------------------------------------------------------------------------------- /src/pymgrid/modules/battery/transition_models/decay_transition_model.py: -------------------------------------------------------------------------------- 1 | from pymgrid.modules.battery.transition_models import BatteryTransitionModel 2 | 3 | 4 | class DecayTransitionModel(BatteryTransitionModel): 5 | yaml_tag = u"!DecayTransitionModel" 6 | 7 | def __init__(self, decay_rate=0.999**(1/24)): 8 | """ 9 | 10 | Parameters 11 | ---------- 12 | decay_rate : float, default 0.99**(1/24) 13 | Amount to decay in one time step; should be in (0, 1]. If 1, no decay and equivalent to parent model. 14 | Default is equivalent to 1/10 of a percent decay in one day. 15 | 16 | """ 17 | self.decay_rate = decay_rate 18 | self.initial_step = None 19 | self._previous_step = 0 20 | 21 | def reset(self, current_step=0): 22 | self.initial_step = current_step 23 | self._previous_step = current_step 24 | 25 | def _current_efficiency(self, efficiency, current_step): 26 | return efficiency * (self.decay_rate ** (current_step-self.initial_step)) 27 | 28 | def _update_step(self, current_step): 29 | if current_step == self._previous_step + 1: 30 | self._previous_step += 1 31 | elif self.initial_step is None or current_step <= self.initial_step or current_step != self._previous_step: 32 | self.reset(current_step) 33 | 34 | def transition(self, external_energy_change, efficiency, current_step, **kwargs): 35 | self._update_step(current_step) 36 | current_efficiency = self._current_efficiency(efficiency, current_step) 37 | 38 | return super().transition(external_energy_change, efficiency=current_efficiency) 39 | 40 | 41 | class DecayCycleTransitionModel(DecayTransitionModel): 42 | # https://en.wikipedia.org/wiki/Capacity_loss 43 | 44 | yaml_tag = u"!DecayCycleTransitionModel" 45 | 46 | def __init__(self, decay_rate_per_cycle=1-2.5e-4): 47 | super().__init__(None) 48 | self.decay_rate_per_cycle = decay_rate_per_cycle 49 | self.cycle_amount = None 50 | self.num_cycles = 0 51 | 52 | def reset(self, current_step=0): 53 | self.num_cycles = 0 54 | super().reset(current_step=current_step) 55 | 56 | def _current_efficiency(self, efficiency, current_step): 57 | self.decay_rate = self.decay_rate_per_cycle ** self.num_cycles 58 | return super()._current_efficiency(efficiency, current_step) 59 | 60 | def _update_num_cycles(self, external_energy_change, max_capacity, min_capacity): 61 | if self.cycle_amount is None: 62 | self.cycle_amount = max_capacity - min_capacity 63 | 64 | if external_energy_change < 0: 65 | return 66 | 67 | self.num_cycles += external_energy_change / self.cycle_amount 68 | 69 | def transition(self, external_energy_change, efficiency, current_step, max_capacity, min_capacity, **kwargs): 70 | self._update_num_cycles(external_energy_change, max_capacity, min_capacity) 71 | 72 | return super().transition(external_energy_change, efficiency, current_step) 73 | -------------------------------------------------------------------------------- /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 | normalized_action_bounds = (0, 1) 19 | ): 20 | 21 | super().__init__(raise_errors, 22 | initial_step=initial_step, 23 | normalized_action_bounds=normalized_action_bounds, 24 | provided_energy_name='loss_load', 25 | absorbed_energy_name='overgeneration') 26 | 27 | self.loss_load_cost, self.overgeneration_cost = loss_load_cost, overgeneration_cost 28 | 29 | def update(self, external_energy_change, as_source=False, as_sink=False): 30 | assert as_source + as_sink == 1, 'Must act as either source or sink but not both or neither.' 31 | 32 | info_key = 'provided_energy' if as_source else 'absorbed_energy' 33 | reward = -1.0 * self.get_cost(external_energy_change, as_source, as_sink) 34 | assert reward <= 0 35 | info = {info_key: external_energy_change} 36 | 37 | return reward, False, info 38 | 39 | def get_cost(self, energy_amount, as_source, as_sink): 40 | """ 41 | Get the cost of unmet load or excess production. 42 | 43 | Parameters 44 | ---------- 45 | energy_amount : float>=0 46 | Amount of unmet load or excess production. 47 | 48 | as_source : bool 49 | Whether the energy is unmet load. 50 | 51 | as_sink : bool 52 | Whether the energy is excess production. 53 | 54 | Returns 55 | ------- 56 | cost : float 57 | 58 | Raises 59 | ------ 60 | TypeError 61 | If both as_source and as_sink are True or neither are. 62 | 63 | """ 64 | if as_source and as_sink: 65 | raise TypeError("as_source and as_sink cannot both be True.") 66 | if as_source: # loss load 67 | return self.loss_load_cost*energy_amount 68 | elif as_sink: 69 | return self.overgeneration_cost*energy_amount 70 | else: 71 | raise TypeError("One of as_source or as_sink must be True.") 72 | 73 | def _state_dict(self): 74 | return dict() 75 | 76 | @property 77 | def state(self): 78 | return np.array([]) 79 | 80 | @property 81 | def min_obs(self): 82 | return np.array([]) 83 | 84 | @property 85 | def max_obs(self): 86 | return np.array([]) 87 | 88 | @property 89 | def min_act(self): 90 | return -np.inf 91 | 92 | @property 93 | def max_act(self): 94 | return np.inf 95 | 96 | @property 97 | def max_production(self): 98 | return np.inf 99 | 100 | @property 101 | def max_consumption(self): 102 | return np.inf 103 | 104 | @property 105 | def is_source(self): 106 | return True 107 | 108 | @property 109 | def is_sink(self): 110 | return True 111 | 112 | @property 113 | def production_marginal_cost(self): 114 | return self.loss_load_cost 115 | 116 | @property 117 | def absorption_marginal_cost(self): 118 | return self.overgeneration_cost 119 | -------------------------------------------------------------------------------- /src/pymgrid/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .dry_run import dry_run 2 | from .serialize import add_pymgrid_yaml_representers 3 | from .code_link import obj_linkcode 4 | -------------------------------------------------------------------------------- /src/pymgrid/utils/code_link.py: -------------------------------------------------------------------------------- 1 | import inspect 2 | import os 3 | import pymgrid 4 | 5 | 6 | def obj_linkcode(obj): 7 | try: 8 | fn = inspect.getsourcefile(inspect.unwrap(obj)) 9 | except TypeError: 10 | try: # property 11 | fn = inspect.getsourcefile(inspect.unwrap(obj.fget)) 12 | except (AttributeError, TypeError): 13 | fn = None 14 | if not fn: 15 | return None 16 | 17 | try: 18 | source, lineno = inspect.getsourcelines(obj) 19 | except TypeError: 20 | try: # property 21 | source, lineno = inspect.getsourcelines(obj.fget) 22 | except (AttributeError, TypeError): 23 | lineno, source = None, '' 24 | except OSError: 25 | lineno, source = None, '' 26 | 27 | if lineno: 28 | linespec = f"#L{lineno}-L{lineno + len(source) - 1}" 29 | else: 30 | linespec = "" 31 | 32 | fn = os.path.relpath(fn, start=os.path.dirname(pymgrid.__file__)) 33 | 34 | return f'https://github.com/ahalev/python-microgrid/tree/v{pymgrid.__version__}/src/pymgrid/{fn}{linespec}' 35 | -------------------------------------------------------------------------------- /src/pymgrid/utils/deprecation.py: -------------------------------------------------------------------------------- 1 | import functools 2 | import warnings 3 | 4 | from pymgrid.errors import PymgridDeprecationWarning, DeprecatedError 5 | 6 | 7 | def deprecation_warning(successor, msg=None): 8 | """ 9 | Decorator for warning of future deprecation 10 | 11 | Raises a DeprecationWarning on the wrapped function and suggests using `successor` instead. 12 | If msg is not None, raises a future warning with said message. In this case `successor` is ignored. 13 | """ 14 | 15 | def decorator(func): 16 | 17 | @functools.wraps(func) 18 | def wrapper(self, *args, **kwargs): 19 | _msg = msg or f"Function '{func.__qualname__}' is deprecated and will be removed in a future version. "\ 20 | f"Use '{successor}' instead." 21 | 22 | warnings.warn(_msg, category=PymgridDeprecationWarning) 23 | 24 | return func(self, *args, **kwargs) 25 | return wrapper 26 | return decorator 27 | 28 | 29 | def deprecation_err(successor, version=None, msg=None): 30 | """ 31 | Decorator for raising error on deprecated method or function. 32 | 33 | Raises a DeprecatedError on the wrapped function and suggests using `successor` instead. 34 | If msg is not None, raises a future warning with said message. In this case `successor` is ignored. 35 | """ 36 | 37 | def decorator(func): 38 | 39 | @functools.wraps(func) 40 | def wrapper(self, *args, **kwargs): 41 | version_msg = f' as of version {version}' if version else '' 42 | _msg = msg or f"Function '{func.__qualname__}' is deprecated{version_msg}. "\ 43 | f"Use '{successor}' instead." 44 | 45 | raise DeprecatedError(_msg) 46 | 47 | return wrapper 48 | return decorator 49 | -------------------------------------------------------------------------------- /src/pymgrid/utils/dry_run.py: -------------------------------------------------------------------------------- 1 | from copy import deepcopy 2 | from contextlib import contextmanager 3 | from typing import Union 4 | 5 | import pymgrid 6 | 7 | 8 | @contextmanager 9 | def dry_run(pymgrid_object: Union['pymgrid.Microgrid', 'pymgrid.modules.base.BaseMicrogridModule']): 10 | yield deepcopy(pymgrid_object) 11 | -------------------------------------------------------------------------------- /src/pymgrid/utils/eq.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def verbose_eq(obj_a, obj_b, attrs_or_indices, indent=0): 5 | ind = '| ' * (indent -1) 6 | reason_num = 1 7 | 8 | if obj_a == obj_b: 9 | print(f'{ind}Objects are equal.') 10 | return 11 | 12 | 13 | def print_reason(reason, num): 14 | print(f"{ind}{num}) {reason}") 15 | num += 1 16 | return num 17 | 18 | if type(obj_a) != type(obj_b): 19 | print_reason(f'type(self)={type(obj_a)} != type(other)={type(obj_b)}"', reason_num) 20 | return 21 | 22 | print(f'{ind}{type(obj_a).__name__}s are not equal due to: ') 23 | 24 | try: 25 | if len(obj_a) != len(obj_b): 26 | reason_num = print_reason(f'len(self)={len(obj_a)} != len(other)={len(obj_b)}"', reason_num) 27 | except TypeError: 28 | pass 29 | 30 | for attr_idx in attrs_or_indices: 31 | self_attr, other_attr, reason = _get_attrs_reason(obj_a, obj_b, attr_idx) 32 | 33 | try: 34 | eq = bool(self_attr == other_attr) 35 | except ValueError: 36 | eq = np.array_equal(self_attr, other_attr) 37 | 38 | if not eq: 39 | reason_num = print_reason(reason, reason_num) 40 | try: 41 | self_attr.verbose_eq(other_attr, indent=indent+1) 42 | except AttributeError: 43 | try: 44 | verbose_eq(self_attr, other_attr, attrs_or_indices=self_attr.__dict__, indent=indent+1) 45 | except Exception: 46 | pass 47 | 48 | 49 | def _get_attrs_reason(obj_a, obj_b, attr_idx): 50 | if isinstance(attr_idx, int): 51 | self_attr = obj_a[attr_idx] 52 | other_attr = obj_b[attr_idx] 53 | reason = f'self[{attr_idx}] != other[{attr_idx}]' 54 | 55 | else: 56 | self_attr = getattr(obj_a, attr_idx) 57 | other_attr = getattr(obj_b, attr_idx) 58 | reason = f'self.{attr_idx} != other.{attr_idx}' 59 | 60 | return self_attr, other_attr, reason 61 | -------------------------------------------------------------------------------- /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=None, **log_items): 19 | if log_items: 20 | if log_dict: 21 | raise TypeError('Cannot pass both positional and keyword arguments.') 22 | 23 | log_dict = log_items 24 | 25 | for key, value in log_dict.items(): 26 | if key not in self: 27 | self[key] = [] 28 | 29 | try: 30 | self[key].append(value.item()) 31 | except AttributeError: 32 | self[key].append(value) 33 | except ValueError: 34 | raise ValueError('Only scalar values can be logged.') 35 | 36 | self._log_length += 1 37 | 38 | def to_dict(self): 39 | return self.data.copy() 40 | 41 | def raw(self): 42 | return {k: list(map(float, v)) for k, v in self.data.items()} 43 | 44 | def to_frame(self): 45 | return pd.DataFrame(self.data) 46 | 47 | def serialize(self, key): 48 | return {key: self.to_frame()} if len(self) > 0 else {} 49 | 50 | def __len__(self): 51 | return self._log_length 52 | 53 | @classmethod 54 | def from_raw(cls, raw): 55 | if raw is None: 56 | return cls() 57 | elif isinstance(raw, str): 58 | raw = pd.read_csv(raw).to_dict() 59 | return cls(raw) 60 | -------------------------------------------------------------------------------- /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/running_mean_std.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | class RunningMeanStd: 5 | # https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm 6 | def __init__(self, epsilon=1e-4, shape=()): 7 | self.mean = np.zeros(shape, 'float64') 8 | self.var = np.ones(shape, 'float64') 9 | self.count = epsilon 10 | 11 | def update(self, x): 12 | batch_mean = np.mean(x, axis=0) 13 | batch_var = np.var(x, axis=0) 14 | batch_count = x.shape[0] 15 | self.update_from_moments(batch_mean, batch_var, batch_count) 16 | 17 | def update_from_moments(self, batch_mean, batch_var, batch_count): 18 | delta = batch_mean - self.mean 19 | tot_count = self.count + batch_count 20 | 21 | new_mean = self.mean + delta * batch_count / tot_count 22 | m_a = self.var * (self.count) 23 | m_b = batch_var * (batch_count) 24 | M2 = m_a + m_b + np.square(delta) * self.count * batch_count / (self.count + batch_count) 25 | new_var = M2 / (self.count + batch_count) 26 | 27 | new_count = batch_count + self.count 28 | 29 | self.mean = new_mean 30 | self.var = new_var 31 | self.count = new_count 32 | -------------------------------------------------------------------------------- /src/pymgrid/utils/space/__init__.py: -------------------------------------------------------------------------------- 1 | from .space import MicrogridSpace, ModuleSpace, extract_builtins 2 | from .utils import flatten, unflatten 3 | -------------------------------------------------------------------------------- /src/pymgrid/utils/space/utils.py: -------------------------------------------------------------------------------- 1 | from gym.spaces import flatten as _flatten, unflatten as _unflatten 2 | 3 | 4 | def flatten(space, x): 5 | try: 6 | return _flatten(space, x) 7 | except Exception as e: 8 | raise ValueError('Exception encountered when flattening action. See stack trace for details.') from e 9 | 10 | 11 | def unflatten(space, x): 12 | try: 13 | return _unflatten(space, x) 14 | except Exception as e: 15 | raise ValueError('Exception encountered when unflattening action. See stack trace for details.') from e 16 | -------------------------------------------------------------------------------- /src/pymgrid/version.py: -------------------------------------------------------------------------------- 1 | __version__ = '1.4.1' 2 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/tests/__init__.py -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | 4 | def pytest_addoption(parser): 5 | parser.addoption( 6 | "--run-slow", action="store_true", default=False, help="run slow tests" 7 | ) 8 | 9 | 10 | def pytest_configure(config): 11 | config.addinivalue_line("markers", "slow: mark test as slow to run") 12 | 13 | 14 | def pytest_collection_modifyitems(config, items): 15 | if config.getoption("--run-slow"): 16 | # --runslow given in cli: do not skip slow tests 17 | return 18 | skip_slow = pytest.mark.skip(reason="need --run-slow option to run") 19 | for item in items: 20 | if "slow" in item.keywords: 21 | item.add_marker(skip_slow) -------------------------------------------------------------------------------- /tests/control/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/tests/control/__init__.py -------------------------------------------------------------------------------- /tests/control/data_generation/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/tests/control/data_generation/__init__.py -------------------------------------------------------------------------------- /tests/control/test_control.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | -------------------------------------------------------------------------------- /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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/tests/envs/__init__.py -------------------------------------------------------------------------------- /tests/helpers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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 | normalized_action_bounds=(0, 1)): 21 | 22 | modules = dict( 23 | genset=GensetModule(running_min_production=10, 24 | running_max_production=50, 25 | genset_cost=0.5, 26 | normalized_action_bounds=normalized_action_bounds), 27 | 28 | battery=BatteryModule(min_capacity=0, 29 | max_capacity=100, 30 | max_charge=50, 31 | max_discharge=50, 32 | efficiency=1.0, 33 | init_soc=0.5, 34 | normalized_action_bounds=normalized_action_bounds), 35 | 36 | renewable=RenewableModule(time_series=50*np.ones(timeseries_length), 37 | normalized_action_bounds=normalized_action_bounds), 38 | 39 | load=LoadModule(time_series=60*np.ones(timeseries_length), 40 | normalized_action_bounds=normalized_action_bounds), 41 | 42 | grid=GridModule(max_import=100, 43 | max_export=100, 44 | time_series=np.ones((timeseries_length, 3)), 45 | normalized_action_bounds=normalized_action_bounds, 46 | raise_errors=True) 47 | ) 48 | 49 | if retain_only is not None: 50 | modules = {k: v for k, v in modules.items() if k in retain_only} 51 | if remove_modules: 52 | raise RuntimeError('Can pass either remove_modules or retain_only, but not both.') 53 | else: 54 | for module in remove_modules: 55 | try: 56 | modules.pop(module) 57 | except KeyError: 58 | raise NameError(f"Module {module} not one of default modules {list(modules.keys())}.") 59 | 60 | modules = list(modules.values()) 61 | modules.extend(additional_modules if additional_modules else []) 62 | 63 | if modules_only: 64 | return modules 65 | 66 | return Microgrid(modules, add_unbalanced_module=add_unbalanced_module) 67 | -------------------------------------------------------------------------------- /tests/helpers/test_case.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import numpy as np 3 | import pandas as pd 4 | 5 | from unittest.util import safe_repr 6 | 7 | class TestCase(unittest.TestCase): 8 | def assertEqual(self, first, second, msg=None) -> None: 9 | try: 10 | super().assertEqual(first, second, msg=msg) 11 | except (ValueError, AssertionError): 12 | # array-like or pandas obj 13 | # convert pandas obj 14 | if isinstance(first, (pd.DataFrame, pd.Series)): 15 | first, second = first.values, second.values 16 | 17 | try: 18 | np.testing.assert_equal(first, second, err_msg=msg if msg else '') 19 | except AssertionError as e: 20 | try: 21 | np.testing.assert_allclose(first, second, rtol=1e-7, atol=1e-10, err_msg=msg if msg else '') 22 | except TypeError: 23 | raise e 24 | 25 | def assertNotEqual(self, first, second, msg=None) -> None: 26 | try: 27 | super().assertNotEqual(first, second, msg=msg) 28 | except ValueError as e: 29 | try: 30 | self.assertEqual(first, second) 31 | except AssertionError: 32 | pass 33 | else: 34 | msg = self._formatMessage(msg, '%s == %s' % (safe_repr(first), 35 | safe_repr(second))) 36 | raise self.failureException(msg) 37 | -------------------------------------------------------------------------------- /tests/microgrid/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/tests/microgrid/__init__.py -------------------------------------------------------------------------------- /tests/microgrid/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/tests/microgrid/modules/__init__.py -------------------------------------------------------------------------------- /tests/microgrid/modules/container_tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/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/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/microgrid/space/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahalev/python-microgrid/09089ccfaab3e95becfda1b26fbce6f9c6195f6a/tests/microgrid/space/__init__.py -------------------------------------------------------------------------------- /tests/microgrid/space/test_microgrid_space.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from pymgrid.utils.space import ModuleSpace 4 | from tests.helpers.test_case import TestCase 5 | 6 | 7 | class TestMicrogridSpace(TestCase): 8 | # Placeholder 9 | pass 10 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------