gtopt/line_losses.hpp file

Modular transmission line losses engine.

Provides a pluggable loss-model dispatch for transmission lines. Each LineLossesMode has its own implementation function that adds the appropriate variables and constraints to the LP.

Supported modes

Counts are PER LOSSY LINE, PER BLOCK — a mode's LP footprint is count × n_lossy_lines × n_blocks. (K = number of segments / tangents.)

(K = segments/tangents, L = loss_secant_segments, default 1.)

  • none — 0 rows, 1 col (signed flow)
  • linear — 0 rows, 2 cols (flow per dir)
  • piecewise (≠tangent) — wraps bidirectional: 4 rows, 2K+4 cols
  • piecewise (tangent layout, legacy shared) — K rows, 3 cols
  • bidirectional — 4 rows, 2K+4 cols (per-dir segs)
  • piecewise_direct — 0 rows, 2K cols (per-dir segs only)
  • tangent_signed_flow — K+3 rows (K tangents, one dropped when K is odd — prefer EVEN K — + 2 abs rows + 1 chord), 2+L cols (signed flow, loss, L abs-flow v cols)
  • tangent_signed_flow + SOS2 λ-form — K+3 rows + 1 SOS2 set, 2L+3 cols
  • adaptive / dynamic — resolved at config time (piecewise / bidirectional)

tangent_signed_flow (Coffrin outer-approximation; LinePwlLayout::tangent) is the plexos2gtopt DEFAULT (eps=0.1, K=6) and is BOTH the most compact (2+L cols) AND the most accurate: its K tangent inequalities form a LOWER outer envelope of (R/V²)·f², exact at every tangent point. CAVEAT — it never over-states loss ONLY while the bus-dual pair-sum stays non-negative: under a negative pair-sum the LP inflates the abs-flow proxy v past |f| and rides the loss up the chord (see test_line_losses_negative_lmp_kvl.cpp and the ε-threshold notes in line.hpp::loss_cost_eps); the exact fix is the SOS2 λ-form (loss_use_sos2 + loss_secant_segments ≥ 2). Example footprint (10-05, 278 lossy lines × 168 blocks): tangent K=6 → 93,408 cols / 326,928 rows, vs the regressed piecewise uniform/midpoint K=2–5 mix → 284,088 cols / 93,408 rows.

Mathematical background

Quadratic loss: P_loss = R · f² / V² [MW], with R [Ω], f [MW], V [kV].

Piecewise-linear approximation with K segments over [0, f_max]:

  • Segment width: w = f_max / K
  • Segment k (1-based) loss coefficient: loss_k = w · R · (2k−1) / V²
  • Total: loss = Σ_k loss_k · seg_k, with Σ_k seg_k = |f|

PWL layout (LinePwlLayout, line_enums.hpp) controls ACCURACY at fixed K:

  • uniform — equal-width SECANT chords. A chord is an UPPER bound of the convex quadratic: exact at the segment endpoints, over-stating between them, worst near f = 0. On a lightly-loaded line (f ≪ f_max) with few segments the first chord (constant slope R·w/V²) sits far above the true R·f²/V², over-stating loss by ≈ w/f. Aggregated this is why the uniform mix booked 93.3 GWh of loss against only ~40 GWh that the flows physically support (10-05).
  • midpoint — each chord shifted to the segment midpoint → de-biased.
  • tangent — Coffrin tangents: a LOWER outer envelope, exact at the tangent points, never over-states. Preferred (and the intended default).

References:

  • [1] Macedo, Vallejos, Fernández, "A Dynamic Piecewise Linear Model for DC Transmission Losses in Optimal Scheduling Problems", IEEE Trans. Power Syst., vol. 26, no. 1, pp. 508–516, 2011.
  • [2] Wood & Wollenberg, "Power Generation, Operation and Control", 3rd ed., Wiley, Ch. 13 (incremental transmission losses).
  • [3] FERC Staff Paper, "Optimal Power Flow Paper 2: Linearization", December 2012.

Namespaces

namespace gtopt
namespace gtopt::line_losses

Classes

struct gtopt::line_losses::AdaptiveSegmentsOpts
struct gtopt::line_losses::BlockResult
LP indices produced by add_block() for one block.
struct gtopt::line_losses::DynamicAssignment
struct gtopt::line_losses::DynamicLayoutOpts
struct gtopt::line_losses::LossConfig
Resolved loss parameters for LP construction.
struct gtopt::line_losses::SegGeom
struct gtopt::line_losses::TangentGeom