LossConfig struct
#include <gtopt/line_losses.hpp>
Resolved loss parameters for LP construction.
Built once per (line, stage) and used for every block in that stage.
Public variables
- LossAllocationMode allocation
- double loss_cost_eps
- double loss_envelope
- double loss_flow_abs_cost
- double loss_overflow_cost
- double loss_row_scale
- double lossfactor
- Effective linear loss [p.u.].
- LineLossesMode mode
- Fully resolved (no
adaptive). - int nseg
- int nseg_secant
- int one_way_sign
- LinePwlLayout pwl_layout
- double resistance
- R [Ω].
- bool segment_flow_cap
- LineThermalLimitMode thermal_limit
- bool use_sos2
- double V2
- V² [kV²].
Variable documentation
double gtopt:: line_losses:: LossConfig:: loss_cost_eps
Per-MWh cost stamped on the per-direction loss columns (loss_p / loss_n) in piecewise/bidirectional modes. Strictly breaks LP-relax bidirectional-flow degeneracy: among all primal-feasible solutions sharing the same net dispatch the LP picks the one with single-direction flow. 0.0 here means no ε; LineLP passes the resolved value (per-line override, else model_options.loss_cost_eps, else 0.1 $/MWh; an explicit 0 disables it). The $/MWh value is block-duration weighted (CostHelper::block_ecost) like any energy cost. Inert for none, linear, piecewise_direct, and tangent layouts.
double gtopt:: line_losses:: LossConfig:: loss_envelope
Upper envelope [MW] over which the K PWL segments are spread. DECOUPLED from the flow cap: when the caller supplies a positive value (typically the ORIGINAL line rating for a soft-cap / enforce_level-lifted line whose fmax flow cap is inflated), the loss segments concentrate over THIS range rather than fmax. 0.0 (default) means "use the per-direction `fmax`/`block_tmax`" — i.e. the legacy flow-cap-anchored envelope, fully backward compatible. The envelope never caps the flow: past it (up to the flow cap) every PWL mode adds a geometric ladder of extra tangent points / secant segments (overflow_breakpoints, ratio ≤ 1.4) so the loss stays within ≈ 2.8 % of the quadratic R·f²/V².
double gtopt:: line_losses:: LossConfig:: loss_flow_abs_cost
Per-MWh pin [$/MWh] on the tangent_signed_flow abs-flow proxy columns v_l; stamped (via CostHelper::block_ecost) only when loss_cost_eps > 0. LineLP passes the resolved value (per-line Line.loss_flow_abs_cost, else model_options.loss_flow_abs_cost, else 0.001 $/MWh). 0 here (the struct default, used by direct make_config callers) means no pin. Inert outside tangent_signed_flow.
double gtopt:: line_losses:: LossConfig:: loss_overflow_cost
Price [$/MWh] on the loss carried by the OVERFLOW tier past a decoupled loss_envelope (flow in (envelope, fmax]). Each overflow column is charged this price times its marginal loss — c·(b_{j−1}+b_j) per MW on |f| ladder columns and overflow secant segments, c·(b²−envelope²) per unit on SOS2 λ weights, 1 per MW on the split overflow loss column of the tangent layout — so the tier costs exactly this price per MWh of loss above c·envelope². Closes the overflow energy sink (see Line.loss_overflow_cost). 0.0 (default here; LineLP passes the resolved value, default the case's demand_fail_cost) disables it. Inert when there is no overflow tier (no envelope or fmax ≤ envelope).
double gtopt:: line_losses:: LossConfig:: loss_row_scale
Row-scale multiplier for the loss-link constraint (s · loss − Σ s · loss_k · seg_k = 0). Default 1.0 (no scaling). Lifts the smallest segment coefficient seg_width · R / V² (typically ~1e-6 for HV lines) toward O(1) so simplex pivoting doesn't see microscopic nonzeros. Set globally via model_options.scale_loss_link; PlanningLP auto-computes from median(R/V²) when unset.
int gtopt:: line_losses:: LossConfig:: nseg
Segment count for PWL modes
int gtopt:: line_losses:: LossConfig:: nseg_secant
Number of L-secant segment columns v_l emitted per (line, block) by add_tangent_signed_flow when the L-secant chord upper bound is active (issue #504). 1 (default) preserves the pre-#504 single-secant chord ℓ ≤ (R·envelope/V²)·v. L > 1 replaces the single v column with L columns bounded v_l ∈ [0, envelope/L] and the chord upper bound becomes the piecewise ℓ ≤ Σ chord_slope_l · v_l with chord_slope_l = (R/V²)·(envelope/L)·(2l − 1). Inert outside tangent_signed_flow mode.
int gtopt:: line_losses:: LossConfig:: one_way_sign
One-way line (Line.flow_direction / line_direction_mode): +1 = only A→B, -1 = only B→A, 0 = both directions (default, today's LP). The two-column modes need nothing extra (the reverse direction gets a zero limit and emits no column); it switches tangent_signed_flow to its ONE-SIDED form: only the tangents on the live side, Σ v_l = ±f as one equality instead of the two abs rows (with L = 1 and no overflow tier the v column is substituted out and the chord sits on f), and the SOS2 ladder keeps only the live-side breakpoints.
LinePwlLayout gtopt:: line_losses:: LossConfig:: pwl_layout
Segment-layout strategy for the PWL loss approximation. See LinePwlLayout (line_enums.hpp): uniform (default; equal- width secant chords — preserves pre-2026-05 behaviour), equal_error (√-spaced minimax: same K and LP row count, ~√K better worst-case chord error), tangent (outer approximation, reserved for future). Per-line override via Line.loss_pwl_layout; otherwise inherits from ModelOptions.loss_pwl_layout (TBD) — default uniform.
bool gtopt:: line_losses:: LossConfig:: segment_flow_cap
Ordered-fill cap on the PWL segment columns (model_options.loss_segment_bound, default true).
LineThermalLimitMode gtopt:: line_losses:: LossConfig:: thermal_limit
How the thermal limit treats the loss (see LineThermalLimitMode, line_enums.hpp). flow (default) leaves the LP untouched; sending / full bound f_dir + a·ℓ_dir ≤ T_dir per direction (a = sending-bus loss share, resp. 1) and fold the same a·ℓ_dir into the capacity rows of expandable lines. LineLP resolves it (per-line override, else model_options.line_thermal_limit_mode, else flow).
bool gtopt:: line_losses:: LossConfig:: use_sos2
Toggle SOS2 enforcement on the L secant-segment columns emitted when nseg_secant > 1 (issue #504). Without SOS2 the LP exploits the segment freedom to maximise the chord ceiling; with SOS2 at most two consecutive v_l are non-zero, forcing fill order v_1 → … → v_L. Requires a MIP-capable LP backend with native SOS2 (CPLEX / Gurobi / HiGHS ≥ 1.6); see SolverBackend::add_sos2 for the support matrix. Inert outside tangent_signed_flow mode or when nseg_secant ≤ 1.