gtopt::SystemLP class

Central coordinator for power system LP formulation.

Manages conversion of System components to LP representations and coordinates:

  • Creation of variables and constraints
  • Time structure management (blocks, stages, scenarios)
  • Grid component interactions
  • Result output

Public types

using collections_t = std::tuple<Collection<BusLP>, Collection<DemandLP>, Collection<GeneratorLP>, Collection<LineLP>, Collection<GeneratorProfileLP>, Collection<DemandProfileLP>, Collection<BatteryLP>, Collection<ConverterLP>, Collection<ReserveZoneLP>, Collection<ReserveProvisionLP>, Collection<JunctionLP>, Collection<WaterwayLP>, Collection<FlowLP>, Collection<ReservoirLP>, Collection<ReservoirSeepageLP>, Collection<ReservoirDischargeLimitLP>, Collection<TurbineLP>, Collection<ReservoirProductionFactorLP>, Collection<FlowRightLP>, Collection<VolumeRightLP>, Collection<UserConstraintLP>>

Constructors, destructors, conversion operators

SystemLP() deleted
SystemLP(const System& system, SimulationLP& simulation, const LpMatrixOptions& flat_opts = {}) explicit
SystemLP(const System& system, SimulationLP& simulation, PhaseLP phase, SceneLP scene, const LpMatrixOptions& flat_opts = {}) explicit
Construct from System with simulation and options.
SystemLP(const SystemLP&) deleted
SystemLP(SystemLP&&) defaulted noexcept
~SystemLP() defaulted noexcept

Public functions

template<typename Self Self>
auto collections(this Self&& self) -> constexpr auto&& noexcept
template<typename Element Element, template<typename> class Id>
auto contains(const Id<Element>& id) const -> constexpr bool noexcept
auto create_lp(const LpMatrixOptions& flat_opts = {}) -> void
template<typename Element Element, typename Self Self, template<typename> class Id>
auto element(this Self&& self, const Id<Element>& id) -> constexpr auto&&
Get element by ID.
template<typename Element Element, template<typename> class Id>
auto element_index(const Id<Element>& id) const -> constexpr auto
Get index of element by ID.
template<typename Element Element, typename Self Self>
auto elements(this Self&& self) -> constexpr auto&& noexcept
Get all elements of specific type.
template<typename Id Id>
auto is_single_bus(const Id& id) const -> constexpr bool
template<typename Self Self>
auto linear_interface(this Self&& self) -> constexpr auto&& noexcept
Access linear interfaces.
auto name() const -> constexpr NameView noexcept
Get system name.
auto operator=(const SystemLP&) -> SystemLP& deleted noexcept
auto operator=(SystemLP&&) -> SystemLP& defaulted noexcept
auto options() const -> constexpr const auto& noexcept
Get system options.
auto phase() const -> constexpr const auto& noexcept
auto prev_phase_sys() const -> constexpr const SystemLP* noexcept
Get the previous phase's SystemLP (nullptr when not set).
template<typename Element Element>
auto push_back(Element&& e) -> constexpr auto noexcept(…)
Add element to appropriate collection.
auto resolve(const SolverOptions& solver_options = {}) -> std::expected<int, Error>
Resolves the linear programming problem.
auto scene() const -> constexpr const auto& noexcept
auto set_prev_phase_sys(const SystemLP* prev_sys) -> constexpr void noexcept
Set the previous phase's SystemLP (nullptr for phase 0).
auto single_bus_id() const -> constexpr const auto& noexcept
template<typename Self Self>
auto system(this Self&& self) -> constexpr auto&& noexcept
Access the underlying system.
template<typename Self Self>
auto system_context(this Self&& self) -> constexpr auto&& noexcept
Get system context.
auto update_lp() -> int
Update LP elements for all (scenario, stage) pairs in this system.
auto write_lp(const std::string& filename) const -> std::expected<std::string, Error>
Writes the LP problem to a file.
auto write_out() const -> void
Write output for all linear interfaces.

Typedef documentation

Function documentation

gtopt::SystemLP::SystemLP(const System& system, SimulationLP& simulation, PhaseLP phase, SceneLP scene, const LpMatrixOptions& flat_opts = {}) explicit

Construct from System with simulation and options.

Parameters
system The power system to model
simulation Reference to the SimulationLP (scenarios, phases, etc.)
phase Phase LP to associate with this system
scene Scene LP to associate with this system
flat_opts Additional LP build options (default empty)

template<typename Element Element, typename Self Self, template<typename> class Id>
constexpr auto&& gtopt::SystemLP::element(this Self&& self, const Id<Element>& id)

Get element by ID.

Parameters
self The object instance (deduced via explicit object parameter)
id Element ID
Returns Reference to the element

template<typename Element Element, template<typename> class Id>
constexpr auto gtopt::SystemLP::element_index(const Id<Element>& id) const

Get index of element by ID.

Parameters
id Element ID
Returns Index of the element

template<typename Element Element, typename Self Self>
constexpr auto&& gtopt::SystemLP::elements(this Self&& self) noexcept

Get all elements of specific type.

Returns Reference to elements container

template<typename Self Self>
constexpr auto&& gtopt::SystemLP::linear_interface(this Self&& self) noexcept

Access linear interfaces.

Returns Linear interfaces container

constexpr NameView gtopt::SystemLP::name() const noexcept

Get system name.

Returns System name as string view

constexpr const auto& gtopt::SystemLP::options() const noexcept

Get system options.

Returns Const reference to options

template<typename Element Element>
constexpr auto gtopt::SystemLP::push_back(Element&& e) noexcept(…)

Add element to appropriate collection.

Parameters
e Element to add
Returns Result of collection push_back

std::expected<int, Error> gtopt::SystemLP::resolve(const SolverOptions& solver_options = {})

Resolves the linear programming problem.

Parameters
solver_options Configuration options for the LP solver
Returns Expected with solver status code (0 = optimal) or error

template<typename Self Self>
constexpr auto&& gtopt::SystemLP::system(this Self&& self) noexcept

Access the underlying system.

Returns Reference to the system

template<typename Self Self>
constexpr auto&& gtopt::SystemLP::system_context(this Self&& self) noexcept

Get system context.

Returns Const reference to system context

int gtopt::SystemLP::update_lp()

Update LP elements for all (scenario, stage) pairs in this system.

Returns Total number of LP modifications across all elements

Iterates over all scenarios and stages in this SystemLP and dispatches element.update_lp() to every collection element that satisfies the HasUpdateLP concept. May update coefficients, bounds, or RHS values.

std::expected<std::string, Error> gtopt::SystemLP::write_lp(const std::string& filename) const

Writes the LP problem to a file.

Parameters
filename Base file name (phase/scene labels and .lp extension are appended automatically).
Returns The full path of the written file (with .lp extension).