diff --git a/CHANGELOG.md b/CHANGELOG.md index a76936d3d0..f294264815 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add workflow that ensures that CHANGELOG.md and the version number are updated (#711) - Print GenX version at startup and export it to disk (#712) - Added the option to output results with time series reconstructed for the entire year (#700) +- Added default settings in multitage optimization (#703) ## [0.4.0] - 2024-03-18 diff --git a/Project.toml b/Project.toml index 4c90dc1973..f3379c115c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "GenX" uuid = "5d317b1e-30ec-4ed6-a8ce-8d2d88d7cfac" authors = ["Bonaldo, Luca", "Chakrabarti, Sambuddha", "Cheng, Fangwei", "Ding, Yifu", "Jenkins, Jesse D.", "Luo, Qian", "Macdonald, Ruaridh", "Mallapragada, Dharik", "Manocha, Aneesha", "Mantegna, Gabe ", "Morris, Jack", "Patankar, Neha", "Pecci, Filippo", "Schwartz, Aaron", "Schwartz, Jacob", "Schivley, Greg", "Sepulveda, Nestor", "Xu, Qingyu", "Zhou, Justin"] -version = "0.4.0-dev.7" +version = "0.4.0-dev.8" [deps] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" diff --git a/docs/src/Public_API/public_api.md b/docs/src/Public_API/public_api.md index 8f4227d688..05be203ac8 100644 --- a/docs/src/Public_API/public_api.md +++ b/docs/src/Public_API/public_api.md @@ -17,6 +17,7 @@ GenX.mga ## Multi-stage specific functions ```@docs +GenX.configure_settings_multistage GenX.configure_multi_stage_inputs GenX.run_ddp GenX.write_multi_stage_outputs diff --git a/src/case_runners/case_runner.jl b/src/case_runners/case_runner.jl index 7d828d59f6..98bbacaf38 100644 --- a/src/case_runners/case_runner.jl +++ b/src/case_runners/case_runner.jl @@ -107,8 +107,8 @@ end function run_genx_case_multistage!(case::AbstractString, mysetup::Dict, optimizer::Any) settings_path = get_settings_path(case) multistage_settings = get_settings_path(case, "multi_stage_settings.yml") # Multi stage settings YAML file path - mysetup["MultiStageSettingsDict"] = YAML.load(open(multistage_settings)) - + # merge default settings with those specified in the YAML file + mysetup["MultiStageSettingsDict"] = configure_settings_multistage(multistage_settings) ### Cluster time series inputs if necessary and if specified by the user if mysetup["TimeDomainReduction"] == 1 tdr_settings = get_settings_path(case, "time_domain_reduction_settings.yml") # Multi stage settings YAML file path diff --git a/src/configure_settings/configure_settings.jl b/src/configure_settings/configure_settings.jl index dcfc13bd3c..c7663a46e1 100644 --- a/src/configure_settings/configure_settings.jl +++ b/src/configure_settings/configure_settings.jl @@ -168,3 +168,34 @@ function configure_writeoutput(output_settings_path::String, settings::Dict) end return writeoutput end + +function default_settings_multistage() + Dict{Any, Any}("NumStages" => 3, + "StageLengths" => [10, 10, 10], + "WACC" => 0.045, + "ConvergenceTolerance" => 0.01, + "Myopic" => 1) +end + +@doc raw""" + configure_settings_multistage(settings_path::String) + +Reads in the settings from the `multi_stage_settings.yml` YAML file and +merges them with the default multistage settings. It then returns the +settings dictionary. + +# Arguments +- `settings_path::String`: The path to the multistage settings YAML file. + +# Returns +- `settings::Dict`: The multistage settings dictionary. +""" +function configure_settings_multistage(settings_path::String) + println("Configuring Multistage Settings") + model_settings = isfile(settings_path) ? YAML.load(open(settings_path)) : Dict{Any, Any}() + + settings = default_settings_multistage() + merge!(settings, model_settings) + + return settings +end diff --git a/src/time_domain_reduction/precluster.jl b/src/time_domain_reduction/precluster.jl index 1d7352b8d4..7e3db51988 100644 --- a/src/time_domain_reduction/precluster.jl +++ b/src/time_domain_reduction/precluster.jl @@ -30,7 +30,7 @@ function run_timedomainreduction_multistage!(case::AbstractString) mysetup = configure_settings(genx_settings) multistage_settings = get_settings_path(case, "multi_stage_settings.yml") - mysetup["MultiStageSettingsDict"] = YAML.load(open(multistage_settings)) + mysetup["MultiStageSettingsDict"] = configure_settings_multistage(multistage_settings) tdr_settings = get_settings_path(case, "time_domain_reduction_settings.yml") TDRSettingsDict = YAML.load(open(tdr_settings))