Skip to content

Commit

Permalink
Cherry-picked benders_decomposed debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmnz committed Jul 24, 2024
1 parent af126d1 commit adc5de4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/andromede/simulation/benders_decomposed.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ def run(
solver_name: str = "XPRESS",
log_level: int = 0,
should_merge: bool = False,
show_debug: bool = False,
) -> bool:
self.initialise(solver_name=solver_name, log_level=log_level)
self.initialise(
solver_name=solver_name, log_level=log_level, is_debug=show_debug
)

if not should_merge:
return_code = BendersRunner(self.emplacement).run()
Expand Down Expand Up @@ -250,15 +253,15 @@ def build_benders_decomposed_problem(
subproblems = [] # Benders Decomposed Sub-problems

for tree_node in decision_tree_root.traverse():
suffix = f"_{tree_node.id}" if decision_tree_root.size > 1 else ""
suffix_tree = f"_{tree_node.id}" if decision_tree_root.size > 1 else ""

masters.append(
build_problem(
tree_node.network,
database,
null_time_block,
null_scenario,
problem_name=f"master{suffix}",
problem_name=f"master{suffix_tree}",
solver_id=solver_id,
build_strategy=InvestmentProblemStrategy(),
decision_tree_node=tree_node.id,
Expand All @@ -267,16 +270,15 @@ def build_benders_decomposed_problem(
)

for block in tree_node.config.blocks:
if len(tree_node.config.blocks) > 1:
suffix += f"_t{block.id}"
suffix_block = f"_b{block.id}" if len(tree_node.config.blocks) > 1 else ""

subproblems.append(
build_problem(
tree_node.network,
database,
block,
tree_node.config.scenarios,
problem_name=f"subproblem{suffix}",
problem_name=f"subproblem{suffix_tree}{suffix_block}",
solver_id=solver_id,
build_strategy=OperationalProblemStrategy(),
decision_tree_node=tree_node.id,
Expand Down

0 comments on commit adc5de4

Please sign in to comment.