Skip to content

Commit

Permalink
Tutorial 07 bug (#485)
Browse files Browse the repository at this point in the history
various fixes in tutorial 07

---------

Co-authored-by: AndreasEppler <[email protected]>
Co-authored-by: Florian Maurer <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2024
1 parent 6c1e86a commit e41ed04
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 4,487 deletions.
4 changes: 1 addition & 3 deletions assume/scenario/loader_amiris.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,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():
Expand Down Expand Up @@ -479,14 +479,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,
index=index,
)
Expand Down
3 changes: 3 additions & 0 deletions docs/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
===========================================

Expand Down
82 changes: 39 additions & 43 deletions examples/notebooks/07_interoperability_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"metadata": {},
"outputs": [],
"source": [
"# Install the ASSUME framework with the PyPSA library for network optimization\n",
"!pip install assume-framework[network]"
"import importlib.util\n",
"\n",
"# Check if 'google.colab' is available\n",
"IN_COLAB = importlib.util.find_spec(\"google.colab\") is not None\n",
"if IN_COLAB:\n",
" !pip install assume-framework[network]"
]
},
{
Expand All @@ -63,14 +64,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"metadata": {},
"outputs": [],
"source": [
"!git clone --depth=1 https://github.com/assume-framework/assume.git assume-repo"
"if IN_COLAB:\n",
" !git clone --depth=1 https://github.com/assume-framework/assume.git assume-repo"
]
},
{
Expand All @@ -83,14 +81,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"metadata": {},
"outputs": [],
"source": [
"!cd assume-repo && assume -s example_01a -c tiny -db \"sqlite:///local_db/assume_db.db\""
"if IN_COLAB:\n",
" !cd assume-repo && assume -s example_01a -c tiny -db \"sqlite:///local_db/assume_db.db\""
]
},
{
Expand All @@ -99,14 +94,15 @@
"source": [
"Protip: with argcomplete - one can create very nice tab completion for python scripts.\n",
"\n",
"Though one has to run `eval \"$(register-python-argcomplete assume)\"` once in the env before"
"Though one has to run `eval \"$(register-python-argcomplete assume)\"` once in the env before (for Linux and Mac). On Windows, one needs to run:\n",
"`register-python-argcomplete --shell powershell assume | Out-String | Invoke-Expression`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We did not use the postgresql database - therefore we can not use our visualization - lets fix this. **You need to have have postgresql and grafana installed (available through docker).**"
"We did not use the postgresql database - therefore we can not use our visualization - lets fix this. **You need to have have postgresql and grafana installed (available through docker).** Please make sure that you have Docker running. Otherwise this code will not work and only run endlessly."
]
},
{
Expand All @@ -119,7 +115,10 @@
},
"outputs": [],
"source": [
"!assume -s example_01a -c base -db \"postgresql://assume:assume@localhost:5432/assume\""
"if not IN_COLAB:\n",
" !cd ../.. && assume -s example_01a -c base -db \"postgresql://assume:assume@localhost:5432/assume\"\n",
"else:\n",
" !assume -s example_01a -c base -db \"postgresql://assume:assume@localhost:5432/assume\""
]
},
{
Expand Down Expand Up @@ -174,16 +173,16 @@
")\n",
"sim_id = \"world_script_simulation\"\n",
"\n",
"world.loop.run_until_complete(\n",
" world.setup(\n",
" start=start,\n",
" end=end,\n",
" save_frequency_hours=48,\n",
" simulation_id=sim_id,\n",
" index=index,\n",
" )\n",
"\n",
"world.setup(\n",
" start=start,\n",
" end=end,\n",
" save_frequency_hours=48,\n",
" simulation_id=sim_id,\n",
" index=index,\n",
")\n",
"\n",
"\n",
"marketdesign = [\n",
" MarketConfig(\n",
" market_id=\"EOM\",\n",
Expand Down Expand Up @@ -290,13 +289,11 @@
" db_uri = \"postgresql://assume:assume@localhost:5432/assume\"\n",
"\n",
"world = World(database_uri=db_uri)\n",
"world.loop.run_until_complete(\n",
" load_amiris(\n",
" world,\n",
" \"amiris\",\n",
" scenario.lower(),\n",
" base_path,\n",
" )\n",
"load_amiris(\n",
" world,\n",
" \"amiris\",\n",
" scenario.lower(),\n",
" base_path,\n",
")\n",
"print(f\"did load {scenario} - now simulating\")\n",
"world.run()"
Expand All @@ -306,7 +303,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If you are running locally and have our docker with the database and the Grafan dashboards installed, we can now look at the results here:\n",
"If you are running locally and have our docker with the database and the Grafana dashboards installed, we can now look at the results here:\n",
"\n",
"http://localhost:3000/d/mQ3Lvkr4k/assume3a-main-overview?orgId=1&var-simulation=amiris_simple&from=1609459200000&to=1609545600000&refresh=5s"
]
Expand Down Expand Up @@ -380,17 +377,16 @@
"\n",
"bidding_strategies = defaultdict(lambda: default_strategies)\n",
"\n",
"world.loop.run_until_complete(\n",
" load_pypsa(world, scenario, study_case, network, marketdesign, bidding_strategies)\n",
")\n",
"load_pypsa(world, scenario, study_case, network, marketdesign, bidding_strategies)\n",
"\n",
"world.run()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you are running locally and have our docker with the database and the Grafan dashboards installed, we can now look at the results here:\n",
"If you are running locally and have our docker with the database and the Grafana dashboards installed, we can now look at the results here:\n",
"\n",
"http://localhost:3000/d/nodalview/assume-nodal-view?orgId=1&var-simulation=world_pypsa_ac_dc_meshed&var-market=EOM\n",
"\n",
Expand All @@ -415,7 +411,7 @@
"toc_visible": true
},
"kernelspec": {
"display_name": "assume",
"display_name": "assume-framework",
"language": "python",
"name": "python3"
},
Expand All @@ -429,7 +425,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.6"
"version": "3.11.9"
},
"nbsphinx": {
"execute": "never"
Expand Down
Loading

0 comments on commit e41ed04

Please sign in to comment.