Skip to content

Commit b08b693

Browse files
authored
Adjustments to EMI v0.9 (#84)
* Adjusted to EMI v0.9 * Updated value in testset * Fixed problems in documentation * Uncertain why the inventories require this now * To be considered to be removed in a later stage * Increased robustness of test
1 parent 331e214 commit b08b693

5 files changed

Lines changed: 31 additions & 26 deletions

File tree

NEWS.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
## Unversioned
44

5+
### Breaking changes
6+
7+
* Adjusted to the changes introduced in [`EnergyModelsInvestments` 0.9](https://github.com/EnergyModelsX/EnergyModelsInvestments.jl/releases/tag/v0.9.0):
8+
* Breaking change required as early retirement is now allowed.
9+
* Changed the function call arguments for [`add_investment_constraints`](https://github.com/EnergyModelsX/EnergyModelsInvestments.jl/blob/0c84eb4fabdf6f3c188812a3555b40f2681e916b/src/model.jl#L1).
10+
11+
### Minor updates
12+
513
* Introduced support in checks for `TwoLevelTree` and `StrategicStochasticProfile`.
614

715
## Version 0.9.5 (2026-03-25)
@@ -59,10 +67,10 @@
5967
### Rework of data
6068

6169
* Renamed extension data related functions and types:
62-
* `Data` is now called `ExtraData`.
70+
* `Data` is now called `ExtensionData`.
6371
* `create_data` is now called `create_ext_data`.
6472
* The old version is still accessible, but will be removed in release 0.10.
65-
* Allow for variable creation for `ExtraData` types and implemented the approach for `InvestmentData` for both `Node`s and `Link`s.
73+
* Allow for variable creation for `ExtensionData` types and implemented the approach for `InvestmentData` for both `Node`s and `Link`s.
6674

6775
### Minor updates
6876

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "EnergyModelsBase"
22
uuid = "5d7e687e-f956-46f3-9045-6f5a5fd49f50"
33
authors = ["Lars Hellemo <Lars.Hellemo@sintef.no>, Julian Straus <Julian.Straus@sintef.no>"]
4-
version = "0.9.5"
4+
version = "0.10.0"
55

66
[deps]
77
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
@@ -15,7 +15,7 @@ EnergyModelsInvestments = "fca3f8eb-b383-437d-8e7b-aac76bb2004f"
1515
EMIExt = "EnergyModelsInvestments"
1616

1717
[compat]
18-
EnergyModelsInvestments = "0.8"
18+
EnergyModelsInvestments = "0.9"
1919
JuMP = "1"
2020
SparseVariables = "0.7.3"
2121
TimeStruct = "0.9"

ext/EMIExt/constraints.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ function EMB.constraints_capacity_installed(
2424
# Extract the investment data, the discount rate, and the strategic periods
2525
disc_rate = discount_rate(modeltype)
2626
inv_data = investment_data(n, :cap)
27-
𝒯ᴵⁿᵛ = strategic_periods(𝒯)
2827

2928
# Add the investment constraints
30-
EMI.add_investment_constraints(m, n, inv_data, :cap, :cap, 𝒯ᴵⁿᵛ, disc_rate)
29+
EMI.add_investment_constraints(m, n, inv_data, :cap, :cap, 𝒯, disc_rate)
3130
else
3231
for t 𝒯
3332
fix(m[:cap_inst][n, t], EMB.capacity(n, t); force = true)
@@ -42,7 +41,6 @@ function EMB.constraints_capacity_installed(
4241
)
4342
# Extract the he discount rate and the strategic periods
4443
disc_rate = discount_rate(modeltype)
45-
𝒯ᴵⁿᵛ = strategic_periods(𝒯)
4644

4745
cap_map = Dict(:charge => charge, :level => level, :discharge => discharge)
4846

@@ -58,7 +56,7 @@ function EMB.constraints_capacity_installed(
5856
inv_data = investment_data(n, cap)
5957

6058
# Add the investment constraints
61-
EMI.add_investment_constraints(m, n, inv_data, cap, prefix, 𝒯ᴵⁿᵛ, disc_rate)
59+
EMI.add_investment_constraints(m, n, inv_data, cap, prefix, 𝒯, disc_rate)
6260

6361
elseif isa(stor_par, EMB.UnionCapacity)
6462
for t 𝒯
@@ -77,10 +75,9 @@ function EMB.constraints_capacity_installed(
7775
# Extract the investment data, the discount rate, and the strategic periods
7876
disc_rate = discount_rate(modeltype)
7977
inv_data = investment_data(l, :cap)
80-
𝒯ᴵⁿᵛ = strategic_periods(𝒯)
8178

8279
# Add the investment constraints
83-
EMI.add_investment_constraints(m, l, inv_data, :cap, :link_cap, 𝒯ᴵⁿᵛ, disc_rate)
80+
EMI.add_investment_constraints(m, l, inv_data, :cap, :link_cap, 𝒯, disc_rate)
8481
else
8582
for t 𝒯
8683
fix(m[:link_cap_inst][l, t], EMB.capacity(l, t); force = true)

src/structures/data.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,18 +229,18 @@ When multiple inputs are provided, a constructor directly creates the correspond
229229
[`StartInvData`](@extref EnergyModelsInvestments.StartInvData) type for the investment data.
230230
- **`inv_mode::Investment`** is the chosen investment mode for the technology. The following
231231
investment modes are currently available:
232-
[`BinaryInvestment`](@extref EnergyModelsInvestments),
233-
[`DiscreteInvestment`](@extref EnergyModelsInvestments),
234-
[`ContinuousInvestment`](@extref EnergyModelsInvestments),
235-
[`SemiContinuousInvestment`](@extref EnergyModelsInvestments), or
236-
[`FixedInvestment`](@extref EnergyModelsInvestments).
232+
[`BinaryInvestment`](@extref EnergyModelsInvestments.BinaryInvestment),
233+
[`DiscreteInvestment`](@extref EnergyModelsInvestments.DiscreteInvestment),
234+
[`ContinuousInvestment`](@extref EnergyModelsInvestments.ContinuousInvestment),
235+
[`SemiContinuousInvestment`](@extref EnergyModelsInvestments.SemiContinuousInvestment), or
236+
[`FixedInvestment`](@extref EnergyModelsInvestments.FixedInvestment).
237237
- **`life_mode::LifetimeMode`** is type of handling the lifetime. Several different
238238
alternatives can be used:
239-
[`UnlimitedLife`](@extref EnergyModelsInvestments),
240-
[`StudyLife`](@extref EnergyModelsInvestments),
241-
[`PeriodLife`](@extref EnergyModelsInvestments), or
242-
[`RollingLife`](@extref EnergyModelsInvestments). If `life_mode` is not specified, the
243-
model assumes an [`UnlimitedLife`](@extref EnergyModelsInvestments).
239+
[`UnlimitedLife`](@extref EnergyModelsInvestments.UnlimitedLife),
240+
[`StudyLife`](@extref EnergyModelsInvestments.StudyLife),
241+
[`PeriodLife`](@extref EnergyModelsInvestments.PeriodLife), or
242+
[`RollingLife`](@extref EnergyModelsInvestments.RollingLife). If `life_mode` is not
243+
specified, the model assumes an [`UnlimitedLife`](@extref EnergyModelsInvestments.UnlimitedLife).
244244
"""
245245
abstract type SingleInvData <: InvestmentData end
246246

test/test_investments.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ using EnergyModelsInvestments
227227
# Test results
228228
# (-724 compared to 0.5.x as RefStorage as emission source does not require a charge
229229
# capacity any longer in 0.7.x)
230-
@test round(objective_value(m)) -302624
230+
# (-10736 compared to 0.9.x due to the potential of early retirment)
231+
@test round(objective_value(m)) -313360.0
231232

232233
# Test that investments are happening
233234
𝒯ᴵⁿᵛ = strategic_periods(get_time_struct(case))
@@ -259,10 +260,9 @@ end
259260
id::Any
260261
from::EMB.Node
261262
to::EMB.Node
262-
formulation::EMB.Formulation
263263
data::Vector{<:ExtensionData}
264264
end
265-
function EMB.create_link(m, 𝒯, 𝒫, l::InvDirect, modeltype::EnergyModel, formulation::EMB.Formulation)
265+
function EMB.create_link(m, l::InvDirect, 𝒯, 𝒫, modeltype::EnergyModel)
266266

267267
# Generic link in which each output corresponds to the input
268268
@constraint(m, [t 𝒯, p EMB.link_res(l)],
@@ -317,7 +317,7 @@ end
317317
nodes = [source_1, source_2, sink]
318318
links = Link[
319319
OpexDirect("OpexDirect", source_1, sink, Linear()),
320-
InvDirect("InvDirect", source_2, sink, Linear(), data_link),
320+
InvDirect("InvDirect", source_2, sink, data_link),
321321
]
322322

323323
# Creation of the time structure and global data
@@ -359,7 +359,7 @@ end
359359
)
360360

361361
# Test that investments are happening
362-
@test value.(m[:link_cap_add])[ℒ[2],𝒯ᴵⁿᵛ[3]] == 3
362+
@test sum(value.(m[:link_cap_add])[ℒ[2], t_inv] for t_inv 𝒯ᴵⁿᵛ) == 3
363363

364364
# Test that the variables are `link_cap_capex`, `link_cap_current`, `link_cap_add` and
365365
# `link_cap_rem` are created for the corresponding links while `link_cap_invest_b` and
@@ -679,7 +679,7 @@ EMB.TEST_ENV = true
679679
Dict(Power => 1),
680680
)
681681
nodes = [source, sink]
682-
links = [InvDirect("scr-sink", nodes[1], nodes[2], Linear(), inv_data)]
682+
links = [InvDirect("scr-sink", nodes[1], nodes[2], inv_data)]
683683
T = TwoLevel(4, 10, SimpleTimes(4, 1))
684684
case = Case(T, products, [nodes, links], [[get_nodes, get_links]])
685685

0 commit comments

Comments
 (0)