HVDCTwoTerminalUnbounded Bug
Describe the bug Wrong variable name in TwoTerminalUnbounded formulation
julia> build_out = build!(sim;serialize = true)
┌ Error: Failed to build UC
└ @ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/simulation/simulation.jl:344
┌ Error: Simulation build failed
│ exception =
│ UndefVarError: `model` not defined
│ Stacktrace:
│ [1] construct_device!(container::PowerSimulations.OptimizationContainer, sys::System, ::InfrastructureSystems.Optimization.ModelConstructStage, device_model::DeviceModel{TwoTerminalHVDCLine, HVDCTwoTerminalUnbounded}, ::NetworkModel{CopperPlatePowerModel})
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/devices_models/device_constructors/branch_constructor.jl:583
│ [2] build_impl!(container::PowerSimulations.OptimizationContainer, template::ProblemTemplate, sys::System)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/core/optimization_container.jl:733
│ [3] build_initial_conditions_model!(model::DecisionModel{GenericOpProblem})
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/initial_conditions/initialization.jl:92
│ [4] build_initial_conditions!(model::DecisionModel{GenericOpProblem})
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/operation/operation_model_interface.jl:183
│ [5] handle_initial_conditions!(model::DecisionModel{GenericOpProblem})
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/operation/operation_model_interface.jl:202
│ [6] build_impl!(model::DecisionModel{GenericOpProblem})
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/operation/decision_model.jl:343
│ [7] _build_single_model_for_simulation(model::DecisionModel{GenericOpProblem}, sim::Simulation, model_number::Int64)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/simulation/simulation.jl:338
│ [8] _build_decision_models!(sim::Simulation)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/simulation/simulation.jl:351
│ [9] _build!(sim::Simulation; serialize::Bool, setup_simulation_partitions::Bool, partitions::Nothing, index::Nothing)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/simulation/simulation.jl:602
│ [10] (::PowerSimulations.var"#423#424"{Nothing, Nothing, Simulation})()
│ @ PowerSimulations ./none:0
│ [11] with_logstate(f::Function, logstate::Any)
│ @ Base.CoreLogging ./logging.jl:515
│ [12] with_logger
│ @ ./logging.jl:627 [inlined]
│ [13] build!(sim::Simulation; recorders::Vector{Any}, console_level::Base.CoreLogging.LogLevel, file_level::Base.CoreLogging.LogLevel, serialize::Bool, partitions::Nothing, index::Nothing)
│ @ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/simulation/simulation.jl:698
│ [14] top-level scope
│ @ REPL[32]:1
│ [15] eval
│ @ ./boot.jl:385 [inlined]
│ [16] eval_user_input(ast::Any, backend::REPL.REPLBackend, mod::Module)
│ @ REPL ~/Downloads/julia-1.10.2/share/julia/stdlib/v1.10/REPL/src/REPL.jl:150
│ [17] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
│ @ REPL ~/Downloads/julia-1.10.2/share/julia/stdlib/v1.10/REPL/src/REPL.jl:246
│ [18] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
│ @ REPL ~/Downloads/julia-1.10.2/share/julia/stdlib/v1.10/REPL/src/REPL.jl:231
│ [19] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
│ @ REPL ~/Downloads/julia-1.10.2/share/julia/stdlib/v1.10/REPL/src/REPL.jl:389
│ [20] run_repl(repl::REPL.AbstractREPL, consumer::Any)
│ @ REPL ~/Downloads/julia-1.10.2/share/julia/stdlib/v1.10/REPL/src/REPL.jl:375
│ [21] (::Base.var"#1013#1015"{Bool, Bool, Bool})(REPL::Module)
│ @ Base ./client.jl:432
│ [22] #invokelatest#2
│ @ ./essentials.jl:892 [inlined]
│ [23] invokelatest
│ @ ./essentials.jl:889 [inlined]
│ [24] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
│ @ Base ./client.jl:416
│ [25] exec_options(opts::Base.JLOptions)
│ @ Base ./client.jl:333
│ [26] _start()
│ @ Base ./client.jl:552
└ @ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/simulation/simulation.jl:725
ERROR: UndefVarError: `model` not defined
Stacktrace:
[1] construct_device!(container::PowerSimulations.OptimizationContainer, sys::System, ::InfrastructureSystems.Optimization.ModelConstructStage, device_model::DeviceModel{…}, ::NetworkModel{…})
@ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/devices_models/device_constructors/branch_constructor.jl:583
[2] build_impl!(container::PowerSimulations.OptimizationContainer, template::ProblemTemplate, sys::System)
@ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/core/optimization_container.jl:733
[3] build_initial_conditions_model!(model::DecisionModel{GenericOpProblem})
@ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/initial_conditions/initialization.jl:92
[4] build_initial_conditions!(model::DecisionModel{GenericOpProblem})
@ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/operation/operation_model_interface.jl:183
[5] handle_initial_conditions!(model::DecisionModel{GenericOpProblem})
@ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/operation/operation_model_interface.jl:202
[6] build_impl!(model::DecisionModel{GenericOpProblem})
@ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/operation/decision_model.jl:343
[7] _build_single_model_for_simulation(model::DecisionModel{GenericOpProblem}, sim::Simulation, model_number::Int64)
@ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/simulation/simulation.jl:338
[8] _build_decision_models!(sim::Simulation)
@ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/simulation/simulation.jl:351
[9] _build!(sim::Simulation; serialize::Bool, setup_simulation_partitions::Bool, partitions::Nothing, index::Nothing)
@ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/simulation/simulation.jl:602
[10] (::PowerSimulations.var"#423#424"{Nothing, Nothing, Simulation})()
@ PowerSimulations ./none:0
[11] with_logstate(f::Function, logstate::Any)
@ Base.CoreLogging ./logging.jl:515
[12] with_logger
@ ./logging.jl:627 [inlined]
[13] build!(sim::Simulation; recorders::Vector{…}, console_level::Base.CoreLogging.LogLevel, file_level::Base.CoreLogging.LogLevel, serialize::Bool, partitions::Nothing, index::Nothing)
@ PowerSimulations ~/.julia/packages/PowerSimulations/cYxdM/src/simulation/simulation.jl:698
[14] top-level scope
@ REPL[32]:1
Some type information was truncated. Use `show(err)` to see complete types.
To Reproduce
Build RTS-GMLC System using PSB
rts_da_sys = build_system(PSISystems, "modified_RTS_GMLC_DA_sys");
Operation Simulations/ System Scheduling
Single-Stage
Template
Solver - HiGHS
solver = optimizer_with_attributes(HiGHS.Optimizer, "time_limit"=>25000.0, "mip_abs_gap"=>1e-5, "log_to_console" => true) horizon = Hour(48) # The time horizon of the uc problem is 24 hours
build UC model
initial_time = DateTime("2020-01-01"); template = ProblemTemplate();
Network Models
set_network_model!( template, NetworkModel(CopperPlatePowerModel, duals = [CopperPlateBalanceConstraint], use_slacks = true), )
AC Branch Models
set_device_model!(template, Line, StaticBranchUnbounded) set_device_model!(template, Transformer2W, StaticBranchUnbounded) set_device_model!(template, TapTransformer, StaticBranchUnbounded) set_device_model!(template, TwoTerminalHVDCLine, HVDCTwoTerminalUnbounded)
ThermalGen
set_device_model!(template, ThermalStandard, ThermalStandardUnitCommitment)
RenewableGen
set_device_model!(template, RenewableDispatch, RenewableFullDispatch) set_device_model!(template, RenewableNonDispatch, FixedOutput)
Loads
set_device_model!(template, PowerLoad, StaticPowerLoad)
Reserves
set_service_model!(template, VariableReserve{ReserveUp}, RangeReserve) set_service_model!(template, VariableReserve{ReserveDown}, RangeReserve)
HydroGen
set_device_model!(template, HydroDispatch, HydroDispatchRunOfRiver)
Setting up the simulation
With Initialization
op_problem = DecisionModel(template, rts_da_sys; name = "UC", optimizer = solver, horizon = horizon, initial_time = initial_time, store_variable_names = true, optimizer_solve_log_print=true, initialize_model=true)
models = SimulationModels(decision_models = [op_problem],) sequence = SimulationSequence(models = models,)
sim = Simulation( name = "test", steps = 2, models = models, sequence = sequence, initial_time = initial_time, simulation_folder = ".", ) build_out = build!(sim;serialize = true)
Expected behavior Expect Unbounded formulation to work with TwoTerminalHVDC
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
@scdhulipala you can try jd/hvdc_area_fix branch