Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update decision state for OnVariable and ActivePowerVariable #1232

Merged
merged 1 commit into from
Feb 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 20 additions & 28 deletions src/simulation/simulation_state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ function update_decision_state!(
event_ocurrence_data =
get_decision_state_data(state, AvailableStatusChangeParameter(), T)
state_data = get_decision_state_data(state, key)
@warn "State data for AvailableStatusParameter decision before any updates: $state_data"
#column_names = get_column_names(key, state_data)[1]
model_resolution = get_resolution(model_params)
state_resolution = get_data_resolution(state_data)
Expand Down Expand Up @@ -343,18 +342,6 @@ function update_decision_state!(
end
end
end
#= offset = resolution_ratio - 1
result_time_index = axes(store_data)[2]
set_update_timestamp!(state_data, simulation_time)
for t in result_time_index
state_range = state_data_index:(state_data_index + offset)
for name in column_names, i in state_range
state_data.values[name, i] = store_data[name, t]
end
set_last_recorded_row!(state_data, state_range[end])
state_data_index += resolution_ratio
end =#
@warn "AvailableStatusParameter decision state after update: $state_data"

return
Expand All @@ -368,9 +355,11 @@ function update_decision_state!(
simulation_time::Dates.DateTime,
model_params::ModelStoreParams,
) where {T <: VariableType, U <: PSY.Component}
event_ocurrence_data = get_decision_state_data(state, AvailableStatusParameter(), U)
@error "UPDATE DECISION STATE $key"
event_ocurrence_data = get_decision_state_data(state, AvailableStatusChangeParameter(), U)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
event_ocurrence_data = get_decision_state_data(state, AvailableStatusChangeParameter(), U)
event_ocurrence_data =
get_decision_state_data(state, AvailableStatusChangeParameter(), U)

event_status_data = get_decision_state_data(state, AvailableStatusParameter(), U)

state_data = get_decision_state_data(state, key)
column_names = get_column_names(key, state_data)[1]
model_resolution = get_resolution(model_params)
state_resolution = get_data_resolution(state_data)
resolution_ratio = model_resolution ÷ state_resolution
Expand All @@ -388,20 +377,23 @@ function update_decision_state!(
else
state_data_index = find_timestamp_index(state_timestamps, simulation_time)
end
#=
offset = resolution_ratio - 1
result_time_index = axes(store_data)[2]
set_update_timestamp!(state_data, simulation_time)
for t in result_time_index
state_range = state_data_index:(state_data_index + offset)
for name in column_names, i in state_range
state_data.values[name, i] = store_data[name, t]
end
set_last_recorded_row!(state_data, state_range[end])
state_data_index += resolution_ratio
for name in column_names
if event_ocurrence_data.values[name, state_data_index] == 1.0
outage_index = state_data_index + 1 #outage occurs at the following timestep
while true
if event_status_data.values[name, outage_index] == 0.0
state_data.values[name, outage_index] = 0.0
Comment on lines +384 to +385
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
if event_status_data.values[name, outage_index] == 0.0
state_data.values[name, outage_index] = 0.0
if event_status_data.values[name, outage_index] == 0.0
state_data.values[name, outage_index] = 0.0

@info "forcing $key to zero at index $outage_index because status was zero for $name"
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
else
else

break
end
if outage_index == length(state_data.values[name, :])
Comment on lines +389 to +390
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
end
if outage_index == length(state_data.values[name, :])
end
if outage_index == length(state_data.values[name, :])

break
end
outage_index += 1
end
Comment on lines +392 to +394
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
end
outage_index += 1
end
end
outage_index += 1
end

end
=#
end
return
end

Expand Down
Loading