DemandLP class
#include <gtopt/demand_lp.hpp>
Base classes
-
template<typename Object Object>struct CapacityObjectLP<Demand>
- A linear programming representation of an object with capacity constraints.
Public types
- using Base = ObjectLP<Demand>
- using CapacityAndCol = std::pair<std::optional<double>, std::optional<ColIndex>>
- Pair of optional capacity value and optional expansion column index.
- using CapacityBase = CapacityObjectLP<Demand>
- using Element = Demand
- using object_type = Demand
- Type of the wrapped object.
Public static variables
- static std::string_view BalanceName
- 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 EminName
- static std::string_view ExpmodName
- static std::string_view FailName
-
static std::array<std::string_view, max_
fail_ segments> FailSegNames - Per-segment failure output field names (
Demand/fail_seg<k>_sol). - static std::string_view LmanName
- static std::string_view LoadName
- static std::string_view LoadSegName
- static std::string_view TypeKey
Constructors, destructors, conversion operators
- DemandLP(const Demand& pdemand, const InputContext& ic) explicit
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
- auto add_to_output(OutputContext& out) const -> bool
- auto annual_capcost_at(StageUid stage_uid, double social_rate) const -> double
- Annualized investment cost [$/unit-year] at a stage.
- auto block_lmax_at(const ScenarioLP& scenario, const StageLP& stage, BlockUid buid) const -> std::optional<double> noexcept
- 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 class_name(this const Self& self) -> auto noexcept
- auto demand(this auto&& 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 fail_sol_at(const ScenarioLP& scenario, const StageLP& stage, const BlockLP& block, const ScaledView& col_sol) const -> double noexcept
- auto fixed_om_cost_at(StageUid stage_uid) const -> OptReal
- Fixed O&M cost [$/unit-year] at a stage (nullopt when unset).
- auto has_fail_segments() 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 load_col_offset(const ScenarioLP& scenario, const StageLP& stage, BlockUid buid) const -> double noexcept
- auto load_cols_at(const ScenarioLP& scenario, const StageLP& stage) const -> const auto&
- auto load_segment_cols(const ScenarioLP& scenario, const StageLP& stage, BlockUid buid) const -> std::span<const ColIndex> noexcept
- auto lookup_load_cols(const ScenarioLP& scenario, const StageLP& stage) const -> const auto& noexcept
- auto object() && -> Demand&& noexcept
- auto object() & -> Demand& noexcept
- Gets the wrapped object.
- auto object() const && -> const Demand&& noexcept
- auto object() const & -> const Demand& noexcept
- 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_lmax(StageUid s, BlockUid b) const -> auto
- auto param_fcost(StageUid s, BlockUid b) const -> auto
- auto param_lossfactor(StageUid s, BlockUid b) const -> auto
Typedef documentation
using gtopt:: DemandLP:: Base = ObjectLP<Demand>
#include <gtopt/capacity_object_lp.hpp>
using gtopt:: DemandLP:: 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:: DemandLP:: Element = Demand
#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:: DemandLP:: object_type = Demand
#include <gtopt/object_lp.hpp>
Type of the wrapped object.
Function documentation
bool gtopt:: DemandLP:: 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
double gtopt:: DemandLP:: 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.
std::optional<double> gtopt:: DemandLP:: block_lmax_at(const ScenarioLP& scenario,
const StageLP& stage,
BlockUid buid) const noexcept
Post-capacity-clamp lmax [MW] of (scenario, stage, block), i.e. the exogenous demand the LP must serve; nullopt when the block has no load path (zero lmax). Read by ReserveZoneLP to build the exogenous system demand of a plane-based reserve requirement.
CapacityAndCol gtopt:: DemandLP:: 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:: DemandLP:: 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:: DemandLP:: 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:: DemandLP:: class_name(this const Self& self) noexcept
#include <gtopt/object_lp.hpp>
auto gtopt:: DemandLP:: 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) |
double gtopt:: DemandLP:: fail_sol_at(const ScenarioLP& scenario,
const StageLP& stage,
const BlockLP& block,
const ScaledView& col_sol) const noexcept
Reconstructed failure quantity at (scenario, stage, block).
After the P0 demand-failure substitution (fail = lmax − load) the fail LP variable no longer exists. The value is derived at read time from the surviving load_cols primal solution and the cached block_lmax_values_ (post-capacity-clamp lmax). Returns 0.0 when no load_cols entry exists for the (s, t, b) — semantically "no failure because there is no demand to serve
here". col_sol is the LP's primal-solution view (the same span that OutputContext::col_sol_span wraps); callers pass it in to avoid per-call re-fetch. Used by SystemLP::accumulate_convergence_indicators to track unserved_demand.
OptReal gtopt:: DemandLP:: 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).
bool gtopt:: DemandLP:: has_fail_segments() const noexcept
True when the served load is split into K ≥ 2 tranche columns (stepwise failure curve active). Consumers that reference the demand's load column must then use load_segment_cols.
auto gtopt:: DemandLP:: id() const noexcept
#include <gtopt/capacity_object_lp.hpp>
| Returns | The object's complete identifier (uid + name) |
|---|
bool gtopt:: DemandLP:: 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 |
double gtopt:: DemandLP:: load_col_offset(const ScenarioLP& scenario,
const StageLP& stage,
BlockUid buid) const noexcept
Constant offset of the served load over its LP column: load = col + offset. Non-zero only under the Option C failure substitution (the column then carries load − lmax).
std::span<const ColIndex> gtopt:: DemandLP:: load_segment_cols(const ScenarioLP& scenario,
const StageLP& stage,
BlockUid buid) const noexcept
All K tranche columns of (scenario, stage, block) when the demand uses a stepwise failure curve (K ≥ 2); empty span otherwise (the single load_cols column then carries the whole served load). The physical served load is the plain sum of these columns (Option A) — every row that references load must stamp each.
const auto& gtopt:: DemandLP:: lookup_load_cols(const ScenarioLP& scenario,
const StageLP& stage) const noexcept
Tolerant inner-map lookup over load_cols. When every block of (scenario, stage) is skipped by the P1 zero-lmax optimization, the outer key is absent and load_cols_at would throw. Returns a reference to an empty block holder instead, so callers such as CapacityProfileLP can skip the stage safely.
Demand&& gtopt:: DemandLP:: object() && noexcept
#include <gtopt/capacity_object_lp.hpp>
Demand& gtopt:: DemandLP:: object() & noexcept
#include <gtopt/capacity_object_lp.hpp>
Gets the wrapped object.
| Returns | Reference to the wrapped object |
|---|
const Demand&& gtopt:: DemandLP:: object() const && noexcept
#include <gtopt/capacity_object_lp.hpp>
const Demand& gtopt:: DemandLP:: object() const & noexcept
#include <gtopt/capacity_object_lp.hpp>
void gtopt:: DemandLP:: 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:: DemandLP:: 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:: DemandLP:: 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:: DemandLP:: short_name(this const Self& self) noexcept
#include <gtopt/object_lp.hpp>
auto gtopt:: DemandLP:: 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:: DemandLP:: sv_key(this const Self& self,
const StageLP& stage,
std::string_view col_name) noexcept
#include <gtopt/object_utils.hpp>
auto gtopt:: DemandLP:: uid() const noexcept
#include <gtopt/capacity_object_lp.hpp>
| Returns | The object's unique identifier |
|---|
Variable documentation
static std::string_view gtopt:: DemandLP:: CapacostName
#include <gtopt/capacity_object_lp.hpp>
static std::string_view gtopt:: DemandLP:: CapacostPrevName
#include <gtopt/capacity_object_lp.hpp>
static std::string_view gtopt:: DemandLP:: CapainstName
#include <gtopt/capacity_object_lp.hpp>
static std::string_view gtopt:: DemandLP:: 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:: DemandLP:: ExpmodName
#include <gtopt/capacity_object_lp.hpp>
static std::string_view gtopt:: DemandLP:: LoadSegName
LP variable name of the served-load tranche columns k ≥ 2 of a stepwise failure curve (fail_segments). Tranche 1 keeps the load name so a single-segment curve is LP-identical to fcost.
static std::string_view gtopt:: DemandLP:: TypeKey
Filter metadata keys published by add_to_lp for sum(...) predicate matching.