Skip to content

Commit

Permalink
fix parameter update code
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Jan 3, 2025
1 parent d5e096f commit 1140b9c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions src/models/network_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ function _update_parameter_values!(
#println("******** state_data_index,",state_data_index)
for name_ix in component_names
# Pass indices in this way since JuMP DenseAxisArray don't support view()
state_value = state_values[name_ix, state_data_index]
state_value = state_values[name_ix, state_data_index]
if name_ix == "10313"
@error "update pm" state_value PSI.get_attribute_key(attributes) current_time
end
Expand Down Expand Up @@ -370,7 +370,7 @@ end
"""
Update parameter function an OperationModel
"""
function PSI.update_container_parameter_values!(
function update_container_parameter_values!(
optimization_container::PSI.OptimizationContainer,
model::PSI.DecisionModel{MultiRegionProblem},
key::PSI.ParameterKey{StateEstimationInjections, PSY.ACBus},
Expand All @@ -391,3 +391,23 @@ function PSI.update_container_parameter_values!(
)
return
end

function PSI.update_parameter_values!(
model::PSI.DecisionModel{MultiRegionProblem},
key::PSI.ParameterKey{StateEstimationInjections, PSY.ACBus},
simulation_state::PSI.SimulationState,
) where {T <: PSI.ParameterType, U <: PSY.Component}
# Enable again for detailed debugging
# TimerOutputs.@timeit RUN_SIMULATION_TIMER "$T $U Parameter Update" begin
optimization_container = PSI.get_optimization_container(model)
update_container_parameter_values!(optimization_container, model, key, simulation_state)
IS.@record :execution PSI.ParameterUpdateEvent(
T,
U,
"state update event", # TODO: Implement correct update recorder event
PSI.get_current_timestamp(model),
PSI.get_name(model),
)
#end
return
end
2 changes: 1 addition & 1 deletion src/problems/multi_region_problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ function PSI.update_parameters!(
@debug "Updating subproblem $ix"
PSI.cost_function_unsynch(subproblem)
for key in keys(PSI.get_parameters(subproblem))
PSI.update_container_parameter_values!(subproblem, model, key, simulation_state)
PSI.update_parameter_values!(subproblem, key, simulation_state)
end
end

Expand Down

0 comments on commit 1140b9c

Please sign in to comment.