#include <gtopt/storage_lp.hpp>
StorageLP class
Base classes
- struct Object
- Base object type providing common identification functionality.
Constructors, destructors, conversion operators
- StorageLP(ObjectT&& pstorage, const InputContext& ic, const LPClassName& cname) explicit
Public functions
-
template<typename SystemContextT SystemContextT>auto add_to_lp(std::string_view cname, SystemContextT& sc, const ScenarioLP& scenario, const StageLP& stage, LinearProblem& lp, const double flow_conversion_rate, const BIndexHolder<ColIndex>& finp_cols, const double finp_efficiency, const BIndexHolder<ColIndex>& fout_cols, const double fout_efficiency, const double stage_capacity, const std::optional<ColIndex> capacity_col = {}, const std::optional<Real> drain_cost = {}, const std::optional<Real> drain_capacity = {}, const StorageOptions opts = {}) -> bool
-
template<typename OutputContext OutputContext>auto add_to_output(OutputContext& out, std::string_view cname) const -> bool
- auto drain_cols_at(const ScenarioLP& scenario, const StageLP& stage) const -> constexpr const auto&
- auto efin_col_at(const ScenarioLP& scenario, const StageLP& stage) const -> constexpr auto
- auto eini_col_at(const ScenarioLP& scenario, const StageLP& stage) const -> ColIndex
- auto energy_cols_at(const ScenarioLP& scenario, const StageLP& stage) const -> constexpr const auto&
- auto energy_rows_at(const ScenarioLP& scenario, const StageLP& stage) const -> constexpr const auto&
- auto energy_scale() const -> constexpr double noexcept
- auto flow_scale() const -> constexpr double noexcept
- auto id(this const Self& self) -> constexpr auto noexcept
- Gets the object's identifier (explicit object syntax)
- auto physical_col_value(std::span<const double> col_values, ColIndex col) const -> constexpr double noexcept
- auto physical_efin(const LinearInterface& li, const ScenarioLP& scenario, const StageLP& stage, double default_efin) const -> double
- auto physical_efin(const SystemLPT& sys, const ScenarioLP& scenario, const StageLP& stage, double default_efin) const -> double
- Overload accepting a SystemLP (extracts LinearInterface internally).
- auto physical_eini(const LinearInterface& li, const ScenarioLP& scenario, const StageLP& stage, double default_eini) const -> double
- auto physical_eini(const SystemLPT& sys, const ScenarioLP& scenario, const StageLP& stage, double default_eini, const SIdT& sid) const -> double
- auto soft_emin_col_at(const ScenarioLP& scenario, const StageLP& stage) const -> std::optional<ColIndex>
- auto storage(this auto&& self) -> constexpr auto&& noexcept
- auto to_physical(double lp_value) const -> constexpr double noexcept
- Convert an LP-unit energy/volume value to physical units.
Parameter accessors for user constraint resolution
- auto param_emin(StageUid s) const -> auto
- auto param_emax(StageUid s) const -> auto
- auto param_ecost(StageUid s) const -> auto
Function documentation
constexpr const auto& gtopt:: StorageLP<Object>:: drain_cols_at(const ScenarioLP& scenario,
const StageLP& stage) const
Return the drain/spill column indices for (scenario, stage).
Drain columns represent the spillway (for reservoirs) or energy curtailment (for batteries). They are only present when the storage object has a non-zero drain cost; if absent for the requested pair, std::out_of_range is thrown (caught by the user-constraint resolver to produce a graceful std::nullopt).
ColIndex gtopt:: StorageLP<Object>:: eini_col_at(const ScenarioLP& scenario,
const StageLP& stage) const
Return the initial-energy column for (scenario, stage).
Three cases:
- Global initial condition (first stage of first phase): stored in eini_cols with a fixed "eini" column.
- Same-phase reuse: eini_cols stores the previous stage's efin col.
- Cross-phase SDDP boundary: sini_cols stores the "sini" col; fall back from eini_cols (which does NOT have this entry) to sini_cols.
Invariant: every active (scenario, stage) pair is stored in exactly one of the two maps. The fallback throws std::out_of_range only if the caller passes an invalid (scenario, stage) combination.
constexpr const auto& gtopt:: StorageLP<Object>:: energy_rows_at(const ScenarioLP& scenario,
const StageLP& stage) const
Return the energy balance row indices for (scenario, stage).
These are the storage balance constraint rows (one per block). External entities can add coefficients to these rows to couple their flow variables into this storage's energy balance.
constexpr double gtopt:: StorageLP<Object>:: energy_scale() const noexcept
Energy/volume scale factor used in the LP: LP_var = physical / scale. For batteries this is Battery::energy_scale; for reservoirs it is Reservoir::energy_scale. Use to convert between LP and physical units.
constexpr double gtopt:: StorageLP<Object>:: flow_scale() const noexcept
Flow variable scale factor used in the LP.
For drain (and extraction/finp/fout in the reservoir case): LP_var = physical / flow_scale. Default 1.0 (no scaling; battery default). Reservoirs use energy_scale.
constexpr double gtopt:: StorageLP<Object>:: physical_col_value(std::span<const double> col_values,
ColIndex col) const noexcept
| Parameters | |
|---|---|
| col_values | LP solution (or bounds) vector indexed by ColIndex |
| col | Column index of the energy/volume variable |
| Returns | The column value converted to physical units |
Retrieve a physical energy/volume value from an LP column vector.
double gtopt:: StorageLP<Object>:: physical_efin(const LinearInterface& li,
const ScenarioLP& scenario,
const StageLP& stage,
double default_efin) const
Retrieve the physical efin (final energy/volume) for a given scenario and stage. Fallback chain:
- LP optimal solution
- Warm column solution (loaded from hot-start state file)
- default_efin
double gtopt:: StorageLP<Object>:: physical_eini(const LinearInterface& li,
const ScenarioLP& scenario,
const StageLP& stage,
double default_eini) const
Retrieve the physical eini without cross-phase lookup.
Used by callers that only have a LinearInterface (e.g. tests, non-SDDP code). Fallback chain: optimal solution → warm solution → default_eini.
double gtopt:: StorageLP<Object>:: physical_eini(const SystemLPT& sys,
const ScenarioLP& scenario,
const StageLP& stage,
double default_eini,
const SIdT& sid) const
| Parameters | |
|---|---|
| sys | Current SystemLP (provides linear_interface and prev_phase_sys for cross-phase lookups). |
| scenario | Current scenario LP object. |
| stage | Current stage LP object. |
| default_eini | Initial energy/volume when no LP solution exists. |
| sid | ObjectSingleId for this element, used to look up the same storage element in the previous phase. |
Retrieve the physical eini (initial energy/volume) for a given scenario and stage.
For the first stage of the first phase the eini column is the fixed initial condition, so default_eini is returned directly.
For cross-phase boundaries (phase > 0), eini corresponds to the previous phase's efin. When the current LP hasn't been solved and no warm solution is available, the method looks up the previous phase's efin from sys.prev_phase_sys(). Fallback chain:
- Current LP optimal solution (eini/sini column)
- Current LP warm column solution (from hot-start state file)
- Previous phase's efin (via sys.prev_phase_sys())
- default_eini (system initial volume / vini)
std::optional<ColIndex> gtopt:: StorageLP<Object>:: soft_emin_col_at(const ScenarioLP& scenario,
const StageLP& stage) const
Return the soft-emin slack column for (scenario, stage), if it exists.
The soft-emin slack is only created when soft_emin > 0 and soft_emin_cost > 0 for the given stage. Returns std::nullopt when the column was not created (i.e., soft_emin is inactive for this stage).