TurbineLP class
#include <gtopt/turbine_lp.hpp>
Linear programming representation of a hydroelectric turbine.
This class extends ObjectLP to provide LP-specific functionality for turbines, including:
- Conversion rate constraints between water flow and power generation
- Relationships with connected waterways and generators
- Output of dual variables for sensitivity analysis
Base classes
-
template<typename ObjectType>class ObjectLP<Turbine>
- Wrapper class that adds LP capabilities to objects.
Public types
- using Element = Turbine
- using object_type = Turbine
- Type of the wrapped object.
Public static variables
- static std::string_view CapacityName
- static std::string_view ConversionName
- static std::string_view FlowName
- Name of the turbine-owned flow column emitted in built-in waterway mode.
Constructors, destructors, conversion operators
- TurbineLP(const Turbine& pturbine, InputContext& ic) explicit
- Construct a TurbineLP from a Turbine and input context.
Public functions
- auto add_to_lp(const SystemContext& sc, const ScenarioLP& scenario, const StageLP& stage, LinearProblem& lp) -> bool
- Adds turbine constraints to the linear problem.
- auto add_to_output(OutputContext& out) const -> bool
- Adds turbine dual variables to the output context.
- auto class_name(this const Self& self) -> auto noexcept
- auto conversion_rows_at(const ScenarioLP& scenario, const StageLP& stage) const -> const BIndexHolder<RowIndex>&
- Access conversion-rate constraint row indices for a (scenario, stage).
- auto drain() const -> auto noexcept
- auto find_conversion_rows(const ScenarioLP& scenario, const StageLP& stage) const -> const BIndexHolder<RowIndex>* noexcept
- auto flow_cols_at(const ScenarioLP& scenario, const StageLP& stage) const -> const auto&
- auto flow_sid() const -> FlowLPSId
- auto generator_sid() const -> auto noexcept
- auto has_junction_b() const -> bool noexcept
- auto id() const -> auto noexcept
- auto is_active(const StageLP& stage) const -> bool
- Checks if object is active in given stage.
- auto junction_a_sid() const -> JunctionLPSId
- auto junction_b_sid() const -> JunctionLPSId
- auto object() & -> Turbine& noexcept
- Gets the wrapped object.
- auto set_id(Uid uid, Name name) -> auto& noexcept
- Sets the object's identifier.
- auto short_name(this const Self& self) -> auto noexcept
- auto stage_efficiency(StageUid tuid) const -> Real
- auto sv_key(this const Self& self, const ScenarioLP& scenario, const StageLP& stage, std::string_view col_name) -> auto noexcept
- Generates a state variable key for the object.
- auto sv_key(this const Self& self, const StageLP& stage, std::string_view col_name) -> auto noexcept
- auto turbine(this auto&& self) -> auto&& noexcept
- auto uid() const -> auto noexcept
- auto uses_flow() const -> bool noexcept
- auto uses_junctions() const -> bool noexcept
- auto waterway_sid() const -> WaterwayLPSId
Parameter accessors for user constraint resolution.
Per-stage Turbine schedules — discard the block argument. Returned by the ampl_dispatch_registry shims so PAMPL constraints can reference turbine('X').<field> as a constant scalar.
- auto param_production_factor(StageUid s) const -> auto
- auto param_efficiency(StageUid s) const -> auto
- auto param_capacity(StageUid s) const -> auto
Typedef documentation
using gtopt:: TurbineLP:: Element = Turbine
#include <gtopt/object_lp.hpp>
Alias for the wrapped data-struct type. Lets generic code reach the canonical LPClassName constant via T::Element::class_name where T is any LP wrapper inheriting from ObjectLP. Single source of truth for the class-name constant lives on the data struct (Bus::class_name, Reservoir::class_name, …); the LP wrappers no longer carry a duplicate ClassName member.
using gtopt:: TurbineLP:: object_type = Turbine
#include <gtopt/object_lp.hpp>
Type of the wrapped object.
Function documentation
gtopt:: TurbineLP:: TurbineLP(const Turbine& pturbine,
InputContext& ic) explicit
Construct a TurbineLP from a Turbine and input context.
| Parameters | |
|---|---|
| pturbine | The turbine to represent |
| ic | Input context containing system configuration |
bool gtopt:: TurbineLP:: add_to_lp(const SystemContext& sc,
const ScenarioLP& scenario,
const StageLP& stage,
LinearProblem& lp)
Adds turbine constraints to the linear problem.
| Parameters | |
|---|---|
| sc | System context containing component relationships |
| scenario | Current scenario being processed |
| stage | Current stage being processed |
| lp | Linear problem to add constraints to |
| Returns | true if successful, false on error |
Adds constraints that enforce the relationship between water flow through the turbine and electrical power generation based on the conversion rate.
bool gtopt:: TurbineLP:: add_to_output(OutputContext& out) const
Adds turbine dual variables to the output context.
| Parameters | |
|---|---|
| out | Output context to write results to |
| Returns | true if successful, false on error |
Outputs the dual variables associated with the turbine's conversion rate constraints for sensitivity analysis.
auto gtopt:: TurbineLP:: class_name(this const Self& self) noexcept
#include <gtopt/object_lp.hpp>
auto gtopt:: TurbineLP:: drain() const noexcept
| Returns | Whether this turbine has drainage enabled |
|---|
const BIndexHolder<RowIndex>* gtopt:: TurbineLP:: find_conversion_rows(const ScenarioLP& scenario,
const StageLP& stage) const noexcept
Non-throwing conversion_rows_at: nullptr when (scenario, stage) was not built (turbine inactive, or no conversion row in the cell).
const auto& gtopt:: TurbineLP:: flow_cols_at(const ScenarioLP& scenario,
const StageLP& stage) const
Access the turbine-owned flow columns (built-in waterway mode) for a (scenario, stage). Returns an empty inner map when the turbine does not use junctions or every block was elided by the zero-bound skip.
bool gtopt:: TurbineLP:: has_junction_b() const noexcept
| Returns | Whether the built-in waterway mode credits a downstream junction. When false (junction_b unset), the turbined flow drains out of the system — used for terminal (run-to-sea) plants. |
|---|
auto gtopt:: TurbineLP:: id() const noexcept
#include <gtopt/object_lp.hpp>
| Returns | The object's complete identifier (uid + name) |
|---|
bool gtopt:: TurbineLP:: is_active(const StageLP& stage) const
#include <gtopt/object_lp.hpp>
Checks if object is active in given stage.
| Parameters | |
|---|---|
| stage | The stage to check |
| Returns | true if active in stage, false otherwise |
Turbine& gtopt:: TurbineLP:: object() & noexcept
#include <gtopt/object_lp.hpp>
Gets the wrapped object.
| Returns | Reference to the wrapped object |
|---|
auto& gtopt:: TurbineLP:: set_id(Uid uid,
Name name) noexcept
#include <gtopt/object_lp.hpp>
Sets the object's identifier.
| Parameters | |
|---|---|
| uid | Unique identifier |
| name | Human-readable name |
| Returns | Reference to self for chaining |
auto gtopt:: TurbineLP:: short_name(this const Self& self) noexcept
#include <gtopt/object_lp.hpp>
Real gtopt:: TurbineLP:: stage_efficiency(StageUid tuid) const
| Returns | The turbine efficiency [p.u.] for the given stage (default 1.0) |
|---|
auto gtopt:: TurbineLP:: sv_key(this const Self& self,
const ScenarioLP& scenario,
const StageLP& stage,
std::string_view col_name) noexcept
#include <gtopt/object_utils.hpp>
Generates a state variable key for the object.
| Parameters | |
|---|---|
| self | Reference to the object |
| scenario | Scenario context |
| stage | Stage context |
| col_name | The column name for the state variable |
| Returns | StateVariable::Key |
auto gtopt:: TurbineLP:: sv_key(this const Self& self,
const StageLP& stage,
std::string_view col_name) noexcept
#include <gtopt/object_utils.hpp>
auto gtopt:: TurbineLP:: uid() const noexcept
#include <gtopt/object_lp.hpp>
| Returns | The object's unique identifier |
|---|
bool gtopt:: TurbineLP:: uses_flow() const noexcept
| Returns | Whether this turbine uses a flow reference (not a waterway) |
|---|
bool gtopt:: TurbineLP:: uses_junctions() const noexcept
| Returns | Whether this turbine carries its own flow arc between junctions (built-in waterway mode), enabled when junction_a is set. In this mode the turbine owns a flow column that debits junction_a, optionally credits junction_b (when set), and converts the flow to power — no separate Waterway element is needed. |
|---|