gtopt/line_direction.hpp file

Radial-line detection and structural flow-direction certificate.

Pure-graph utilities (no LP / SystemContext coupling) behind model_options.line_direction_mode and Line.flow_direction = "auto".

Definitions

The transport graph is the multigraph over buses whose edges are the lines active in ANY stage of the LP being built (AC, DC links, ties and expansion candidates alike; self-loops dropped). A radial corridor is a bus pair whose parallel circuits together form a cut: a bridge of the simple graph obtained by collapsing parallel circuits. Because a bridge of this union graph stays a bridge in every per-stage / per-block sub-graph (and its cut-off side only loses elements there), the certificate below is valid for every stage, block and scenario of the LP — line outages, commitment and stage activity can only shrink it.

Every bus carries the injection-sign classes of the elements attached to it (BusInjection): withdraw (demand: served load ≥ 0, gas compressor drive, …), inject (generator with pmin ≥ 0) or both (anything that can do either — a generator with pmin < 0, a carrier converter on the bus, or an element the caller cannot classify). A side of a radial corridor is

  • empty — no element at all;
  • load — only withdraw elements;
  • gen — only inject elements;
  • mixed — anything else.

Verdict per circuit of a radial corridor:

  • dead end when either side is empty, or both sides are load (or both gen): the only non-circulating feasible flow is 0, so the line can be dropped;
  • one-way toward a load side, or away from a gen side;
  • both otherwise (a mixed side can reverse the flow).

The subtree balance Σ inj(S) + inflow(S) − losses(S) = 0 fixes the sign of the NET flow of every non-circulating feasible point; the one-way restriction removes only simultaneous two-way flow (fp > 0 ∧ fn > 0), which with non-negative losses and transmission cost is never profitable unless the LP values disposing of energy (negative prices / must-run surplus without spill) — the fictitious loss-arbitrage sink.

Multi-circuit corridors are certified only when the caller marks every circuit kvl_coupled (AC with positive reactance under an active Kirchhoff formulation): the 2-cycle KVL rows then force the same sign on all circuits. Otherwise a circulation between the circuits would be feasible, so the corridor keeps both (it is still reported as radial).

Namespaces

namespace gtopt
namespace gtopt::line_direction

Classes

struct gtopt::line_direction::BusInjection
Injection-sign class flags of one bus (OR of its elements).
struct gtopt::line_direction::Edge
One circuit of the transport graph.
struct gtopt::line_direction::ElementRefs
struct gtopt::line_direction::LineClass
Per-circuit classification.
struct gtopt::line_direction::LineDecision
Decision applied to one line in the LP (stored in SystemContext).
struct gtopt::line_direction::Summary
Aggregate counts for logging / tests.