Skip to content

Commit

Permalink
update code for decomposition
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Apr 4, 2024
1 parent 25771ec commit 4dfab11
Showing 1 changed file with 28 additions and 57 deletions.
85 changes: 28 additions & 57 deletions src/parameters/update_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -331,38 +331,26 @@ end
"""
Update parameter function an OperationModel
"""
function update_parameter_values!(
function update_container_parameter_values!(
optimization_container::OptimizationContainer,
model::OperationModel,
key::ParameterKey{T, U},
input::DatasetContainer{InMemoryDataset},
) where {T <: ParameterType, U <: PSY.Component}
# Enable again for detailed debugging
# TimerOutputs.@timeit RUN_SIMULATION_TIMER "$T $U Parameter Update" begin
optimization_container = get_optimization_container(model)
# Note: Do not instantite a new key here because it might not match the param keys in the container
# if the keys have strings in the meta fields
parameter_array = get_parameter_array(optimization_container, key)
parameter_attributes = get_parameter_attributes(optimization_container, key)
_update_parameter_values!(parameter_array, parameter_attributes, U, model, input)
IS.@record :execution ParameterUpdateEvent(
T,
U,
parameter_attributes,
get_current_timestamp(model),
get_name(model),
)
# end
return
end

function update_parameter_values!(
function update_container_parameter_values!(
optimization_container::OptimizationContainer,
model::OperationModel,
key::ParameterKey{T, U},
input::DatasetContainer{InMemoryDataset},
) where {T <: ObjectiveFunctionParameter, U <: PSY.Component}
# Enable again for detailed debugging
# TimerOutputs.@timeit RUN_SIMULATION_TIMER "$T $U Parameter Update" begin
optimization_container = get_optimization_container(model)
# Note: Do not instantite a new key here because it might not match the param keys in the container
# if the keys have strings in the meta fields
parameter_array = get_parameter_array(optimization_container, key)
Expand All @@ -377,86 +365,69 @@ function update_parameter_values!(
model,
input,
)
IS.@record :execution ParameterUpdateEvent(
T,
U,
parameter_attributes,
get_current_timestamp(model),
get_name(model),
)
# end
return
end

function update_parameter_values!(
function update_container_parameter_values!(
optimization_container::OptimizationContainer,
model::OperationModel,
key::ParameterKey{FixValueParameter, T},
key::ParameterKey{FixValueParameter, U},
input::DatasetContainer{InMemoryDataset},
) where {T <: PSY.Component}
# Enable again for detailed debugging
# TimerOutputs.@timeit RUN_SIMULATION_TIMER "$T $U Parameter Update" begin
optimization_container = get_optimization_container(model)
) where {U <: PSY.Component}
# Note: Do not instantite a new key here because it might not match the param keys in the container
# if the keys have strings in the meta fields
parameter_array = get_parameter_array(optimization_container, key)
parameter_attributes = get_parameter_attributes(optimization_container, key)
_update_parameter_values!(parameter_array, parameter_attributes, T, model, input)
_fix_parameter_value!(optimization_container, parameter_array, parameter_attributes)
IS.@record :execution ParameterUpdateEvent(
FixValueParameter,
T,
parameter_attributes,
get_current_timestamp(model),
get_name(model),
)
# end
return
end

"""
Update parameter function an OperationModel
"""
function update_parameter_values!(
function update_container_parameter_values!(
optimization_container::OptimizationContainer,
model::OperationModel,
key::ParameterKey{T, U},
input::DatasetContainer{InMemoryDataset},
) where {T <: ParameterType, U <: PSY.Service}
# Enable again for detailed debugging
# TimerOutputs.@timeit RUN_SIMULATION_TIMER "$T $U Parameter Update" begin
optimization_container = get_optimization_container(model)
# Note: Do not instantite a new key here because it might not match the param keys in the container
# if the keys have strings in the meta fields
parameter_array = get_parameter_array(optimization_container, key)
parameter_attributes = get_parameter_attributes(optimization_container, key)
service = PSY.get_component(U, get_system(model), key.meta)
@assert service !== nothing
_update_parameter_values!(parameter_array, parameter_attributes, service, model, input)
IS.@record :execution ParameterUpdateEvent(
T,
U,
parameter_attributes,
get_current_timestamp(model),
get_name(model),
)
#end
return
end

function update_parameter_values!(
function update_container_parameter_values!(
optimization_container::OptimizationContainer,
model::OperationModel,
key::ParameterKey{T, U},
input::DatasetContainer{InMemoryDataset},
) where {T <: ObjectiveFunctionParameter, U <: PSY.Service}
# Enable again for detailed debugging
# TimerOutputs.@timeit RUN_SIMULATION_TIMER "$T $U Parameter Update" begin
optimization_container = get_optimization_container(model)
# Note: Do not instantite a new key here because it might not match the param keys in the container
# if the keys have strings in the meta fields
parameter_array = get_parameter_array(optimization_container, key)
parameter_attributes = get_parameter_attributes(optimization_container, key)
service = PSY.get_component(U, get_system(model), key.meta)
@assert service !== nothing
_update_parameter_values!(parameter_array, parameter_attributes, service, model, input)
return
end

"""
Update parameter function an OperationModel
"""
function update_parameter_values!(
model::OperationModel,
key::ParameterKey{T, U},
input::DatasetContainer{InMemoryDataset},
) where {T <: ParameterType, U <: PSY.Component}
# Enable again for detailed debugging
# TimerOutputs.@timeit RUN_SIMULATION_TIMER "$T $U Parameter Update" begin
optimization_container = get_optimization_container(model)
update_container_parameter_values!(optimization_container, model, key, input)
parameter_attributes = get_parameter_attributes(optimization_container, key)
IS.@record :execution ParameterUpdateEvent(
T,
U,
Expand Down

0 comments on commit 4dfab11

Please sign in to comment.