Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect ylabel #11

Merged
merged 1 commit into from
Sep 9, 2024
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
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "EnergyModelsGUI"
uuid = "737a7361-d3b7-40e9-b1ac-59bee4c5ea2d"
authors = ["Jon Vegard Venås <JonVegard.Venas@sintef.no>", "Magnus Askeland <Magnus.Askeland@sintef.no>", "Shweta Tiwari <Shweta.Tiwari@sintef.no>"]
version = "0.5.3"
version = "0.5.4"

[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Expand Down
Binary file modified docs/src/figures/EMI_geography.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/src/figures/example.png
Binary file not shown.
1 change: 1 addition & 0 deletions src/datastructures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
25 changes: 11 additions & 14 deletions src/utils_GUI/GUI_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)]...)
Expand Down
Loading