Post · 23 min read· pp. 403–433

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 a thread pool to evaluate scenarios in parallel — threads work reliably in notebooks on every operating system, and the solver still runs in parallel because it releases the GIL during optimisation.

In [2]:

Copied! diagram

ipynb
import logging
import warnings
from functools import partial
from multiprocessing import cpu_count
from multiprocessing.pool import ThreadPool

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(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)

import logging import warnings from functools import partial from multiprocessing import cpu_count from multiprocessing.pool import ThreadPool 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(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.

In [3]:

Copied! diagram

ipynb
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

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.

In [4]:

Copied! diagram

ipynb
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,
}

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.

In [5]:

Copied! diagram

ipynb
samples = sobol_sample(uncertainty_space, SAMPLES, calc_second_order=SECOND)
display(samples[:4])
display(len(samples))

samples = sobol_sample(uncertainty_space, SAMPLES, calc_second_order=SECOND) display(samples[:4]) display(len(samples))

text
array([[0.80025365, 0.88202516, 0.72455177, 0.9160872 ],
       [0.62382879, 0.88202516, 0.72455177, 0.9160872 ],
       [0.80025365, 0.89967042, 0.72455177, 0.9160872 ],
       [0.80025365, 0.88202516, 0.98439865, 0.9160872 ]])
text
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.

In [6]:

Copied! diagram

ipynb
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

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.

In [7]:

Copied! diagram

ipynb
with ThreadPool(processes=THREADS) as pool:
    func = partial(evaluate, n=n)
    results = np.array(pool.map(func, samples))
display(results[:4])

with ThreadPool(processes=THREADS) as pool: func = partial(evaluate, n=n) results = np.array(pool.map(func, samples)) display(results[:4])

text
Set parameter WLSAccessID
Set parameter WLSAccessID
text
Set parameter WLSSecret
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
Set parameter WLSAccessID
Set parameter LicenseID to value 2537914
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Set parameter WLSAccessID
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-pkbldcn1.lp
Read LP format model from file /tmp/linopy-problem-8so1iscq.lp
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
Read LP format model from file /tmp/linopy-problem-7onreuiq.lp
Reading time = 0.05 seconds
Reading time = 0.03 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
obj: 14022 rows, 6430 columns, 26000 nonzeros
Reading time = 0.02 seconds
text
Set parameter LogToConsole to value 0
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
Set parameter LogToConsole to value 0
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-_z401ex0.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-8v7t336p.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-sk70ktp3.lp
text
Reading time = 0.03 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
Read LP format model from file /tmp/linopy-problem-nnyte47a.lp
text
Reading time = 0.03 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Read LP format model from file /tmp/linopy-problem-z3gzrqcx.lp
text
Reading time = 0.04 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-lkkxokyi.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-80e6id8l.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-rua7z1tr.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-3p5bqplq.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter WLSAccessID
Set parameter LicenseID to value 2537914
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
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
text
Read LP format model from file /tmp/linopy-problem-4xxgy4g6.lp
text
Reading time = 0.03 seconds
Read LP format model from file /tmp/linopy-problem-rpx2qyf1.lp
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
Set parameter WLSAccessID
text
Set parameter WLSSecret
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
Set parameter LicenseID to value 2537914
text
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
text
Read LP format model from file /tmp/linopy-problem-6k2bx70c.lp
Read LP format model from file /tmp/linopy-problem-9zutyqru.lp
text
Reading time = 0.02 seconds
Reading time = 0.04 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-25mpem3p.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSAccessID
Set parameter WLSSecret
text
Set parameter WLSSecret
Set parameter LicenseID to value 2537914
text
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-ebwe7hct.lp
Read LP format model from file /tmp/linopy-problem-o_t2w01m.lp
text
Reading time = 0.03 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
Set parameter LogToConsole to value 0
Set parameter WLSAccessID
text
Set parameter LogToConsole to value 0
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-xswyba_b.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-inuid4um.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-hkx7b0tk.lp
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Reading time = 0.02 seconds
Set parameter WLSAccessID
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Read LP format model from file /tmp/linopy-problem-cq_uj7x2.lp
text
Set parameter WLSSecret
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
Set parameter LicenseID to value 2537914
text
Set parameter LogToConsole to value 0
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-cw02gbm5.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-7i7z1_f6.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-2jb0faro.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
Set parameter WLSAccessID
text
Set parameter WLSSecret
Set parameter LogToConsole to value 0
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-h6w_t7n9.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-v8rfw3e_.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-u52ei2la.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-7p5zyben.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-2xn7z1da.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-gzry0my2.lp
text
Reading time = 0.03 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-p4o50vab.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-cmt7vh5y.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-yjjqztg9.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-os03ndf0.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
Set parameter WLSAccessID
text
Set parameter LicenseID to value 2537914
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-pb6wzwyg.lp
text
Reading time = 0.03 seconds
text
Read LP format model from file /tmp/linopy-problem-9hnlek6a.lp
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Reading time = 0.02 seconds
text
Set parameter LogToConsole to value 0
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-s98094_2.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-subugisa.lp
text
Reading time = 0.03 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-zu0k_h2n.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-fhv_r5r7.lp
text
Reading time = 0.03 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSAccessID
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
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
text
Read LP format model from file /tmp/linopy-problem-mr3_u7pz.lp
text
Reading time = 0.05 seconds
Read LP format model from file /tmp/linopy-problem-s1b4nqut.lp
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
Reading time = 0.03 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
Set parameter LogToConsole to value 0
text
Set parameter LogToConsole to value 0
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Warning: environment still referenced so free is deferred (Continue to use WLS)
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-wfw_s40b.lp
text
Reading time = 0.02 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Set parameter LicenseID to value 2537914
text
Read LP format model from file /tmp/linopy-problem-eojj0jz0.lp
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Reading time = 0.02 seconds
text
Read LP format model from file /tmp/linopy-problem-2y5jux0t.lp
text
Reading time = 0.02 seconds
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
Set parameter LogToConsole to value 0
text
Set parameter LogToConsole to value 0
text
Set parameter WLSAccessID
text
Set parameter WLSSecret
text
Set parameter LicenseID to value 2537914
text
Academic license 2537914 - for non-commercial use only - registered to l.___@tu-berlin.de
text
Read LP format model from file /tmp/linopy-problem-y_l72d_0.lp
text
Reading time = 0.03 seconds
text
obj: 14022 rows, 6430 columns, 26000 nonzeros
text
Set parameter LogToConsole to value 0
text
array([[ 5.8731752 , 34.54541324, 26.63417458, 23.60574103,  1.42527402],
       [ 5.55109025, 36.2027921 , 26.58674166, 21.87256598,  1.46763697],
       [ 5.92090852, 34.57342403, 26.58805152, 23.50993779,  1.44620469],
       [ 6.22773083, 35.77581909, 26.58818519, 20.18074455,  1.71270911]])

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.

In [8]:

Copied! diagram

ipynb
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")

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")

No description has been provided for this image

No description has been provided for this image

No description has been provided for this image

No description has been provided for this image

No description has been provided for this image

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

diagram 2026-08-05

diagram 2026-02-05