GeneratorLP class
#include <gtopt/generator_lp.hpp>
Base classes
-
template<typename Object Object>struct CapacityObjectLP<Generator>
- A linear programming representation of an object with capacity constraints.
Public types
- using Base = ObjectLP<Generator>
- using CapacityAndCol = std::pair<std::optional<double>, std::optional<ColIndex>>
- Pair of optional capacity value and optional expansion column index.
- using CapacityBase = CapacityObjectLP<Generator>
- using Element = Generator
- using object_type = Generator
- Type of the wrapped object.
Public static variables
- static std::string_view BusKey
- static std::string_view CapacityName
- static std::string_view CapacostName
- static std::string_view CapacostPrevName
- static std::string_view CapainstName
- static std::string_view CapainstPrevName
- static std::string_view ExpmodName
- static std::string_view GenerationName
- static std::string_view HeatRateKinkName
- static std::string_view HeatRateSlackName
- static std::string_view OutageFractionName
- Applied maintenance outage fraction output (
outage_fraction_sol). - static std::string_view PminSoftName
- static std::string_view QgenName
- LinDistFlow reactive output column (
qmin/qmaxset). - static std::string_view TypeKey
- static std::string_view UnservedName
- static double usage_on_threshold
- Dispatch above which a block counts as an operating hour [MW].
- static std::string_view UsageOnName
- Usage-accounting output streams (
options.output_usage_metrics). - static std::string_view UsageRampName
Constructors, destructors, conversion operators
- GeneratorLP(const Generator& generator, const InputContext& ic) explicit
- Constructs a GeneratorLP from a Generator.
Public functions
- auto add_to_lp(SystemContext& sc, std::string_view ampl_class, const ScenarioLP& scenario, const StageLP& stage, LinearProblem& lp) -> bool
- Add capacity constraints to the linear problem.
- auto add_to_lp(SystemContext& sc, const ScenarioLP& scenario, const StageLP& stage, LinearProblem& lp) -> bool
- Adds generator variables and constraints to the linear problem.
- auto add_to_output(OutputContext& out) const -> bool
- Adds generator output results to the output context.
- auto annual_capcost_at(StageUid stage_uid, double social_rate) const -> double
- Annualized investment cost [$/unit-year] at a stage.
- auto bus_sid() const -> auto noexcept
- auto capacity_and_col(const StageLP& stage, LinearProblem& lp) const -> CapacityAndCol
- Query capacity value and optional expansion column for a stage.
- auto capacity_at(const StageLP& stage, const double def_capacity = std::numeric_limits<double>::max()) const -> double
- Get the capacity at a specific stage.
- auto capacity_col_at(const StageLP& stage) const -> auto noexcept
- Get the column index for capacity at a specific stage.
- auto capacity_rows_at(const ScenarioLP& scenario, const StageLP& stage) const -> const auto&
- auto class_name(this const Self& self) -> auto noexcept
- auto expmod_col_at(const StageLP& stage) const -> auto noexcept
- Get the column index for the expansion-modules variable at a stage.
- auto fixed_om_cost_at(StageUid stage_uid) const -> OptReal
- Fixed O&M cost [$/unit-year] at a stage (nullopt when unset).
- auto fuel_burn_legs(const ScenarioLP& scenario, const StageLP& stage, BlockUid buid) const -> std::vector<std::pair<ColIndex, double>>
- auto generation_cols_at(const ScenarioLP& scenario, const StageLP& stage) const -> const auto&
- auto generator(this auto&& self) -> auto&& noexcept
- auto has_fuel_per_block() const -> bool noexcept
- auto has_heat_rate_segments() const -> bool noexcept
- auto heat_rate_kink_breakpoints() const -> const auto& noexcept
- auto heat_rate_kink_rows() const -> const auto& noexcept
- auto heat_rate_slack_cols() const -> const auto& noexcept
- auto id() const -> auto noexcept
- auto is_active(const StageLP& stage) const -> bool
- Checks if object is active in given stage.
- auto lookup_generation_col(const ScenarioLP& scenario, const StageLP& stage, BlockUid buid) const -> std::optional<ColIndex> noexcept
- auto lookup_generation_cols(const ScenarioLP& scenario, const StageLP& stage) const -> const auto& noexcept
- auto lookup_unserved_cols(const ScenarioLP& scenario, const StageLP& stage) const -> const auto& noexcept
- auto object() && -> Generator&& noexcept
- auto object() & -> Generator& noexcept
- Gets the wrapped object.
- auto object() const && -> const Generator&& noexcept
- auto object() const & -> const Generator& noexcept
- auto param_fuel_per_block(StageUid s, BlockUid b) const -> std::optional<Uid>
- auto qgen_cols_at(const ScenarioLP& scenario, const StageLP& stage) const -> const auto&
- LinDistFlow reactive-output columns (empty unless
qmin/qmax). - void set_annuity_inputs(const InputContext& ic, OF&& overnight_capcost, OF&& economic_life, OF&& wacc)
- Set the annuity inputs of an object priced by overnight cost.
- void set_fixed_om_cost(const InputContext& ic, OF&& fixed_om_cost)
- Set the fixed O&M cost of the expansion capacity.
- auto set_id(Uid uid, Name name) -> auto& noexcept
- Sets the object's identifier.
- auto short_name(this const Self& self) -> auto noexcept
- 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 uid() const -> auto noexcept
Parameter accessors for user constraint resolution
- auto param_pmax(StageUid s, BlockUid b) const -> auto
- auto param_pmin(StageUid s, BlockUid b) const -> auto
- auto param_gcost(StageUid s, BlockUid b) const -> auto
- auto srmc_at(const ScenarioLP& scenario, const StageLP& stage, BlockUid buid) const -> std::optional<double> noexcept
- auto available_fraction_at(const ScenarioLP& scenario, const StageLP& stage, BlockUid buid) const -> double noexcept
- auto has_outage_schedule() const -> bool noexcept
- True when the generator carries an
outage_fractionschedule. - auto param_heat_rate(StageUid s, BlockUid b) const -> auto
- auto param_lossfactor(StageUid s, BlockUid b) const -> auto
- auto param_emission_rate(StageUid s, BlockUid b) const -> auto
Typedef documentation
using gtopt:: GeneratorLP:: Base = ObjectLP<Generator>
#include <gtopt/capacity_object_lp.hpp>
using gtopt:: GeneratorLP:: CapacityAndCol = std::pair<std::optional<double>, std::optional<ColIndex>>
#include <gtopt/capacity_object_lp.hpp>
Pair of optional capacity value and optional expansion column index.
using gtopt:: GeneratorLP:: Element = Generator
#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:: GeneratorLP:: object_type = Generator
#include <gtopt/object_lp.hpp>
Type of the wrapped object.
Function documentation
gtopt:: GeneratorLP:: GeneratorLP(const Generator& generator,
const InputContext& ic) explicit
Constructs a GeneratorLP from a Generator.
| Parameters | |
|---|---|
| generator | Generator object to convert to LP representation |
| ic | Input context for parameter processing |
Creates an LP representation of a generator including time-dependent parameters like minimum/maximum generation limits, loss factors, and costs.
bool gtopt:: GeneratorLP:: add_to_lp(SystemContext& sc,
std::string_view ampl_class,
const ScenarioLP& scenario,
const StageLP& stage,
LinearProblem& lp)
#include <gtopt/capacity_object_lp.hpp>
Add capacity constraints to the linear problem.
| Parameters | |
|---|---|
| sc | System context providing stage/scenario info |
| ampl_class | Canonical lowercase PAMPL class name ("generator", "demand", "line", "battery", "converter") — used to register the stage-level capainst column into the AMPL variable registry for user-constraint lookups. |
| scenario | Current scenario |
| stage | Current stage |
| lp | Linear problem to modify |
| Returns | true if successful, false otherwise |
Adds capacity-related variables and constraints:
- Capacity installation variables
- Capacity cost variables
- Expansion model variables (if applicable)
- Balance equations between stages
- Cost tracking equations
bool gtopt:: GeneratorLP:: add_to_lp(SystemContext& sc,
const ScenarioLP& scenario,
const StageLP& stage,
LinearProblem& lp)
Adds generator variables and constraints to the linear problem.
| Parameters | |
|---|---|
| sc | System context containing current state |
| scenario | Scenario being built |
| stage | Stage being built |
| lp | Linear problem to add variables and constraints to |
| Returns | True if successful, false otherwise |
This method creates:
- Generation variables for each time block
- Capacity constraints linking generation to installed capacity
- Contributions to bus power balance equations
It handles:
- Time-dependent generation limits
- Generator loss factors
- Generation costs in the objective function
- Capacity constraints when capacity expansion is modeled
bool gtopt:: GeneratorLP:: add_to_output(OutputContext& out) const
Adds generator output results to the output context.
| Parameters | |
|---|---|
| out | Output context to add results to |
| Returns | True if successful, false otherwise |
Processes planning results for:
- Generation variables (primal solution and costs)
- Capacity constraint dual values (shadow prices)
- Capacity-related outputs via base class
double gtopt:: GeneratorLP:: annual_capcost_at(StageUid stage_uid,
double social_rate) const
#include <gtopt/capacity_object_lp.hpp>
Annualized investment cost [$/unit-year] at a stage.
annual_capcost when set; else the annuity of overnight_capcost at the object's wacc (or social_rate when unset) over its economic_life; else 0.
CapacityAndCol gtopt:: GeneratorLP:: capacity_and_col(const StageLP& stage,
LinearProblem& lp) const
#include <gtopt/capacity_object_lp.hpp>
Query capacity value and optional expansion column for a stage.
| Parameters | |
|---|---|
| stage | The stage to query |
| lp | Linear problem reference (needed for expansion col bounds) |
Returns {std::optional<double>, std::optional<ColIndex>}. The capacity is nullopt when no expansion column exists AND no capacity schedule value is defined — i.e. when the physical capacity is truly undefined. Callers that need a numeric fallback should use value_or(default) on the returned optional.
double gtopt:: GeneratorLP:: capacity_at(const StageLP& stage,
const double def_capacity = std::numeric_limits<double>::max()) const
#include <gtopt/capacity_object_lp.hpp>
Get the capacity at a specific stage.
| Parameters | |
|---|---|
| stage | The stage to query capacity for |
| def_capacity | Default value if capacity not specified (default: unlimited) |
| Returns | The capacity at given stage or default if not specified |
auto gtopt:: GeneratorLP:: capacity_col_at(const StageLP& stage) const noexcept
#include <gtopt/capacity_object_lp.hpp>
Get the column index for capacity at a specific stage.
| Parameters | |
|---|---|
| stage | The stage to get column index for |
| Returns | Optional containing column index if exists |
auto gtopt:: GeneratorLP:: class_name(this const Self& self) noexcept
#include <gtopt/object_lp.hpp>
auto gtopt:: GeneratorLP:: expmod_col_at(const StageLP& stage) const noexcept
#include <gtopt/capacity_object_lp.hpp>
Get the column index for the expansion-modules variable at a stage.
| Parameters | |
|---|---|
| stage | The stage to query |
| Returns | Optional column index (empty when the object has no expansion capacity or the stage did not create an expmod column) |
OptReal gtopt:: GeneratorLP:: fixed_om_cost_at(StageUid stage_uid) const
#include <gtopt/capacity_object_lp.hpp>
Fixed O&M cost [$/unit-year] at a stage (nullopt when unset).
std::vector<std::pair<ColIndex, double>> gtopt:: GeneratorLP:: fuel_burn_legs(const ScenarioLP& scenario,
const StageLP& stage,
BlockUid buid) const
Fuel burn of this generator at one (scenario, stage, block) as LP legs {(col, coef)} in fuel-units per hour: Σ coef · col is the fuel burn rate, so dur_b · Σ coef · col is the block's fuel use.
- scalar / per-(stage, block)
heat_rate:{(gen, hr_b)} - piecewise
heat_rate_segments:{(gen, h_1)}plus{(s_k, h_{k+1} − h_k)}for every heat-rate slack column — the convex PWL burnh₁·p + Σₖ Δhₖ · max(0, p − P̄ₖ). Empty when the block has no generation column or no heat rate. Must be called after this generator'sadd_to_lpfor the cell.
bool gtopt:: GeneratorLP:: has_fuel_per_block() const noexcept
True iff this generator carries a per-(stage, block) fuel override schedule (Generator.fuel_per_block). When true, callers should consult param_fuel_per_block(stage, block) to obtain the resolved uid for each block and fall back to Generator.fuel only when the per-block value is the sentinel uid 0 (or absent from fuel_array).
bool gtopt:: GeneratorLP:: has_heat_rate_segments() const noexcept
True iff this generator has piecewise-linear heat-rate segments (both pmax_segments and heat_rate_segments non-empty + same length). When true, add_to_lp installs K−1 slack columns + K−1 kink rows on top of the single primary generation column to express the convex piecewise cost.
const auto& gtopt:: GeneratorLP:: heat_rate_kink_breakpoints() const noexcept
Per-segment cumulative breakpoints (cumulative MW) used by the u-gating retro-fit in CommitmentLP::add_to_lp. Mirrors Generator.pmax_segments[0..K-2] (the kink RHS values) — the generator-side accessor avoids forcing CommitmentLP to re-read the OptTBRealSched and re-resolve the per-block sample. Empty when no segments are configured.
const auto& gtopt:: GeneratorLP:: heat_rate_kink_rows() const noexcept
[segment_index] -> STBIndexHolder<RowIndex> of piecewise kink rows. Same shape as heat_rate_slack_cols_. Exposed so CommitmentLP::add_to_lp can retro-fit the rows with the -pmax_segs[k-1] · u term that gates the segment by the commitment binary — the refactor that moved piecewise off Commitment dropped that u-link, producing an over-loose LP-relax (fractional u could dispatch full piecewise capacity). See commitment_lp.cpp "u-gate piecewise heat-rate kink rows".
const auto& gtopt:: GeneratorLP:: heat_rate_slack_cols() const noexcept
Resolved per-segment piecewise slack columns, ordered as [s_1, s_2, ..., s_{K-1}] matching breakpoints [pmax_segments[0], ..., pmax_segments[K-2]]. Empty when has_heat_rate_segments() is false. Used by add_emission_cap (in system_lp.cpp) to inject per-segment emission coefficients alongside the primary generation_cols entry.
auto gtopt:: GeneratorLP:: id() const noexcept
#include <gtopt/capacity_object_lp.hpp>
| Returns | The object's complete identifier (uid + name) |
|---|
bool gtopt:: GeneratorLP:: is_active(const StageLP& stage) const
#include <gtopt/capacity_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 |
std::optional<ColIndex> gtopt:: GeneratorLP:: lookup_generation_col(const ScenarioLP& scenario,
const StageLP& stage,
BlockUid buid) const noexcept
Tolerant block-level lookup over generation_cols — see lookup_inner (index_holder.hpp). Consumers (turbines, etc.) use this to handle blocks where the P1 zero-pmax skip elided the gen column, instead of flat_map::at-throwing.
const auto& gtopt:: GeneratorLP:: lookup_generation_cols(const ScenarioLP& scenario,
const StageLP& stage) const noexcept
Tolerant inner-map lookup over generation_cols. When every block of (scenario, stage) was skipped by the P1 zero-pmax optimization, the outer key is absent and generation_cols_at would throw. Mirrors WaterwayLP::flow_cols_at's tolerant behaviour via find_or_empty_inner.
const auto& gtopt:: GeneratorLP:: lookup_unserved_cols(const ScenarioLP& scenario,
const StageLP& stage) const noexcept
Per-(scenario, stage) map of unserved soft-pmin slack columns, keyed by block uid. Only populated for blocks where the soft-pmin branch fired (pmin_fcost > 0 and pmin > 0); tolerant lookup — returns an empty inner map when the outer key is absent.
Generator&& gtopt:: GeneratorLP:: object() && noexcept
#include <gtopt/capacity_object_lp.hpp>
Generator& gtopt:: GeneratorLP:: object() & noexcept
#include <gtopt/capacity_object_lp.hpp>
Gets the wrapped object.
| Returns | Reference to the wrapped object |
|---|
const Generator&& gtopt:: GeneratorLP:: object() const && noexcept
#include <gtopt/capacity_object_lp.hpp>
const Generator& gtopt:: GeneratorLP:: object() const & noexcept
#include <gtopt/capacity_object_lp.hpp>
std::optional<Uid> gtopt:: GeneratorLP:: param_fuel_per_block(StageUid s,
BlockUid b) const
Resolved per-(stage, block) fuel-uid override. Returns nullopt only when has_fuel_per_block() is false; when the schedule is set but the cell is unspecified, the OptSchedule layer returns the schedule's default (Uid {0} by convention), which callers interpret as "no override, use the static `Generator.fuel`".
void gtopt:: GeneratorLP:: set_annuity_inputs(const InputContext& ic,
OF&& overnight_capcost,
OF&& economic_life,
OF&& wacc)
#include <gtopt/capacity_object_lp.hpp>
Set the annuity inputs of an object priced by overnight cost.
Used where annual_capcost is unset at a stage: the LP charges overnight_capcost × CRF(wacc, economic_life) per unit-year, wacc falling back to the planning-wide annual_discount_rate.
void gtopt:: GeneratorLP:: set_fixed_om_cost(const InputContext& ic,
OF&& fixed_om_cost)
#include <gtopt/capacity_object_lp.hpp>
Set the fixed O&M cost of the expansion capacity.
fixed_om_cost [$/unit-year] is charged, next to the annuity, on the capacity built from a stage on. Unset → no fixed O&M.
auto& gtopt:: GeneratorLP:: 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:: GeneratorLP:: short_name(this const Self& self) noexcept
#include <gtopt/object_lp.hpp>
auto gtopt:: GeneratorLP:: 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:: GeneratorLP:: sv_key(this const Self& self,
const StageLP& stage,
std::string_view col_name) noexcept
#include <gtopt/object_utils.hpp>
auto gtopt:: GeneratorLP:: uid() const noexcept
#include <gtopt/capacity_object_lp.hpp>
| Returns | The object's unique identifier |
|---|
std::optional<double> gtopt:: GeneratorLP:: srmc_at(const ScenarioLP& scenario,
const StageLP& stage,
BlockUid buid) const noexcept
Short-run marginal cost (VOM + active-segment fuel, $/MWh) of the generation column at (scenario, stage, block), as built by add_to_lp; nullopt when the block has no generation column.
double gtopt:: GeneratorLP:: available_fraction_at(const ScenarioLP& scenario,
const StageLP& stage,
BlockUid buid) const noexcept
Available fraction 1 − outage_fraction of the unit applied at (scenario, stage, block); 1 when no outage is scheduled there.
Variable documentation
static std::string_view gtopt:: GeneratorLP:: CapacostName
#include <gtopt/capacity_object_lp.hpp>
static std::string_view gtopt:: GeneratorLP:: CapacostPrevName
#include <gtopt/capacity_object_lp.hpp>
static std::string_view gtopt:: GeneratorLP:: CapainstName
#include <gtopt/capacity_object_lp.hpp>
static std::string_view gtopt:: GeneratorLP:: CapainstPrevName
#include <gtopt/capacity_object_lp.hpp>
LP metadata variable_names for the dependent capainst/capacost columns that mirror a publisher in the previous phase at a cross-phase boundary. Named with a distinct suffix so the eager duplicate detector in LinearInterface::add_col can tell the dependent mirror apart from the current stage's own capainst/capacost (which share everything else in the 4-tuple metadata: class_name, variable_uid, stage context). The StateVariable lookup key still uses the un-suffixed names to match the publisher side in the previous phase.
static std::string_view gtopt:: GeneratorLP:: ExpmodName
#include <gtopt/capacity_object_lp.hpp>
static std::string_view gtopt:: GeneratorLP:: HeatRateKinkName
PAMPL-visible row name for piecewise kink rows p − s_k ≤ pmax_segments[k-1].
static std::string_view gtopt:: GeneratorLP:: HeatRateSlackName
PAMPL-visible slack column name for the convex piecewise heat-rate encoding. Disambiguated by segment index via the outer vector heat_rate_slack_cols_ (one holder per segment k = 1..K-1).
static std::string_view gtopt:: GeneratorLP:: PminSoftName
PAMPL-visible row name for the soft-pmin floor generation + unserved ≥ pmin.
static std::string_view gtopt:: GeneratorLP:: TypeKey
Filter metadata keys published by add_to_lp for sum(...) predicate matching.
static std::string_view gtopt:: GeneratorLP:: UnservedName
PAMPL-visible slack column name for the soft-pmin encoding: the non-negative shortfall unserved ≥ pmin − generation, priced at pmin_fcost. Present only on blocks where pmin_fcost > 0.