BoxEdgeStats struct
#include <gtopt/benders_cut.hpp>
Per-cut tally of how many contributing links land in each decile band of the source-column box [source_low, source_upp].
Shared diagnostic structure used by both build_feasibility_cut_physical (single-cut path) and build_multi_cuts (per-link multi-cut path). The same band-classifier drift between the two emitters used to silently produce subtly different degeneracy thresholds; centralising it here keeps the threshold tunable in exactly one place.
Decile bands (10 % of box_width = source_upp − source_low):
upper← clamped value within the top 10 % of the box (≥ source_upp − 0.10 × box_width).lower← clamped value within the bottom 10 % of the box.inside← everything else (the middle 80 %).
The "all-upper" pattern (all_upper_degenerate() returns true) is the signature of a degenerate "every state floored at emax" cut: the master cannot satisfy a floor at every reservoir's emax simultaneously in one phase, so installing such a cut guarantees cascade-infeasibility on the next forward attempt. Cut emitters use this signal to drop the cut rather than install a doomed retry chain.
Exposed (rather than kept anonymous) so that the band-classification invariant is unit-testable in isolation, without spinning up a full elastic clone.
Public functions
- auto all_upper_degenerate() const -> bool noexcept
- void tally(double clamped, const StateVarLink& link)
- auto total() const -> int noexcept
- Total active links contributing to a cut (=
upper + lower + inside).
Public variables
- int inside
- int lower
- int upper
- std::string upper_names
- Comma-joined element names for WARN message.
Function documentation
bool gtopt:: BoxEdgeStats:: all_upper_degenerate() const noexcept
True when EVERY active link clamps at the upper edge. The threshold of ≥ 2 active keeps the warning quiet for trivial single-link cuts on a small reservoir while still flaring on the multi-reservoir degenerate cascade observed on the large hydrothermal case.
void gtopt:: BoxEdgeStats:: tally(double clamped,
const StateVarLink& link)
Tally one link's clamp into the appropriate decile bucket. clamped is the cut's implied source value after the per-link std::clamp(dep_clone_phys, source_low, source_upp); the helper compares it to the box's top / bottom 10 % bands. Names land in upper_names only when the link has a non-empty AMPL name — otherwise the diagnostic falls back to the numeric uid in the WARN message that consumes upper_names.