Skip to main content

BatiPathway

Renovation pathway optimizer for residential building stocks.

BatiPathway decides which renovation combination to apply to each building in a stock so as to minimize Net Present Cost (NPC) subject to policy constraints (GHG caps, energy caps, primary energy per m², electric peak, renovation-rate caps, minimum EPC class).

It implements the optimization core of SHAPE (Rit et al., Applied Energy 2024) as a vectorized multidimensional multiple-choice knapsack problem (MMCKP) — a binary MILP built with linopy and solved by default with the open-source HiGHS solver.

The heavy lifting — enumerating valid renovation combinations and simulating their energy consumption — happens in an upstream simulation package. BatiPathway consumes that package's output (a single xarray.Dataset) and performs only the selection optimization.

  • Status: 0.2.0 (Alpha)
  • Python: ≥ 3.11 (tested on 3.11, 3.12, 3.13)
  • License: MIT

Installation

pip install batipathway

Or from source:

git clone https://gitlab.com/energytransition/BatiPathway.git
cd BatiPathway
pip install -e ".[dev]"

Optional extras: gurobi (Gurobi solver), docs (Sphinx docs), plot (seaborn), dev (test/lint tooling).

Quick start

import batipathway as bp
import xarray as xr

# Dataset produced by the upstream simulation package
ds = xr.open_dataset("renovation_options.nc")

config = bp.ScenarioConfig(
    discount_rate=0.04,
    growth_rate=0.02,
    ghg_cap={2050: 2_000.0},
    pe_per_m2_cap={2050: 80.0},
)

model = bp.build_model(bp.validate_input(ds), config)
bp.solve(model)

decisions = bp.extract_decisions(model, ds)
kpis = bp.compute_kpis(decisions, ds, config)
print(f"Total NPC: {kpis['total_npc']:.2e} €")

The typical flow is validate_input → build_model → solve → extract_decisions → compute_kpis. See examples/ for runnable scenarios.

How it works

For each building b, the upstream package enumerates valid renovation combinations c (including the do-nothing baseline). BatiPathway introduces a binary variable x[b, c] ∈ {0, 1} and selects exactly one combination per building to minimize total NPC:

min  Σ_{b,c} x[b,c] · npc[b,c]

The per-combination NPC coefficient is pre-aggregated into a scalar (discounted investment plus block-aggregated, annualized energy billing), so the objective is a single inner product. Policy targets are added as linear constraints, each independently disableable via ScenarioConfig:

Constraint Config field SHAPE ref
Annual GHG cap ghg_cap O_GHG_12
Annual total final-energy cap energy_cap O_EC
Average primary energy per m² pe_per_m2_cap O_EC_EPC
Electric peak cap peak_electric_factor O_PE
Renovation-rate cap reno_count_cap O_nb_reno, Eq. (13)
Minimum EPC class min_epc_class_by_year O_class_EPC

See docs/theory.md for the full formulation and its mapping to the paper.

Input data

BatiPathway expects a single xarray.Dataset with these dimensions: building, combination, year, carrier, gesture_type. Required variables are valid, is_baseline, consumption, investment, is_renovating, and area, plus exogenous energy_price and emission_factor on a full annual year_full axis. Optional variables (peak_electric, epc_energy_class, pe_factor) unlock the corresponding constraints.

validate_input enforces the schema strictly; pass coerce=True for sensible automatic fixes. The authoritative reference is docs/input_schema.md, and a complete synthetic example lives in tests/fixtures.py:make_synthetic_dataset.

Documentation

The full documentation (built with Sphinx) lives in docs/:

Development

pip install -e ".[dev]"

ruff check src/ tests/          # lint
ruff format --check src/ tests/ # format check
mypy src/batipathway/           # type-check (strict)
pytest --cov                    # tests

These mirror the CI pipeline (.github/workflows/ci.yml), which runs on Python 3.11–3.13.

References

  • Rit, M., Thomas, A., Villot, J., Thorel, M., Garreau, E., & Girard, R. (2024). SHAPE: A temporal optimization model for residential buildings retrofit to discuss policy objectives. Applied Energy, 361, 122936. doi:10.1016/j.apenergy.2024.122936
  • Hofmann, F. (2023). Linopy: Linear optimization with n-dimensional labeled variables. Journal of Open Source Software, 8(84), 4823.

License

MIT — see LICENSE.

Metadata

Release files for batipathway 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for batipathway 0.2.0
File Size Uploaded Provenance Actions
batipathway-0.2.0.tar.gz 187.8 kB Without provenance Details for batipathway-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for batipathway 0.2.0
File Interpreter ABI Platform Actions
batipathway-0.2.0-py3-none-any.whl Python 3 none any Details for batipathway-0.2.0-py3-none-any.whl

Total release size: 219.6 kB

Release files / batipathway-0.2.0.tar.gz

Download URL batipathway-0.2.0.tar.gz
Size 187.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3cad6313a92ce607ebb1bd46f8ae9362ef7e99c914537cd17b76e0a34e96fbc1
BLAKE2b-256 checksum
How to use checksums
40a5d7a34ae065e3e96ec3fb9b3fa4dca87c828ddbaef28d5e49858dfea26048
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / batipathway-0.2.0-py3-none-any.whl

Download URL batipathway-0.2.0-py3-none-any.whl
Size 31.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9f559ffde361de4984e34fcf286718c5be0736decd32c79f933b99c52e25dd2
BLAKE2b-256 checksum
How to use checksums
269f8f7f0943e95cb4ed7506fe82a63c5692f7c597dfdcb59a2ed6ad5fe8a8ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for batipathway 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page