gtopt::StageLP class

A class representing a stage in a linear programming planning problem.

Encapsulates a collection of blocks with time duration, discounting, and indexing

Public static variables

static std::string_view ClassName
static std::string_view DurationName
Total stage duration in hours.
static std::string_view MonthName
Calendar month attribute name (1=Jan..12=Dec when set).
static std::string_view UidName
Stage uid attribute name (numeric uid of the active stage).

Public static functions

static auto calculate_discount_factor(double annual_rate, double timeinit) -> auto noexcept

Constructors, destructors, conversion operators

StageLP() defaulted
StageLP(Stage stage, std::span<const Block> blocks = {}, double annual_discount_rate = 0.0, StageIndex stage_index = StageIndex {unknown_index}, PhaseIndex phase_index = PhaseIndex {unknown_index}, PhaseStageIndex phase_stage_index = PhaseStageIndex {unknown_index}) explicit
Constructs a StageLP from a Stage and a collection of blocks.

Public functions

auto annual_discount_rate() const -> auto noexcept
auto blocks() const -> const auto& noexcept
auto commitment_breaks() const -> std::span<const Real> noexcept
auto cycle_group() const -> auto noexcept
auto cycle_weight() const -> double noexcept
auto discount_factor() const -> auto noexcept
auto duration() const -> auto noexcept
auto is_active() const -> auto noexcept
auto is_chronological() const -> bool noexcept
auto is_horizon_first() const -> bool noexcept
auto is_periodic() const -> bool noexcept
auto is_phase_first() const -> bool noexcept
auto month() const -> auto noexcept
auto period_hours() const -> auto noexcept
auto phase_index() const -> auto noexcept
auto phase_stage_index() const -> PhaseStageIndex noexcept
auto point_sampling() const -> bool noexcept
auto real_duration(const BlockLP& block) const -> double noexcept
auto repetitions() const -> double noexcept
auto stage() const -> const auto& noexcept
auto stage_index() const -> StageIndex noexcept
auto start_hour() const -> double noexcept
auto time_scale() const -> double noexcept
auto timeinit() const -> auto noexcept
auto total_duration() const -> auto noexcept
auto uid() const -> auto noexcept

Function documentation

static auto gtopt::StageLP::calculate_discount_factor(double annual_rate, double timeinit) noexcept

Returns Combined discount factor (annual and stage-specific)

gtopt::StageLP::StageLP(Stage stage, std::span<const Block> blocks = {}, double annual_discount_rate = 0.0, StageIndex stage_index = StageIndex {unknown_index}, PhaseIndex phase_index = PhaseIndex {unknown_index}, PhaseStageIndex phase_stage_index = PhaseStageIndex {unknown_index}) explicit

Constructs a StageLP from a Stage and a collection of blocks.

Parameters
stage The stage definition
blocks Collection of blocks
annual_discount_rate Annual discount rate for time value calculations
stage_index GLOBAL position (in SimulationLP::stages())
phase_index Index of the parent phase
phase_stage_index Position inside the parent phase (unknown for the flat global copies)

const auto& gtopt::StageLP::blocks() const noexcept

Returns Span of blocks in this stage

std::span<const Real> gtopt::StageLP::commitment_breaks() const noexcept

Returns Daily commitment grid of this stage (Stage. commitment_breaks; empty = the planning default)

auto gtopt::StageLP::cycle_group() const noexcept

Returns Storage cycle group id (unset = per-stage daily closure)

double gtopt::StageLP::cycle_weight() const noexcept

Returns Repetitions of this stage inside its cycle group (default: periods represented, duration / period_hours; days, duration / 24, when period_hours is unset)

auto gtopt::StageLP::duration() const noexcept

Returns Total duration of the stage in hours

auto gtopt::StageLP::is_active() const noexcept

Returns Whether this stage is active in the planning

bool gtopt::StageLP::is_chronological() const noexcept

Returns Whether this stage has chronologically ordered blocks

bool gtopt::StageLP::is_horizon_first() const noexcept

Returns true for the first stage of the first phase (the horizon start, where the case eini IS the incoming state). Only phase copies (PhaseLP::stages()) know this; the flat global copies carry no phase position and answer false, as the pre-typed check did.

bool gtopt::StageLP::is_periodic() const noexcept

Returns True when the stage is a circular typical period (Stage.periodic, default: period_hours set or point sampling); see Stage::periodic for the options that make its couplings wrap

bool gtopt::StageLP::is_phase_first() const noexcept

Returns true for the first stage of its phase.

auto gtopt::StageLP::month() const noexcept

Returns Calendar month for this stage (if set)

auto gtopt::StageLP::period_hours() const noexcept

Returns Real length of the sampled chronological period [h], if set

PhaseStageIndex gtopt::StageLP::phase_stage_index() const noexcept

Returns Position of this stage inside its phase (PhaseLP::stages()); unknown for the flat global copies held by SimulationLP::stages().

bool gtopt::StageLP::point_sampling() const noexcept

Returns True when block values are point samples at Block.time (Stage.sampling = "point")

double gtopt::StageLP::real_duration(const BlockLP& block) const noexcept

Returns Real time step of a block of this stage [h]

double gtopt::StageLP::repetitions() const noexcept

Returns Repetitions n of the typical period inside the stage (duration / period_hours, 1 when period_hours is unset)

StageIndex gtopt::StageLP::stage_index() const noexcept

Returns GLOBAL position of this stage (in SimulationLP::stages(), active stages only). There is deliberately no plain index(): a stage has two positions and the caller must say which one.

double gtopt::StageLP::start_hour() const noexcept

Returns Clock time of the stage start [h after midnight, any value >= 0, taken modulo 24 by the daily commitment grid]; 0 when unset

double gtopt::StageLP::time_scale() const noexcept

Returns Real-time factor κ: real Δt_b = duration_b · κ (period_hours / duration, 1 when period_hours is unset)

auto gtopt::StageLP::uid() const noexcept

Returns Unique identifier for this stage

Variable documentation

static std::string_view gtopt::StageLP::ClassName

Class name used in user-constraint expressions (stage.month, ...). Stage is not a registered LP element collection, but it is exposed as a singleton class in the AMPL parameter resolver so PAMPL constraints can read calendar metadata for the active stage.