Sienna-Platform / Sienna-Platform/PowerOperationsModels.jl
InitialConditions updates need to check formulations to avoid looking for OnVariable with StandardDispatch
Open
@jd-lara is already working on this.
Since Feb 13, 2025.
- Dominant language
- Julia
- Stars
- 2
- Forks
- 1
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 26
Description
If this is a question, something isn't working or an idea please start a Q&A discussion in the Discussion tab
Open a bug report only if you can provide the details below
Describe the bug
Standard Dispatch is not designed to operate without having an OnVariable from a unit commitment problem.
To Reproduce
Steps to reproduce the behavior:
using PowerSystems
using PowerSimulations
using PowerSystemCaseBuilder
using PowerGraphics
using Logging
using Dates
using Ipopt
using HydroPowerSimulations
const PSI = PowerSimulations
const PSY = PowerSystems
function configure_ED_template(sys, horizon, interval)
PSY.transform_single_time_series!(sys, horizon, interval)
for line in get_components(Line, sys)
if (get_base_voltage(get_from(get_arc(line))) >= 230.0) &&
(get_base_voltage(get_to(get_arc(line))) >= 230.0)
@info "Changing $(get_name(line)) to MonitoredLine"
convert_component!(MonitoredLine, line, sys)
end
end
# ### Create a `template`
template = template_economic_dispatch(network=NetworkModel(ACPPowerModel, use_slacks=false))
set_device_model!(template, Line, StaticBranchUnbounded)
set_device_model!(template, TapTransformer, StaticBranchUnbounded)
set_device_model!(template, MonitoredLine, StaticBranch)
set_device_model!(template, ThermalStandard, ThermalStandardDispatch)
# set_device_model!(template, ThermalStandard, ThermalBasicDispatch)
set_device_model!(template, RenewableDispatch, RenewableFullDispatch)
set_device_model!(template, PowerLoad, StaticPowerLoad)
return template
end
sys = build_system(PSISystems, "5_bus_matpower_RT")
solver_ED = optimizer_with_attributes(Ipopt.Optimizer,)
horizon_RT = Dates.Hour(1)
interval_RT = Dates.Hour(1)
template_rt = configure_ED_template(sys, horizon_RT, interval_RT)
models = SimulationModels(
decision_models=[
DecisionModel(
template_rt,
sys,
name="RT",
optimizer=solver_ED,
optimizer_solve_log_print=true,
system_to_file=false,
initialize_model=false,
check_numerical_bounds=false,
calculate_conflict=true,
store_variable_names=true,
warm_start=true,
),
]
)
sequence = SimulationSequence(
models=models,
feedforwards=Dict(),
ini_cond_chronology = InterProblemChronology(),
)
steps = 24
sim = Simulation(
name="test",
steps=steps,
models=models,
sequence=sequence,
simulation_folder="sim",
# initial_time=DateTime("2017-01-01T18:00:00"),
)
build!(sim,
console_level=Logging.Info,
file_level=Logging.Debug,
recorders=[:simulation],
)
execute!(sim, enable_progress_bar=false) # Execute the simulation
results = SimulationResults(sim);
ed_results = get_decision_problem_results(results, "RT")
Expected behavior
The economic dispatch problem should solve as expected without the bug. However, under the current implementation, one gets the following error:
┌ Error: simulation failed
│ exception =
│ KeyError: key InfrastructureSystems.Optimization.VariableKey{OnVariable, ThermalStandard}("") not found
│ Stacktrace:
│ [1] getindex
│ @ ./dict.jl:477 [inlined]
│ [2] get_dataset
│ @ ~/.julia/packages/PowerSimulations/qdSY6/src/core/dataset_container.jl:78 [inlined]
│ [3] get_dataset_values
│ @ ~/.julia/packages/PowerSimulations/qdSY6/src/core/dataset_container.jl:137 [inlined]
│ [4] get_system_state_value(state::PowerSimulations.SimulationState, key::InfrastructureSystems.Optimization.VariableKey{OnVariable, ThermalStandard})
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/simulation_state.jl:323
│ [5] get_system_state_value(state::PowerSimulations.SimulationState, ::OnVariable, ::Type{ThermalStandard})
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/simulation_state.jl:426
│ [6] update_initial_conditions!(ics::Vector{InitialCondition{DevicePower, JuMP.VariableRef}}, state::PowerSimulations.SimulationState, ::Millisecond)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/initial_condition_update_simulation.jl:74
│ [7] _update_initial_conditions!(model::DecisionModel{GenericOpProblem}, key::InfrastructureSystems.Optimization.InitialConditionKey{DevicePower, ThermalStandard}, source::PowerSimulations.SimulationState)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/initial_conditions/update_initial_conditions.jl:16
│ [8] update_initial_conditions!(model::DecisionModel{GenericOpProblem}, key::InfrastructureSystems.Optimization.InitialConditionKey{DevicePower, ThermalStandard}, source::PowerSimulations.SimulationState)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/initial_conditions/update_initial_conditions.jl:34
│ [9] update_initial_conditions!(model::DecisionModel{GenericOpProblem}, state::PowerSimulations.SimulationState, ::InterProblemChronology)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/initial_condition_update_simulation.jl:7
│ [10] macro expansion
│ @ ~/.julia/packages/PowerSimulations/qdSY6/src/operation/operation_model_interface.jl:440 [inlined]
│ [11] macro expansion
│ @ ~/.julia/packages/TimerOutputs/NRdsv/src/TimerOutput.jl:237 [inlined]
│ [12] update_model!(model::DecisionModel{GenericOpProblem}, source::PowerSimulations.SimulationState, ini_cond_chronology::InterProblemChronology)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/operation/operation_model_interface.jl:439
│ [13] update_model!(model::DecisionModel{GenericOpProblem}, sim::Simulation)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/simulation.jl:896
│ [14] macro expansion
│ @ ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/simulation.jl:995 [inlined]
│ [15] macro expansion
│ @ ~/.julia/packages/TimerOutputs/NRdsv/src/TimerOutput.jl:237 [inlined]
│ [16] macro expansion
│ @ ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/simulation.jl:994 [inlined]
│ [17] macro expansion
│ @ ~/.julia/packages/TimerOutputs/NRdsv/src/TimerOutput.jl:237 [inlined]
│ [18] _execute!(sim::Simulation; cache_size_mib::Int64, min_cache_flush_size_mib::Int64, exports::Nothing, enable_progress_bar::Bool, disable_timer_outputs::Bool, results_channel::Nothing)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/simulation.jl:987
│ [19] macro expansion
│ @ ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/simulation.jl:1086 [inlined]
│ [20] macro expansion
│ @ ~/.julia/packages/TimerOutputs/NRdsv/src/TimerOutput.jl:237 [inlined]
│ [21] (::PowerSimulations.var"#418#422"{@Kwargs{enable_progress_bar::Bool}, Simulation})(store::PowerSimulations.HdfSimulationStore)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/simulation.jl:1085
│ [22] open_store(func::PowerSimulations.var"#418#422"{@Kwargs{enable_progress_bar::Bool}, Simulation}, ::Type{PowerSimulations.HdfSimulationStore}, directory::String, mode::String; filename::String)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/hdf_simulation_store.jl:108
│ [23] open_store
│ @ ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/hdf_simulation_store.jl:98 [inlined]
│ [24] (::PowerSimulations.var"#417#421"{@Kwargs{enable_progress_bar::Bool}, Simulation, DataType})()
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/simulation.jl:1081
│ [25] with_logstate(f::PowerSimulations.var"#417#421"{@Kwargs{enable_progress_bar::Bool}, Simulation, DataType}, logstate::Base.CoreLogging.LogState)
│ @ Base.CoreLogging ./logging/logging.jl:522
│ [26] with_logger
│ @ ./logging/logging.jl:632 [inlined]
│ [27] execute!(sim::Simulation; kwargs::@Kwargs{enable_progress_bar::Bool})
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/simulation.jl:1080
│ [28] top-level scope
│ @ ~/UserApps/GMI-CASCADE/gmi-cascde/pcm/example.jl:93
│ [29] include(mod::Module, _path::String)
│ @ Base ./Base.jl:557
│ [30] exec_options(opts::Base.JLOptions)
│ @ Base ./client.jl:323
│ [31] _start()
│ @ Base ./client.jl:531
└ @ PowerSimulations ~/.julia/packages/PowerSimulations/qdSY6/src/simulation/simulation.jl:1097
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.