From a0e27850b4a3503a589857d7646eda35e33f3ad6 Mon Sep 17 00:00:00 2001 From: sstroemer Date: Fri, 11 Oct 2024 18:53:24 +0200 Subject: [PATCH] feat: renaming public function from "component" to "get_component" --- src/IESopt.jl | 8 ++-- src/core/expression.jl | 6 +-- src/core/profile.jl | 4 +- src/core/virtual.jl | 2 +- src/opt/benders.jl | 27 ++++++------ src/opt/sddp.jl | 67 +++++++++++++++-------------- src/opt/stochastic.jl | 12 +++--- src/templates/functions/finalize.jl | 4 +- src/utils/docs.jl | 2 +- src/utils/general.jl | 4 +- test/src/examples.jl | 14 +++--- 11 files changed, 77 insertions(+), 73 deletions(-) diff --git a/src/IESopt.jl b/src/IESopt.jl index ccdc3b4..bca499e 100644 --- a/src/IESopt.jl +++ b/src/IESopt.jl @@ -181,7 +181,7 @@ function _build_model!(model::JuMP.Model; callbacks::Union{Nothing, Dict}) push!(obj.constants, term) else comp, proptype, prop = rsplit(term, "."; limit=3) - field = getproperty(getproperty(component(model, comp), Symbol(proptype)), Symbol(prop)) + field = getproperty(getproperty(get_component(model, comp), Symbol(proptype)), Symbol(prop)) if field isa Vector push!(obj.terms, sum(field)) else @@ -674,11 +674,11 @@ function compute_IIS(model::JuMP.Model; filename::String="") end """ - function component(model::JuMP.Model, component_name::String) + function get_component(model::JuMP.Model, component_name::String) Get the component `component_name` from `model`. """ -function component(model::JuMP.Model, component_name::AbstractString) +function get_component(model::JuMP.Model, component_name::AbstractString) if !haskey(_iesopt(model).model.components, component_name) st = stacktrace() trigger = length(st) > 0 ? st[1] : nothing @@ -710,7 +710,7 @@ function _components_tagged(model::JuMP.Model, tags::Vector{String}) end function extract_result(model::JuMP.Model, component_name::String, field::String; mode::String) - return _result(component(model, component_name), mode, field)[2] + return _result(get_component(model, component_name), mode, field)[2] end """ diff --git a/src/core/expression.jl b/src/core/expression.jl index ff26f8c..30fa6ff 100644 --- a/src/core/expression.jl +++ b/src/core/expression.jl @@ -139,11 +139,11 @@ function _finalize(e::_Expression) # Add all `Decision`s to the inner expression. for (coeff, cname, field) in e.decisions if field == "value" - var = _value(component(model, cname)) + var = _value(get_component(model, cname)) elseif field == "size" - var = _size(component(model, cname)) + var = _size(get_component(model, cname)) elseif field == "count" - var = _count(component(model, cname)) + var = _count(get_component(model, cname)) else @critical "Wrong Decision accessor in unnamed expression" coeff decision = cname accessor = field end diff --git a/src/core/profile.jl b/src/core/profile.jl index 37ae66e..77da337 100644 --- a/src/core/profile.jl +++ b/src/core/profile.jl @@ -130,10 +130,10 @@ function _prepare!(profile::Profile) model = profile.model # Extract the carrier from the connected nodes. - if !isnothing(profile.node_from) && (profile.carrier != component(model, profile.node_from).carrier) + if !isnothing(profile.node_from) && (profile.carrier != get_component(model, profile.node_from).carrier) @critical "Profile mismatch" profile = profile.name node_from = profile.node_from end - if !isnothing(profile.node_to) && (profile.carrier != component(model, profile.node_to).carrier) + if !isnothing(profile.node_to) && (profile.carrier != get_component(model, profile.node_to).carrier) @critical "Profile mismatch" profile = profile.name node_to = profile.node_to end diff --git a/src/core/virtual.jl b/src/core/virtual.jl index 9c270eb..405f633 100644 --- a/src/core/virtual.jl +++ b/src/core/virtual.jl @@ -46,7 +46,7 @@ function Base.getproperty(cc::Virtual, field::Symbol) # See if we may be trying to find a component that is "inside" this Virtual? cname = "$(getfield(cc, :name)).$field" model = getfield(cc, :model) - haskey(_iesopt(model).model.components, cname) && return component(model, cname) + haskey(_iesopt(model).model.components, cname) && return get_component(model, cname) return getfield(cc, field) catch e diff --git a/src/opt/benders.jl b/src/opt/benders.jl index 12ab82a..fb58d76 100644 --- a/src/opt/benders.jl +++ b/src/opt/benders.jl @@ -154,10 +154,10 @@ function benders( # Modify Decisions in sub-problem. @info "[benders] Modifying sub model with fixed Decisions" for comp_name in benders_data.decisions - component(benders_data.sub, comp_name).mode = :fixed - component(benders_data.sub, comp_name).cost = nothing - component(benders_data.sub, comp_name).fixed_cost = nothing - component(benders_data.sub, comp_name).fixed_value = 0.0 + get_component(benders_data.sub, comp_name).mode = :fixed + get_component(benders_data.sub, comp_name).cost = nothing + get_component(benders_data.sub, comp_name).fixed_cost = nothing + get_component(benders_data.sub, comp_name).fixed_value = 0.0 end # Build sub-problem. @@ -168,8 +168,8 @@ function benders( # JuMP.@variable(benders_data.main, _x >= 0) # JuMP.@variable(benders_data.sub, _x >= 0) - # JuMP.@constraint(benders_data.main, _c, benders_data.main[:_x] >= component(benders_data.main, "invest1_1").var.value) - # JuMP.@constraint(benders_data.sub, _c, benders_data.sub[:_x] >= component(benders_data.sub, "invest1_1").var.value) + # JuMP.@constraint(benders_data.main, _c, benders_data.main[:_x] >= get_component(benders_data.main, "invest1_1").var.value) + # JuMP.@constraint(benders_data.sub, _c, benders_data.sub[:_x] >= get_component(benders_data.sub, "invest1_1").var.value) # user_defined = Dict( # :main => Set([:_x]), :sub => Set([:_x, :_c]) @@ -280,7 +280,7 @@ function _cb_benders(benders_data::BendersData, cb_data::Any) # Get the current solution from the main-problem. current_decisions = Dict( - comp_name => JuMP.callback_value(cb_data, component(benders_data.main, comp_name).var.value) for + comp_name => JuMP.callback_value(cb_data, get_component(benders_data.main, comp_name).var.value) for comp_name in benders_data.decisions ) current_user_defined_variables = Dict( @@ -289,7 +289,7 @@ function _cb_benders(benders_data::BendersData, cb_data::Any) # Update the sub-problem. for (comp_name, value) in current_decisions - JuMP.fix(component(benders_data.sub, comp_name).var.value, value; force=true) + JuMP.fix(get_component(benders_data.sub, comp_name).var.value, value; force=true) end for (obj, value) in current_user_defined_variables JuMP.fix.(benders_data.sub[obj], value; force=true) @@ -326,7 +326,8 @@ function _cb_benders(benders_data::BendersData, cb_data::Any) obj_sub + sum( extract_result(benders_data.sub, comp_name, "value"; mode="dual") * - (component(benders_data.main, comp_name).var.value - value) for (comp_name, value) in current_decisions + (get_component(benders_data.main, comp_name).var.value - value) for + (comp_name, value) in current_decisions ) + user_sum ) @@ -358,7 +359,7 @@ function _iterative_benders(benders_data::BendersData; exploration_iterations=0) if (benders_data.iteration <= exploration_iterations) && isempty(benders_data.user_defined_variables) # Random values in the beginning to explore. for comp_name in benders_data.decisions - comp = component(benders_data.main, comp_name) + comp = get_component(benders_data.main, comp_name) lb = !isnothing(comp.lb) ? comp.lb : -500 ub = !isnothing(comp.ub) ? comp.ub : 500 current_decisions[comp_name] = lb + rand() * (ub - lb) @@ -380,7 +381,7 @@ function _iterative_benders(benders_data::BendersData; exploration_iterations=0) # Update the sub-problem. for (comp_name, value) in current_decisions - JuMP.fix(component(benders_data.sub, comp_name).var.value, value; force=true) + JuMP.fix(get_component(benders_data.sub, comp_name).var.value, value; force=true) end for (obj, value) in current_user_defined_variables JuMP.fix.(benders_data.sub[obj], value; force=true) @@ -397,7 +398,7 @@ function _iterative_benders(benders_data::BendersData; exploration_iterations=0) exploration_sum = 0.0 if exploration exploration_dict = Dict( - component(benders_data.main, comp_name).var.value => current_decisions[comp_name] for + get_component(benders_data.main, comp_name).var.value => current_decisions[comp_name] for comp_name in benders_data.decisions ) exploration_dict[benders_data.main[:θ]] = 0.0 @@ -453,7 +454,7 @@ function _iterative_benders(benders_data::BendersData; exploration_iterations=0) obj_sub + sum( extract_result(benders_data.sub, comp_name, "value"; mode="dual") * - (component(benders_data.main, comp_name).var.value - value) for + (get_component(benders_data.main, comp_name).var.value - value) for (comp_name, value) in current_decisions ) + user_sum diff --git a/src/opt/sddp.jl b/src/opt/sddp.jl index 1303019..ccce0a6 100644 --- a/src/opt/sddp.jl +++ b/src/opt/sddp.jl @@ -32,8 +32,8 @@ generate!( build_cost1=500.0, build_cost2=5000.0, ) -JuMP.fix.(component(model, "inflow").var.aux_value, _inflow; force=true); -JuMP.fix.(component(model, "demand").var.aux_value, _demand; force=true); +JuMP.fix.(get_component(model, "inflow").var.aux_value, _inflow; force=true); +JuMP.fix.(get_component(model, "demand").var.aux_value, _demand; force=true); true_cost = [] for t in 1:365 append!(true_cost, [_cost[t * 24 * 4] for _ in 1:(24 * 4)]) @@ -42,7 +42,7 @@ objs = _iesopt(model).model.objectives JuMP.@objective( model, Min, - sum(component(model, "thermal").var.aux_value[t] * true_cost[t] for t in 1:(8760 * 4)) + + sum(get_component(model, "thermal").var.aux_value[t] * true_cost[t] for t in 1:(8760 * 4)) + objs["build1_value"].func + objs["build2_value"].func ); @@ -69,19 +69,19 @@ sddp_model = SDDP.LinearPolicyGraph(; stages=365, sense=:Min, lower_bound=0.0, o JuMP.@constraint(model, x_storage.in <= x_storage_cap.in) JuMP.@constraint(model, x_storage.out <= x_storage_cap.in) - # JuMP.@constraint(model, component(model, "reservoir").var.state[1] <= x_storage_cap.in) + # JuMP.@constraint(model, get_component(model, "reservoir").var.state[1] <= x_storage_cap.in) - JuMP.@constraint(model, component(model, "reservoir").var.state[1] == x_storage.in) + JuMP.@constraint(model, get_component(model, "reservoir").var.state[1] == x_storage.in) JuMP.@constraint( model, - -JuMP.constraint_object(component(model, "reservoir").con.last_state_lb).func == x_storage.out + -JuMP.constraint_object(get_component(model, "reservoir").con.last_state_lb).func == x_storage.out ) if t == 1 JuMP.@constraint( model, x_storage_cap.out == - x_storage_cap.in + component(model, "build1").var.value + component(model, "build2").var.value + x_storage_cap.in + get_component(model, "build1").var.value + get_component(model, "build2").var.value ) else JuMP.@constraint(model, x_storage_cap.out == x_storage_cap.in) @@ -93,8 +93,8 @@ sddp_model = SDDP.LinearPolicyGraph(; stages=365, sense=:Min, lower_bound=0.0, o return end - JuMP.fix.(component(model, "inflow").var.aux_value, _inflow[((t - 1) * 24 * 4 + 1):(t * 24 * 4)]; force=true) - JuMP.fix.(component(model, "demand").var.aux_value, _demand[((t - 1) * 24 * 4 + 1):(t * 24 * 4)]; force=true) + JuMP.fix.(get_component(model, "inflow").var.aux_value, _inflow[((t - 1) * 24 * 4 + 1):(t * 24 * 4)]; force=true) + JuMP.fix.(get_component(model, "demand").var.aux_value, _demand[((t - 1) * 24 * 4 + 1):(t * 24 * 4)]; force=true) objs = _iesopt(model).model.objectives if t == 1 @@ -119,8 +119,9 @@ simulations = SDDP.simulate( custom_recorders=Dict{Symbol, Function}( :build => (model::JuMP.Model) -> - JuMP.value(component(model, "build1").var.value) + JuMP.value(component(model, "build2").var.value), - :thermal => (model::JuMP.Model) -> JuMP.value(component(model, "thermal").var.aux_value[1]), + JuMP.value(get_component(model, "build1").var.value) + + JuMP.value(get_component(model, "build2").var.value), + :thermal => (model::JuMP.Model) -> JuMP.value(get_component(model, "thermal").var.aux_value[1]), ), ) @@ -162,18 +163,18 @@ sddp_model = SDDP.LinearPolicyGraph(; stages=20, sense=:Min, lower_bound=0.0, op JuMP.@constraint(model, x_storage.in <= x_storage_cap.in) JuMP.@constraint(model, x_storage.out <= x_storage_cap.in) - # JuMP.@constraint(model, component(model, "reservoir").var.state[1] <= x_storage_cap.in) + # JuMP.@constraint(model, get_component(model, "reservoir").var.state[1] <= x_storage_cap.in) - JuMP.@constraint(model, component(model, "reservoir").var.state[1] == x_storage.in) + JuMP.@constraint(model, get_component(model, "reservoir").var.state[1] == x_storage.in) JuMP.@constraint( model, - -JuMP.constraint_object(component(model, "reservoir").con.last_state_lb).func == x_storage.out + -JuMP.constraint_object(get_component(model, "reservoir").con.last_state_lb).func == x_storage.out ) JuMP.@constraint( model, x_storage_cap.out == - x_storage_cap.in + component(model, "build1").var.value + component(model, "build2").var.value + x_storage_cap.in + get_component(model, "build1").var.value + get_component(model, "build2").var.value ) _z = 0 @@ -182,7 +183,7 @@ sddp_model = SDDP.LinearPolicyGraph(; stages=20, sense=:Min, lower_bound=0.0, op JuMP.@constraint(model, x_storage.out + _z >= 5) end - v = JuMP.fix_value(component(model, "inflow").var.aux_value[1]) + v = JuMP.fix_value(get_component(model, "inflow").var.aux_value[1]) objs = _iesopt(model).model.objectives Ω = [1.0] @@ -208,8 +209,9 @@ simulations = SDDP.simulate( custom_recorders=Dict{Symbol, Function}( :build => (model::JuMP.Model) -> - JuMP.value(component(model, "build1").var.value) + JuMP.value(component(model, "build2").var.value), - :thermal => (model::JuMP.Model) -> JuMP.value(component(model, "thermal").var.aux_value[1]), + JuMP.value(get_component(model, "build1").var.value) + + JuMP.value(get_component(model, "build2").var.value), + :thermal => (model::JuMP.Model) -> JuMP.value(get_component(model, "thermal").var.aux_value[1]), ), ) @@ -247,18 +249,18 @@ sddp_model = SDDP.LinearPolicyGraph(; stages=20, sense=:Min, lower_bound=0.0, op JuMP.@constraint(model, x_storage.in <= x_storage_cap.in) JuMP.@constraint(model, x_storage.out <= x_storage_cap.in) - # JuMP.@constraint(model, component(model, "reservoir").var.state[1] <= x_storage_cap.in) + # JuMP.@constraint(model, get_component(model, "reservoir").var.state[1] <= x_storage_cap.in) - JuMP.@constraint(model, component(model, "reservoir").var.state[1] == x_storage.in) + JuMP.@constraint(model, get_component(model, "reservoir").var.state[1] == x_storage.in) JuMP.@constraint( model, - -JuMP.constraint_object(component(model, "reservoir").con.last_state_lb).func == x_storage.out + -JuMP.constraint_object(get_component(model, "reservoir").con.last_state_lb).func == x_storage.out ) JuMP.@constraint( model, x_storage_cap.out == - x_storage_cap.in + component(model, "build1").var.value + component(model, "build2").var.value + x_storage_cap.in + get_component(model, "build1").var.value + get_component(model, "build2").var.value ) _z = 0 @@ -267,7 +269,7 @@ sddp_model = SDDP.LinearPolicyGraph(; stages=20, sense=:Min, lower_bound=0.0, op JuMP.@constraint(model, x_storage.out + _z >= 5) end - v = JuMP.fix_value(component(model, "inflow").var.aux_value[1]) + v = JuMP.fix_value(get_component(model, "inflow").var.aux_value[1]) objs = _iesopt(model).model.objectives lower = -convert(Int64, floor(t / 5.0 * 2500)) @@ -277,7 +279,7 @@ sddp_model = SDDP.LinearPolicyGraph(; stages=20, sense=:Min, lower_bound=0.0, op P = [1.0 / length(Ω) for i in 1:length(Ω)] SDDP.parameterize(model, Ω, P) do ω - # JuMP.fix(component(model, "inflow").var.aux_value[1], max(0., v + ω.inflow); force=true) + # JuMP.fix(get_component(model, "inflow").var.aux_value[1], max(0., v + ω.inflow); force=true) # SDDP.@stageobjective(model, objs["thermal"].func + _z * 1e4) SDDP.@stageobjective( model, @@ -300,8 +302,9 @@ simulations = SDDP.simulate( custom_recorders=Dict{Symbol, Function}( :build => (model::JuMP.Model) -> - JuMP.value(component(model, "build1").var.value) + JuMP.value(component(model, "build2").var.value), - :thermal => (model::JuMP.Model) -> JuMP.value(component(model, "thermal").var.aux_value[1]), + JuMP.value(get_component(model, "build1").var.value) + + JuMP.value(get_component(model, "build2").var.value), + :thermal => (model::JuMP.Model) -> JuMP.value(get_component(model, "thermal").var.aux_value[1]), ), ) @@ -333,10 +336,10 @@ sddp_model = SDDP.LinearPolicyGraph(; stages=52, sense=:Min, lower_bound=0.0, op parametric=true, ) - JuMP.@constraint(model, component(model, "reservoir").var.state[1] == x_storage.in) + JuMP.@constraint(model, get_component(model, "reservoir").var.state[1] == x_storage.in) JuMP.@constraint( model, - -JuMP.constraint_object(component(model, "reservoir").con.last_state_lb).func == x_storage.out + -JuMP.constraint_object(get_component(model, "reservoir").con.last_state_lb).func == x_storage.out ) _z = 0 @@ -345,7 +348,7 @@ sddp_model = SDDP.LinearPolicyGraph(; stages=52, sense=:Min, lower_bound=0.0, op JuMP.@constraint(model, x_storage.out + _z >= 300) end - v = JuMP.fix_value(component(model, "inflow").var.aux_value[1]) + v = JuMP.fix_value(get_component(model, "inflow").var.aux_value[1]) objs = _iesopt(model).model.objectives Ω = [ @@ -358,7 +361,7 @@ sddp_model = SDDP.LinearPolicyGraph(; stages=52, sense=:Min, lower_bound=0.0, op P /= sum(P) SDDP.parameterize(model, Ω, P) do ω - JuMP.fix(component(model, "inflow").var.aux_value[1], max(0.0, v + ω.inflow); force=true) + JuMP.fix(get_component(model, "inflow").var.aux_value[1], max(0.0, v + ω.inflow); force=true) SDDP.@stageobjective(model, ω.fuel_multiplier * objs["thermal"].func + _z * 1e4) return end @@ -406,8 +409,8 @@ simulations = SDDP.simulate( 50, [:x_storage]; custom_recorders=Dict{Symbol, Function}( - :thermal => (model::JuMP.Model) -> JuMP.value(component(model, "thermal").var.aux_value[1]), - :spillage => (model::JuMP.Model) -> JuMP.value(component(model, "spill").var.aux_value[1]), + :thermal => (model::JuMP.Model) -> JuMP.value(get_component(model, "thermal").var.aux_value[1]), + :spillage => (model::JuMP.Model) -> JuMP.value(get_component(model, "spill").var.aux_value[1]), ), ) diff --git a/src/opt/stochastic.jl b/src/opt/stochastic.jl index 4dee6dd..ad9c7d1 100644 --- a/src/opt/stochastic.jl +++ b/src/opt/stochastic.jl @@ -169,10 +169,10 @@ function stochastic( @showprogress "Modifying sub models: " for sub in stochastic_data.subs for comp_name in stochastic_data.decisions - component(sub, comp_name).mode = :fixed - component(sub, comp_name).cost = nothing - component(sub, comp_name).fixed_cost = nothing - component(sub, comp_name).fixed_value = 0.0 + get_component(sub, comp_name).mode = :fixed + get_component(sub, comp_name).cost = nothing + get_component(sub, comp_name).fixed_cost = nothing + get_component(sub, comp_name).fixed_value = 0.0 end end @@ -286,7 +286,7 @@ function _iterative_stochastic(stochastic_data::StochasticData) # Update the sub-problems. for sub in stochastic_data.subs for (comp_name, value) in current_decisions - JuMP.fix(component(sub, comp_name).var.value, value; force=true) + JuMP.fix(get_component(sub, comp_name).var.value, value; force=true) end end @@ -339,7 +339,7 @@ function _iterative_stochastic(stochastic_data::StochasticData) stochastic_data.main[:θ][i] >= obj_subs[i] + sum( extract_result(stochastic_data.subs[i], comp_name, "value"; mode="dual") * - (component(stochastic_data.main, comp_name).var.value - value) for + (get_component(stochastic_data.main, comp_name).var.value - value) for (comp_name, value) in current_decisions ) ) diff --git a/src/templates/functions/finalize.jl b/src/templates/functions/finalize.jl index 75969fb..d21de0a 100644 --- a/src/templates/functions/finalize.jl +++ b/src/templates/functions/finalize.jl @@ -68,8 +68,8 @@ function _build_template_function_finalize(template::CoreTemplate) get_ts(s::String) = _get_timeseries_safe(s, __parameters__, __model__) access(sub) = - sub == "self" ? component(__model__, __component__) : - component(__model__, "$(__component__).$(sub)") + sub == "self" ? get_component(__model__, __component__) : + get_component(__model__, "$(__component__).$(sub)") try $code_ex diff --git a/src/utils/docs.jl b/src/utils/docs.jl index a96b10b..ff85cb1 100644 --- a/src/utils/docs.jl +++ b/src/utils/docs.jl @@ -57,7 +57,7 @@ function _docs_docstr_to_admonition(f::Function) Access this $(obj_longtype) by using: ```julia # Julia - component(model, "your_$(obj_cc)").$(obj_type).$(obj_name) + get_component(model, "your_$(obj_cc)").$(obj_type).$(obj_name) ``` ```python # Python diff --git a/src/utils/general.jl b/src/utils/general.jl index 4809e09..2ba71f0 100644 --- a/src/utils/general.jl +++ b/src/utils/general.jl @@ -291,7 +291,7 @@ function _conv_S2NI(model::JuMP.Model, str::AbstractString) if isnothing(findfirst("@", str)) # Check if this is a link to an Expression. if haskey(_iesopt(model).model.components, str) - component = component(model, str) + component = get_component(model, str) error( "You ended up in an outdated part of IESopt, which should not have happened. Please report this error including the model you are trying to run.", ) @@ -325,7 +325,7 @@ function _presolve(model::JuMP.Model, data::_AbstractAffExpr) return _PresolvedAffExpr( data.constant, [ - (coeff=coeff, var=_PresolvedVarRef(component(model, var.comp_name), getfield(IESopt, var.field))) for + (coeff=coeff, var=_PresolvedVarRef(get_component(model, var.comp_name), getfield(IESopt, var.field))) for (coeff, var) in data.variables ], ) diff --git a/test/src/examples.jl b/test/src/examples.jl index 2ba2aed..a95a647 100644 --- a/test/src/examples.jl +++ b/test/src/examples.jl @@ -53,15 +53,15 @@ end model = generate!(joinpath(PATH_EXAMPLES, "20_chp.iesopt.yaml"); verbosity=false) optimize!(model) @test all( - JuMP.value.(component(model, "chp.power").exp.out_electricity) .== + JuMP.value.(get_component(model, "chp.power").exp.out_electricity) .== [2.75, 5.50, 7.00, 8.00, 9.00, 10.00, 5.00, 5.00, 9.00], ) @test all( - JuMP.value.(component(model, "chp.heat").exp.out_heat) .== + JuMP.value.(get_component(model, "chp.heat").exp.out_heat) .== [5.00, 10.00, 10.00, 10.00, 5.00, 0.00, 0.00, 5.00, 5.00], ) @test all( - JuMP.value.(component(model, "create_gas").exp.value) .== + JuMP.value.(get_component(model, "create_gas").exp.value) .== [9.375, 18.75, 22.5, 25.0, 25.0, 25.0, 12.5, 15.0, 25.0], ) IESopt.save_close_filelogger(model) @@ -76,7 +76,7 @@ end @testset "snapshots (22 and 23)" begin model = generate!(joinpath(PATH_EXAMPLES, "22_snapshot_weights.iesopt.yaml"); verbosity=false) optimize!(model) - @test all(JuMP.value.(component(model, "buy").exp.value) .≈ [10.0, 6.0, 6.0, 0.0, 7.0, 4.0]) + @test all(JuMP.value.(get_component(model, "buy").exp.value) .≈ [10.0, 6.0, 6.0, 0.0, 7.0, 4.0]) obj_val_example_22 = JuMP.objective_value(model) _test_example_default_solver("23_snapshots_from_csv.iesopt.yaml"; obj=obj_val_example_22) IESopt.save_close_filelogger(model) @@ -108,8 +108,8 @@ end model = generate!(joinpath(PATH_EXAMPLES, "31_exclusive_operation.iesopt.yaml"); verbosity=false) optimize!(model) @test JuMP.objective_value(model) ≈ -10.0 - @test JuMP.value.(IESopt.component(model, "buy_id").exp.value) == [1, 0, 1, 0] - @test JuMP.value.(IESopt.component(model, "sell_id").exp.value) == [0, 1, 0, 1] + @test JuMP.value.(IESopt.get_component(model, "buy_id").exp.value) == [1, 0, 1, 0] + @test JuMP.value.(IESopt.get_component(model, "sell_id").exp.value) == [0, 1, 0, 1] IESopt.save_close_filelogger(model) end @@ -161,7 +161,7 @@ end @test JuMP.objective_value(model_coupled) <= JuMP.objective_value(model_AT_DE) + JuMP.objective_value(model_CH) <= JuMP.objective_value(model_individual) - + IESopt.save_close_filelogger(model_coupled) IESopt.save_close_filelogger(model_individual) IESopt.save_close_filelogger(model_AT_DE)