LpReplayBuffer class
#include <gtopt/lp_replay_buffer.hpp>
Replay state for LinearInterface low-memory reconstruct.
Owns the dynamic-cols / dynamic-rows / active-cuts vectors, the pending-col-bounds map, and the in-replay flag. See the file- level comment for the contract.
Public types
- class ReplayGuard
Public functions
- auto active_cuts() const -> std::span<const SparseRow> noexcept
- auto active_cuts_capacity() const -> std::size_t noexcept
- auto active_cuts_mut() -> std::vector<SparseRow>& noexcept
- auto active_cuts_size() const -> std::size_t noexcept
- void clear() noexcept
- auto dynamic_cols() const -> std::span<const SparseCol> noexcept
- auto dynamic_cols_mut() -> std::vector<SparseCol>& noexcept
- auto dynamic_cols_size() const -> std::size_t noexcept
- auto dynamic_rows() const -> std::span<const SparseRow> noexcept
- auto dynamic_rows_mut() -> std::vector<SparseRow>& noexcept
- auto dynamic_rows_size() const -> std::size_t noexcept
- auto is_empty() const -> bool noexcept
- auto pending_coeffs() const -> const std::map<std::pair<RowIndex, ColIndex>, double>& noexcept
- auto pending_coeffs_size() const -> std::size_t noexcept
- auto pending_col_bounds() const -> const std::map<ColIndex, std::pair<double, double>>& noexcept
- auto pending_col_bounds_size() const -> std::size_t noexcept
- auto pending_rhs() const -> const std::map<RowIndex, double>& noexcept
- auto pending_rhs_size() const -> std::size_t noexcept
- void record_cut_deletion(std::span<const int> deleted_indices, int base_numrows)
- void record_cut_row_if_tracked(SparseRow row)
- void record_dynamic_col_if_tracked(SparseCol col)
- void record_dynamic_row_if_tracked(SparseRow row)
- auto replaying() const -> bool noexcept
- void reserve_active_cuts(std::size_t n)
- void restore_active_cuts(std::vector<SparseRow> cuts) noexcept
- void restore_dynamic_cols(std::vector<SparseCol> cols) noexcept
- void set_pending_coeff(RowIndex row, ColIndex col, double value) noexcept
- void set_pending_col_lower(ColIndex idx, double new_lower, double current_upper) noexcept
- void set_pending_col_upper(ColIndex idx, double current_lower, double new_upper) noexcept
- void set_pending_rhs(RowIndex row, double value) noexcept
- Insert or update the raw LP RHS at
row. Last write wins. - void set_replaying(bool v) noexcept
- auto take_active_cuts() -> std::vector<SparseRow> noexcept
- Move out the active cuts and leave the internal vector empty.
- auto take_dynamic_cols() -> std::vector<SparseCol> noexcept
- Move out the dynamic columns and leave the internal vector empty.
- auto update_dynamic_col_bounds(std::string_view class_name, std::string_view variable_name, double new_lowb, double new_uppb) -> bool noexcept
- auto update_dynamic_col_bounds(std::string_view class_name, std::string_view variable_name, Uid variable_uid, double new_lowb, double new_uppb) -> bool noexcept
- auto update_dynamic_col_lowb(std::string_view class_name, std::string_view variable_name, double new_lowb) -> bool noexcept
Function documentation
std::size_t gtopt:: LpReplayBuffer:: active_cuts_capacity() const noexcept
Allocated capacity of the active-cut buffer. Exposed so tests can assert that clear() actually RELEASES the buffer (size alone cannot distinguish a freed vector from a cleared-but-still-allocated one).
std::vector<SparseCol>& gtopt:: LpReplayBuffer:: dynamic_cols_mut() noexcept
Mutable reference to the dynamic-cols vector — needed by the add_cols(span) call in apply_post_load_replay which consumes the span by value (and may extend m_scaling_.col_scales based on col.scale != 1.0 entries).
bool gtopt:: LpReplayBuffer:: is_empty() const noexcept
R1 debug self-check. Returns true iff the buffer is in the default-constructed state.
void gtopt:: LpReplayBuffer:: record_cut_deletion(std::span<const int> deleted_indices,
int base_numrows)
R5 — drop cut entries at global row indices deleted_indices, offset by base_numrows to get the active_cuts index. Indices outside [base_numrows, base_numrows + active_cuts.size()) are silently skipped (defence against caller bugs). No-op when active_cuts is empty.
void gtopt:: LpReplayBuffer:: set_pending_coeff(RowIndex row,
ColIndex col,
double value) noexcept
Insert or update the raw LP coefficient at (row, col). Last write wins — repeated updates on the same cell overwrite without growing the map.
void gtopt:: LpReplayBuffer:: set_pending_col_lower(ColIndex idx,
double new_lower,
double current_upper) noexcept
Insert or update the lower bound for idx. When inserting a fresh entry, the caller supplies the current upper bound from the live backend so a single-sided update doesn't reset the unset side to zero on replay.
void gtopt:: LpReplayBuffer:: set_pending_col_upper(ColIndex idx,
double current_lower,
double new_upper) noexcept
Insert or update the upper bound for idx. When inserting a fresh entry, the caller supplies the current lower bound from the live backend.
bool gtopt:: LpReplayBuffer:: update_dynamic_col_bounds(std::string_view class_name,
std::string_view variable_name,
double new_lowb,
double new_uppb) noexcept
Update both bounds of the first matching dynamic column. Returns true iff the entry was found.
bool gtopt:: LpReplayBuffer:: update_dynamic_col_bounds(std::string_view class_name,
std::string_view variable_name,
Uid variable_uid,
double new_lowb,
double new_uppb) noexcept
Update both bounds of the dynamic column matching (class_name, variable_name, variable_uid). Needed by CutSharingMode::multicut, where the N future-cost columns (varphi_0..N-1) all share the α class/variable name and differ ONLY by variable_uid = sddp_alpha_uid + source_scene; the name-only overload above would always match varphi_0. Returns true iff the entry was found.
bool gtopt:: LpReplayBuffer:: update_dynamic_col_lowb(std::string_view class_name,
std::string_view variable_name,
double new_lowb) noexcept
Update the lower bound of the first matching dynamic column. Returns true iff the entry was found. Linear search — buffer stays tiny in practice (≤ a few alpha cols).