cobre-sddp 0.8.2

Stochastic Dual Dynamic Programming (SDDP) for hydrothermal dispatch and energy planning
Documentation
//! Cut management data structures for the SDDP Future Cost Function (FCF).
//!
//! This module provides the per-stage cut pool, the all-stages FCF container,
//! the wire format for MPI exchange, cut-row construction for the LP, and
//! supporting types used to store, query, and prune Benders cuts during the
//! SDDP training loop.
//!
//! ## Contents
//!
//! - [`pool`] — [`CutPool`]: pre-allocated per-stage cut storage with
//!   deterministic slot assignment, activity tracking, and state evaluation.
//!   [`CutPool::set_active`] is the canonical toggle for the activity flag;
//!   [`CutPool::cuts_in_lp`] returns the LP-row-count metric (populated count).
//! - [`fcf`] — [`FutureCostFunction`]: all-stages container wrapping one
//!   [`CutPool`] per stage; provides the high-level API for the training loop,
//!   including [`FutureCostFunction::set_active`] and
//!   [`FutureCostFunction::cuts_in_lp`].
//! - [`wire`] — [`CutWireHeader`] and serialization functions for the MPI
//!   cut-exchange wire format (24-byte header + variable coefficient tail).
//! - [`row`] — cut-row construction for the SDDP LP; owns the cut-sign
//!   convention (`push_scaled_coefficient`
//!   negates the raw subgradient). Entry points:
//!   [`build_cut_row_batch_into`](row::build_cut_row_batch_into),
//!   [`append_new_cuts_to_lp`](row::append_new_cuts_to_lp),
//!   [`append_slots_to_lp`](row::append_slots_to_lp).
//! - [`row_map`] — [`CutRowMap`]: slot-to-LP-row mapping that preserves cut-pool
//!   slot identity for warm-start basis reconstruction.
//! - [`cut_selection`] — [`CutSelectionStrategy`] (and `CutMetadata`): per-cut
//!   activity tracking and the LML1/LML2 dominated-cut selection strategies.
//! - [`dcs`] — Dynamic Cut Selection: scores all resident cuts per stage.
//! - [`cut_sync`] — [`CutSyncBuffers`]: MPI cut-synchronization scratch space.
//! - [`basis_reconstruct`] — warm-start basis reconstruction for the baked
//!   hot path and the DCS path.
//!
//! ## Sentinel value
//!
//! [`WARM_START_ITERATION`] is the sentinel stored in
//! [`CutMetadata::iteration_generated`](crate::cut_selection::CutMetadata::iteration_generated) for every cut loaded from a policy
//! checkpoint.  Cut selection strategies may inspect this sentinel to apply
//! warm-start-specific pruning policies (e.g., exempt warm-start cuts from
//! LML1 deactivation).

pub mod basis_reconstruct;
pub mod cut_selection;
pub mod cut_sync;
pub mod dcs;
pub mod fcf;
pub mod pool;
pub mod row;
pub mod row_map;
pub mod wire;

pub use cut_selection::CutSelectionStrategy;
pub use cut_sync::CutSyncBuffers;
pub use fcf::FutureCostFunction;
pub use pool::{CutPool, SparsityReport};
pub use row_map::CutRowMap;
pub use wire::CutWireHeader;

/// Sentinel value stored in [`crate::cut_selection::CutMetadata::iteration_generated`]
/// for warm-start cuts loaded from a policy checkpoint.
///
/// Set to [`u64::MAX`] so that `WARM_START_ITERATION != current_iteration` is
/// always true for any valid training iteration, allowing cut selection
/// strategies to distinguish warm-start cuts from training-generated cuts
/// without special casing.
pub const WARM_START_ITERATION: u64 = u64::MAX;