line_losses namespace
Classes
- struct BlockResult
- LP indices produced by add_block() for one block.
- struct LossConfig
- Resolved loss parameters for LP construction.
Functions
- auto add_block(const LossConfig& config, const SystemContext& sc, const ScenarioLP& scenario, const StageLP& stage, const BlockLP& block, LinearProblem& lp, SparseRow& brow_a, SparseRow& brow_b, double block_tmax_ab, double block_tmax_ba, double block_tcost, std::optional<ColIndex> capacity_col, Uid uid, std::string_view cname) -> BlockResult
- Add loss model variables and constraints for one block.
- auto make_config(LineLossesMode mode, const Line& line, LossAllocationMode allocation, double lossfactor, double resistance, double voltage, int loss_segments, double fmax) -> LossConfig
- Build a LossConfig for the given line and stage parameters.
- auto resolve_mode(const Line& line, const PlanningOptionsLP& options, bool has_expansion) -> LineLossesMode
- Resolve the effective LineLossesMode for a line.
Function documentation
BlockResult gtopt:: line_losses:: add_block(const LossConfig& config,
const SystemContext& sc,
const ScenarioLP& scenario,
const StageLP& stage,
const BlockLP& block,
LinearProblem& lp,
SparseRow& brow_a,
SparseRow& brow_b,
double block_tmax_ab,
double block_tmax_ba,
double block_tcost,
std::optional<ColIndex> capacity_col,
Uid uid,
std::string_view cname)
#include <gtopt/line_losses.hpp>
Add loss model variables and constraints for one block.
| Returns | LP indices for the created variables and constraints. |
|---|
Dispatches to the appropriate mode implementation:
none: single bidirectional flow, no losslinear: directional flows with loss coefficientspiecewise: shared segments for |f| = fp + fn [1]bidirectional: independent segments per direction [3]
LossConfig gtopt:: line_losses:: make_config(LineLossesMode mode,
const Line& line,
LossAllocationMode allocation,
double lossfactor,
double resistance,
double voltage,
int loss_segments,
double fmax)
#include <gtopt/line_losses.hpp>
Build a LossConfig for the given line and stage parameters.
Combines mode resolution with physical parameter extraction. For linear mode, auto-computes lossfactor from R/V if needed: λ = R · f_max / V² (linearization at rated flow [2]).
For PWL modes, validates that R > 0 and V > 0 and nseg > 1; falls back to linear or none if insufficient.
LineLossesMode gtopt:: line_losses:: resolve_mode(const Line& line,
const PlanningOptionsLP& options,
bool has_expansion)
#include <gtopt/line_losses.hpp>
Resolve the effective LineLossesMode for a line.
| Parameters | |
|---|---|
| line | The line data (per-element overrides) |
| options | Global planning options |
| has_expansion | Whether the line has capacity expansion (expcap) |
Fallback chain:
- Per-line
line_losses_mode(string → enum) - Per-line
use_line_losses(deprecated bool: false → none) - Global
line_losses_mode()from PlanningOptionsLP
If the resolved mode is adaptive, it is mapped to:
bidirectionalif the line has expansion modules (has_expansion)piecewiseotherwise
If the resolved mode is dynamic, it falls back to piecewise (with a log warning on first call).