#include <gtopt/capacity_object_lp.hpp>
template<typename Object Object>
CapacityObjectLP struct
A linear programming representation of an object with capacity constraints.
| Template parameters | |
|---|---|
| Object | The type of object being modeled, must provide capacity-related attributes |
Base classes
-
template<typename ObjectType>class ObjectLP<Object>
- Wrapper class that adds LP capabilities to objects.
- struct CapacityObjectBase
- Base class providing capacity constraint logic for LP objects.
Public types
- using Base = ObjectLP<Object>
- using CapacityAndCol = std::pair<std::optional<double>, std::optional<ColIndex>>
- Pair of optional capacity value and optional expansion column index.
- using Element = Object
- using object_type = Object
- Type of the wrapped object.
Public static variables
- static std::string_view CapacostName
- static std::string_view CapacostPrevName
- static std::string_view CapainstName
- static std::string_view ExpmodName
Constructors, destructors, conversion operators
-
template<typename ObjectT>CapacityObjectLP(ObjectT&& pobject, const InputContext& ic, const LPClassName cname) explicit constexpr
- Construct a new CapacityObjectLP object.
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 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 id() const -> auto noexcept
- auto is_active(const StageLP& stage) const -> bool
- Checks if object is active in given stage.
- auto object() && -> Object&& noexcept
- auto object() & -> Object& noexcept
- Gets the wrapped object.
- auto object() const && -> const Object&& noexcept
- auto object() const & -> const Object& 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 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
Typedef documentation
#include <gtopt/object_lp.hpp>
template<typename Object Object>
using gtopt:: CapacityObjectLP<Object>:: Element = Object
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.
#include <gtopt/object_lp.hpp>
template<typename Object Object>
using gtopt:: CapacityObjectLP<Object>:: object_type = Object
Type of the wrapped object.
Function documentation
template<typename Object Object>
template<typename ObjectT>
gtopt:: CapacityObjectLP<Object>:: CapacityObjectLP(ObjectT&& pobject,
const InputContext& ic,
const LPClassName cname) explicit constexpr
Construct a new CapacityObjectLP object.
| Template parameters | |
|---|---|
| ObjectT | Type of object being wrapped (deduced) |
| Parameters | |
| pobject | The object to wrap, will be moved if rvalue |
| ic | Input context providing stage/scenario information |
| cname | Class name for labeling columns/rows |
Initializes all capacity-related schedules from the wrapped object:
- Base capacity
- Expansion capacity
- Maximum capacity
- Expansion model
- Annual capacity costs
- Annual derating factors
template<typename Object Object>
bool gtopt:: CapacityObjectLP<Object>:: 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
template<typename Object Object>
bool gtopt:: CapacityObjectLP<Object>:: 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
template<typename Object Object>
CapacityAndCol gtopt:: CapacityObjectLP<Object>:: 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.
#include <gtopt/object_lp.hpp>
template<typename Object Object>
auto gtopt:: CapacityObjectLP<Object>:: class_name(this const Self& self) noexcept
#include <gtopt/object_lp.hpp>
template<typename Object Object>
auto& gtopt:: CapacityObjectLP<Object>:: set_id(Uid uid,
Name name) noexcept
Sets the object's identifier.
| Parameters | |
|---|---|
| uid | Unique identifier |
| name | Human-readable name |
| Returns | Reference to self for chaining |
#include <gtopt/object_lp.hpp>
template<typename Object Object>
auto gtopt:: CapacityObjectLP<Object>:: short_name(this const Self& self) noexcept
#include <gtopt/object_utils.hpp>
template<typename Object Object>
auto gtopt:: CapacityObjectLP<Object>:: sv_key(this const Self& self,
const ScenarioLP& scenario,
const StageLP& stage,
std::string_view col_name) noexcept
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 |
#include <gtopt/object_utils.hpp>
template<typename Object Object>
auto gtopt:: CapacityObjectLP<Object>:: sv_key(this const Self& self,
const StageLP& stage,
std::string_view col_name) noexcept