diff --git a/assume/scenario/loader_amiris.py b/assume/scenario/loader_amiris.py index 7c3b2246b..3b4eb127f 100644 --- a/assume/scenario/loader_amiris.py +++ b/assume/scenario/loader_amiris.py @@ -155,7 +155,7 @@ def add_agent_to_world( match agent["Type"]: case "SupportPolicy": support_data = agent["Attributes"]["SetSupportData"] - supports |= {x.pop("Set"): x for x in support_data} + supports |= {x.pop("PolicySet"): x for x in support_data} world.add_unit_operator(agent["Id"]) for name, support in supports.items(): @@ -480,14 +480,12 @@ def load_amiris( start += timedelta(minutes=2) end += timedelta(minutes=2) sim_id = f"{scenario}_{study_case}" - save_interval = amiris_scenario["GeneralProperties"]["Output"]["Interval"] prices = {} index = pd.date_range(start=start, end=end, freq="1h", inclusive="left") world.bidding_strategies["support"] = SupportStrategy world.setup( start=start, end=end, - save_frequency_hours=save_interval, simulation_id=sim_id, ) # helper dict to map trader markups/markdowns to powerplants diff --git a/docs/source/release_notes.rst b/docs/source/release_notes.rst index 9c43725cc..7f0b56024 100644 --- a/docs/source/release_notes.rst +++ b/docs/source/release_notes.rst @@ -13,6 +13,9 @@ Upcoming Release The features in this section are not released yet, but will be part of the next release! To use the features already you have to install the main branch, e.g. ``pip install git+https://github.com/assume-framework/assume`` + **Bugfixes:** + - **Tutorial 07**: Aligned Amiris loader with changes in format in Amiris compare (https://gitlab.com/fame-framework/fame-io/-/issues/203 and https://gitlab.com/fame-framework/fame-io/-/issues/208) + v0.4.3 - (11th November 2024) =========================================== diff --git a/examples/inputs/example_02a/config.yaml b/examples/inputs/example_02a/config.yaml index 8da7961f6..0979c4805 100644 --- a/examples/inputs/example_02a/config.yaml +++ b/examples/inputs/example_02a/config.yaml @@ -2,136 +2,124 @@ # # SPDX-License-Identifier: AGPL-3.0-or-later -tiny: - start_date: 2019-01-01 00:00 - end_date: 2019-01-05 00:00 - time_step: 1h - save_frequency_hours: null - learning_mode: True - +base: + end_date: 2019-03-31 00:00 learning_config: - continue_learning: False - trained_policies_save_path: null - max_bid_price: 100 algorithm: matd3 - actor_architecture: mlp - learning_rate: 0.001 - training_episodes: 10 - episodes_collecting_initial_experience: 3 - train_freq: 24h - gradient_steps: -1 - batch_size: 64 - gamma: 0.99 + batch_size: 256 + continue_learning: false device: cpu - noise_sigma: 0.1 - noise_scale: 1 + episodes_collecting_initial_experience: 5 + gamma: 0.99 + gradient_steps: -1 + learning_rate: 0.001 + max_bid_price: 100 noise_dt: 1 + noise_scale: 1 + noise_sigma: 0.1 + train_freq: 24h + trained_policies_save_path: null + training_episodes: 100 validation_episodes_interval: 5 - + learning_mode: true markets_config: EOM: + market_mechanism: pay_as_clear + maximum_bid_price: 3000 + maximum_bid_volume: 100000 + minimum_bid_price: -500 + opening_duration: 1h + opening_frequency: 1h operator: EOM_operator + price_unit: EUR/MWh product_type: energy products: - - duration: 1h - count: 1 - first_delivery: 1h - opening_frequency: 1h - opening_duration: 1h + - count: 1 + duration: 1h + first_delivery: 1h volume_unit: MWh - maximum_bid_volume: 100000 - maximum_bid_price: 3000 - minimum_bid_price: -500 - price_unit: EUR/MWh - market_mechanism: pay_as_clear - - -base: + save_frequency_hours: null start_date: 2019-03-01 00:00 - end_date: 2019-03-31 00:00 time_step: 1h - save_frequency_hours: null - learning_mode: True - +base_lstm: + end_date: 2019-03-31 00:00 learning_config: - continue_learning: False - trained_policies_save_path: null - max_bid_price: 100 + actor_architecture: lstm algorithm: matd3 - actor_architecture: mlp - learning_rate: 0.001 - training_episodes: 50 - episodes_collecting_initial_experience: 5 - train_freq: 24h - gradient_steps: -1 batch_size: 256 - gamma: 0.99 + continue_learning: false device: cpu - noise_sigma: 0.1 - noise_scale: 1 - noise_dt: 1 - validation_episodes_interval: 5 early_stopping_steps: 10 early_stopping_threshold: 0.05 - + episodes_collecting_initial_experience: 5 + gamma: 0.99 + gradient_steps: -1 + learning_rate: 0.001 + max_bid_price: 100 + noise_dt: 1 + noise_scale: 1 + noise_sigma: 0.1 + train_freq: 24h + trained_policies_save_path: null + training_episodes: 50 + validation_episodes_interval: 5 + learning_mode: true markets_config: EOM: + market_mechanism: pay_as_clear + maximum_bid_price: 3000 + maximum_bid_volume: 100000 + minimum_bid_price: -500 + opening_duration: 1h + opening_frequency: 1h operator: EOM_operator + price_unit: EUR/MWh product_type: energy products: - - duration: 1h - count: 1 - first_delivery: 1h - opening_frequency: 1h - opening_duration: 1h + - count: 1 + duration: 1h + first_delivery: 1h volume_unit: MWh - maximum_bid_volume: 100000 - maximum_bid_price: 3000 - minimum_bid_price: -500 - price_unit: EUR/MWh - market_mechanism: pay_as_clear - -base_lstm: + save_frequency_hours: null start_date: 2019-03-01 00:00 - end_date: 2019-03-31 00:00 time_step: 1h - save_frequency_hours: null - learning_mode: True - +tiny: + end_date: 2019-01-05 00:00 learning_config: - continue_learning: False - trained_policies_save_path: null - max_bid_price: 100 + actor_architecture: mlp algorithm: matd3 - actor_architecture: lstm - learning_rate: 0.001 - training_episodes: 50 - episodes_collecting_initial_experience: 5 - train_freq: 24h - gradient_steps: -1 - batch_size: 256 - gamma: 0.99 + batch_size: 64 + continue_learning: false device: cpu - noise_sigma: 0.1 - noise_scale: 1 + episodes_collecting_initial_experience: 3 + gamma: 0.99 + gradient_steps: -1 + learning_rate: 0.001 + max_bid_price: 100 noise_dt: 1 + noise_scale: 1 + noise_sigma: 0.1 + train_freq: 24h + trained_policies_save_path: null + training_episodes: 10 validation_episodes_interval: 5 - early_stopping_steps: 10 - early_stopping_threshold: 0.05 - + learning_mode: true markets_config: EOM: + market_mechanism: pay_as_clear + maximum_bid_price: 3000 + maximum_bid_volume: 100000 + minimum_bid_price: -500 + opening_duration: 1h + opening_frequency: 1h operator: EOM_operator + price_unit: EUR/MWh product_type: energy products: - - duration: 1h - count: 1 - first_delivery: 1h - opening_frequency: 1h - opening_duration: 1h + - count: 1 + duration: 1h + first_delivery: 1h volume_unit: MWh - maximum_bid_volume: 100000 - maximum_bid_price: 3000 - minimum_bid_price: -500 - price_unit: EUR/MWh - market_mechanism: pay_as_clear + save_frequency_hours: null + start_date: 2019-01-01 00:00 + time_step: 1h diff --git a/examples/notebooks/04_reinforcement_learning_algorithm_example.ipynb b/examples/notebooks/04_reinforcement_learning_algorithm_example.ipynb index 736d21de5..63fa583f8 100644 --- a/examples/notebooks/04_reinforcement_learning_algorithm_example.ipynb +++ b/examples/notebooks/04_reinforcement_learning_algorithm_example.ipynb @@ -37,7 +37,47 @@ "id": "m0DaRwFA7VgW", "outputId": "5655adad-5b7a-4fe3-9067-6b502a06136b" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: assume-framework[learning] in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (0.4.3)\n", + "Requirement already satisfied: argcomplete>=3.1.4 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (3.5.1)\n", + "Requirement already satisfied: nest-asyncio>=1.5.6 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (1.6.0)\n", + "Requirement already satisfied: mango-agents>=2.1.1 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (2.1.1)\n", + "Requirement already satisfied: numpy>=1.26.4 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (1.26.4)\n", + "Requirement already satisfied: tqdm>=4.64.1 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (4.66.6)\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (2.9.0)\n", + "Requirement already satisfied: sqlalchemy>=2.0.9 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (2.0.36)\n", + "Requirement already satisfied: pandas>=2.0.0 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (2.2.3)\n", + "Requirement already satisfied: psycopg2-binary>=2.9.5 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (2.9.10)\n", + "Requirement already satisfied: pyyaml>=6.0 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (6.0.2)\n", + "Requirement already satisfied: pyyaml-include>=2.2a in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (2.2a1)\n", + "Requirement already satisfied: pyomo>=6.8.0 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (6.8.0)\n", + "Requirement already satisfied: highspy in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (1.8.0)\n", + "Requirement already satisfied: torch>=2.0.1 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from assume-framework[learning]) (2.5.1)\n", + "Requirement already satisfied: paho-mqtt>=2.1.0 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from mango-agents>=2.1.1->assume-framework[learning]) (2.1.0)\n", + "Requirement already satisfied: dill>=0.3.8 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from mango-agents>=2.1.1->assume-framework[learning]) (0.3.9)\n", + "Requirement already satisfied: protobuf==5.27.2 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from mango-agents>=2.1.1->assume-framework[learning]) (5.27.2)\n", + "Requirement already satisfied: networkx>=3.4.1 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from mango-agents>=2.1.1->assume-framework[learning]) (3.4.2)\n", + "Requirement already satisfied: pytz>=2020.1 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from pandas>=2.0.0->assume-framework[learning]) (2024.2)\n", + "Requirement already satisfied: tzdata>=2022.7 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from pandas>=2.0.0->assume-framework[learning]) (2024.2)\n", + "Requirement already satisfied: ply in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from pyomo>=6.8.0->assume-framework[learning]) (3.11)\n", + "Requirement already satisfied: six>=1.5 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from python-dateutil>=2.8.2->assume-framework[learning]) (1.16.0)\n", + "Requirement already satisfied: fsspec>=2021.04.0 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from pyyaml-include>=2.2a->assume-framework[learning]) (2024.10.0)\n", + "Requirement already satisfied: typing-extensions>=4.6.0 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from sqlalchemy>=2.0.9->assume-framework[learning]) (4.12.2)\n", + "Requirement already satisfied: greenlet!=0.4.17 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from sqlalchemy>=2.0.9->assume-framework[learning]) (3.1.1)\n", + "Requirement already satisfied: filelock in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from torch>=2.0.1->assume-framework[learning]) (3.16.1)\n", + "Requirement already satisfied: jinja2 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from torch>=2.0.1->assume-framework[learning]) (3.1.4)\n", + "Requirement already satisfied: setuptools in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from torch>=2.0.1->assume-framework[learning]) (75.1.0)\n", + "Requirement already satisfied: sympy==1.13.1 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from torch>=2.0.1->assume-framework[learning]) (1.13.1)\n", + "Requirement already satisfied: mpmath<1.4,>=1.1.0 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from sympy==1.13.1->torch>=2.0.1->assume-framework[learning]) (1.3.0)\n", + "Requirement already satisfied: colorama in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from tqdm>=4.64.1->assume-framework[learning]) (0.4.6)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\aeppl\\.conda\\envs\\assume\\lib\\site-packages (from jinja2->torch>=2.0.1->assume-framework[learning]) (3.0.2)\n" + ] + } + ], "source": [ "!pip install assume-framework[learning]" ] @@ -112,11 +152,7 @@ "cell_type": "code", "execution_count": null, "id": "7d9899ff", - "metadata": { - "vscode": { - "languageId": "python" - } - }, + "metadata": {}, "outputs": [], "source": [ "import importlib.util\n", @@ -159,10 +195,7 @@ "execution_count": null, "id": "ade14744", "metadata": { - "id": "xUsbeZdPJ_2Q", - "vscode": { - "languageId": "python" - } + "id": "xUsbeZdPJ_2Q" }, "outputs": [], "source": [ @@ -219,10 +252,7 @@ "execution_count": null, "id": "94517a3e", "metadata": { - "id": "UXYSesx4Ifp5", - "vscode": { - "languageId": "python" - } + "id": "UXYSesx4Ifp5" }, "outputs": [], "source": [ @@ -424,11 +454,7 @@ "cell_type": "code", "execution_count": null, "id": "daed035c", - "metadata": { - "vscode": { - "languageId": "python" - } - }, + "metadata": {}, "outputs": [], "source": [ "class Learning(Learning):\n", @@ -521,10 +547,7 @@ "execution_count": null, "id": "632844c2", "metadata": { - "id": "0ww-L9fABnw3", - "vscode": { - "languageId": "python" - } + "id": "0ww-L9fABnw3" }, "outputs": [], "source": [ @@ -582,11 +605,7 @@ "cell_type": "code", "execution_count": null, "id": "c715f90e", - "metadata": { - "vscode": { - "languageId": "python" - } - }, + "metadata": {}, "outputs": [], "source": [ "class TD3(TD3):\n", @@ -654,11 +673,7 @@ "cell_type": "code", "execution_count": null, "id": "753dbab1", - "metadata": { - "vscode": { - "languageId": "python" - } - }, + "metadata": {}, "outputs": [], "source": [ "class TD3(TD3):\n", @@ -853,16 +868,13 @@ "execution_count": null, "id": "6bb09b5b", "metadata": { - "id": "moZ_UD7FfkOh", - "vscode": { - "languageId": "python" - } + "id": "moZ_UD7FfkOh" }, "outputs": [], "source": [ "learning_config = {\n", " \"continue_learning\": False,\n", - " \"trained_policies_save_path\": \"None\",\n", + " \"trained_policies_save_path\": None,\n", " \"max_bid_price\": 100,\n", " \"algorithm\": \"matd3\",\n", " \"learning_rate\": 0.001,\n", @@ -885,15 +897,12 @@ "execution_count": null, "id": "5cff2f6a", "metadata": { - "id": "iPz8v4N5hpfr", - "vscode": { - "languageId": "python" - } + "id": "iPz8v4N5hpfr" }, "outputs": [], "source": [ "# Read the YAML file\n", - "with open(\"assume/examples/inputs/example_02a/config.yaml\") as file:\n", + "with open(f\"{inputs_path}/example_02a/config.yaml\") as file:\n", " data = yaml.safe_load(file)\n", "\n", "# store our modifications to the config file\n", @@ -901,7 +910,7 @@ "data[\"base\"][\"learning_config\"] = learning_config\n", "\n", "# Write the modified data back to the file\n", - "with open(\"assume/examples/inputs/example_02a/config.yaml\", \"w\") as file:\n", + "with open(f\"{inputs_path}/example_02a/config.yaml\", \"w\") as file:\n", " yaml.safe_dump(data, file)" ] }, @@ -926,12 +935,63 @@ }, "id": "ZlWxXxZr54WV", "lines_to_next_cell": 0, - "outputId": "e30f4279-7a4e-4efc-9cfb-61416e4fe2f1", - "vscode": { - "languageId": "python" - } + "outputId": "e30f4279-7a4e-4efc-9cfb-61416e4fe2f1" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "INFO:assume.world:connected to db\n", + "INFO:assume.scenario.loader_csv:Starting Scenario example_02a/base from ../inputs\n", + "INFO:assume.scenario.loader_csv:storage_units not found. Returning None\n", + "INFO:assume.scenario.loader_csv:industrial_dsm_units not found. Returning None\n", + "INFO:assume.scenario.loader_csv:residential_dsm_units not found. Returning None\n", + "INFO:assume.scenario.loader_csv:forecasts_df not found. Returning None\n", + "INFO:assume.scenario.loader_csv:Downsampling demand_df successful.\n", + "INFO:assume.scenario.loader_csv:cross_border_flows not found. Returning None\n", + "INFO:assume.scenario.loader_csv:availability_df not found. Returning None\n", + "INFO:assume.scenario.loader_csv:electricity_prices not found. Returning None\n", + "INFO:assume.scenario.loader_csv:price_forecasts not found. Returning None\n", + "INFO:assume.scenario.loader_csv:temperature not found. Returning None\n", + "INFO:assume.scenario.loader_csv:Adding markets\n", + "INFO:assume.scenario.loader_csv:Read units from file\n", + "INFO:assume.scenario.loader_csv:Adding power_plant units\n", + "INFO:assume.scenario.loader_csv:Adding demand units\n", + "INFO:assume.scenario.loader_csv:Adding unit operators and units\n", + "INFO:assume.scenario.loader_csv:storage_units not found. Returning None\n", + "INFO:assume.scenario.loader_csv:industrial_dsm_units not found. Returning None\n", + "INFO:assume.scenario.loader_csv:residential_dsm_units not found. Returning None\n", + "INFO:assume.scenario.loader_csv:forecasts_df not found. Returning None\n", + "INFO:assume.scenario.loader_csv:Downsampling demand_df successful.\n", + "INFO:assume.scenario.loader_csv:cross_border_flows not found. Returning None\n", + "INFO:assume.scenario.loader_csv:availability_df not found. Returning None\n", + "INFO:assume.scenario.loader_csv:electricity_prices not found. Returning None\n", + "INFO:assume.scenario.loader_csv:price_forecasts not found. Returning None\n", + "INFO:assume.scenario.loader_csv:temperature not found. Returning None\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Training Episodes: 0%| | 0/100 [00:00