gtopt::BoundaryGapDiagnostics struct

Gap accounting under boundary (terminal FutureCost) cuts.

With boundary cuts the SDDP lower bound carries the terminal future cost Φ(v_T) through the master's α, while the forward-pass upper bound strips every α — including the terminal one — and so omits it. The mean-shift rebase (boundary_cuts_mean_shift) moves the constant c̄ = mean(Φ) out of the cuts (Φ' = Φ − c̄) and into the first-phase objective, so it is present in BOTH bounds. Hence, at convergence,

LB − UB  →  E[Φ'(v_T)] + (cut over-estimation)

and a negative raw gap is expected even with perfectly valid cuts (docs/formulation/sddp-cut-validity.md §9). The corrected upper bound UB* = UB + E[Φ'(v_T)] = E[stage costs] + c̄ + E[Φ'(v_T)] = E[stage costs + Φ(v_T)] puts the terminal term back, so the residual LB − UB* isolates the over-estimation: ≈ 0 (or negative while the policy is still improving) with valid cuts, > 0 when some cut claims more future cost than the forward pass realises (e.g. cuts that are invalid for this system's phases).

Under BoundaryCutsMode::phi_expectation the forward pass does NOT strip the terminal φ_j columns (PLP ZSPF convention), so E[Φ'] is already inside the UB: terminal_in_ub = true and UB* = UB.

All amounts are in the bounds' units (physical $, scene probability folded in, summed over feasible scenes).

Public functions

auto overestimation_exceeds(double tol) const -> bool noexcept
auto overestimation_vs_opex() const -> double noexcept
overestimation relative to E[|opex|] (0 when E[|opex|] < 1).
auto overestimation_vs_ub() const -> double noexcept
overestimation relative to |UB*| (0 when |UB*| < 1).

Public variables

bool active
True when boundary cuts were loaded; every other field is 0 otherwise.
double alpha_offset
c̄ folded into the objective (Σ_s of the per-scene restitution).
double corrected_gap
(UB* − LB) / max(1, |UB*|), same normalisation as the raw gap.
double corrected_upper_bound
UB* = UB + E[Φ'(v_T)] (= UB under terminal_in_ub).
double expected_abs_opex
double expected_opex
double overestimation
LB − UB*: cut over-estimation (> 0) beyond the terminal accounting.
double terminal_future_cost
bool terminal_in_ub

Function documentation

bool gtopt::BoundaryGapDiagnostics::overestimation_exceeds(double tol) const noexcept

True when the residual over-estimation exceeds tol relative to BOTH |UB*| and E[|opex|] (i.e. overestimation > tol · max(|UB*|, E|opex|, 1)), so a near-zero UB of a net-reward case cannot trigger it on its own.

Variable documentation

double gtopt::BoundaryGapDiagnostics::expected_abs_opex

Σ_s |opex_s| — scale for the over-estimation test that stays meaningful when positive and negative scene opex cancel.

double gtopt::BoundaryGapDiagnostics::expected_opex

Expected stage cost (opex), EXCLUDING c̄ and the terminal term. Can be negative (net-reward cases); see expected_abs_opex.

double gtopt::BoundaryGapDiagnostics::terminal_future_cost

E[Φ'(v_T)]: the (rebased) terminal future cost at the forward pass's final states — Σ_s of the last phase's weighted α / φ_j values.

bool gtopt::BoundaryGapDiagnostics::terminal_in_ub

True when the forward-pass UB already includes E[Φ'(v_T)] (phi_expectation); the correction then adds nothing.