{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Multiple runs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Perform Multiple Optimization Runs with EnergyScope\n", "\n", "In this tutorial, we will demonstrate how to perform multiple optimization runs using the EnergyScope model. This is useful for sensitivity analysis, scenario exploration, and understanding how changes in parameters affect the energy system configuration.\n", "\n", "### Import Necessary Libraries\n", "\n", "We begin by importing the required libraries and modules:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:48.069855Z", "start_time": "2025-03-17T14:52:47.943040Z" } }, "outputs": [], "source": [ "import pandas as pd\n", "import pickle \n", "from energyscope.energyscope import Energyscope\n", "from energyscope.models import infrastructure_ch_2050\n", "from energyscope.result import postprocessing\n", "from energyscope.plots import plot_sankey, plot_parametrisation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "- **`pandas`**: For data manipulation and handling data frames.\n", "- **`pickle`**: For saving and loading Python objects to and from files.\n", "- **`Energyscope`**: The main class for initializing and running the EnergyScope model.\n", "- **`infrastructure_ch_2050`**: A predefined model configuration focusing on energy infrastructure In Switzerland in 2050.\n", "- **`postprocessing`**: Functions for processing and analyzing results after optimization.\n", "- **`plot_sankey`**, **`plot_parametrisation`**: Functions for visualizing results.\n", "\n", "### Define Solver Options\n", "\n", "We specify the solver options to control the optimization process:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:48.072059Z", "start_time": "2025-03-17T14:52:48.070532Z" } }, "outputs": [], "source": [ "solver_options = {\n", " 'solver': 'gurobi',\n", " 'solver_msg': 0,\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "- **`'solver': 'gurobi'`**: Specifies that the Gurobi solver should be used.\n", "- **`'solver_msg': 0`**: Suppresses solver messages during execution.\n", "\n", "### Initialize and Run the Base Model\n", "\n", "We initialize the EnergyScope model with the chosen dataset and solver options:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:48.074121Z", "start_time": "2025-03-17T14:52:48.072574Z" } }, "outputs": [], "source": [ "# Load the model with the chosen dataset and solver options\n", "es_infra_ch = Energyscope(model=infrastructure_ch_2050, solver_options=solver_options)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "Then, we perform an initial calculation to ensure the model is set up correctly:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:49.069638Z", "start_time": "2025-03-17T14:52:48.074719Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Gurobi 12.0.2:" ] } ], "source": [ "# Solve the model\n", "results_ch = es_infra_ch.calc()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "> **Note**: This initial run is optional but recommended to verify that the model and solver are functioning properly before proceeding to multiple runs.\n", "\n", "### Load Parameter Sequence Data\n", "\n", "We load a sequence of parameters from an Excel file, which will be used to perform multiple optimization runs:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:49.139340Z", "start_time": "2025-03-17T14:52:49.070403Z" } }, "outputs": [ { "data": { "application/vnd.microsoft.datawrangler.viewer.v0+json": { "columns": [ { "name": "index", "rawType": "int64", "type": "integer" }, { "name": "param", "rawType": "object", "type": "string" }, { "name": "index0", "rawType": "object", "type": "string" }, { "name": "index1", "rawType": "object", "type": "unknown" }, { "name": "index2", "rawType": "float64", "type": "float" }, { "name": "index3", "rawType": "float64", "type": "float" }, { "name": "value1", "rawType": "int64", "type": "integer" }, { "name": "value2", "rawType": "float64", "type": "float" }, { "name": "value3", "rawType": "float64", "type": "float" }, { "name": "value4", "rawType": "float64", "type": "float" }, { "name": "value5", "rawType": "float64", "type": "float" }, { "name": "value6", "rawType": "float64", "type": "float" }, { "name": "value7", "rawType": "float64", "type": "float" }, { "name": "value8", "rawType": "float64", "type": "float" }, { "name": "value9", "rawType": "float64", "type": "float" }, { "name": "value10", "rawType": "float64", "type": "float" }, { "name": "value11", "rawType": "float64", "type": "float" } ], "ref": "4d0df92e-8e1d-4dff-930b-42fd7a68b341", "rows": [ [ "0", "f_min", "PV", null, null, null, "2", "2.6", "5.2", "7.8", "10.4", "13.0", "15.6", "18.2", "20.8", "23.400000000000002", "26.0" ], [ "1", "f_max", "PV", null, null, null, "2", "2.6", "5.2", "7.8", "10.4", "13.0", "15.6", "18.2", "20.8", "23.400000000000002", "26.0" ], [ "2", "end_uses_demand_year", "MOBILITY_FREIGHT", "TRANSPORTATION", null, null, "45000", "33226.71", "33226.71", "33226.71", "33226.71", "33226.71", "33226.71", "33226.71", "33226.71", "33226.71", "33226.71" ], [ "3", "c_inv", "WIND", null, null, null, "800", "850.0", "900.0", "950.0", "1000.0", "1050.0", "1100.0", "1150.0", "1200.0", "1250.0", "1300.0" ] ], "shape": { "columns": 16, "rows": 4 } }, "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
paramindex0index1index2index3value1value2value3value4value5value6value7value8value9value10value11
0f_minPVNaNNaNNaN22.605.207.8010.4013.0015.6018.2020.8023.4026.00
1f_maxPVNaNNaNNaN22.605.207.8010.4013.0015.6018.2020.8023.4026.00
2end_uses_demand_yearMOBILITY_FREIGHTTRANSPORTATIONNaNNaN4500033226.7133226.7133226.7133226.7133226.7133226.7133226.7133226.7133226.7133226.71
3c_invWINDNaNNaNNaN800850.00900.00950.001000.001050.001100.001150.001200.001250.001300.00
\n", "
" ], "text/plain": [ " param index0 index1 index2 index3 \\\n", "0 f_min PV NaN NaN NaN \n", "1 f_max PV NaN NaN NaN \n", "2 end_uses_demand_year MOBILITY_FREIGHT TRANSPORTATION NaN NaN \n", "3 c_inv WIND NaN NaN NaN \n", "\n", " value1 value2 value3 value4 value5 value6 value7 \\\n", "0 2 2.60 5.20 7.80 10.40 13.00 15.60 \n", "1 2 2.60 5.20 7.80 10.40 13.00 15.60 \n", "2 45000 33226.71 33226.71 33226.71 33226.71 33226.71 33226.71 \n", "3 800 850.00 900.00 950.00 1000.00 1050.00 1100.00 \n", "\n", " value8 value9 value10 value11 \n", "0 18.20 20.80 23.40 26.00 \n", "1 18.20 20.80 23.40 26.00 \n", "2 33226.71 33226.71 33226.71 33226.71 \n", "3 1150.00 1200.00 1250.00 1300.00 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Load the parameter sequence DataFrame\n", "seq_data = pd.read_excel(\"tutorial_input/param_run_es_n_infrastructure_ch_2050.xlsx\")\n", "display(seq_data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "- **`seq_data`**: A DataFrame containing different sets of parameters for each run.\n", "- **`display(seq_data)`**: Displays the DataFrame to inspect the parameters being varied.\n", "\n", "### Perform Multiple Optimization Runs\n", "\n", "We use the `calc_sequence` method to run the model multiple times based on the parameter changes specified in `seq_data`:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:59.468649Z", "start_time": "2025-03-17T14:52:49.140035Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Gurobi 12.0.2:Run 1 complete.\n", "Gurobi 12.0.2:Run 2 complete.\n", "Gurobi 12.0.2:Run 3 complete.\n", "Gurobi 12.0.2:Run 4 complete.\n", "Gurobi 12.0.2:Run 5 complete.\n", "Gurobi 12.0.2:Run 6 complete.\n", "Gurobi 12.0.2:Run 7 complete.\n", "Gurobi 12.0.2:Run 8 complete.\n", "Gurobi 12.0.2:Run 9 complete.\n", "Gurobi 12.0.2:Run 10 complete.\n", "Gurobi 12.0.2:Run 11 complete.\n" ] } ], "source": [ "# Run multiple optimizations based on parameters changed in seq_data\n", "results_ch_n = es_infra_ch.calc_sequence(seq_data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "- **`results_ch_n`**: A `Result` object that contains the outputs of all runs.\n", "\n", "### Post-Process the Results\n", "\n", "After obtaining the results from multiple runs, we apply post-processing to compute Key Performance Indicators (KPIs) and prepare the data for visualization:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:59.525452Z", "start_time": "2025-03-17T14:52:59.469453Z" } }, "outputs": [], "source": [ "# Postcompute KPIs\n", "results_ch_n = postprocessing(results_ch_n)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "### Visualize Results with Sankey Diagrams\n", "\n", "We can visualize the energy flows for specific runs using Sankey diagrams.\n", "\n", "#### Generate and Display Sankey Diagram for Run 1" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:59.765876Z", "start_time": "2025-03-17T14:52:59.526158Z" } }, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Generate the Sankey diagram for run 1\n", "fig = plot_sankey(results_ch_n, run_id=1)\n", "fig.show(renderer=\"notebook\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "- **`run_id=1`**: Specifies that we want to visualize the results from the first run.\n", "\n", "#### Generate and Display Sankey Diagram for Run 11" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:59.802623Z", "start_time": "2025-03-17T14:52:59.766480Z" } }, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Generate the Sankey diagram for run 11\n", "fig = plot_sankey(results_ch_n, run_id=11)\n", "fig.show(renderer=\"notebook\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "- **`run_id=11`**: Visualizes the results from the eleventh run.\n", "\n", "> **Optional**: You can save the generated Sankey diagrams as HTML files or images by uncommenting and modifying the following lines:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:59.806392Z", "start_time": "2025-03-17T14:52:59.804970Z" } }, "outputs": [], "source": [ "# Save the generated Sankey diagram as an HTML file\n", "# fig.write_html(\"tutorial_output/Sankey_results_ch_1.html\")\n", "\n", "# Save the generated Sankey diagram as an image\n", "# fig.write_image('tutorial_output/Sankey_results_ch_1.png')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "### Analyze Parametrization Results\n", "\n", "We can further analyze how the changes in parameters affect the results using the `plot_parametrisation` function.\n", "\n", "#### Inspect Annual Results DataFrame" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:59.811830Z", "start_time": "2025-03-17T14:52:59.806974Z" } }, "outputs": [ { "data": { "application/vnd.microsoft.datawrangler.viewer.v0+json": { "columns": [ { "name": "(None, 'Run')", "rawType": "object", "type": "unknown" }, { "name": "C_inv", "rawType": "float64", "type": "float" }, { "name": "C_maint", "rawType": "float64", "type": "float" }, { "name": "Annual_Prod", "rawType": "float64", "type": "float" }, { "name": "F_Mult", "rawType": "float64", "type": "float" }, { "name": "tau", "rawType": "float64", "type": "float" }, { "name": "C_op", "rawType": "float64", "type": "float" }, { "name": "C_inv_an", "rawType": "float64", "type": "float" }, { "name": "Annual_Use", "rawType": "float64", "type": "float" }, { "name": "Category", "rawType": "object", "type": "string" }, { "name": "Category_2", "rawType": "object", "type": "string" }, { "name": "Sector", "rawType": "object", "type": "string" } ], "ref": "9a739d07-0085-4342-aea8-2ce8bb4dabcd", "rows": [ [ "('MP_NG_GRID', np.int64(1))", "0.0", "0.0", "12102.61844191816", "1.38901847954314", "0.026793672807472076", "0.0", "0.0", "12102.618441918155", "Others", "Gas Infrastructure", "Others" ] ], "shape": { "columns": 11, "rows": 1 } }, "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
C_invC_maintAnnual_ProdF_MulttauC_opC_inv_anAnnual_UseCategoryCategory_2Sector
Run
MP_NG_GRID10.00.012102.6184421.3890180.0267940.00.012102.618442OthersGas InfrastructureOthers
\n", "
" ], "text/plain": [ " C_inv C_maint Annual_Prod F_Mult tau C_op \\\n", " Run \n", "MP_NG_GRID 1 0.0 0.0 12102.618442 1.389018 0.026794 0.0 \n", "\n", " C_inv_an Annual_Use Category Category_2 Sector \n", " Run \n", "MP_NG_GRID 1 0.0 12102.618442 Others Gas Infrastructure Others " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Display a sample from the annual results DataFrame\n", "display(results_ch_n.postprocessing['df_annual'].sample())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "- Displays a random sample from the annual results DataFrame for inspection.\n", "\n", "#### Plot Investment Costs by Sector" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:59.945882Z", "start_time": "2025-03-17T14:52:59.812442Z" } }, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Plot annualized investment costs aggregated by sector\n", "fig = plot_parametrisation(results=results_ch_n, variable=\"C_inv_an\", category=\"Sector\", \n", " labels = {\"Run\": \"Simulation Run\",\"C_inv_an\": \"Annualized investment costs [MCHF/y]\"})\n", "fig.show(renderer=\"notebook\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "- **`variable=\"C_inv_an\"`**: Specifies that we want to plot annual investment costs.\n", "- **`category=\"Sector\"`**: Aggregates the costs by sector.\n", "\n", "#### Plot Investment Costs by Category\n" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:52:59.993906Z", "start_time": "2025-03-17T14:52:59.946535Z" } }, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Plot annualized investment costs aggregated by category\n", "fig = plot_parametrisation(results=results_ch_n, variable=\"C_inv_an\", category=\"Category\")\n", "fig.show(renderer=\"notebook\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "- Aggregates the costs by category.\n", "\n", "#### Plot Investment Costs by Sub-Category" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:53:00.042719Z", "start_time": "2025-03-17T14:52:59.994951Z" } }, "outputs": [ { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Plot annualized investment costs aggregated by sub-category\n", "fig = plot_parametrisation(results=results_ch_n, variable=\"C_inv_an\", category=\"Category_2\")\n", "fig.show(renderer=\"notebook\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "- **`Category_2`**: A more detailed level of categorization, allowing for a finer analysis.\n", "\n", "### Save and Load Results\n", "\n", "To preserve the results of the multiple runs and avoid re-running the optimizations, we can save the results to a file and load them later.\n", "\n", "#### Define Save Function" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:53:00.045898Z", "start_time": "2025-03-17T14:53:00.043619Z" } }, "outputs": [], "source": [ "def save_result_to_pickle(data, filename):\n", " \"\"\"\n", " Save the Result object to a pickle file.\n", "\n", " Parameters:\n", " data: The Result object to save.\n", " filename (str): The file path to save the object to.\n", " \"\"\"\n", " with open(filename, 'wb') as fp:\n", " pickle.dump(data, fp, protocol=pickle.HIGHEST_PROTOCOL)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "#### Define Load Function" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:53:00.048871Z", "start_time": "2025-03-17T14:53:00.046721Z" } }, "outputs": [], "source": [ "def load_result_from_pickle(filename):\n", " \"\"\"\n", " Load the Result object from a pickle file.\n", "\n", " Parameters:\n", " filename (str): The file path to load the object from.\n", "\n", " Returns:\n", " The loaded Result object.\n", " \"\"\"\n", " with open(filename, 'rb') as handle:\n", " result = pickle.load(handle)\n", " return result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "> **Note**: These utility functions could be integrated into the EnergyScope library for convenience.\n", "\n", "#### Save the Results" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:53:00.066600Z", "start_time": "2025-03-17T14:53:00.049436Z" } }, "outputs": [], "source": [ "# Save the result object to a pickle file\n", "save_result_to_pickle(results_ch_n, \"tutorial_input/results_ch_n.pickle\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "#### Clear the Results Variable" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:53:00.072920Z", "start_time": "2025-03-17T14:53:00.068115Z" } }, "outputs": [], "source": [ "# Empty the variable to simulate a fresh environment\n", "results_ch_n = None " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "#### Load the Results" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:53:00.105702Z", "start_time": "2025-03-17T14:53:00.074690Z" } }, "outputs": [], "source": [ "# Load the saved result from the pickle file\n", "results_ch_n = load_result_from_pickle(\"tutorial_input/results_ch_n.pickle\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "#### Display Total Cost" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "ExecuteTime": { "end_time": "2025-03-17T14:53:00.113210Z", "start_time": "2025-03-17T14:53:00.106781Z" } }, "outputs": [ { "data": { "application/vnd.microsoft.datawrangler.viewer.v0+json": { "columns": [ { "name": "index", "rawType": "int64", "type": "integer" }, { "name": "TotalCost", "rawType": "float64", "type": "float" }, { "name": "Run", "rawType": "int64", "type": "integer" } ], "ref": "3f46b413-9436-4410-b8d5-db77e83a923f", "rows": [ [ "0", "8639.711875643636", "1" ], [ "0", "8627.882622795169", "2" ], [ "0", "8839.060852123352", "3" ], [ "0", "9070.17096846102", "4" ], [ "0", "9317.948509854092", "5" ], [ "0", "9603.542275300759", "6" ], [ "0", "9898.659555646724", "7" ], [ "0", "10195.80547165489", "8" ], [ "0", "10488.03583420024", "9" ], [ "0", "10776.62437431914", "10" ], [ "0", "11066.1094723285", "11" ] ], "shape": { "columns": 2, "rows": 11 } }, "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TotalCostRun
08639.7118761
08627.8826232
08839.0608523
09070.1709684
09317.9485105
09603.5422756
09898.6595567
010195.8054728
010488.0358349
010776.62437410
011066.10947211
\n", "
" ], "text/plain": [ " TotalCost Run\n", "0 8639.711876 1\n", "0 8627.882623 2\n", "0 8839.060852 3\n", "0 9070.170968 4\n", "0 9317.948510 5\n", "0 9603.542275 6\n", "0 9898.659556 7\n", "0 10195.805472 8\n", "0 10488.035834 9\n", "0 10776.624374 10\n", "0 11066.109472 11" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Show the total cost from the loaded results\n", "results_ch_n.variables['TotalCost']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "- Accesses and displays the total cost from each run in the loaded results, verifying that the data was correctly saved and loaded.\n", "\n", "---\n", "\n", "By following these steps, you can:\n", "\n", "- **Perform multiple optimization runs** with varying parameters to analyze different scenarios.\n", "- **Visualize the results** of specific runs using Sankey diagrams, providing insight into energy flows.\n", "- **Analyze the impact** of parameter changes on key variables like investment costs through parametrization plots.\n", "- **Save and load the results** for future analysis, enhancing reproducibility and efficiency.\n", "\n", "This approach is particularly useful for conducting sensitivity analyses, exploring different energy strategies, and gaining deeper insights into the energy system's behavior under various conditions.\n", "\n", "> **Note**: Ensure that the Excel file `\"tutorial_input/param_run_es_n_infrastructure_ch_2050.xlsx\"` and the pickle file paths are correctly set in your environment. Additionally, the `plot_parametrisation` function may require specific data structures; refer to the EnergyScope documentation for more details.\n", "\n", "By leveraging these techniques, you can effectively utilize the EnergyScope model for comprehensive energy system analysis." ] } ], "metadata": { "kernelspec": { "display_name": "venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.2" } }, "nbformat": 4, "nbformat_minor": 2 }