Skip to content

Commit

Permalink
update decision state for OnVariable and ActivePowerVariable
Browse files Browse the repository at this point in the history
  • Loading branch information
m-bossart committed Jan 31, 2025
1 parent e1dbf5c commit 11ca36d
Showing 1 changed file with 20 additions and 28 deletions.
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)
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
@info "forcing $key to zero at index $outage_index because status was zero for $name"
else
break
end
if outage_index == length(state_data.values[name, :])
break
end
outage_index += 1
end
end
=#
end
return
end

Expand Down

0 comments on commit 11ca36d

Please sign in to comment.