Cost-Benefit Analysis (CBA)¶
The Cost-Benefit Analysis (CBA) workflow is implemented in rules/cba.smk. Rules are organised into stages: Retrieve, Build MSV, Build rolling horizon, Postprocess and Benchmark. In addition, a Collect stage provides convenient target rules that run the workflow up to a specific stage, aggregating each stage's output across all configured wildcards.
Retrieve¶
Rule retrieve_tyndp_cba_projects¶
Downloads the CBA project explorer dataset, containing project definitions.
Rule retrieve_tyndp_cba_non_co2_emissions¶
Downloads non-CO₂ emission factors (NOx, SO₂, PM, etc.) used to compute B4 indicators.
Rule retrieve_cba_guidelines_reference_projects¶
Downloads the CBA Implementation Guidelines reference project table
(table_B1_CBA_Implementations_Guidelines_TYNDP2024.csv) used to reconcile SB investments
with CBA project definitions.
Rule retrieve_presolved_sb_networks¶
Downloads pre-solved SB networks from a previous Open-TYNDP release for use as CBA inputs
when cba.cba_scenario_input.use_presolved is true.
Build MSV¶
Rule clean_projects (checkpoint)¶
Extracts and cleans CBA transmission and storage projects from Excel exports.
Reads transmission projects from the "Trans.Projects" sheet of the CBA projects Excel file. For projects with multiple borders (newline-separated in the Excel), the script explodes these into separate rows, creating one row per border. Bus codes are extracted from the border strings (expected format: "BUS0-BUS1") and projects that don't match this format are filtered out with a warning.
Storage project extraction is not yet implemented and returns an empty DataFrame.
Inputs
data/tyndp_2024_bundle/cba_projects/20250312_export_transmission.xlsx: Excel file containing CBA transmission projectsdata/tyndp_2024_bundle/cba_projects/20250312_export_storage.xlsx: Excel file containing CBA storage projects (not yet processed)
Outputs
resources/cba/transmission_projects.csv: Cleaned CSV with columns:project_id: Integer project identifierproject_name: Project nameborder: Border string in format "BUS0-BUS1"p_nom 0->1: Transfer capacity increase from bus0 to bus1 (MW)p_nom 1->0: Transfer capacity increase from bus1 to bus0 (MW)bus0: Source bus code (4 alphanumeric characters)bus1: Destination bus code (4 alphanumeric characters)length_km: Total route length in km (from Trans.Investments)capex_meur: Total estimated CAPEX in MEUR (from Trans.Investments)-
underwater_fraction: Fraction of route that is offshore cable -
resources/cba/storage_projects.csv: Empty CSV with columns project_id and project_name (stub implementation)
Rule clean_tyndp_indicators¶
Extract and clean 2024 TYNDP CBA indicators for transmission and storage projects.
Reads scenario sheets (tabs starting with 2030/2040), maps shortcuts using the table on the "Readme" tab, and outputs a long-format CSV.
Rule simplify_sb_network¶
Simplify scenario building network for CBA analysis.
Creates the base CBA network with: - Fixed optimal capacities from scenario building - Hurdle costs on DC links - Extended primary fuel source capacities
Inputs
- Solved network from scenario building workflow
Outputs
resources/cba/networks/simple_{planning_horizons}.nc: Simplified network for CBA
Rule fix_reference_sb_to_cba¶
Build a Link dataframe of capacity corrections to align SB transmission projects with the CBA reference grid. A positive p_nom indicates capacity to add (potentially as a new link), while a negative p_nom indicates capacity to reduce on an existing link.
This only works for 2040, as we are assuming the 2030 reference grid does not need corrections.
Rule prepare_reference¶
Prepare CBA reference network with all TOOT projects included.
Takes the simplified network and ensures all projects that will be evaluated with TOOT methodology are present. This creates a common baseline for both MSV extraction and TOOT/PINT evaluation.
TODO: Implement project addition logic - currently passes through unchanged.
Rule build_msv_snapshot_weightings¶
Generate snapshot weightings for MSV extraction temporal aggregation.
Produces a CSV with resampled snapshot weightings at the configured
MSV extraction resolution. Follows the same logic as time_aggregation.py
for the supported resolution formats:
false: No aggregation, outputs empty CSV"Nsn": Representative snapshots (e.g., "2sn"), outputs empty CSV (handled directly byset_temporal_aggregation)"Nh": Hourly resampling (e.g., "24H", "48H"), outputs resampled weightings
Inputs
resources/cba/networks/reference_{planning_horizons}.nc: Reference network
Outputs
resources/cba/msv_snapshot_weightings_{planning_horizons}.csv: Snapshot weightings
Build rolling horizon¶
Rule prepare_rolling_horizon¶
Prepare network for cost-benefit analysis rolling horizon dispatch.
Modifications applied: - cyclic_carriers: keep cyclicity (short-term, e.g., batteries) - All other stores/storage units: disable cyclicity, apply marginal storage value, and set initial state of charge from perfect foresight for those that were cyclic in the full-year optimisation - Remove global constraints not needed for cost-benefit analysis - Disable volume limits (e_sum_min/e_sum_max)
Rule prepare_project¶
Prepare a single CBA project network based on the assigned method (TOOT/PINT).
TOOT removes the project from the reference network, PINT adds the project. Handles multi-border projects, creates links when needed, and validates capacity changes.
Solve¶
Rule solve_cba_msv_extraction¶
Extract marginal storage values via perfect foresight optimization.
Solves the reference network with perfect foresight (full year) to extract shadow prices from store energy balance constraints. These values capture the future value of stored energy and guide seasonal storage dispatch in rolling horizon optimization.
Inputs
resources/cba/networks/reference_{planning_horizons}.nc: Reference networkresources/cba/msv_snapshot_weightings_{planning_horizons}.csv: Snapshot weightings (optional)
Outputs
resources/cba/networks/msv_{planning_horizons}.nc: Network with marginal storage values in stores_t.mu_energy_balance
Rule solve_cba_reference_network¶
Solves the reference network using the rolling horizon approach. Shares the script with
solve_cba_network.
Solves optimal operation in rolling horizons for fixed capacities.
This script is used for optimizing the electrical network as well as the sector coupled network.
Description
The optimization is based on the network.optimize_with_rolling_horizon method.
Additionally, some extra constraints specified in solve_network are added, if
they apply to the dispatch.
Rule solve_cba_network¶
Solves the CBA network using the rolling horizon approach. Shares the script with solve_cba_reference_network.
Solves optimal operation in rolling horizons for fixed capacities.
This script is used for optimizing the electrical network as well as the sector coupled network.
Description
The optimization is based on the network.optimize_with_rolling_horizon method.
Additionally, some extra constraints specified in solve_network are added, if
they apply to the dispatch.
Postprocess¶
Rule make_indicators¶
Calculate CBA indicators by comparing reference and project scenarios.
This script computes the B1 indicator (operational cost difference) and other CBA metrics by analyzing the solved networks for reference and project cases.
PINT (Put In at a Time):
- Reference: Network WITHOUT any projects
- Project: Network WITH the specific project added
- B1 = OPEX(reference) - OPEX(with project)
TOOT (Take Out One at a Time):
- Reference: Network WITH all projects (current plan)
- Project: Network WITHOUT the specific project (removed)
- B1 = OPEX(without project) - OPEX(reference)
References:
- CBA guidelines, section 3.2.2: TOOT and PINT, page 23-24
- CBA implementation guidelines, section 5.1: B1 - SEW, page 58-59
Rule combine_indicators¶
Concatenate indicators from individual indicators files.
This script reads all individual project indicator CSV files and combines them into a single CSV file.
Rule plot_indicators¶
Create plots for CBA indicators.
This script reads the combined indicators CSV file and generates various plots to visualize the cost-benefit analysis results, including the B1 indicator (Total System Cost difference).
Benchmark¶
Rule plot_cba_benchmark¶
Plots per-project indicator benchmarking charts comparing computed indicators against
TYNDP 2024 reference values. Shares the script with plot_weather_benchmark.
Create benchmark plots for CBA indicators.
This script reads a indicators CSV file that includes Open-TYNDP rows and TYNDP benchmark rows, and generates plots comparing Open-TYNDP values to the 2024 TYNDP values.
Rule plot_weather_benchmark¶
Plots weather ensemble benchmarking charts from indicators aggregated across climate years.
Shares the script with plot_cba_benchmark.
Create benchmark plots for CBA indicators.
This script reads a indicators CSV file that includes Open-TYNDP rows and TYNDP benchmark rows, and generates plots comparing Open-TYNDP values to the 2024 TYNDP values.
Rule average_indicators_per_project_and_planning_horizon¶
Collect indicators from individual indicators files and create weighted average indicator.
This script reads all collected project indicators from the different weather years and calculates a new combined indicator which is stores in a new CSV file.
Rule summarize_indicators_per_project¶
Collect indicators from individual indicators files and create weighted average indicator.
This script reads all collected project indicators from the different weather years and calculates a new combined indicator which is stores in a new CSV file.
Rule summarize_all_indicators¶
Collect indicators from individual indicators files and create weighted average indicator.
This script reads all collected project indicators from the different weather years and calculates a new combined indicator which is stores in a new CSV file.
Collect¶
Aggregate rules that run the corresponding base rule across all configured wildcards. They do not have dedicated scripts.
Rule prepare_references¶
Aggregate prepare_reference outputs.
Rule collect_cba_scenario¶
Collects all per-scenario outputs (indicator plots, benchmark charts) into a single target
for a single climate year run (e.g. NT-cy2009).
Rule cba¶
Top-level target rule. Collects ensemble outputs from all climate year runs in a collection
scenario (e.g. NT-cyears) and the per-scenario results from nested runs.