Skip to content

Combine Active/Reactive device constructors #165

Description

@acostarelli

Currently there's a number of device constructors that have reactive and non-reactive formulations where the reactive formulation is a strict superset of the non-reactive. I experimented in the past with making some helpers like _maybe_add_reactive... which unfortunately ended up in https://github.com/Sienna-Platform/PowerOperationsModels.jl/blob/main/src/common_models/network_conditional.jl which I would like removed ASAP.

I had Claude sketch a plan in https://github.com/Sienna-Platform/PowerOperationsModels.jl/tree/ac/reactive-refactor that I haven't examined closely yet. The important parts are:

on_reactive_power(f::F, ::NetworkModel{<:AbstractPowerModel}) where {F} = f()
on_reactive_power(::F, ::NetworkModel{<:AbstractActivePowerModel}) where {F} = nothing

and then for example

on_reactive_power(network_model) do
    add_variables!(container, ReactivePowerVariable, devices, D)
    add_to_expression!(
        container,
        ReactivePowerBalance,
        ReactivePowerVariable,
        devices,
        model,
        network_model,
    )
end

The diff is hard to tell right now, but looks like roughly ~1700 LOC removed and ~500 LOC added. My guess though is it slightly hurts precompilation time because now both branches have to be compiled?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions