diff --git a/docs/src/get_test_data.jl b/docs/src/get_test_data.jl index 2c99e65808..a664aa53dc 100644 --- a/docs/src/get_test_data.jl +++ b/docs/src/get_test_data.jl @@ -38,4 +38,3 @@ set_services_template!( ) op_results = solve!(operation_problem) -re_results = PSI.run_economic_dispatch(system; optimizer = solver, use_parameters = true) diff --git a/src/PowerSimulations.jl b/src/PowerSimulations.jl index 7dca8191ef..73cc11e950 100644 --- a/src/PowerSimulations.jl +++ b/src/PowerSimulations.jl @@ -117,8 +117,6 @@ export template_agc_reserve_deployment export EconomicDispatchProblem export UnitCommitmentProblem export AGCReserveDeployment -export run_economic_dispatch -export run_unit_commitment export set_device_model! export set_service_model! export set_network_model! @@ -548,9 +546,6 @@ include("network_models/network_constructor.jl") # Templates for Operation Problems include("operation/operation_problem_templates.jl") -# Operations Decision Problems -include("operation/decision_problems.jl") - # Utils include("utils/printing.jl") include("utils/file_utils.jl") @@ -562,12 +557,4 @@ include("utils/recorder_events.jl") include("utils/datetime_utils.jl") include("utils/generate_valid_formulations.jl") -# TODO: These exist for backward compatibility and need to be deprecated and removed. -read_aux_variables_with_keys(args...; kwargs...) = - read_results_with_keys(args...; kwargs...) -read_duals_with_keys(args...; kwargs...) = read_results_with_keys(args...; kwargs...) -read_expressions_with_keys(args...; kwargs...) = read_results_with_keys(args...; kwargs...) -read_parameters_with_keys(args...; kwargs...) = read_results_with_keys(args...; kwargs...) -read_variables_with_keys(args...; kwargs...) = read_results_with_keys(args...; kwargs...) - end diff --git a/src/operation/decision_problems.jl b/src/operation/decision_problems.jl deleted file mode 100644 index 4b758c08de..0000000000 --- a/src/operation/decision_problems.jl +++ /dev/null @@ -1,152 +0,0 @@ -_TEMPLATE_KWARGS = [:network, :devices, :services] - -function _filter_kwargs(kwargs) - template_kwargs = Dict(kwargs) - build_kwargs = Dict() - for kw in setdiff(keys(template_kwargs), _TEMPLATE_KWARGS) - build_kwargs[kw] = pop!(template_kwargs, kw) - end - return template_kwargs, build_kwargs -end - -""" - EconomicDispatchProblem(system::PSY.System; kwargs...) - -Creates a `ProblemTemplate` with default DeviceModels for an EconomicDispatch -problem. Uses the template to create an `DecisionProblem`. - -# Example - -ed_problem = EconomicDispatchProblem(system) - -``` - -# Accepted Key Words -- `network::Type{<:PM.AbstractPowerModel}` : override default network model settings -- `devices::Dict{String, DeviceModel}` : override default `DeviceModel` settings -- `services::Dict{String, ServiceModel}` : override default `ServiceModel` settings -- Key word arguments supported by `DecisionProblem` -``` -""" -function EconomicDispatchProblem(system::PSY.System; kwargs...) - kwargs, problem_kwargs = _filter_kwargs(kwargs) - output_dir = pop!(problem_kwargs, :output_dir) - template = template_economic_dispatch(; kwargs...) - model = DecisionModel(EconomicDispatchProblem, template, system; problem_kwargs...) - res = build!(model; output_dir = output_dir) - if res != BuildStatus.BUILT - error("The EconomicDispatch problem didn't build successfully") - end - return model -end - -""" - UnitCommitmentProblem(system::PSY.System; kwargs...) - -Creates a `ProblemTemplate` with default DeviceModels for a Unit Commitment -problem. Uses the template to create an `DecisionProblem`. - -# Example - -uc_problem = UnitCommitmentProblem(system) - -``` - -# Accepted Key Words -- `network::Type{<:PM.AbstractPowerModel}` : override default network model settings -- `devices::Dict{String, DeviceModel}` : override default `DeviceModel` settings -- `services::Dict{String, ServiceModel}` : override default `ServiceModel` settings -- Key word arguments supported by `DecisionProblem` -``` -""" -function UnitCommitmentProblem(system::PSY.System; kwargs...) - kwargs, problem_kwargs = _filter_kwargs(kwargs) - output_dir = pop!(problem_kwargs, :output_dir) - template = template_unit_commitment(; kwargs...) - model = DecisionModel(UnitCommitmentProblem, template, system; problem_kwargs...) - res = build!(model; output_dir = output_dir) - if res != BuildStatus.BUILT - error("The EconomicDispatch problem didn't build successfully") - end - return model -end - -""" - AGCReserveDeployment(system::PSY.System; kwargs...) - -Creates a `ProblemTemplate` with default DeviceModels for an AGC Reserve Deployment Problem. -Uses the template to create an `DecisionProblem`. - -# Example - -agc_problem = AGCReserveDeployment(system) - -``` - -# Accepted Key Words -- Key word arguments supported by `DecisionProblem` -``` -""" -function AGCReserveDeployment(system::PSY.System; kwargs...) - kwargs, problem_kwargs = _filter_kwargs(kwargs) - output_dir = pop!(problem_kwargs, :output_dir) - template = template_agc_reserve_deployment(; kwargs...) - model = DecisionModel(UnitCommitmentProblem, template, system; problem_kwargs...) - res = build!(model; output_dir = output_dir) - if res != BuildStatus.BUILT - error("The EconomicDispatch problem didn't build successfully") - end - return model -end - -""" - run_unit_commitment(system::PSY.System; kwargs...) - -Creates a `ProblemTemplate` with default DeviceModels for a Unit Commitment -problem. Uses the template to create an `DecisionProblem`. Solves the created operations problem. - -# Example -results = run_unit_commitment(system; optimizer = optimizer) -``` - -# Accepted Key Words -- `network::Type{<:PM.AbstractPowerModel}` : override default network model settings -- `devices::Dict{String, DeviceModel}` : override default `DeviceModel` settings -- `services::Dict{String, ServiceModel}` : override default `ServiceModel` settings -- `optimizer::JuMP Optimizer` : An optimizer is a required key word -- `output_dir::AbstractString` : Path to save outputs -- Key word arguments supported by `DecisionProblem` -""" - -function run_unit_commitment(sys::PSY.System; kwargs...) - model = UnitCommitmentProblem(sys; kwargs...) - solve_status = solve!(model) - return solve_status -end - -""" - run_economic_dispatch(system::PSY.System; kwargs...) - -Creates a `ProblemTemplate` with default DeviceModels for an EconomicDispatch -problem. Uses the template to create an `DecisionProblem`. - -# Example - -results = run_economic_dispatch(system; optimizer = optimizer) - -``` - -# Accepted Key Words -- `network::Type{<:PM.AbstractPowerModel}` : override default network model settings -- `devices::Dict{String, DeviceModel}` : override default `DeviceModel` settings -- `services::Dict{String, ServiceModel}` : override default `ServiceModel` settings -- `optimizer::JuMP optimizer` : a JuMP optimizer is a required key word -- `output_dir::AbstractString` : Path to save outputs -- Key word arguments supported by `DecisionProblem` -``` -""" -function run_economic_dispatch(sys::PSY.System; kwargs...) - model = EconomicDispatchProblem(sys; kwargs...) - solve_status = solve!(model) - return solve_status -end diff --git a/test/test_model_decision.jl b/test/test_model_decision.jl index 5b9b91a7f8..1b5361c5c1 100644 --- a/test/test_model_decision.jl +++ b/test/test_model_decision.jl @@ -134,26 +134,6 @@ end end end -@testset "Default Decisions Constructors" begin - c_sys5 = PSB.build_system(PSITestSystems, "c_sys5") - model_ed = - EconomicDispatchProblem( - c_sys5; - output_dir = mktempdir(), - optimizer = HiGHS_optimizer, - ) - moi_tests(model_ed, 120, 0, 120, 120, 24, false) - model_uc = - UnitCommitmentProblem(c_sys5; output_dir = mktempdir(), optimizer = HiGHS_optimizer) - moi_tests(model_uc, 480, 0, 240, 120, 144, true) - ED_output = - run_economic_dispatch(c_sys5; output_dir = mktempdir(), optimizer = HiGHS_optimizer) - UC_output = - run_unit_commitment(c_sys5; output_dir = mktempdir(), optimizer = HiGHS_optimizer) - @test ED_output == RunStatus.SUCCESSFUL - @test UC_output == RunStatus.SUCCESSFUL -end - @testset "Test Locational Marginal Prices between DC lossless with PowerModels vs PTDFPowerModel" begin networks = [DCPPowerModel, PTDFPowerModel] sys = PSB.build_system(PSITestSystems, "c_sys5")