Rolling horizon: option to pin storage SoC at window seams

オープン
#1,997 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

Start with optimize_with_rolling_horizon() in abstract.py and read the existing rolling-horizon example and water-value example (#1492). The issue describes the desired seam calculation, option behavior, and prototype tests, but asks whether the feature belongs in the API and whether to wait for related changes (#1973, #1987, #1934). Confirm that direction with maintainers before implementing; done means seam SoC is pinned while overlap remains free and existing settings are restored even if a solve raises.

索引モデルが issue の本文から書いたものです。

説明

Note: AI-assisted. Claims about the current behaviour and the prototype were machine-checked: the upstream code was read at e74a67ee, and the numbers below come from running the prototype branch with HiGHS.

Describe the feature you'd like to see

optimize_with_rolling_horizon() has no foresight past the end of a window. When a window is shorter than the natural storage cycle, energy left in storage at the end of the window has no value to the LP, so it tends to discharge it. The next window then starts with storage that is too low.

The water-value example (#1492) fixes this by giving the store a time-varying marginal_cost taken from a perfect-foresight run. That works well, but it needs the perfect-foresight run first, which is exactly what rolling horizon is meant to avoid on large models.

I'd like a cheaper option: fix the state of charge at each window seam to a fraction of capacity. Every window then behaves as a closed cycle that ends where the next one starts.

n.optimize.optimize_with_rolling_horizon(
    horizon=24, overlap=6, pin_terminal_soc=True, boundary_soc=0.5
)

The pin goes on the last snapshot a window commits (start + horizon - overlap - 1), not on the last snapshot of the window, so the overlap stays free as lookahead. It uses the existing state_of_charge_set and e_set, temporarily switches off cyclic_state_of_charge / e_cyclic, and restores both flags and set points after the run, also when a solve raises.

Users can do this today by computing the seams themselves and filling e_set, but it's easy to get wrong with overlap > 0. My own first version pinned the window end instead of the seam, and the store still drained at every seam.

I have a working prototype with tests on my fork: MaykThewessen/PyPSA@feat/rolling-horizon-closed-cycle (+112/-27 lines in abstract.py, plus tests).

Two questions before I open a PR:

  1. Is this something you want in optimize_with_rolling_horizon(), or would you rather see it as a short recipe in the rolling-horizon example next to the water values?
  2. If it goes in, should I wait until #1973 / #1987 land? Both change the same function. I also see #1934 moving storage to Store, so I could restrict it to stores only if that fits the plan better.
Prototype details (AI-generated summary)
  • boundary_soc is a float in [0, 1], applied as a fraction of p_nom * max_hours (StorageUnit) or e_nom (Store).
  • Existing user set points in state_of_charge_set / e_set are kept; the frames are reindexed, not rebuilt.
  • Probe with horizon 8, overlap 3, 24 snapshots and one 10 MW / 4 h battery against a sinusoidal price: with the pin on the window end instead of the seam, SoC at the seams (snapshots 4, 9, 14, 19) was 0, 30, 30, 0 MWh; with seam pinning it is 20 MWh (50 %) at each.
  • Tests: pin holds at the seams for overlap 0 and 3, with StorageUnit and Store alone and together; user set points survive; flags and set points are restored after success and after a raised solve; out-of-range boundary_soc raises.
主要言語
Python
スター
2.2k
フォーク
732
平均マージ
3日 59分
マージ済み PR(30日)
58

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PyPSA/PyPSA のほかの issue

PyPSA/PyPSA の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。