Global Sensitivity Analysis¶
This example demonstrates how PyPSA can be combined with Global Sensitivity Analysis (GSA) methods using Sobol indices to understand how capital cost uncertainties affect system design and costs. The third-party tool SALib is used for this example. It makes sense to first read the basic SALib tutorial to understand the concepts before diving into this example.
Import Required Libraries¶
We'll need PyPSA for energy system modelling and SALib for global sensitivity analysis functions. We'll also use multiprocessing to speed up the evaluation of multiple scenarios.
import logging
import multiprocessing as mp
import warnings
from functools import partial
import matplotlib.pyplot as plt
import numpy as np
from SALib.analyze.sobol import analyze as sobol_analyze
from SALib.sample.sobol import sample as sobol_sample
import pypsa
THREADS = min(mp.cpu_count(), 15)
# Set to True for interaction effects
SECOND = False
# Small number of samples for demo; use 64+ for real analysis
SAMPLES = 8
logging.basicConfig(level=logging.ERROR)
logging.getLogger("linopy").setLevel(logging.ERROR)
warnings.simplefilter(action="ignore", category=FutureWarning)
Create Base PyPSA Model¶
We will re-use the model.energy style example network. The model is a single-node capacity expansion model with only wind, solar, battery and hydrogen storage to cover a year of hourly demand. To save some computation time, we will sample just every fifth day of the year. Each day is considered at 3-hourly resolution, so we will have 8 snapshots per representative day.
n = pypsa.examples.model_energy()
selected = n.snapshots.normalize().unique()[::5]
snapshots = n.snapshots[n.snapshots.normalize().isin(selected)]
n.set_snapshots(snapshots)
n.snapshot_weightings[["objective", "generators"]] *= 5
Define Uncertainty Parameters¶
We specify which technology costs are uncertain, how much they can vary and what distribution to use for sampling. The uncertainties are defined as scaling factors relative to the base investment costs for solar, wind, batteries and electrolysers.
uncertainty_space = {
"num_vars": 4,
"names": ["solar", "wind", "battery", "electrolysis"],
"bounds": [
[0.6, 1],
[0.8, 1],
[0.6, 1],
[0.6, 1],
],
"dists": ["unif"] * 4,
}
Generate Sample Points¶
Sobol sampling creates a systematic set of parameter combinations that efficiently explores the uncertainty space (low-discrepancy series). Each row represents one scenario to simulate.
samples = sobol_sample(uncertainty_space, SAMPLES, calc_second_order=SECOND)
display(samples[:4])
display(len(samples))
array([[0.60888159, 0.94023996, 0.9771957 , 0.95426363],
[0.61460719, 0.94023996, 0.9771957 , 0.95426363],
[0.60888159, 0.99111789, 0.9771957 , 0.95426363],
[0.60888159, 0.94023996, 0.7002083 , 0.95426363]])
48
Define Evaluation Function¶
This function takes the sampled cost scaling factors, applies them to the network, runs optimization, and extracts the total system cost and optimal capacities.
def evaluate(
s: np.ndarray, n: pypsa.Network
) -> tuple[float, float, float, float, float]:
"""Optimize with given scaling factors and evaluate system costs and capacities."""
n_sim = n.copy()
attr = "capital_cost"
n_sim.generators.loc["solar", attr] = s[0] * n.generators.loc["solar", attr]
n_sim.generators.loc["wind", attr] = s[1] * n.generators.loc["wind", attr]
n_sim.storage_units.loc["battery storage", attr] = (
s[2] * n.storage_units.loc["battery storage", attr]
)
n_sim.links.loc["electrolysis", attr] = s[3] * n.links.loc["electrolysis", attr]
n_sim.optimize(solver_name="gurobi")
tsc = (n_sim.statistics.opex().sum() + n_sim.statistics.capex().sum()) / 1e9
solar = n_sim.generators.p_nom_opt["solar"] / 1e3
wind = n_sim.generators.p_nom_opt["wind"] / 1e3
battery = n_sim.storage_units.p_nom_opt["battery storage"] / 1e3
electrolysis = n_sim.links.p_nom_opt["electrolysis"] / 1e3
return tsc, solar, wind, battery, electrolysis
Run Sensitivity Analysis¶
We use parallel processing to evaluate all sample scenarios simultaneously, significantly reducing computation time. Each simulation optimizes the energy system with different cost assumptions and returns the total system cost and optimal capacities.
with mp.Pool(processes=THREADS) as pool:
func = partial(evaluate, n=n)
results = np.array(pool.map(func, samples))
display(results[:4])
Set parameter WLSAccessID
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-5sa8jtw0.lp
Read LP format model from file /tmp/linopy-problem-v818p6st.lp
Reading time = 0.02 seconds
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-4pamiui6.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-7bne1mx4.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-add8c7e7.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-0i5wcug_.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-eje6sh97.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-j3mkjhd5.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-rl96xrs9.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-zeio__c0.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-qb05mq9l.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-0a4_qo45.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-sls8qv0_.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-jxe_q4nh.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-b8btn36l.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-hv4ts6ub.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-1c9bd_kr.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-wws5my1u.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-v4duf7vi.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-em3uap47.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-su1vwpd6.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-rxlokeza.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-qjwyremc.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-_m5x9rq8.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-v0mn_k7n.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-anjtl2ui.lp
Reading time = 0.02 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-slfmzcjz.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-q6x8sqt7.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-4rza_sb8.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-ow6u8s44.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-zvgjca8h.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-6ry2jlo2.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-qhl5b1ap.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-rahv3ivb.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-j44g5trk.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-ni9fps1w.lp
Warning: environment still referenced so free is deferred (Continue to use WLS)
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-c48_jys1.lp
Reading time = 0.04 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Warning: environment still referenced so free is deferred (Continue to use WLS)
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-lcn47z1j.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-s9jp1wgj.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-t_schbw1.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-80yrznoh.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-65in6nge.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-z359kxxm.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-73_gczg1.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-dk1rttjs.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-4r7bqnxm.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-bczx57ac.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-xzxueh_7.lp
Reading time = 0.03 seconds
obj: 12854 rows, 5846 columns, 24832 nonzeros
Set parameter LogToConsole to value 0
Warning: environment still referenced so free is deferred (Continue to use WLS)
Warning: environment still referenced so free is deferred (Continue to use WLS)
array([[ 6.03650597, 35.8147374 , 26.62305654, 20.22047525, 1.69199388],
[ 6.0470352 , 35.8147374 , 26.62305654, 20.22047525, 1.69199388],
[ 6.17305335, 35.54798941, 25.9001417 , 21.51815859, 1.77746486],
[ 5.65736756, 36.14040398, 26.52132397, 21.83879884, 1.49436637]])
Visualize Sensitivity Indices¶
Sobol analysis calculates sensitivity indices showing how much each technology's cost uncertainty contributes to variability in system outcomes (i.e. total system cost and expanded capacities). The larger the index, the more impact that technology's cost has on the outcome. First-order indices show direct effects. Error bars indicate 95% confidence intervals. Note that for SAMPLES = 16, the confidence intervals may be quite large, so larger sample sizes are recommended for more reliable results.
outputs = ["Total Cost", "Solar", "Wind", "Battery", "Electrolysis"]
for i, output in enumerate(outputs):
sobol_analyze(uncertainty_space, results[:, i], calc_second_order=SECOND).plot()
plt.gcf().suptitle(f"{output} Sensitivity")
These illustrative results show that solar and battery costs have the largest impact on total system cost. The deployment of solar also substantially depends on the cost of batteries (next to its own cost).
For more global sensitivity analysis functions, like the Method of Morris, see the SALib documentation.
References¶
Herman and Usher (2017). SALib: An open-source Python library for Sensitivity Analysis, Journal of Open Source Software (JOSS).
Usher et al. (2023), Global sensitivity analysis to enhance the transparency and rigour of energy system optimisation modelling, Open Research Europe.
Tröndle et al. (2020), Trade-Offs between Geographic Scale, Cost, and Infrastructure Requirements for Fully Renewable Electricity in Europe, Joule.
Neumann et al. (2023), Broad ranges of investment configurations for renewable power systems, robust to cost uncertainty and near-optimality, iScience.