Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix for correct tracking of current investment stage by SDDP #530

Merged
merged 1 commit into from
Aug 21, 2023

Conversation

filippopecci
Copy link
Collaborator

The value of mysetup["CurrStage"] is modified in run_genx_case_multistage! inside a for loop. The dictionary mysetup is then passed to function run_ddp as setup_d and the current stage value is used by function initialize_cost_to_go but it is not updated to match the current stage, and left set to the last stage as done by parent function run_genx_case_multistage!.

This commit fixes that and set the right current stage in setup_d before initializing the cost-to-go.

…rogramming.jl. This value is modified in case_runners.jl and left set to the last stage
Copy link
Collaborator

@gmantegna gmantegna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@gmantegna gmantegna merged commit d51683a into develop Aug 21, 2023
@RuaridhMacd
Copy link
Collaborator

Just for future reference, the bug was caused by the following:

  1. In run_genx_case_multistage! the code looks over time steps t in 1:mysetup["MultiStageSettingsDict"]["NumStages"] to create the different models and inputs and store them in a dictionary.
  2. In doing so, it sets mysetup["MultiStageSettingsDict"]["CurStage"] = t to pass t to generate_mode
  3. That means t = mysetup["MultiStageSettingsDict"]["NumStages"] at this point.
  4. run_genx_case_multistage! then calls run_ddp on the dicts of models and inputs but a shared setup dictionary
  5. run_ddp then loops over the stages using t again, calling initialize_cost_to_go(shared_settings, model[t], inputs[t] for each time step t.
  6. To calculate the discount factor, initialize_cost_to_go defines the time (aka cur_stage) as cur_stage = settings_d["CurStage"], which is the total number of stages, based on steps 1 -> 3

@RuaridhMacd RuaridhMacd deleted the sddp-CurStage-BugFix branch August 23, 2023 13:47
lbonaldo pushed a commit to lbonaldo/GenX that referenced this pull request Oct 12, 2023
…rogramming.jl(GenXProject#530)

The current stage value is currently modified in case_runners.jl and erroneously left set to the last stage.
@filippopecci filippopecci restored the sddp-CurStage-BugFix branch February 14, 2024 20:00
@filippopecci filippopecci deleted the sddp-CurStage-BugFix branch February 14, 2024 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants