From 683e431325f83cf9ea944840d94ee4a015e9b9f2 Mon Sep 17 00:00:00 2001 From: Jose Daniel Lara Date: Tue, 17 Sep 2024 14:16:17 -0600 Subject: [PATCH] param updating --- .../operation_model_simulation_interface.jl | 6 ++++++ src/parameters/update_container_parameter_values.jl | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/operation/operation_model_simulation_interface.jl b/src/operation/operation_model_simulation_interface.jl index 99d45c714..e857af8eb 100644 --- a/src/operation/operation_model_simulation_interface.jl +++ b/src/operation/operation_model_simulation_interface.jl @@ -8,6 +8,12 @@ function update_model!(model::OperationModel, source::SimulationState, ini_cond_ return end +function update_parameters!(model::EmulationModel, state::SimulationState) + data = get_system_states(state) + update_parameters!(model, data) + return +end + function update_parameters!( model::DecisionModel, simulation_state::SimulationState, diff --git a/src/parameters/update_container_parameter_values.jl b/src/parameters/update_container_parameter_values.jl index c900ff5f3..7d78a777e 100644 --- a/src/parameters/update_container_parameter_values.jl +++ b/src/parameters/update_container_parameter_values.jl @@ -259,7 +259,6 @@ function _update_parameter_values!( for name in component_names # Pass indices in this way since JuMP DenseAxisArray don't support view() value = round(state_values[name, state_data_index]) - @assert 0.0 <= value <= 1.0 if !isfinite(value) error( "The value for the system state used in $(encode_key_as_string(get_attribute_key(attributes))) is not a finite value $(value) \ @@ -267,6 +266,10 @@ function _update_parameter_values!( Consider reviewing your models' horizon and interval definitions", ) end + if 0.0 > value || value > 1.0 + error( + "The value for the system state used in $(encode_key_as_string(get_attribute_key(attributes))): $(value) is out of the [0, 1] range") + end _set_param_value!(parameter_array, value, name, t) end end @@ -309,7 +312,6 @@ function _update_parameter_values!( for name in component_names # Pass indices in this way since JuMP DenseAxisArray don't support view() value = round(state_values[name, state_data_index]) - @assert 0.0 <= value <= 1.0 if !isfinite(value) error( "The value for the system state used in $(encode_key_as_string(get_attribute_key(attributes))) is not a finite value $(value) \ @@ -317,7 +319,11 @@ function _update_parameter_values!( Consider reviewing your models' horizon and interval definitions", ) end - _set_param_value!(parameter_array, value, name, 1) + if 0.0 > value || value > 1.0 + error( + "The value for the system state used in $(encode_key_as_string(get_attribute_key(attributes))): $(value) is out of the [0, 1] range") + end + _set_param_value!(parameter_array, value, name, t) end return end