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

Write subproblem directory if 1 subproblem w stages #872

Merged
merged 1 commit into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion gridpath/auxiliary/scenario_chars.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def get_subproblem_structure_from_disk(scenario_directory):
# If we have subproblems, check for stage subdirectories for each
# subproblem directory
if subproblem_directories:
all_subproblems = subproblem_directories
for subproblem in subproblem_directories:
subproblem_dir = os.path.join(scenario_directory, str(subproblem))
# Convert to integers
Expand Down
6 changes: 5 additions & 1 deletion gridpath/get_scenario_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
def write_model_inputs(
scenario_directory,
subproblem_structure,
multi_stage,
modules_to_use,
scenario_id,
subscenarios,
Expand Down Expand Up @@ -81,7 +82,9 @@ def write_model_inputs(
delete_prior_aux_files(scenario_directory=scenario_directory)

# Determine whether we will have subproblem directories
if len(subproblem_structure.SUBPROBLEM_STAGES) == 1:
# We write the subproblem directories if we have multiple subproblems or if we
# have a single subroblem with stages (the multi_stage flag will be True)
if len(subproblem_structure.SUBPROBLEM_STAGES) == 1 and multi_stage is False:
make_subproblem_directories = False
else:
make_subproblem_directories = True
Expand Down Expand Up @@ -495,6 +498,7 @@ def main(args=None):
write_model_inputs(
scenario_directory=scenario_directory,
subproblem_structure=subproblem_structure,
multi_stage=stages_flag,
modules_to_use=modules_to_use,
scenario_id=scenario_id,
subscenarios=subscenarios,
Expand Down
12 changes: 9 additions & 3 deletions gridpath/run_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,15 @@ def run_optimization_for_subproblem(
Check if there are stages in the subproblem; if not solve subproblem;
if, yes, solve each stage sequentially
"""
# If we only have a single subproblem, set the subproblem_string to an
# empty string (no directory created)
if list(subproblem_structure.SUBPROBLEM_STAGES.keys()) == [1]:

# If we only have a single subproblem AND it does not have stages, set the
# subproblem_string to an empty string (the subproblem directory should not
# have been created)
# If we have multiple subproblems or a single subproblems with stages,
# we're expecting a subproblem directory
if list(subproblem_structure.SUBPROBLEM_STAGES.keys()) == [
1
] and subproblem_structure.SUBPROBLEM_STAGES[subproblem] == [1]:
subproblem_directory = ""
else:
subproblem_directory = str(subproblem)
Expand Down