gtopt::CapacityObjectBase struct

Base class providing capacity constraint logic for LP objects.

This class handles capacity constraints, expansion capabilities, and associated costs in a linear programming formulation.

Derived classes

template<typename Object Object>
struct CapacityObjectLP
A linear programming representation of an object with capacity constraints.
template<typename Object Object>
struct CapacityObjectLP
A linear programming representation of an object with capacity constraints.
template<typename Object Object>
struct CapacityObjectLP
A linear programming representation of an object with capacity constraints.
template<typename Object Object>
struct CapacityObjectLP
A linear programming representation of an object with capacity constraints.
template<typename Object Object>
struct CapacityObjectLP
A linear programming representation of an object with capacity constraints.
template<typename Object Object>
struct CapacityObjectLP
A linear programming representation of an object with capacity constraints.
template<typename Object Object>
struct CapacityObjectLP
A linear programming representation of an object with capacity constraints.
template<typename Object Object>
struct CapacityObjectLP
A linear programming representation of an object with capacity constraints.

Public types

using CapacityAndCol = std::pair<std::optional<double>, std::optional<ColIndex>>
Pair of optional capacity value and optional expansion column index.

Public static variables

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

Constructors, destructors, conversion operators

template<typename OF>
CapacityObjectBase(const InputContext& ic, const LPClassName cname, Id pid, OF&& capacity, OF&& expcap, OF&& capmax, OF&& expmod, OF&& annual_capcost, OF&& annual_derating, OptBool integer_expmod = {}) explicit constexpr

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_output(OutputContext& out) const -> bool
Add capacity solution data to output context.
auto annual_capcost_at(StageUid stage_uid, double social_rate) const -> double
Annualized investment cost [$/unit-year] at a stage.
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 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 id() const -> const Id& noexcept
template<typename OF>
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.
template<typename OF>
void set_fixed_om_cost(const InputContext& ic, OF&& fixed_om_cost)
Set the fixed O&M cost of the expansion capacity.
auto uid() const -> auto noexcept

Function documentation

bool gtopt::CapacityObjectBase::add_to_lp(SystemContext& sc, std::string_view ampl_class, const ScenarioLP& scenario, const StageLP& stage, LinearProblem& lp)

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::CapacityObjectBase::add_to_output(OutputContext& out) const

Add capacity solution data to output context.

Parameters
out Output context to populate
Returns true if successful, false otherwise

Adds:

  • Solution values for capacity variables
  • Cost values for capacity variables
  • Dual values for capacity constraints

double gtopt::CapacityObjectBase::annual_capcost_at(StageUid stage_uid, double social_rate) const

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::CapacityObjectBase::capacity_and_col(const StageLP& stage, LinearProblem& lp) const

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::CapacityObjectBase::capacity_at(const StageLP& stage, const double def_capacity = std::numeric_limits<double>::max()) const

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::CapacityObjectBase::capacity_col_at(const StageLP& stage) const noexcept

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::CapacityObjectBase::expmod_col_at(const StageLP& stage) const noexcept

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)

template<typename OF>
void gtopt::CapacityObjectBase::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.

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.

template<typename OF>
void gtopt::CapacityObjectBase::set_fixed_om_cost(const InputContext& ic, OF&& fixed_om_cost)

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.

Variable documentation

static std::string_view gtopt::CapacityObjectBase::CapainstPrevName

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.