From 0c07cc957d9476af8ca8adac0b8fe528c814bd6e Mon Sep 17 00:00:00 2001 From: Maya Mutic Date: Mon, 22 Apr 2024 16:29:36 -0400 Subject: [PATCH 01/11] Added full time series reconstruction --- example_systems/1_three_zones/settings/genx_settings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example_systems/1_three_zones/settings/genx_settings.yml b/example_systems/1_three_zones/settings/genx_settings.yml index d48032b1d1..5c529c44cd 100644 --- a/example_systems/1_three_zones/settings/genx_settings.yml +++ b/example_systems/1_three_zones/settings/genx_settings.yml @@ -10,4 +10,4 @@ ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 2 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering TimeDomainReduction: 1 # Time domain reduce (i.e. cluster) inputs based on Demand_data.csv, Generators_variability.csv, and Fuels_data.csv; 0 = not active (use input data as provided); 0 = active (cluster input data, or use data that has already been clustered) -OutputFullTimeSeries: 1 \ No newline at end of file +OutputFullTimeSeries: 1 From 14b1567a07aa9008568f12bc514afc582fab1ea0 Mon Sep 17 00:00:00 2001 From: Maya Mutic Date: Mon, 22 Apr 2024 16:35:07 -0400 Subject: [PATCH 02/11] Added setup key --- src/write_outputs/write_outputs.jl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/write_outputs/write_outputs.jl b/src/write_outputs/write_outputs.jl index fcff73e84b..2a7375777e 100644 --- a/src/write_outputs/write_outputs.jl +++ b/src/write_outputs/write_outputs.jl @@ -512,11 +512,6 @@ function write_fulltimeseries(fullpath::AbstractString, return dfOut end -""" - write_settings_file(path, setup) - -Internal function for writing settings files -""" function write_settings_file(path, setup) YAML.write_file(joinpath(path, "run_settings.yml"), setup) end From 4a37328900a47a9a19cfa843072923e5bfe78795 Mon Sep 17 00:00:00 2001 From: Maya Mutic Date: Thu, 16 May 2024 17:03:18 -0400 Subject: [PATCH 03/11] Added configure_settings_multistage --- src/case_runners/case_runner.jl | 4 ++- .../configure_settings_multistage.jl | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/configure_settings/configure_settings_multistage.jl diff --git a/src/case_runners/case_runner.jl b/src/case_runners/case_runner.jl index 7d828d59f6..55b5c4e1f7 100644 --- a/src/case_runners/case_runner.jl +++ b/src/case_runners/case_runner.jl @@ -106,8 +106,10 @@ end function run_genx_case_multistage!(case::AbstractString, mysetup::Dict, optimizer::Any) settings_path = get_settings_path(case) + + # NEW: Call configure_settings_multistage(multistage_settings) to merge default settings with those specified in the YAML file multistage_settings = get_settings_path(case, "multi_stage_settings.yml") # Multi stage settings YAML file path - mysetup["MultiStageSettingsDict"] = YAML.load(open(multistage_settings)) + mysetup["MultiStageSettingsDict"] = configure_settings_multistage(multistage_settings) ### Cluster time series inputs if necessary and if specified by the user if mysetup["TimeDomainReduction"] == 1 diff --git a/src/configure_settings/configure_settings_multistage.jl b/src/configure_settings/configure_settings_multistage.jl new file mode 100644 index 0000000000..33c6e4cf83 --- /dev/null +++ b/src/configure_settings/configure_settings_multistage.jl @@ -0,0 +1,30 @@ +function default_settings_multistage() + Dict{Any, Any}("NumStages" => 3, + "StageLengths" => [10,10,10], + "WACC" => 0.045, + "ConvergenceTolerance" => 0.01, + "Myopic" => 0) +end + +@doc raw""" + configure_settings(settings_path::String, output_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 = YAML.load(open(settings_path)) + + settings = default_settings_multistage() + merge!(settings, model_settings) + + return settings +end From 8b80beec946bdfd0dd1bd38e3dc2756a65a28d92 Mon Sep 17 00:00:00 2001 From: Maya Mutic Date: Fri, 17 May 2024 09:54:55 -0500 Subject: [PATCH 04/11] Update --- src/case_runners/case_runner.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/case_runners/case_runner.jl b/src/case_runners/case_runner.jl index 55b5c4e1f7..d710046d78 100644 --- a/src/case_runners/case_runner.jl +++ b/src/case_runners/case_runner.jl @@ -110,7 +110,7 @@ function run_genx_case_multistage!(case::AbstractString, mysetup::Dict, optimize # NEW: Call configure_settings_multistage(multistage_settings) to merge default settings with those specified in the YAML file multistage_settings = get_settings_path(case, "multi_stage_settings.yml") # Multi stage settings YAML file path 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 From d35e4936978747ad98cd771de8039b3600407f84 Mon Sep 17 00:00:00 2001 From: Maya Mutic Date: Tue, 18 Jun 2024 13:18:53 +0200 Subject: [PATCH 05/11] Added WriteIntermittentOutputs to default MS settings: --- src/configure_settings/configure_settings_multistage.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/configure_settings/configure_settings_multistage.jl b/src/configure_settings/configure_settings_multistage.jl index 33c6e4cf83..aca95aa5de 100644 --- a/src/configure_settings/configure_settings_multistage.jl +++ b/src/configure_settings/configure_settings_multistage.jl @@ -3,7 +3,8 @@ function default_settings_multistage() "StageLengths" => [10,10,10], "WACC" => 0.045, "ConvergenceTolerance" => 0.01, - "Myopic" => 0) + "Myopic" => 0), + "WriteIntermittentOutputs" => 0 end @doc raw""" From 0a3758c7c6300fbed481040673f0d2159a554e10 Mon Sep 17 00:00:00 2001 From: lbonaldo Date: Fri, 28 Jun 2024 18:33:15 -0400 Subject: [PATCH 06/11] Fix formatting --- example_systems/1_three_zones/settings/genx_settings.yml | 2 +- src/case_runners/case_runner.jl | 4 +--- src/configure_settings/configure_settings_multistage.jl | 5 ++--- src/write_outputs/write_outputs.jl | 5 +++++ 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/example_systems/1_three_zones/settings/genx_settings.yml b/example_systems/1_three_zones/settings/genx_settings.yml index 5c529c44cd..d48032b1d1 100644 --- a/example_systems/1_three_zones/settings/genx_settings.yml +++ b/example_systems/1_three_zones/settings/genx_settings.yml @@ -10,4 +10,4 @@ ParameterScale: 1 # Turn on parameter scaling wherein demand, capacity and power WriteShadowPrices: 1 # Write shadow prices of LP or relaxed MILP; 0 = not active; 1 = active UCommit: 2 # Unit committment of thermal power plants; 0 = not active; 1 = active using integer clestering; 2 = active using linearized clustering TimeDomainReduction: 1 # Time domain reduce (i.e. cluster) inputs based on Demand_data.csv, Generators_variability.csv, and Fuels_data.csv; 0 = not active (use input data as provided); 0 = active (cluster input data, or use data that has already been clustered) -OutputFullTimeSeries: 1 +OutputFullTimeSeries: 1 \ No newline at end of file diff --git a/src/case_runners/case_runner.jl b/src/case_runners/case_runner.jl index d710046d78..98bbacaf38 100644 --- a/src/case_runners/case_runner.jl +++ b/src/case_runners/case_runner.jl @@ -106,11 +106,9 @@ end function run_genx_case_multistage!(case::AbstractString, mysetup::Dict, optimizer::Any) settings_path = get_settings_path(case) - - # NEW: Call configure_settings_multistage(multistage_settings) to merge default settings with those specified in the YAML file multistage_settings = get_settings_path(case, "multi_stage_settings.yml") # Multi stage settings YAML file path + # 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_multistage.jl b/src/configure_settings/configure_settings_multistage.jl index aca95aa5de..5a9cb091d6 100644 --- a/src/configure_settings/configure_settings_multistage.jl +++ b/src/configure_settings/configure_settings_multistage.jl @@ -1,10 +1,9 @@ function default_settings_multistage() Dict{Any, Any}("NumStages" => 3, - "StageLengths" => [10,10,10], + "StageLengths" => [10, 10, 10], "WACC" => 0.045, "ConvergenceTolerance" => 0.01, - "Myopic" => 0), - "WriteIntermittentOutputs" => 0 + "Myopic" => 0) end @doc raw""" diff --git a/src/write_outputs/write_outputs.jl b/src/write_outputs/write_outputs.jl index 2a7375777e..fcff73e84b 100644 --- a/src/write_outputs/write_outputs.jl +++ b/src/write_outputs/write_outputs.jl @@ -512,6 +512,11 @@ function write_fulltimeseries(fullpath::AbstractString, return dfOut end +""" + write_settings_file(path, setup) + +Internal function for writing settings files +""" function write_settings_file(path, setup) YAML.write_file(joinpath(path, "run_settings.yml"), setup) end From 6bf24dfc9f92cba653485628fa2e1a2cd8a65475 Mon Sep 17 00:00:00 2001 From: lbonaldo Date: Fri, 28 Jun 2024 18:51:51 -0400 Subject: [PATCH 07/11] Move config multistage to configure settings --- src/configure_settings/configure_settings.jl | 31 +++++++++++++++++++ .../configure_settings_multistage.jl | 30 ------------------ src/time_domain_reduction/precluster.jl | 2 +- 3 files changed, 32 insertions(+), 31 deletions(-) delete mode 100644 src/configure_settings/configure_settings_multistage.jl diff --git a/src/configure_settings/configure_settings.jl b/src/configure_settings/configure_settings.jl index dcfc13bd3c..bd93c78022 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(settings_path::String, output_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 = YAML.load(open(settings_path)) + + settings = default_settings_multistage() + merge!(settings, model_settings) + + return settings +end diff --git a/src/configure_settings/configure_settings_multistage.jl b/src/configure_settings/configure_settings_multistage.jl deleted file mode 100644 index 5a9cb091d6..0000000000 --- a/src/configure_settings/configure_settings_multistage.jl +++ /dev/null @@ -1,30 +0,0 @@ -function default_settings_multistage() - Dict{Any, Any}("NumStages" => 3, - "StageLengths" => [10, 10, 10], - "WACC" => 0.045, - "ConvergenceTolerance" => 0.01, - "Myopic" => 0) -end - -@doc raw""" - configure_settings(settings_path::String, output_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 = YAML.load(open(settings_path)) - - 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)) From 5e80f19130032ad7c9b498b3880215c055b4fb8a Mon Sep 17 00:00:00 2001 From: lbonaldo Date: Fri, 28 Jun 2024 19:00:10 -0400 Subject: [PATCH 08/11] Make multi_stage_settings.yml optional --- src/configure_settings/configure_settings.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/configure_settings/configure_settings.jl b/src/configure_settings/configure_settings.jl index bd93c78022..7ae9819e7a 100644 --- a/src/configure_settings/configure_settings.jl +++ b/src/configure_settings/configure_settings.jl @@ -192,7 +192,7 @@ settings dictionary. """ function configure_settings_multistage(settings_path::String) println("Configuring Multistage Settings") - model_settings = YAML.load(open(settings_path)) + model_settings = isfile(settings_path) ? YAML.load(open(settings_path)) : Dict{Any, Any}() settings = default_settings_multistage() merge!(settings, model_settings) From a572951a94dfe3972becba82a2acb23acfbd6d53 Mon Sep 17 00:00:00 2001 From: lbonaldo Date: Fri, 28 Jun 2024 19:01:57 -0400 Subject: [PATCH 09/11] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 8f486350646e022b679e3d5135c9fc54544a046b Mon Sep 17 00:00:00 2001 From: lbonaldo Date: Fri, 28 Jun 2024 19:02:27 -0400 Subject: [PATCH 10/11] Update dev branch version to 0.4.0-dev.8 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 1a9f5a62f64301229bbae3544413b2263d245c85 Mon Sep 17 00:00:00 2001 From: lbonaldo Date: Fri, 28 Jun 2024 19:06:19 -0400 Subject: [PATCH 11/11] Update docs --- docs/src/Public_API/public_api.md | 1 + src/configure_settings/configure_settings.jl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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/configure_settings/configure_settings.jl b/src/configure_settings/configure_settings.jl index 7ae9819e7a..c7663a46e1 100644 --- a/src/configure_settings/configure_settings.jl +++ b/src/configure_settings/configure_settings.jl @@ -178,7 +178,7 @@ function default_settings_multistage() end @doc raw""" - configure_settings(settings_path::String, output_settings_path::String) + 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