gtopt::FlowRight struct

Flow-based water right (derechos de caudal).

Models the flow entitlement of a right holder at a river point. Always represents a consumptive outflow (direction = -1, fixed). When a junction is referenced, the flow variable is subtracted from the junction's physical balance row.

The (fmin, target, fmax, fcost, uvalue) tuple selects one of the 7 unified-mode LP shapes documented in flow_right_lp.cpp.

The purpose field indicates the use case: "irrigation", "generation", "environmental", etc.

Public static variables

static LPClassName class_name

Public functions

auto bypass_requested() const -> bool noexcept
auto flow_mode_enum() const -> std::optional<FlowRightMode> noexcept

Public variables

OptActive active
Activation status (default: active).
std::optional<RightBoundRule> bound_rule
OptReal bypass_cost
OptReal bypass_fmax
OptBool consumptive
OptInt direction
OptTBRealFieldSched fcost
OptName flow_mode
OptTBRealFieldSched fmax
OptTBRealFieldSched fmin
OptSingleId junction_a
OptSingleId junction_b
Name name
Human-readable name.
OptReal priority
Priority level for allocation ordering [dimensionless].
OptName purpose
OptTBRealFieldSched target
Uid uid
Unique identifier.
OptBool use_average
OptBool use_bypass
OptTBRealFieldSched uvalue

Function documentation

bool gtopt::FlowRight::bypass_requested() const noexcept

Resolved opt-in for the pass-through bypass arc (see use_bypass). Does not check that the junctions are set.

std::optional<FlowRightMode> gtopt::FlowRight::flow_mode_enum() const noexcept

Parsed flow_mode: the explicit name when set (std::nullopt for an unknown name, reported by validate_planning), else the legacy use_average mapping (true → stage_average, unset / false → per_block).

Variable documentation

static LPClassName gtopt::FlowRight::class_name

Canonical class-name constant used in LP row labels and config fields like VariableScale::class_name. Single source of truth — FlowRightLP exposes no separate ClassName member; callers reach the constant via FlowRight::class_name directly (or FlowRightLP::Element::class_name in generic contexts).

std::optional<RightBoundRule> gtopt::FlowRight::bound_rule

Volume-dependent bound rule for dynamic fmax adjustment. When set, update_lp evaluates the piecewise-linear function at the referenced reservoir's current volume and updates the flow column upper bound to min(fmax, rule_value). This implements PLP cushion zone logic (Laja/Maule).

OptReal gtopt::FlowRight::bypass_cost

Per-unit cost on the bypass column ($/m³/s·h). Defaults to 0 (free pass-through). Set a small positive value to prefer consumption (flow_col) over pass-through, or a large value to make the bypass a last-resort pressure release. Only meaningful when the bypass is enabled (see use_bypass).

OptReal gtopt::FlowRight::bypass_fmax

Upper bound on the bypass column [m³/s] (the pass-through channel capacity). Unset ⇒ unbounded. Only meaningful when the bypass is enabled (see use_bypass).

OptBool gtopt::FlowRight::consumptive

Consumptive flag for the SERVED flow (flow_b / qeh).

Unset / true (default, backward-compatible): the served flow is consumed — subtracted (−1) from junction_a's balance and returned nowhere (irrigation / filtration offtake).

false: NON-consumptive — the served flow is ALSO credited (+1) to junction_b's balance, so the right keeps the water in the river: it debits junction_a and credits junction_b exactly like a Waterway/Turbine arc, while still enforcing the [fmin,fmax] / target / fcost band on the carried flow. Models a minimum river / turbined flow (cf. SDDP "minimum turbined/total outflow"). Requires junction_b. Water above the served band needs its own outlet at junction_a (e.g. a spill waterway, or the opt-in use_bypass arc).

OptInt gtopt::FlowRight::direction

Direction sign for LP coupling: +1 = supply (inflow to balance point) -1 = withdrawal (outflow / consumptive extraction)

OptTBRealFieldSched gtopt::FlowRight::fcost

