Skip to content

Commit fe585ff

Browse files
hellemoJulStraus
andauthored
Add support for JuMP.AbstractModel (#87)
* Add support for JuMP.AbstractModel and simplify optional model passing code. * Updated version number for new release --------- Co-authored-by: Julian Straus <julian.straus@sintef.no>
1 parent dbf38a2 commit fe585ff

3 files changed

Lines changed: 10 additions & 23 deletions

File tree

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Release notes
22

3-
## Unversioned
3+
## Version 0.10.1 (2026-04-14)
4+
5+
### Minor updates
6+
7+
* Add support for JuMP.AbstractModel to allow custom model types, e.g. for decomposition.
48

59
### Bug fixes
610

Project.toml

Lines changed: 1 addition & 1 deletion
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.10.0"
4+
version = "0.10.1"
55

66
[deps]
77
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"

src/model.jl

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
create_model(
33
case::Case,
44
modeltype::EnergyModel,
5-
m::JuMP.Model;
5+
m::JuMP.AbstractModel = JuMP.Model();
66
check_timeprofiles::Bool = true,
77
check_any_data::Bool = true,
88
)
@@ -32,7 +32,7 @@ Create the model and call all required functions.
3232
function create_model(
3333
case::Case,
3434
modeltype::EnergyModel,
35-
m::JuMP.Model;
35+
m::JuMP.AbstractModel = JuMP.Model();
3636
check_timeprofiles::Bool = true,
3737
check_any_data::Bool = true,
3838
)
@@ -85,34 +85,17 @@ function create_model(
8585

8686
return m
8787
end
88-
function create_model(
89-
case::Case,
90-
modeltype::EnergyModel;
91-
check_timeprofiles::Bool = true,
92-
check_any_data::Bool = true,
93-
)
94-
m = JuMP.Model()
95-
create_model(case, modeltype, m; check_timeprofiles, check_any_data)
96-
end
88+
9789
function create_model(
9890
case::Dict,
9991
modeltype::EnergyModel,
100-
m::JuMP.Model;
92+
m::JuMP.AbstractModel = JuMP.Model();
10193
check_timeprofiles::Bool = true,
10294
check_any_data::Bool = true,
10395
)
10496
case_new = Case(case[:T], case[:products], [case[:nodes], case[:links]])
10597
create_model(case_new, modeltype, m; check_timeprofiles, check_any_data)
10698
end
107-
function create_model(
108-
case::Dict,
109-
modeltype::EnergyModel;
110-
check_timeprofiles::Bool = true,
111-
check_any_data::Bool = true,
112-
)
113-
m = JuMP.Model()
114-
create_model(case, modeltype, m; check_timeprofiles, check_any_data)
115-
end
11699

117100
"""
118101
variables_capacity(m, 𝒩::Vector{<:Node}, 𝒳ᵛᵉᶜ, 𝒯, modeltype::EnergyModel)

0 commit comments

Comments
 (0)