using SIIPExamples using PowerSystems using PowerSimulations using PowerSystemCaseBuilder using Dates sim_folder = mktempdir(".", cleanup = true) sys = build_system(PSITestSystems, "modified_RTS_GMLC_DA_sys") transform_single_time_series!(sys, 1, Hour(1)) using Ipopt solver = optimizer_with_attributes(Ipopt.Optimizer) using HiGHS # mip solver uc_solver = optimizer_with_attributes(HiGHS.Optimizer, "mip_rel_gap" => 0.5) print_tree(PowerSimulations.PM.AbstractPowerModel) ed_template = ProblemTemplate() set_device_model!(ed_template, ThermalStandard, ThermalStandardDispatch) set_device_model!(ed_template, PowerLoad, StaticPowerLoad) set_device_model!(ed_template, Line, StaticBranch) set_device_model!(ed_template, TapTransformer, StaticBranch) set_device_model!(ed_template, Transformer2W, StaticBranch) set_device_model!(ed_template, HVDCLine, HVDCDispatch) set_network_model!(ed_template, NetworkModel(ACPPowerModel, use_slacks = true)) uc_template = ProblemTemplate(DCPPowerModel) set_device_model!(uc_template, ThermalStandard, ThermalBasicUnitCommitment) set_device_model!(uc_template, PowerLoad, StaticPowerLoad) set_device_model!(uc_template, Line, StaticBranch) set_device_model!(uc_template, TapTransformer, StaticBranch) set_device_model!(uc_template, Transformer2W, StaticBranch) set_device_model!(uc_template, HVDCLine, HVDCDispatch) set_service_model!(uc_template, VariableReserve{ReserveUp}, RangeReserve) models = SimulationModels( decision_models = [ DecisionModel(uc_template, sys, name = "UC", optimizer = uc_solver), DecisionModel( ed_template, sys, name = "ACOPF", optimizer = solver, initialize_model = false, ), ], ) sequence = SimulationSequence( models = models, feedforwards = Dict( "ACOPF" => [ SemiContinuousFeedforward( component_type = ThermalStandard, source = OnVariable, affected_values = [ActivePowerVariable, ReactivePowerVariable], ), ], ), ini_cond_chronology = InterProblemChronology(), ) sim = Simulation( name = "UC-ACOPF", steps = 12, models = models, sequence = sequence, simulation_folder = sim_folder, ) build!(sim) execute!(sim, enable_progress_bar = false) results = SimulationResults(sim) ac_results = get_problem_results(results, "ACOPF") slack_keys = [ k for k in list_variable_keys(ac_results) if PSI.get_entry_type(k) ∈ [SystemBalanceSlackDown, SystemBalanceSlackUp] ] slack_vars = read_realized_variables(ac_results, slack_keys) plot_results(slack_vars);