ScaledView class
#include <gtopt/lp_scaling.hpp>
Zero-copy lazy view that applies a per-element scale factor.
Models a random-access range: view[i] returns data[i] * scales[i] (or data[i] / scales[i] when constructed with divides). When scales are empty, returns raw data unchanged.
Optional physical-space clamp: when lower_ and upper_ spans are both non-empty, operator[](i) additionally clamps the result to [lower_[i] * scales_[i], upper_[i] * scales_[i]] — i.e., the clamp is applied after descaling, in the same physical space the caller sees. Used by LinearInterface::get_col_sol() to scrub solver noise (value returned slightly outside its bound-box on an optimal solve) so downstream SDDP state propagation can pin clean values without causing next-phase infeasibility.
Accepts any integer-like index type (int, size_t, ColIndex, RowIndex).
Public types
Constructors, destructors, conversion operators
- ScaledView() defaulted constexpr noexcept
-
ScaledView(const double* data,
Index n,
const double* scales,
size_t ns,
const double* lower,
Index nlo,
const double* upper,
Index nup,
Op op = Op::
multiply, double global_factor = 1.0) constexpr noexcept -
ScaledView(const double* data,
Index n,
const double* scales,
size_t ns,
Op op = Op::
multiply, double global_factor = 1.0) constexpr noexcept - ScaledView(std::span<const double> raw) explicit constexpr noexcept
- Construct from a raw span (no scaling).
Public functions
Function documentation
gtopt:: ScaledView:: ScaledView(const double* data,
Index n,
const double* scales,
size_t ns,
const double* lower,
Index nlo,
const double* upper,
Index nup,
Op op = Op:: multiply,
double global_factor = 1.0) constexpr noexcept
Construct with physical-space clamp bounds (lower/upper in the same raw-LP space as data; each element is descaled by scales before clamping). When either span is empty, clamping is skipped.