Skip to content

Commit a409b45

Browse files
authored
Removal of legacy constructors (#86)
1 parent b08b693 commit a409b45

10 files changed

Lines changed: 12 additions & 543 deletions

File tree

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Release notes
22

3-
## Unversioned
3+
## Version 0.10.0 (2026-04-09)
44

55
### Breaking changes
66

77
* Adjusted to the changes introduced in [`EnergyModelsInvestments` 0.9](https://github.com/EnergyModelsX/EnergyModelsInvestments.jl/releases/tag/v0.9.0):
88
* Breaking change required as early retirement is now allowed.
99
* Changed the function call arguments for [`add_investment_constraints`](https://github.com/EnergyModelsX/EnergyModelsInvestments.jl/blob/0c84eb4fabdf6f3c188812a3555b40f2681e916b/src/model.jl#L1).
10+
* Removed legacy constructors for the old descriptions of `RefStorage` as outlined in the *[documentation](https://energymodelsx.github.io/EnergyModelsBase.jl/stable/how-to/update-models/#how_to-update-06-nodes)*.
11+
* Removed legacy constructors for `SingleInvData` (based on the change of the field `initial` in `EnergyModelsInvestments`), `InvData`, `InvDataStorage`, and all `Investment` modes and `LifetimeMode`s.
1012

1113
### Minor updates
1214

docs/src/how-to/update-models.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ This implies that we removed the argument `formulation::Formulation` and reorder
4343
The field `formulation` still exists for `Direct`.
4444
It can be used to provide differnet submethods, *e.g.*, when creating capacity constraints.
4545

46-
## [Adjustments from 0.6.x to 0.8.x](@id how_to-update-06)
46+
## [Adjustments from 0.6.x to 0.9.x](@id how_to-update-06)
4747

4848
### [Key changes for nodal descriptions](@id how_to-update-06-nodes)
4949

5050
Version 0.7 introduced both *[storage behaviours](@ref lib-pub-nodes-stor_behav)* resulting in a rework of the individual approach for calculating the level balance as well as the potential to have charge and discharge capacities through *[storage parameters](@ref lib-pub-nodes-stor_par)*.
5151

52-
!!! note
53-
The legacy constructors for calls of the composite type of version 0.6 will be included at least until version 0.8.
52+
!!! warning
53+
The legacy constructors for calls of the composite type of version 0.6 were removed in version 0.10.
54+
In addition, the adjustments will not be updated in release 0.10 as potential models will be at that time most likely more than 1 year old.
5455

5556
### [`RefStorage`](@ref)
5657

docs/src/library/internals/reference_EMIExt.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,6 @@ EMB.check_link_data(l::Link, data::InvestmentData, 𝒯, modeltype::AbstractInve
4141

4242
## [EnergyModelsInvestments](@id lib-int-EMIext-EMI)
4343

44-
### [Constructors](@id lib-int-EMIext-construct)
45-
46-
The following constructors are only relevant for the legacy constructors introduced within the extension.
47-
They do not provide any additional information.
48-
49-
```@docs
50-
EMI.BinaryInvestment
51-
EMI.ContinuousInvestment
52-
EMI.DiscreteInvestment
53-
EMI.FixedInvestment
54-
EMI.PeriodLife
55-
EMI.RollingLife
56-
EMI.SemiContinuousInvestment
57-
EMI.SemiContinuousOffsetInvestment
58-
EMI.StudyLife
59-
```
60-
6144
### [Methods](@id lib-int-EMIext-met)
6245

6346
```@docs

docs/src/library/public/emi_extension.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ In this case, we use constructors within the extension for the abstract types de
77
The following page provides you with an overview of the individual constructors.
88
The described fields are only available if you load `EnergyModelsInvestments` as well.
99

10-
## [`AbstractInvestmentModel`](@id lib-pub-emi_ext-types)
10+
## [`AbstractInvestmentModel` types](@id lib-pub-emi_ext-types)
1111

1212
Including the extension for [`EnergyModelsInvestments`](https://energymodelsx.github.io/EnergyModelsInvestments.jl/) results in the declaration of the types `AbstractInvestmentModel` and `InvestmentModel` which can be used for creating models with investments
1313
It takes as additional input the `discount_rate`.
@@ -19,7 +19,7 @@ AbstractInvestmentModel
1919
InvestmentModel
2020
```
2121

22-
## [Functions for accessing fields of `AbstractInvestmentModel` types](@id lib-pub-fun_field_model)
22+
### [Functions for accessing fields of `AbstractInvestmentModel` types](@id lib-pub-fun_field_model)
2323

2424
The current implementation extracts the discount rate through a function.
2525

@@ -30,9 +30,7 @@ The current implementation extracts the discount rate through a function.
3030
discount_rate
3131
```
3232

33-
## [Investment data](@id lib-pub-emi_ext-inv_data)
34-
35-
### [`InvestmentData` types](@id lib-pub-emi_ext-inv_data-types)
33+
## [`InvestmentData` types](@id lib-pub-emi_ext-inv_data)
3634

3735
`InvestmentData` subtypes are used to provide technologies introduced in `EnergyModelsX` (nodes and transmission modes) a subtype of `ExtensionData` that can be used for dispatching.
3836
Two different types are directly introduced, `SingleInvData` and `StorageInvData`.
@@ -49,13 +47,3 @@ InvestmentData
4947
SingleInvData
5048
StorageInvData
5149
```
52-
53-
### [Legacy constructors](@id lib-pub-emi_ext-inv_data-leg)
54-
55-
We provide a legacy constructor, `InvData` and `InvDataStorage`, that use the same input as in version 0.5.x.
56-
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)*.
57-
58-
```@docs
59-
InvData
60-
InvDataStorage
61-
```

docs/src/library/public/model_data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# [Model and data](@id lib-pub-mod_data)
33

4-
### [`EnergyModel`](@id lib-pub-mod_data-types)
4+
## [`EnergyModel`](@id lib-pub-mod_data-types)
55

66
The type `EnergyModel` is used for creating the global parameters of a model.
77
It can be as well used for extending `EnergyModelsBase` as described in the section *[Extensions to the model](@ref man-phil-ext)*.

ext/EMIExt/EMIExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ EMI.investment_data(inv_data::SingleInvData) = inv_data.cap
7373
Return the `InvestmentData` of the Node `n` or Link `l`. It will return an error if the
7474
if the Node `n` or Link `l` does not have investment data.
7575
76-
If `field` is specified, it returns the `InvData` for the corresponding capacity.
76+
If `field` is specified, it returns the `InvestmentData` for the corresponding capacity.
7777
"""
7878
EMI.investment_data(n::EMB.Node) =
7979
filter(data -> typeof(data) <: InvestmentData, node_data(n))[1]
Lines changed: 0 additions & 253 deletions
Original file line numberDiff line numberDiff line change
@@ -1,253 +0,0 @@
1-
2-
function EMB.SingleInvData(
3-
capex_trans::TimeProfile,
4-
trans_max_inst::TimeProfile,
5-
initial::Real,
6-
inv_mode::Investment,
7-
)
8-
@warn(
9-
"The used implementation of a `StartInvData` will be discontinued in the near future.\n" *
10-
"You have to only change the value of the field `initial` to a `FixedProfile` " *
11-
"for utilizing the new version.",
12-
maxlog = 1
13-
)
14-
return SingleInvData(
15-
StartInvData(capex_trans, trans_max_inst, FixedProfile(initial), inv_mode)
16-
)
17-
end
18-
function EMB.SingleInvData(
19-
capex_trans::TimeProfile,
20-
trans_max_inst::TimeProfile,
21-
initial::Real,
22-
inv_mode::Investment,
23-
life_mode::LifetimeMode,
24-
)
25-
@warn(
26-
"The used implementation of a `StartInvData` will be discontinued in the near future.\n" *
27-
"You have to only change the value of the field `initial` to a `FixedProfile` " *
28-
"for utilizing the new version.",
29-
maxlog = 1
30-
)
31-
return SingleInvData(
32-
StartInvData(capex_trans, trans_max_inst, FixedProfile(initial), inv_mode, life_mode),
33-
)
34-
end
35-
36-
function EMB.InvData(;
37-
capex_cap::TimeProfile,
38-
cap_max_inst::TimeProfile,
39-
cap_max_add::TimeProfile,
40-
cap_min_add::TimeProfile,
41-
inv_mode::Investment = ContinuousInvestment(),
42-
cap_start::Union{Real,Nothing} = nothing,
43-
cap_increment::TimeProfile = FixedProfile(0),
44-
life_mode::LifetimeMode = UnlimitedLife(),
45-
lifetime::TimeProfile = FixedProfile(0),
46-
)
47-
48-
# Create the new investment mode structures
49-
if isa(inv_mode, BinaryInvestment)
50-
@error(
51-
"BinaryInvestment() cannot use the constructor as it is not possible to " *
52-
"deduce the capacity for the investment. You have to instead use the new " *
53-
"types as outlined in the documentation (https://energymodelsx.github.io/EnergyModelsInvestments.jl/how-to/update-models)"
54-
)
55-
return
56-
elseif isa(inv_mode, FixedInvestment)
57-
@error(
58-
"FixedInvestment() cannot use the constructor as it is not possible to " *
59-
"deduce the capacity for the investment. You have to instead use the new " *
60-
"types as outlined in the documentation (https://energymodelsx.github.io/EnergyModelsInvestments.jl/how-to/update-models)"
61-
)
62-
return
63-
elseif isa(inv_mode, DiscreteInvestment)
64-
tmp_inv_mode = DiscreteInvestment(cap_increment)
65-
elseif isa(inv_mode, ContinuousInvestment)
66-
tmp_inv_mode = ContinuousInvestment(cap_min_add, cap_max_add)
67-
elseif isa(inv_mode, SemiContinuousInvestment)
68-
tmp_inv_mode = SemiContinuousInvestment(cap_min_add, cap_max_add)
69-
end
70-
71-
@warn(
72-
"The used implementation of a `InvData` will be discontinued in the near " *
73-
"future. See the documentation for the new implementation using the type " *
74-
"`SingleInvData` in the section on _How to update your model to the latest versions_.\n" *
75-
"The core change is that we allow the individual parameters are moved to the " *
76-
"fields `inv_mode` and `life_mode`.\n",
77-
maxlog = 1
78-
)
79-
80-
# Create the new lifetime mode structures
81-
if isa(life_mode, UnlimitedLife)
82-
tmp_life_mode = UnlimitedLife()
83-
elseif isa(life_mode, StudyLife)
84-
tmp_life_mode = StudyLife(lifetime)
85-
elseif isa(life_mode, PeriodLife)
86-
tmp_life_mode = PeriodLife(lifetime)
87-
elseif isa(life_mode, RollingLife)
88-
tmp_life_mode = RollingLife(lifetime)
89-
end
90-
91-
# Create the new generalized investment data
92-
if isnothing(cap_start)
93-
return EMB.SingleInvData(capex_cap, cap_max_inst, tmp_inv_mode, tmp_life_mode)
94-
else
95-
return EMB.SingleInvData(
96-
capex_cap,
97-
cap_max_inst,
98-
cap_start,
99-
tmp_inv_mode,
100-
tmp_life_mode,
101-
)
102-
end
103-
end
104-
105-
function EMB.InvDataStorage(;
106-
#Investment data related to storage power
107-
capex_rate::TimeProfile,
108-
rate_max_inst::TimeProfile,
109-
rate_max_add::TimeProfile,
110-
rate_min_add::TimeProfile,
111-
capex_stor::TimeProfile,
112-
stor_max_inst::TimeProfile,
113-
stor_max_add::TimeProfile,
114-
stor_min_add::TimeProfile,
115-
inv_mode::Investment = ContinuousInvestment(),
116-
rate_start::Union{Real,Nothing} = nothing,
117-
stor_start::Union{Real,Nothing} = nothing,
118-
rate_increment::TimeProfile = FixedProfile(0),
119-
stor_increment::TimeProfile = FixedProfile(0),
120-
life_mode::LifetimeMode = UnlimitedLife(),
121-
lifetime::TimeProfile = FixedProfile(0),
122-
)
123-
124-
# Create the new investment mode structures
125-
if isa(inv_mode, BinaryInvestment)
126-
@error(
127-
"BinaryInvestment() cannot use the constructor as it is not possible to " *
128-
"deduce the capacity for the investment. You have to instead use the new " *
129-
"types as outlined in the documentation (https://energymodelsx.github.io/EnergyModelsInvestments.jl/how-to/update-models)"
130-
)
131-
return
132-
elseif isa(inv_mode, FixedInvestment)
133-
@error(
134-
"FixedInvestment() cannot use the constructor as it is not possible to " *
135-
"deduce the capacity for the investment. You have to instead use the new " *
136-
"types as outlined in the documentation (https://energymodelsx.github.io/EnergyModelsInvestments.jl/how-to/update-models)"
137-
)
138-
return
139-
elseif isa(inv_mode, DiscreteInvestment)
140-
inv_mode_rate = DiscreteInvestment(rate_increment)
141-
inv_mode_cap = DiscreteInvestment(stor_increment)
142-
elseif isa(inv_mode, ContinuousInvestment)
143-
inv_mode_rate = ContinuousInvestment(rate_min_add, rate_max_add)
144-
inv_mode_cap = ContinuousInvestment(stor_min_add, stor_max_add)
145-
elseif isa(inv_mode, SemiContinuousInvestment)
146-
inv_mode_rate = SemiContinuousInvestment(rate_min_add, rate_max_add)
147-
inv_mode_cap = SemiContinuousInvestment(stor_min_add, stor_max_add)
148-
end
149-
150-
@warn(
151-
"The used implementation of a `InvDataStorage` will be discontinued in the near " *
152-
"future. See the documentation for the new implementation using the type " *
153-
"`StorageInvData` in the section on _How to update your model to the latest " *
154-
"versions_.\n" *
155-
"The core change is that we allow now for individual investments in `charge`, " *
156-
"`level`, as well `discharge` capacities.\n" *
157-
"This constructore should NOT be used for `HydroStor` or `PumpedHydroStor nodes " *
158-
"introduced in the package [EnergyModelsRenewableProducers]" *
159-
"(https://energymodelsx.github.io/EnergyModelsRenewableProducers.jl/stable/library/public/#EnergyModelsRenewableProducers.HydroStor).",
160-
maxlog = 1
161-
)
162-
163-
# Create the new lifetime mode structures
164-
if isa(life_mode, UnlimitedLife)
165-
tmp_life_mode = UnlimitedLife()
166-
elseif isa(life_mode, StudyLife)
167-
tmp_life_mode = StudyLife(lifetime)
168-
elseif isa(life_mode, PeriodLife)
169-
tmp_life_mode = PeriodLife(lifetime)
170-
elseif isa(life_mode, RollingLife)
171-
tmp_life_mode = RollingLife(lifetime)
172-
end
173-
174-
# Create the new generalized investment data
175-
if isnothing(rate_start)
176-
charge_type =
177-
NoStartInvData(capex_rate, rate_max_inst, inv_mode_rate, tmp_life_mode)
178-
else
179-
charge_type = StartInvData(
180-
capex_rate,
181-
rate_max_inst,
182-
rate_start,
183-
inv_mode_rate,
184-
tmp_life_mode,
185-
)
186-
end
187-
if isnothing(stor_start)
188-
level_type = NoStartInvData(capex_stor, stor_max_inst, inv_mode_cap, tmp_life_mode)
189-
else
190-
level_type =
191-
StartInvData(capex_stor, stor_max_inst, stor_start, inv_mode_cap, tmp_life_mode)
192-
end
193-
194-
return EMB.StorageInvData(charge = charge_type, level = level_type)
195-
end
196-
197-
"""
198-
When the field `cap` is not included, it is assumed that its value is `FixedProfile(0)`.
199-
This behavior is only for allowing the legacy constructor to work, while it will be removed
200-
in the near future.
201-
"""
202-
EMI.FixedInvestment() = EMI.FixedInvestment(FixedProfile(0))
203-
"""
204-
When the field `cap` is not included, it is assumed that its value is `FixedProfile(0)`.
205-
This behavior is only for allowing the legacy constructor to work, while it will be removed
206-
in the near future.
207-
"""
208-
EMI.BinaryInvestment() = EMI.BinaryInvestment(FixedProfile(0))
209-
"""
210-
When the field `increment` is not included, it is assumed that its value is `FixedProfile(0)`.
211-
This behavior is only for allowing the legacy constructor to work, while it will be removed
212-
in the near future.
213-
"""
214-
EMI.DiscreteInvestment() = EMI.DiscreteInvestment(FixedProfile(0))
215-
"""
216-
When the fields `min_add` and `max_add` are not included, it is assumed that their values
217-
are `FixedProfile(0)`. This behavior is only for allowing the legacy constructor to work,
218-
while it will be removed in the near future.
219-
"""
220-
EMI.ContinuousInvestment() = EMI.ContinuousInvestment(FixedProfile(0), FixedProfile(0))
221-
"""
222-
When the fields `min_add` and `max_add` are not included, it is assumed that their values
223-
are `FixedProfile(0)`. This behavior is only for allowing the legacy constructor to work,
224-
while it will be removed in the near future.
225-
"""
226-
EMI.SemiContinuousInvestment() =
227-
EMI.SemiContinuousInvestment(FixedProfile(0), FixedProfile(0))
228-
"""
229-
When the fields `min_add`, `max_add`, and `capex_offset` are not included, it is assumed
230-
that their values are `FixedProfile(0)`. This behavior is only for allowing the legacy
231-
constructor to work, while it will be removed in the near future.
232-
"""
233-
EMI.SemiContinuousOffsetInvestment() =
234-
EMI.SemiContinuousOffsetInvestment(FixedProfile(0), FixedProfile(0), FixedProfile(0))
235-
236-
"""
237-
When the field `lifetime` is not included, it is assumed that its value is `FixedProfile(0)`.
238-
This behavior is only for allowing the legacy constructor to work, while it will be removed
239-
in the near future.
240-
"""
241-
EMI.StudyLife() = EMI.StudyLife(FixedProfile(0))
242-
"""
243-
When the field `lifetime` is not included, it is assumed that its value is `FixedProfile(0)`.
244-
This behavior is only for allowing the legacy constructor to work, while it will be removed
245-
in the near future.
246-
"""
247-
EMI.PeriodLife() = EMI.PeriodLife(FixedProfile(0))
248-
"""
249-
When the field `lifetime` is not included, it is assumed that its value is `FixedProfile(0)`.
250-
This behavior is only for allowing the legacy constructor to work, while it will be removed
251-
in the near future.
252-
"""
253-
EMI.RollingLife() = EMI.RollingLife(FixedProfile(0))

src/EnergyModelsBase.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ export PreviousPeriods, CyclicPeriods
7171
# Export of the types for investment models
7272
export AbstractInvestmentModel, InvestmentModel
7373
export InvestmentData, SingleInvData, StorageInvData
74-
export InvData, InvDataStorage
7574

7675
# Export commonly used functions for model generation
7776
export @assert_or_log

0 commit comments

Comments
 (0)