From 01aee0dbd9569ff0ba5bd9ade750edbb32e577bf Mon Sep 17 00:00:00 2001 From: Julian Straus Date: Wed, 15 Apr 2026 09:52:36 +0200 Subject: [PATCH 1/3] Removed `TransInvData` legacy constructor --- NEWS.md | 1 + docs/src/library/public/emi_extension.md | 9 ++- ext/EMIExt/legacy_constructor.jl | 86 ------------------------ src/EnergyModelsGeography.jl | 3 - src/structures/data.jl | 26 ------- 5 files changed, 5 insertions(+), 120 deletions(-) diff --git a/NEWS.md b/NEWS.md index 2daa8ac..dcd5177 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,7 @@ * Breaking change required as early retirement is now allowed. * Changed the function call arguments for [`add_investment_constraints`](https://github.com/EnergyModelsX/EnergyModelsInvestments.jl/blob/0c84eb4fabdf6f3c188812a3555b40f2681e916b/src/model.jl#L1). * Adjustment can change model behavior and results. +* Removed legacy constructors for `TransInvData`. ## Version 0.11.6 (2026-04-15) diff --git a/docs/src/library/public/emi_extension.md b/docs/src/library/public/emi_extension.md index ef841c6..757650b 100644 --- a/docs/src/library/public/emi_extension.md +++ b/docs/src/library/public/emi_extension.md @@ -12,9 +12,8 @@ Transmission mode investments utilize the same investment data type ([`SingleInv ### [Legacy constructors](@id lib-pub-emi_ext-inv_data-leg) -We provide a legacy constructor, `TransInvData`, that uses the same input as in version 0.5.x. -If you want to adjust your model to the latest changes, please refer to the section *[Update your model to the latest version of EnergyModelsInvestments](@extref EnergyModelsInvestments how_to-update-05)*. +We provided a legacy constructor, `TransInvData`, that uses the same input as in version 0.5.x. +This legacy constructor was removed starting in version 0.12. -```@docs -TransInvData -``` +This implies you must adjust your model if you still utilize the for version. +The adjustment is explained in the section *[Update your model to the latest version of EnergyModelsInvestments](@extref EnergyModelsInvestments how_to-update-05)*. diff --git a/ext/EMIExt/legacy_constructor.jl b/ext/EMIExt/legacy_constructor.jl index 7b60ee0..e69de29 100644 --- a/ext/EMIExt/legacy_constructor.jl +++ b/ext/EMIExt/legacy_constructor.jl @@ -1,86 +0,0 @@ - -""" - TransInvData(; - capex_trans::TimeProfile, - trans_max_inst::TimeProfile, - trans_max_add::TimeProfile, - trans_min_add::TimeProfile, - inv_mode::Investment = ContinuousInvestment(), - trans_start::Union{Real, Nothing} = nothing, - trans_increment::TimeProfile = FixedProfile(0), - capex_trans_offset::TimeProfile = FixedProfile(0), - ) - -Legacy constructor for a `TransInvData`. - -The new storage descriptions allows now for a reduction in functions which is used -to make `EnergModelsInvestments` less dependent on `EnergyModelsBase`. - -The core changes to the existing structure is the move of the required parameters to the -type Investment (_e.g._, the minimum and maximum added capacity is only required -for investment mdodes that require these parameters) as well as moving the `lifetime` to the -type [`LifetimeMode`], when required. - -See the _[documentation](https://energymodelsx.github.io/EnergyModelsInvestments.jl/stable/how-to/update-models)_ -for further information regarding how you can translate your existing model to the new model. -""" -function EMG.TransInvData(; - capex_trans::TimeProfile, - trans_max_inst::TimeProfile, - trans_max_add::TimeProfile, - trans_min_add::TimeProfile, - inv_mode::Investment = ContinuousInvestment(), - trans_start::Union{Real, Nothing} = nothing, - trans_increment::TimeProfile = FixedProfile(0), - capex_trans_offset::TimeProfile = FixedProfile(0), -) - # Create the new investment mode structures - if isa(inv_mode, BinaryInvestment) - @error( - "BinaryInvestment() cannot use the constructor as it is not possible to " * - "deduce the capacity for the investment. You have to instead use the new " * - "types as outlined in the documentation (https://energymodelsx.github.io/EnergyModelsInvestments.jl/stable/how-to/update-models)" - ) - return - elseif isa(inv_mode, FixedInvestment) - @error( - "FixedInvestment() cannot use the constructor as it is not possible to " * - "deduce the capacity for the investment. You have to instead use the new " * - "types as outlined in the documentation (https://energymodelsx.github.io/EnergyModelsInvestments.jl/stable/how-to/update-models)" - ) - return - elseif isa(inv_mode, DiscreteInvestment) - tmp_inv_mode = DiscreteInvestment(trans_increment) - elseif isa(inv_mode, ContinuousInvestment) - tmp_inv_mode = ContinuousInvestment(trans_min_add, trans_max_add) - elseif isa(inv_mode, SemiContinuousInvestment) - tmp_inv_mode = SemiContinuousInvestment(trans_min_add, trans_max_add) - elseif isa(inv_mode, SemiContinuousOffsetInvestment) - tmp_inv_mode = SemiContinuousOffsetInvestment(trans_min_add, trans_max_add, capex_trans_offset) - end - - @warn( - "The used implementation of a `TransInvData` will be discontinued in the near " * - "future. See the documentation for the new implementation using the type " * - "`SingleInvData` in the section on _How to update your model to the latest versions_.\n" * - "The core change is that we allow the individual parameters are moved to the " * - "field `inv_mode` and we allow now for `life_mode`.\n", - maxlog = 1, - ) - - # Create the new generalized investment data - if isnothing(trans_start) - return SingleInvData( - capex_trans, - trans_max_inst, - tmp_inv_mode, - ) - else - return SingleInvData( - capex_trans, - trans_max_inst, - trans_start, - tmp_inv_mode, - ) - end -end diff --git a/src/EnergyModelsGeography.jl b/src/EnergyModelsGeography.jl index cc71d27..4f59590 100644 --- a/src/EnergyModelsGeography.jl +++ b/src/EnergyModelsGeography.jl @@ -34,9 +34,6 @@ export Transmission, TransmissionMode export RefStatic, RefDynamic export PipeMode, PipeSimple, PipeLinepackSimple -# Export the legacy constructor for transmission investment data -export TransInvData - # Export utility functions export getnodesinarea, nodes_in_area diff --git a/src/structures/data.jl b/src/structures/data.jl index ab67368..e69de29 100644 --- a/src/structures/data.jl +++ b/src/structures/data.jl @@ -1,26 +0,0 @@ -""" - TransInvData(; - capex_trans::TimeProfile, - trans_max_inst::TimeProfile, - trans_max_add::TimeProfile, - trans_min_add::TimeProfile, - inv_mode::Investment = ContinuousInvestment(), - trans_start::Union{Real, Nothing} = nothing, - trans_increment::TimeProfile = FixedProfile(0), - capex_trans_offset::TimeProfile = FixedProfile(0), - ) - -Legacy constructor for a `InvData`. - -The new storage descriptions allows now for a reduction in functions which is used -to make `EnergModelsInvestments` less dependent on `EnergyModelsBase`. - -The core changes to the existing structure is the move of the required parameters to the -type Investment (_e.g._, the minimum and maximum added capacity is only required -for investment mdodes that require these parameters) as well as moving the `lifetime` to the -type [`LifetimeMode`], when required. - -See the _[documentation](https://energymodelsx.github.io/EnergyModelsInvestments.jl/stable/how-to/update-models)_ -for further information regarding how you can translate your existing model to the new model. -""" -TransInvData(nothing) = nothing From 8dd4b151587749435543d8fc251e5c53245083e1 Mon Sep 17 00:00:00 2001 From: Julian Straus Date: Wed, 15 Apr 2026 10:27:03 +0200 Subject: [PATCH 2/3] Removed legacy constructors for: * `GeoAvailability`, * `PipeSimple`, and * `PipeLinepackSimple` --- NEWS.md | 3 +- docs/src/how-to/update-models.md | 19 ++- src/legacy_constructors.jl | 211 ------------------------------- 3 files changed, 16 insertions(+), 217 deletions(-) diff --git a/NEWS.md b/NEWS.md index dcd5177..649eb5a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,7 +8,8 @@ * Breaking change required as early retirement is now allowed. * Changed the function call arguments for [`add_investment_constraints`](https://github.com/EnergyModelsX/EnergyModelsInvestments.jl/blob/0c84eb4fabdf6f3c188812a3555b40f2681e916b/src/model.jl#L1). * Adjustment can change model behavior and results. -* Removed legacy constructors for `TransInvData`. +* Removed legacy constructors for `TransInvData` (you can see how to update existing models in *[the documentation of `EnergyModelsInvestments`](https://energymodelsx.github.io/EnergyModelsInvestments.jl/stable/how-to/update-models/#how_to-update-05-inv_data)). +* Removed legacy constructors for `GeoAvailability`, `PipeSimple`, and `PipeLinepackSimple` (you can see how to update existing models in *[the documentation of `EnergyModelsGeography`](https://energymodelsx.github.io/EnergyModelsGeography.jl/stable/how-to/update-models/#how_to-update-09)) ## Version 0.11.6 (2026-04-15) diff --git a/docs/src/how-to/update-models.md b/docs/src/how-to/update-models.md index 714b4d8..9fa5d72 100644 --- a/docs/src/how-to/update-models.md +++ b/docs/src/how-to/update-models.md @@ -40,7 +40,7 @@ Furthermore, we reworked the design for inclusion of emission and OPEX variables It is now necessary to provide a new method to the function [`EnergyModelsBase.has_emissions`](@ref) if you plan to include [`TransmissionMode`](@ref)s with emissions instead of a separate function declared within `EnergyModelsGeography`. In addition, the function `emission` was renamed to [`emissions`](@ref EnergyModelsGeography.emissions) and, if not called with a `TimePeriod` as input argument, returns a `TimeProfile` instead of a Real. -## [Adjustments from 0.9.x](@id how_to-update-09) +## [Adjustments from 0.9.x to 0.11.x](@id how_to-update-09) ### [Key changes for transmission mode descriptions](@id how_to-update-09-mode) @@ -68,9 +68,10 @@ We consider it to be more consistent with the framework philosophy to remove tha The translations below describe the keyword constructor. You only have to remove the entry to the field of directions. -!!! note "Timeline for constructors" - The legacy constructors for calls of the composite types of version 0.9 will be included at least until version 0.11. - However, it is recommended to update your model as soon as possible to the latest version. +!!! warning "Removal of constructors" + The legacy constructors for calls of the composite types of version 0.9 where removed in version 0.12. + + This implies that you must adjust existing models to the lastest version if you have not done this yet. ### [`PipeSimple`](@ref) @@ -140,7 +141,7 @@ PipeLinepackSimple( ) ``` -## [Adjustments from 0.7.x](@id how_to-update-07) +## [Adjustments from 0.7.x to 0.11.x](@id how_to-update-07) ### [`GeoAvailability`](@ref) @@ -156,4 +157,12 @@ GeoAvailability( # This translates to the following new version GeoAvailability(id, collect(keys(input)), collect(keys(output))) + +# or alternatively +GeoAvailability(id, collect(keys(input))) ``` + +!!! warning "Removal of constructor" + The legacy constructor for calls of the composite types of version 0.7 was removed in version 0.12. + + This implies that you must adjust existing models to the lastest version if you have not done this yet. diff --git a/src/legacy_constructors.jl b/src/legacy_constructors.jl index 8663eb5..e69de29 100644 --- a/src/legacy_constructors.jl +++ b/src/legacy_constructors.jl @@ -1,211 +0,0 @@ -""" -Legacy constructor for a `GeoAvailability`. This version will be discontinued -in the near future and replaced with the application of Arrays instead of Dictionaries. -""" -function GeoAvailability( - id, - input::Dict{<:Resource,<:Real}, - output::Dict{<:Resource,<:Real}, - ) - - @warn("This implementation of a `GeoAvailability` will be discontinued in \ - the near future. See the documentation for the new implementation not requiring using \ - a dictionary. It is recommended to update the existing version to the new version.") - - return GeoAvailability(id, collect(keys(input)), collect(keys(output))) -end - -""" - PipeSimple( - id::String, - inlet::EMB.Resource, - outlet::EMB.Resource, - consuming::EMB.Resource, - consumption_rate::TimeProfile, - trans_cap::TimeProfile, - trans_loss::TimeProfile, - opex_var::TimeProfile, - opex_fixed::TimeProfile, - directions::Int = 1 - data::Vector{ExtensionData} = ExtensionData[] - ) - -Legacy constructor for a `PipeSimple`. -This version will be discontinued in the near future and replaced with the new version that -is no longer using the field directions. - -See the *[documentation](https://energymodelsx.github.io/EnergyModelsBase.jl/stable/how-to/update-models)* -for further information regarding how you can translate your existing model to the new model. -""" -function PipeSimple( - id::String, - inlet::EMB.Resource, - outlet::EMB.Resource, - consuming::EMB.Resource, - consumption_rate::TimeProfile, - trans_cap::TimeProfile, - trans_loss::TimeProfile, - opex_var::TimeProfile, - opex_fixed::TimeProfile, - directions::Int, - data::Vector{ExtensionData}, -) - @warn( - "The used implementation of a `PipeSimple` will be discontinued in the near future. " * - "See the documentation for the new implementation in which we no longer utilize " * - "the keyword constructor.\n" * - "The only change required is to remove the keywords or alternatively the value for " * - "directions.", - maxlog = 1 - ) - - tmp = PipeSimple( - id, - inlet, - outlet, - consuming, - consumption_rate, - trans_cap, - trans_loss, - opex_var, - opex_fixed, - data, - ) - return tmp -end -function PipeSimple(; - id::String, - inlet::EMB.Resource, - outlet::EMB.Resource, - consuming::EMB.Resource, - consumption_rate::TimeProfile, - trans_cap::TimeProfile, - trans_loss::TimeProfile, - opex_var::TimeProfile, - opex_fixed::TimeProfile, - directions::Int = 1, - data::Vector{ExtensionData} = ExtensionData[], -) - @warn( - "The used implementation of a `PipeSimple` will be discontinued in the near future. " * - "See the documentation for the new implementation in which we no longer utilize " * - "the keyword constructor.\n" * - "The only change required is to remove the keywords or alternatively the value for " * - "directions.", - maxlog = 1 - ) - - tmp = PipeSimple( - id, - inlet, - outlet, - consuming, - consumption_rate, - trans_cap, - trans_loss, - opex_var, - opex_fixed, - data, - ) - return tmp -end - -""" - PipeLinepackSimple( - id::String, - inlet::EMB.Resource, - outlet::EMB.Resource, - consuming::EMB.Resource, - consumption_rate::TimeProfile, - trans_cap::TimeProfile, - trans_loss::TimeProfile, - opex_var::TimeProfile, - opex_fixed::TimeProfile, - energy_share::Float64, - directions::Int = 1 - data::Vector{ExtensionData} = ExtensionData[] - ) - -Legacy constructor for a `PipeLinepackSimple`. -This version will be discontinued in the near future and replaced with the new version that -is no longer using the field directions. - -See the *[documentation](https://energymodelsx.github.io/EnergyModelsBase.jl/stable/how-to/update-models)* -for further information regarding how you can translate your existing model to the new model. -""" -function PipeLinepackSimple( - id::String, - inlet::EMB.Resource, - outlet::EMB.Resource, - consuming::EMB.Resource, - consumption_rate::TimeProfile, - trans_cap::TimeProfile, - trans_loss::TimeProfile, - opex_var::TimeProfile, - opex_fixed::TimeProfile, - energy_share::Float64, - directions::Int, - data::Vector{ExtensionData}, -) - @warn( - "The used implementation of a `PipeLinepackSimple` will be discontinued in the near future. " * - "See the documentation for the new implementation in which we no longer utilize " * - "the keyword constructor.\n" * - "The only change required is to remove the keywords or alternatively the value for " * - "directions.", - maxlog = 1 - ) - - tmp = PipeLinepackSimple( - id, - inlet, - outlet, - consuming, - consumption_rate, - trans_cap, - trans_loss, - opex_var, - opex_fixed, - energy_share, - data, - ) - return tmp -end -function PipeLinepackSimple(; - id::String, - inlet::EMB.Resource, - outlet::EMB.Resource, - consuming::EMB.Resource, - consumption_rate::TimeProfile, - trans_cap::TimeProfile, - trans_loss::TimeProfile, - opex_var::TimeProfile, - opex_fixed::TimeProfile, - energy_share::Float64, - directions::Int = 1, - data::Vector{ExtensionData} = ExtensionData[], -) - @warn( - "The used implementation of a `PipeLinepackSimple` will be discontinued in the near future. " * - "See the documentation for the new implementation in which we no longer utilize " * - "the keyword constructor.\n" * - "The only change required is to remove the keywords or alternatively the value for " * - "directions.", - maxlog = 1 - ) - - tmp = PipeLinepackSimple( - id, - inlet, - outlet, - consuming, - consumption_rate, - trans_cap, - trans_loss, - opex_var, - opex_fixed, - energy_share, - data, - ) - return tmp -end From 01149602eb102f5239e7f69130014c3df330bea9 Mon Sep 17 00:00:00 2001 From: Julian Straus Date: Wed, 15 Apr 2026 10:59:49 +0200 Subject: [PATCH 3/3] Moved from `Data` to `ExtensionData` --- docs/src/how-to/extend-resource-functionality.md | 2 +- docs/src/how-to/update-models.md | 4 +++- test/test_resource_flow.jl | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/src/how-to/extend-resource-functionality.md b/docs/src/how-to/extend-resource-functionality.md index 12c0076..79f886e 100644 --- a/docs/src/how-to/extend-resource-functionality.md +++ b/docs/src/how-to/extend-resource-functionality.md @@ -40,7 +40,7 @@ struct PotentialLossMode{T <: PotentialPower} <: TransmissionMode opex_var::TimeProfile opex_fixed::TimeProfile directions::Int - data::Vector{Data} + data::Vector{<:ExtensionData} loss_factor::Float64 end ``` diff --git a/docs/src/how-to/update-models.md b/docs/src/how-to/update-models.md index 9fa5d72..8fdaab4 100644 --- a/docs/src/how-to/update-models.md +++ b/docs/src/how-to/update-models.md @@ -70,9 +70,11 @@ You only have to remove the entry to the field of directions. !!! warning "Removal of constructors" The legacy constructors for calls of the composite types of version 0.9 where removed in version 0.12. - This implies that you must adjust existing models to the lastest version if you have not done this yet. + `Data` was furthermore replaced with `ExtensionData` in [`EnergyModelsBase` v0.9.1](https://github.com/EnergyModelsX/EnergyModelsBase.jl/releases/tag/v0.9.1). + This means that you must also replace the field information to `Vector{<:ExtensionData}` and a potential vector that is added to `ExtensionData[]`. + ### [`PipeSimple`](@ref) ```julia diff --git a/test/test_resource_flow.jl b/test/test_resource_flow.jl index 583e5e4..2a529de 100644 --- a/test/test_resource_flow.jl +++ b/test/test_resource_flow.jl @@ -17,7 +17,7 @@ struct PotentialLossMode{T <: PotentialPower} <: TransmissionMode opex_var::TimeProfile opex_fixed::TimeProfile directions::Int - data::Vector{Data} + data::Vector{<:ExtensionData} loss_factor::Float64 end @@ -38,7 +38,7 @@ function PotentialLossMode( opex_var, opex_fixed, 1, - Data[], + ExtensionData[], loss_factor, ) end