#include <gtopt/profile_object_lp.hpp>
template<typename ProfileType, typename ElementLPType>
ProfileObjectLP class
Base class for profile-based LP objects.
| Template parameters | |
|---|---|
| ProfileType | The profile type (DemandProfile/GeneratorProfile) |
| ElementLPType | The associated element LP type (DemandLP/GeneratorLP) |
Base classes
-
template<typename ObjectType>class ObjectLP<ProfileType>
- Wrapper class that adds LP capabilities to objects.
Public types
- using Base = ObjectLP<ProfileType>
- using Element = ProfileType
- using object_type = ProfileType
- Type of the wrapped object.
Constructors, destructors, conversion operators
- ProfileObjectLP(ProfileType pprofile, InputContext& ic, const LPClassName& cname) explicit
- Construct a new ProfileObjectLP.
Public functions
- auto add_profile_to_lp(std::string_view full_class_name, const ScenarioLP& scenario, const StageLP& stage, LinearProblem& lp, std::string_view profile_name, const auto& element_cols, const std::optional<ColIndex>& capacity_col, double stage_capacity, ProfileLPMode mode = {}) -> bool
- Add profile constraints to LP.
- auto add_profile_to_output(std::string_view cname, OutputContext& out, std::string_view profile_name) const -> bool
- Add profile results to output.
- auto aperture_value(ScenarioUid scenario_uid, StageUid stage_uid, BlockUid block_uid) const -> std::optional<double>
- Return the profile value for a given scenario/stage/block.
- auto class_name(this const Self& self) -> auto noexcept
- auto id() const -> auto noexcept
- auto is_active(const StageLP& stage) const -> bool
- Checks if object is active in given stage.
- auto object() && -> ProfileType&& noexcept
- auto object() & -> ProfileType& noexcept
- Gets the wrapped object.
- auto object() const && -> const ProfileType&& noexcept
- auto object() const & -> const ProfileType& noexcept
- auto profile_rows() const -> const auto& noexcept
- Profile rows per (scenario, stage, block) — tests / diagnostics.
- auto profile_slack_cols() const -> const auto& noexcept
- 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
- auto update_aperture(LinearInterface& li, const ScenarioLP& base_scenario, F&& value_fn, const StageLP& stage) const -> bool
- Update profile constraint for an aperture scenario.
Typedef documentation
#include <gtopt/object_lp.hpp>
template<typename ProfileType, typename ElementLPType>
using gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: Element = ProfileType
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 ProfileType, typename ElementLPType>
using gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: object_type = ProfileType
Type of the wrapped object.
Function documentation
template<typename ProfileType, typename ElementLPType>
gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: ProfileObjectLP(ProfileType pprofile,
InputContext& ic,
const LPClassName& cname) explicit
Construct a new ProfileObjectLP.
| Parameters | |
|---|---|
| pprofile | The profile object |
| ic | Input context |
| cname | Class name for labeling columns/rows |
template<typename ProfileType, typename ElementLPType>
bool gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: add_profile_to_lp(std::string_view full_class_name,
const ScenarioLP& scenario,
const StageLP& stage,
LinearProblem& lp,
std::string_view profile_name,
const auto& element_cols,
const std::optional<ColIndex>& capacity_col,
double stage_capacity,
ProfileLPMode mode = {})
Add profile constraints to LP.
| Parameters | |
|---|---|
| full_class_name | Full class name used to label the profile columns/rows |
| scenario | Scenario |
| stage | Stage |
| lp | Linear problem |
| profile_name | Profile type name ("spillover"/"unserved") |
| element_cols | Element column indices per block |
| capacity_col | Capacity column index (if any) |
| stage_capacity | Stage capacity value |
| mode | Owner-kind specific formulation switches |
| Returns | true if successful |
A profile is a per-unit factor p of the owner capacity C. Two row forms are emitted (see ProfileLPMode and the formulation doc):
- slack-free (generator, no spillover cost):
x ≤ A, withA = min(C·p, x̄)for a fixed capacity (x̄= the owner column upper bound, i.e. the block pmax) orx − min(p, 1)·C_col ≤ 0with a capacity column. SpilloverA − xis reconstructed at output time; its dual is the dual of the≤row. - slack (demand, or a generator with
scost ≠ 0):x + s = A(resp.x + s − p·C_col = 0),0 ≤ s ≤ A(resp.s ≤ p·C̄).
template<typename ProfileType, typename ElementLPType>
bool gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: add_profile_to_output(std::string_view cname,
OutputContext& out,
std::string_view profile_name) const
Add profile results to output.
| Parameters | |
|---|---|
| cname | Class name prefix for labeling |
| out | Output context |
| profile_name | Profile type name ("spillover"/"unserved") |
| Returns | true if successful |
Slack-form stages read the slack column; slack-free stages rebuild slack = A − x ≥ 0 (or min(p·C_col, x̄) − x) from the owner primal and report the slack reduced cost as −dual of the ≤ row (the reduced cost of a zero-cost slack in the equivalent equality form), so <profile_name>_sol/_cost/_dual keep their meaning.
#include <gtopt/object_lp.hpp>
template<typename ProfileType, typename ElementLPType>
auto gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: class_name(this const Self& self) noexcept
template<typename ProfileType, typename ElementLPType>
auto gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: id() const noexcept
| Returns | The object's complete identifier (uid + name) |
|---|
#include <gtopt/object_lp.hpp>
template<typename ProfileType, typename ElementLPType>
ProfileType&& gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: object() && noexcept
#include <gtopt/object_lp.hpp>
template<typename ProfileType, typename ElementLPType>
ProfileType& gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: object() & noexcept
Gets the wrapped object.
| Returns | Reference to the wrapped object |
|---|
#include <gtopt/object_lp.hpp>
template<typename ProfileType, typename ElementLPType>
const ProfileType&& gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: object() const && noexcept
#include <gtopt/object_lp.hpp>
template<typename ProfileType, typename ElementLPType>
const ProfileType& gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: object() const & noexcept
template<typename ProfileType, typename ElementLPType>
const auto& gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: profile_slack_cols() const noexcept
Slack columns per (scenario, stage, block); empty for slack-free (scenario, stage) pairs — tests / diagnostics.
#include <gtopt/object_lp.hpp>
template<typename ProfileType, typename ElementLPType>
auto& gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: 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 ProfileType, typename ElementLPType>
auto gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: short_name(this const Self& self) noexcept
#include <gtopt/object_utils.hpp>
template<typename ProfileType, typename ElementLPType>
auto gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: 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 ProfileType, typename ElementLPType>
auto gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: sv_key(this const Self& self,
const StageLP& stage,
std::string_view col_name) noexcept
template<typename ProfileType, typename ElementLPType>
auto gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: uid() const noexcept
| Returns | The object's unique identifier |
|---|
template<typename ProfileType, typename ElementLPType>
template<std::invocable<StageUid, BlockUid> F>
bool gtopt:: ProfileObjectLP<ProfileType, ElementLPType>:: update_aperture(LinearInterface& li,
const ScenarioLP& base_scenario,
F&& value_fn,
const StageLP& stage) const
Update profile constraint for an aperture scenario.
| Parameters | |
|---|---|
| li | Cloned LinearInterface to modify in-place. |
| base_scenario | Original scenario (identifies stored rows). |
| value_fn | (StageUid, BlockUid) -> optional<double> provider. |
| stage | Stage to update. |
| Returns | true on success. |
Re-reads the profile value via value_fn and updates the constraint row accordingly (same clipping as add_profile_to_lp). When a capacity column was used during LP construction, updates the coefficient; otherwise updates the row RHS (and the slack bound in slack form).