gtopt::SceneCutStore class

Per-scene container for SDDP Benders cuts (step 1 of the docs/analysis/investigations/sddp/sddp_cut_store_split_plan_2026-04-30.md refactor).

Wraps the per-scene std::vector<StoredCut> plus the per-scene snapshot that cut-sharing reads to identify newly-added cuts. Single-writer during the forward/backward pass (phase access within a scene is serial), so no mutex is needed.

In step 1 the methods on SDDPCutManager continue to do all the per-scene work; this type just changes the layout of m_scene_cuts_ from vector<StoredCut> to SceneCutStore. Subsequent migration steps move per-scene operations onto this class proper.

The class exposes vector-like forwarders (size, empty, begin/end, front/back, operator[], push_back, clear, erase, resize) so existing call sites that read or mutate the per-scene vector compile unchanged after the layout swap. Direct access to the underlying vector is available via cuts() for the rare sites that need to call std::erase_if or other free algorithms specialised on std::vector.

Constructors, destructors, conversion operators

SceneCutStore() defaulted

Public functions

auto back() const -> const auto& noexcept
auto back() -> auto& noexcept
auto begin() const -> auto noexcept
auto begin() -> auto noexcept
auto cbegin() const -> auto noexcept
auto cend() const -> auto noexcept
void clear() noexcept
auto clear_with_lp(PlanningLP& planning_lp, SceneIndex scene_index, bool keep_feasibility = false) -> std::ptrdiff_t
auto cuts() const -> const std::vector<StoredCut>& noexcept
auto cuts() -> std::vector<StoredCut>& noexcept
auto cuts_before() const -> std::size_t noexcept
template<class... Args>
auto emplace_back(Args && ... args) -> auto&
auto empty() const -> bool noexcept
auto end() const -> auto noexcept
auto end() -> auto noexcept
template<class It>
auto erase(It first, It last) -> auto
template<class It>
auto erase(It it) -> auto
void forget_first(std::ptrdiff_t count)
auto front() const -> const auto& noexcept
auto front() -> auto& noexcept
auto operator[](std::size_t i) const -> const auto& noexcept
auto operator[](std::size_t i) -> auto& noexcept
void push_back(const StoredCut& c)
void push_back(StoredCut&& c)
void resize(std::size_t n)
void set_cuts_before(std::size_t n) noexcept
auto size() const -> auto noexcept
void store(const SparseRow& cut, CutType type, RowIndex row, SceneUid scene_uid_val, PhaseUid phase_uid_val)

Function documentation

std::ptrdiff_t gtopt::SceneCutStore::clear_with_lp(PlanningLP& planning_lp, SceneIndex scene_index, bool keep_feasibility = false)

Parameters
planning_lp PlanningLP whose cells hold the cut rows.
scene_index Scene that owns this store's cuts.
keep_feasibility When true (elastic_filter_mode = state_repair / farkas_recursive), CutType::Feasibility rows are EXEMPT from the rollback: PLP's feasibility cuts are bound-consistent state-space constraints valid independently of the iteration that produced them, and PLP keeps them for the whole run. Only optimality rows are deleted; kept cuts get their LP row indices shifted down by the number of deleted rows below them.

Drop every cut this scene has accumulated, deleting matching LP rows from each (scene_index, phase) cell via LinearInterface::delete_rows + SystemLP::record_cut_deletion. Used by SDDPOptions::forward_infeas_rollback to roll back a scene declared infeasible in the forward pass — both forward-pass feasibility cuts and earlier backward-pass optimality cuts go. Returns the number of LP rows actually deleted.

scene_index is required: it identifies which PlanningLP::system(s, p) cells own the rows (cuts in this store live on (scene_index, *) cells by ownership invariant). The caller already has it in scope.

std::vector<StoredCut>& gtopt::SceneCutStore::cuts() noexcept

Mutable view; used by call sites that need std::erase_if(cuts(), ...) or other free algorithms specialised on std::vector<T>.

std::size_t gtopt::SceneCutStore::cuts_before() const noexcept

Cut count snapshot before the backward pass starts. The cut- sharing pass uses cuts().size() - cuts_before() to identify newly-added cuts. Stored per-scene here (replaces the parallel m_scene_cuts_before_ vector that the legacy class kept beside m_scene_cuts_).

void gtopt::SceneCutStore::forget_first(std::ptrdiff_t count)

Erase the first count cuts from this scene (clamped to the current size). Used by the manager-level forget_first_cuts pass that walks every scene applying the same cap. The per-scene erase is the only piece of forget_first_cuts that is naturally per-scene; the cross-scene name-set + row-shift bookkeeping stays on the manager because it spans every per-scene store.

void gtopt::SceneCutStore::store(const SparseRow& cut, CutType type, RowIndex row, SceneUid scene_uid_val, PhaseUid phase_uid_val)

Push one cut into this scene's per-scene vector. Single-writer during the forward/backward pass (phase access within a scene is serial), so no mutex is needed even when multiple scene workers call store concurrently — each touches its own SceneCutStore.