diff --git a/NEWS.md b/NEWS.md index f4ddc71..cfaa964 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,16 @@ # Release notes +## Version 0.5.4 (2024-09-09) + +### Bugfix + +* Fix incorrect ylabel when using scale_tot_opex=true. + +### Enhancement + +* Improve performance with a workaround for slicing a JuMP.Containers.SparseAxisArray. +* Enable collect for ::EnergySystemDesign by providing the function length(::EnergySystemDesign). + ## Version 0.5.3 (2024-09-02) ### Bugfix diff --git a/Project.toml b/Project.toml index 7328126..178b895 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "EnergyModelsGUI" uuid = "737a7361-d3b7-40e9-b1ac-59bee4c5ea2d" authors = ["Jon Vegard Venås ", "Magnus Askeland ", "Shweta Tiwari "] -version = "0.5.3" +version = "0.5.4" [deps] CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" diff --git a/docs/src/figures/EMI_geography.png b/docs/src/figures/EMI_geography.png index 15d088c..ac4863c 100644 Binary files a/docs/src/figures/EMI_geography.png and b/docs/src/figures/EMI_geography.png differ diff --git a/docs/src/figures/example.png b/docs/src/figures/example.png deleted file mode 100644 index 3b5ef53..0000000 Binary files a/docs/src/figures/example.png and /dev/null differ diff --git a/src/datastructures.jl b/src/datastructures.jl index c68d637..6bb2f7c 100644 --- a/src/datastructures.jl +++ b/src/datastructures.jl @@ -226,6 +226,7 @@ function Base.iterate(itr::EnergySystemIterator, state=nothing) return itr.stack[idx], idx end Base.length(itr::EnergySystemIterator) = length(itr.stack) +Base.length(design::EnergySystemDesign) = length(EnergySystemIterator(design)) function Base.iterate(design::EnergySystemDesign, state=(nothing, nothing)) itr = isnothing(state[2]) ? EnergySystemIterator(design) : state[2] diff --git a/src/utils_GUI/GUI_utils.jl b/src/utils_GUI/GUI_utils.jl index 291c2cd..ff53f77 100644 --- a/src/utils_GUI/GUI_utils.jl +++ b/src/utils_GUI/GUI_utils.jl @@ -240,20 +240,17 @@ function initialize_available_data!(gui) for combination ∈ get_combinations(var, i_T) selection = collect(combination) - if isa(var, SparseVariables.IndexedVarArray) - field_data = JuMP.Containers.SparseAxisArray( - Dict( - (t,) => - var[vcat(selection[1:(i_T - 1)], t, selection[i_T:end])...] - for t ∈ periods - ), + if isa(var, SparseVars) # Slicing for SparseVars performs worse than the following + field_data = JuMP.Containers.DenseAxisArray( + [ + var[vcat(selection[1:(i_T - 1)], t, selection[i_T:end])...] for + t ∈ periods + ], + periods, ) - else + else # For DenseAxisArrays, slicing performs best field_data = var[vcat(selection[1:(i_T - 1)], :, selection[i_T:end])...] end - if isempty(field_data) - continue - end element::Plotable = getfirst( x -> isa(x, Union{EMB.Node,Link,Area,TransmissionMode}), selection ) @@ -338,8 +335,8 @@ function initialize_available_data!(gui) # add total operational cost to available data description = "Total operational cost" - if scale_tot_capex - description *= " (scaled to year)" + if scale_tot_opex + description *= " (scaled to strategic period)" end container = Dict( :name => "tot_opex", @@ -486,7 +483,7 @@ end Get an iterator of combinations of unique indices excluding the time index located at index `i_T`. """ function get_combinations(var::SparseVars, i_T::Int) - return unique([(key[1:(i_T - 1)]..., key[(i_T + 1):end]...) for key ∈ keys(var.data)]) + return unique((key[1:(i_T - 1)]..., key[(i_T + 1):end]...) for key ∈ keys(var.data)) end function get_combinations(var::JuMP.Containers.DenseAxisArray, i_T::Int) return Iterators.product(axes(var)[vcat(1:(i_T - 1), (i_T + 1):end)]...)