gtopt/storage_integration.hpp file

Banded (local Lagrange) integration weights for storage balances on non-uniform node grids.

The default storage balance is the block recursion e_k = e_{k−1} + w_k·f_k (block weight w_k = duration). On a Chebyshev node grid whose durations are Clenshaw–Curtis weights this is the Clenshaw–Curtis rule (storage_integration = cc / clenshaw_curtis, aliases of block): every node carries its own positive CC weight (node 0 carries w_0 + w_N, the closing node of the periodic grid), e_k is the level AFTER node k's cell, one previous level plus node k's own flows per row (as sparse as a block balance, monotone, no overshoot), and over the closed period Σ_k (e_k − e_{k−1}) = Σ_k w_k f_k is exactly the CC quadrature that also integrates energy and cost. The intermediate levels are only first order (the exact integral of the interpolant over one interval would make every row dense).

storage_integration = trapezoid | lg4 | lg6 replaces it with a banded rule (2 / 4 / 6 coefficients per row). The level e_k is the state AT the node t_k (the last one at the period end). The increment over [p_{k−1}, p_k] integrates the linear (trapezoid: the interval's two end nodes), cubic or quintic Lagrange interpolant of the flows on the 2 / 4 / 6 nodes nearest to the interval. The stencil is shifted at the ends to keep its size. The weights are then corrected so that Σ_k D_kj = w_j (the period total is exactly the block-weight (CC) quadrature) AND Σ_j D_kj = Δ_k (a constant flow integrates exactly over every interval): a balanced minimum-norm additive correction for the signed rules, an alternating row / column scaling for the _pos rules.

Lagrange weights on non-uniform grids can be negative (≈ 8 % of the mass for Chebyshev–Lobatto nodes). The _pos variants clip them to zero before the (nonnegative) balancing. Signed lg4 / lg6 are not recommended for an LP: negative weights shift energy between intervals.

Namespaces

namespace gtopt
namespace gtopt::detail

Classes

struct gtopt::detail::GaussRule
Gauss–Legendre nodes / weights on [−1, 1] (Newton on P_m).
struct gtopt::IntegrationTerm
One nonzero (node index, weight) of a banded integration row.
struct gtopt::StorageIntegration
Parsed model_options.storage_integration value.