Penalty cost for unmet flow below target [$/m³/s·h]. Analogous to Demand::fcost for electrical load curtailment. Higher values give this right higher priority in the LP. Per-(stage, block) scheduling (mirrors Demand::fcost since PR-A). Accepts a scalar (broadcasts), a 2-D nested array, or a file-backed schedule.

OptName gtopt::FlowRight::flow_mode

Time-resolution mode for the flow LP variables and constraints. One of:

  • "per_block" (default): one LP flow_b per block; all bounds and the kink (target / fcost / uvalue) are applied per-block.
  • "stage_average": one LP flow_b per block (hard [fmin_b, fmax_b] bounds only), plus a stage-level qeh = Σ_b dur_ratio_b × flow_b column. The kink and all costs are applied to qeh at stage scope. Mirrors PLP's H- suffix stage-average variables (IQDRH, IQDEH).
  • "stage_uniform": a single stage-level qeh column is created and used in every block's junction balance — no per-block flow_b. All bounds and the kink are applied to qeh. Use when the right's flow is required to be constant across the stage (e.g. steady environmental releases).

OptTBRealFieldSched gtopt::FlowRight::fmax

Hard upper bound on the served flow [m³/s]. When unset, defaults to target when target is set, else to fmin (yielding a forced exact flow). Per-stage-block scheduling.

OptTBRealFieldSched gtopt::FlowRight::fmin

Hard lower bound on the served flow [m³/s]. Default 0. Below this no shortfall is admissible — the bound is always enforced regardless of fcost. Per-stage-block scheduling (mirrors Demand::lmax): the value can vary hourly within a stage (e.g. PLP's hourly pmin obligations).

OptSingleId gtopt::FlowRight::junction_a

Source junction where the right is exercised (the extraction point). When set, the FlowRight's flow is subtracted from this junction's balance row (consumptive extraction). Named junction_a for parity with Waterway/Turbine's upstream endpoint.

OptSingleId gtopt::FlowRight::junction_b

Optional downstream junction (the return / pass-through point). Named junction_b for parity with Waterway/Turbine's downstream endpoint. It is used by two independent, explicit mechanisms:

  • consumptive = false — the SERVED flow is credited (+1) to junction_b (carry mode, see consumptive);
  • the optional pass-through bypass arc (see use_bypass).

Setting junction_b alone does NOT create any extra water path: the bypass arc is opt-in.

OptName gtopt::FlowRight::purpose

Purpose of the water right: "irrigation", "generation", "environmental", etc. Metadata only — does not affect LP.

OptTBRealFieldSched gtopt::FlowRight::target

Soft kink point [m³/s]. Below target: fcost penalty applies (irrigation-style soft demand). Above target: uvalue bonus / penalty applies (variable-allocation style). When unset, the column reduces to a plain hard band [fmin, fmax] with no slack-side costs. Aliases legacy discharge for back-compat. Per-stage-block scheduling so hourly irrigation/forced-flow profiles round-trip through parquet without duplicate-uid warnings.

OptBool gtopt::FlowRight::use_average

Deprecated legacy boolean that maps to flow_mode:

  • true → flow_mode = "stage_average"
  • false → flow_mode = "per_block" Ignored when flow_mode is set explicitly.

OptBool gtopt::FlowRight::use_bypass

Opt-in pass-through bypass arc junction_a → junction_b.

When enabled (and both junctions are set, in per_block / stage_average mode) the LP adds one bypass_b column per block, bounded by [0, bypass_fmax] and priced at bypass_cost·cf, contributing −1 to junction_a's balance and +1 to junction_b's balance (mass-conserving). It models PLEXOS-style rights where the river continues downstream after the offtake regardless of how much the right consumes. The primal is written to the output as FlowRight/bypass_sol.

Resolution: an explicit value wins; when unset the arc is enabled iff bypass_cost or bypass_fmax is set (legacy implicit opt-in). A junction_b with none of the three emits no arc.

OptTBRealFieldSched gtopt::FlowRight::uvalue

Value of exercising the right above target [$/m³/s·h]. Subtracted from the objective (benefit): positive = incentivizes flow above target, negative = penalizes flow above target. Renamed from legacy use_value for naming parity with fcost. Per-(stage, block) scheduling.