gtopt/lp_replay_buffer.hpp file

LpReplayBuffer — replay state for LowMemoryMode reconstruct.

LpReplayBuffer owns the 5 replay-on-reconstruct fields that previously lived directly on LinearInterface:

  • m_dynamic_cols_ — columns added after load_flat (typically α).
  • m_dynamic_rows_ — structural rows added after load_flat (e.g. cascade elastic-target constraints).
  • m_active_cuts_ — net active Benders cuts.
  • m_pending_col_bounds_ — overrides applied via set_col_low_raw/set_col_upp_raw after load_flat so they survive the release→reconstruct cycle.
  • m_replaying_ — defence-in-depth flag set inside apply_post_load_replay's bulk replay so the auto-record path on add_col/add_row short-circuits.

Extraction is Phase 2a of the LinearInterface split.

Lifecycle:

  • Default-constructed: all empty / false.
  • Every dynamic addition is mirrored here regardless of mode — including under off, because system_lp.cpp:560 saves a snapshot for every cell and sddp_aperture.cpp uses clone_from_flat(with_replay=true) to build the per-aperture clones. That path needs the buffer as the SOLE source of post-snapshot cuts and dynamic cols (without it, aperture clones drop every Benders cut — the large hydrothermal case regression 2026-05-11). Under compress (and the legacy snapshot alias) the buffer additionally feeds LinearInterface::apply_post_load_replay() when the backend is reloaded.

Invariants (asserted in debug, see validate_consistency()):

  • R1. Default-constructed LpReplayBuffer{} reports all vectors empty, replaying() == false, and zero pending col bounds.
  • R2. record_*_if_tracked(...) always records. The _if_tracked suffix is retained for grep-friendliness with older code; the LowMemoryMode mode parameter was dropped 2026-05-13 (every caller passes the same effective value, and the rebuild mode that motivated mode-gating is gone).
  • R3. take_dynamic_cols() / take_active_cuts() move-out the internal vector and leave the buffer in the default-constructed state for that field.
  • R4. update_dynamic_col_lowb(...) / update_dynamic_col_bounds(...) return true iff a matching (class_name, variable_name) entry was found and updated. Linear search — replay buffers stay tiny (≤ a few alpha cols).
  • R5. record_cut_deletion(deleted, base_numrows) is a no-op when active_cuts is empty. Otherwise it removes the cuts at the supplied global row indices (offset by base_numrows to get the m_active_cuts_ index).
  • R6. set_replaying(true) / set_replaying(false) flip the flag idempotently. An RAII helper ReplayGuard is provided for scope-bound use inside apply_post_load_replay.

Namespaces

namespace gtopt

Classes

class gtopt::LpReplayBuffer
Replay state for LinearInterface low-memory reconstruct.
class gtopt::LpReplayBuffer::ReplayGuard