Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unversioned

### Breaking changes

* Adjusted to the changes introduced in [`EnergyModelsInvestments` 0.9](https://github.com/EnergyModelsX/EnergyModelsInvestments.jl/releases/tag/v0.9.0):
* 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).

### Minor updates

* Introduced support in checks for `TwoLevelTree` and `StrategicStochasticProfile`.

## Version 0.9.5 (2026-03-25)
Expand Down Expand Up @@ -59,10 +67,10 @@
### Rework of data

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

### Minor updates

Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "EnergyModelsBase"
uuid = "5d7e687e-f956-46f3-9045-6f5a5fd49f50"
authors = ["Lars Hellemo <Lars.Hellemo@sintef.no>, Julian Straus <Julian.Straus@sintef.no>"]
version = "0.9.5"
version = "0.10.0"

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

[compat]
EnergyModelsInvestments = "0.8"
EnergyModelsInvestments = "0.9"
JuMP = "1"
SparseVariables = "0.7.3"
TimeStruct = "0.9"
Expand Down
9 changes: 3 additions & 6 deletions ext/EMIExt/constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ function EMB.constraints_capacity_installed(
# Extract the investment data, the discount rate, and the strategic periods
disc_rate = discount_rate(modeltype)
inv_data = investment_data(n, :cap)
𝒯ᴵⁿᵛ = strategic_periods(𝒯)

# Add the investment constraints
EMI.add_investment_constraints(m, n, inv_data, :cap, :cap, 𝒯ᴵⁿᵛ, disc_rate)
EMI.add_investment_constraints(m, n, inv_data, :cap, :cap, 𝒯, disc_rate)
else
for t ∈ 𝒯
fix(m[:cap_inst][n, t], EMB.capacity(n, t); force = true)
Expand All @@ -42,7 +41,6 @@ function EMB.constraints_capacity_installed(
)
# Extract the he discount rate and the strategic periods
disc_rate = discount_rate(modeltype)
𝒯ᴵⁿᵛ = strategic_periods(𝒯)

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

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

# Add the investment constraints
EMI.add_investment_constraints(m, n, inv_data, cap, prefix, 𝒯ᴵⁿᵛ, disc_rate)
EMI.add_investment_constraints(m, n, inv_data, cap, prefix, 𝒯, disc_rate)

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

# Add the investment constraints
EMI.add_investment_constraints(m, l, inv_data, :cap, :link_cap, 𝒯ᴵⁿᵛ, disc_rate)
EMI.add_investment_constraints(m, l, inv_data, :cap, :link_cap, 𝒯, disc_rate)
else
for t ∈ 𝒯
fix(m[:link_cap_inst][l, t], EMB.capacity(l, t); force = true)
Expand Down
20 changes: 10 additions & 10 deletions src/structures/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,18 @@ When multiple inputs are provided, a constructor directly creates the correspond
[`StartInvData`](@extref EnergyModelsInvestments.StartInvData) type for the investment data.
- **`inv_mode::Investment`** is the chosen investment mode for the technology. The following
investment modes are currently available:
[`BinaryInvestment`](@extref EnergyModelsInvestments),
[`DiscreteInvestment`](@extref EnergyModelsInvestments),
[`ContinuousInvestment`](@extref EnergyModelsInvestments),
[`SemiContinuousInvestment`](@extref EnergyModelsInvestments), or
[`FixedInvestment`](@extref EnergyModelsInvestments).
[`BinaryInvestment`](@extref EnergyModelsInvestments.BinaryInvestment),
[`DiscreteInvestment`](@extref EnergyModelsInvestments.DiscreteInvestment),
[`ContinuousInvestment`](@extref EnergyModelsInvestments.ContinuousInvestment),
[`SemiContinuousInvestment`](@extref EnergyModelsInvestments.SemiContinuousInvestment), or
[`FixedInvestment`](@extref EnergyModelsInvestments.FixedInvestment).
- **`life_mode::LifetimeMode`** is type of handling the lifetime. Several different
alternatives can be used:
[`UnlimitedLife`](@extref EnergyModelsInvestments),
[`StudyLife`](@extref EnergyModelsInvestments),
[`PeriodLife`](@extref EnergyModelsInvestments), or
[`RollingLife`](@extref EnergyModelsInvestments). If `life_mode` is not specified, the
model assumes an [`UnlimitedLife`](@extref EnergyModelsInvestments).
[`UnlimitedLife`](@extref EnergyModelsInvestments.UnlimitedLife),
[`StudyLife`](@extref EnergyModelsInvestments.StudyLife),
[`PeriodLife`](@extref EnergyModelsInvestments.PeriodLife), or
[`RollingLife`](@extref EnergyModelsInvestments.RollingLife). If `life_mode` is not
specified, the model assumes an [`UnlimitedLife`](@extref EnergyModelsInvestments.UnlimitedLife).
"""
abstract type SingleInvData <: InvestmentData end

Expand Down
12 changes: 6 additions & 6 deletions test/test_investments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ using EnergyModelsInvestments
# Test results
# (-724 compared to 0.5.x as RefStorage as emission source does not require a charge
# capacity any longer in 0.7.x)
@test round(objective_value(m)) ≈ -302624
# (-10736 compared to 0.9.x due to the potential of early retirment)
@test round(objective_value(m)) ≈ -313360.0

# Test that investments are happening
𝒯ᴵⁿᵛ = strategic_periods(get_time_struct(case))
Expand Down Expand Up @@ -259,10 +260,9 @@ end
id::Any
from::EMB.Node
to::EMB.Node
formulation::EMB.Formulation
data::Vector{<:ExtensionData}
end
function EMB.create_link(m, 𝒯, 𝒫, l::InvDirect, modeltype::EnergyModel, formulation::EMB.Formulation)
function EMB.create_link(m, l::InvDirect, 𝒯, 𝒫, modeltype::EnergyModel)

# Generic link in which each output corresponds to the input
@constraint(m, [t ∈ 𝒯, p ∈ EMB.link_res(l)],
Expand Down Expand Up @@ -317,7 +317,7 @@ end
nodes = [source_1, source_2, sink]
links = Link[
OpexDirect("OpexDirect", source_1, sink, Linear()),
InvDirect("InvDirect", source_2, sink, Linear(), data_link),
InvDirect("InvDirect", source_2, sink, data_link),
]

# Creation of the time structure and global data
Expand Down Expand Up @@ -359,7 +359,7 @@ end
)

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

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

Expand Down
Loading