Skip to content

Commit

Permalink
param updating
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Sep 17, 2024
1 parent 0d3bb47 commit 683e431
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/operation/operation_model_simulation_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 14 in src/operation/operation_model_simulation_interface.jl

View check run for this annotation

Codecov / codecov/patch

src/operation/operation_model_simulation_interface.jl#L11-L14

Added lines #L11 - L14 were not covered by tests
end

function update_parameters!(
model::DecisionModel,
simulation_state::SimulationState,
Expand Down
12 changes: 9 additions & 3 deletions src/parameters/update_container_parameter_values.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,17 @@ 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(

Check warning on line 263 in src/parameters/update_container_parameter_values.jl

View check run for this annotation

Codecov / codecov/patch

src/parameters/update_container_parameter_values.jl#L263

Added line #L263 was not covered by tests
"The value for the system state used in $(encode_key_as_string(get_attribute_key(attributes))) is not a finite value $(value) \
This is commonly caused by referencing a state value at a time when such decision hasn't been made. \
Consider reviewing your models' horizon and interval definitions",
)
end
if 0.0 > value || value > 1.0
error(

Check warning on line 270 in src/parameters/update_container_parameter_values.jl

View check run for this annotation

Codecov / codecov/patch

src/parameters/update_container_parameter_values.jl#L270

Added line #L270 was not covered by tests
"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
Expand Down Expand Up @@ -309,15 +312,18 @@ function _update_parameter_values!(
for name in component_names

Check warning on line 312 in src/parameters/update_container_parameter_values.jl

View check run for this annotation

Codecov / codecov/patch

src/parameters/update_container_parameter_values.jl#L306-L312

Added lines #L306 - L312 were not covered by tests
# 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(

Check warning on line 316 in src/parameters/update_container_parameter_values.jl

View check run for this annotation

Codecov / codecov/patch

src/parameters/update_container_parameter_values.jl#L314-L316

Added lines #L314 - L316 were not covered by tests
"The value for the system state used in $(encode_key_as_string(get_attribute_key(attributes))) is not a finite value $(value) \
This is commonly caused by referencing a state value at a time when such decision hasn't been made. \
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(

Check warning on line 323 in src/parameters/update_container_parameter_values.jl

View check run for this annotation

Codecov / codecov/patch

src/parameters/update_container_parameter_values.jl#L322-L323

Added lines #L322 - L323 were not covered by tests
"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

Check warning on line 328 in src/parameters/update_container_parameter_values.jl

View check run for this annotation

Codecov / codecov/patch

src/parameters/update_container_parameter_values.jl#L326-L328

Added lines #L326 - L328 were not covered by tests
end
Expand Down

0 comments on commit 683e431

Please sign in to comment.