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: accept Integer as weights in config #19

Merged
merged 1 commit into from
Sep 27, 2024
Merged

Conversation

daschw
Copy link
Collaborator

@daschw daschw commented Sep 27, 2024

If I set

config:
  optimization:
    snapshots:
      weights: 1

in the IESopt config yaml, I get the following error:

┌ Error: Error(s) during model generation
│   debug = "not available"
│   number_of_errors = 1= = = = = = = = = [ Error #1 ] = = = = = = = = =
│    MethodError: Cannot `convert` an object of type
│      Int64 to an object of type
│      Union{Float64, String}
│ 
│    Closest candidates are:convert(::Type{T}, ::T) where T
│       @ Base Base.jl:84
│ 
│    Stacktrace:
│     [1] IESopt._ConfigSnapshots(count::Int64, offset::Int64, names::Nothing, weights::Int64, representatives::Nothing, aggregate::Nothing)
│       @ IESopt C:\Users\SchwabenederD\.julia\dev\IESopt\src\config\optimization.jl:9
│     [2] IESopt._ConfigSnapshots(config::Dict{String, Any})
│       @ IESopt C:\Users\SchwabenederD\.julia\dev\IESopt\src\config\optimization.jl:86
│     [3] IESopt._ConfigOptimization(config::Dict{String, Any})
│       @ IESopt C:\Users\SchwabenederD\.julia\dev\IESopt\src\config\optimization.jl:47
│     [4] IESopt._Config(model::JuMP.Model)
│       @ IESopt C:\Users\SchwabenederD\.julia\dev\IESopt\src\config\config.jl:45
│     [5] _parse_model!(model::JuMP.Model, filename::String, global_parameters::Dict{String, Any}; verbosity::Nothing)
│       @ IESopt C:\Users\SchwabenederD\.julia\dev\IESopt\src\parser.jl:11
│     [6] parse!(model::JuMP.Model, filename::String; verbosity::Nothing, kwargs::@Kwargs{weight::Int64})
│       @ IESopt C:\Users\SchwabenederD\.julia\dev\IESopt\src\IESopt.jl:511
│     [7] generate!(model::JuMP.Model, filename::String; verbosity::Nothing, kwargs::@Kwargs{weight::Int64})
│       @ IESopt C:\Users\SchwabenederD\.julia\dev\IESopt\src\IESopt.jl:325
│     [8] run(filename::String; verbosity::Nothing, kwargs::@Kwargs{weight::Int64})
│       @ IESopt C:\Users\SchwabenederD\.julia\dev\IESopt\src\IESopt.jl:279
└ @ IESopt C:\Users\SchwabenederD\.julia\dev\IESopt\src\IESopt.jl:365

This change fixes this and also allows integers in the weigths config.

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.45%. Comparing base (911d03d) to head (163b1ef).
Report is 2 commits behind head on main.

@@            Coverage Diff             @@
##             main      #19      +/-   ##
==========================================
+ Coverage   52.42%   52.45%   +0.02%     
==========================================
  Files          99       99              
  Lines        3792     3794       +2     
==========================================
+ Hits         1988     1990       +2     
  Misses       1804     1804              
Files with missing lines Coverage Δ
src/config/optimization.jl 92.00% <100.00%> (+0.69%) ⬆️

@sstroemer
Copy link
Member

Looks good!

@daschw daschw merged commit e9a6248 into ait-energy:main Sep 27, 2024
4 of 5 checks passed
@daschw daschw deleted the weights branch September 27, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants