diff --git a/src/andromede/simulation/benders_decomposed.py b/src/andromede/simulation/benders_decomposed.py index eb52cf26..e94d968e 100644 --- a/src/andromede/simulation/benders_decomposed.py +++ b/src/andromede/simulation/benders_decomposed.py @@ -37,7 +37,7 @@ InvestmentProblemStrategy, OperationalProblemStrategy, ) -from andromede.simulation.time_block import ConfiguredTree, TimeBlock +from andromede.simulation.time_block import TimeBlock from andromede.study.data import DataBase from andromede.study.network import Network from andromede.utils import read_json, serialize, serialize_json @@ -228,7 +228,6 @@ def build_benders_decomposed_problem( master = build_problem( master_network, database, - configured_tree.root, # Could be any node, given the implmentation of get_nodes() null_time_block := TimeBlock( # Not necessary for master, but list must be non-empty 0, [0] ), diff --git a/tests/integration/test_benders_decomposed.py b/tests/integration/test_benders_decomposed.py index 38cc06b0..a6011161 100644 --- a/tests/integration/test_benders_decomposed.py +++ b/tests/integration/test_benders_decomposed.py @@ -19,8 +19,7 @@ CONSTANT, DEMAND_MODEL, GENERATOR_MODEL, - NODE_BALANCE_MODEL, - NODE_WITH_SPILL_AND_ENS_MODEL, + NODE_WITH_SPILL_AND_ENS, ) from andromede.model import ( Constraint, @@ -38,6 +37,10 @@ TimeBlock, build_benders_decomposed_problem, ) +from andromede.simulation.decision_tree import ( + create_network_on_tree, + create_single_node_decision_tree, +) from andromede.study import ( Component, ConstantData, @@ -214,7 +217,7 @@ def test_benders_decomposed_integration( demand = create_component(model=DEMAND_MODEL, id="D") - node = Node(model=NODE_WITH_SPILL_AND_ENS_MODEL, id="N") + node = Node(model=NODE_WITH_SPILL_AND_ENS, id="N") network = Network("test") network.add_node(node) network.add_component(demand) @@ -228,9 +231,13 @@ def test_benders_decomposed_integration( PortRef(cluster_candidate, "balance_port"), PortRef(node, "balance_port") ) scenarios = 1 + blocks = [TimeBlock(1, [0])] + + configured_tree = create_single_node_decision_tree(blocks, scenarios) + tree_node_to_network = create_network_on_tree(network, configured_tree.root) xpansion = build_benders_decomposed_problem( - network, database, [TimeBlock(1, [0])], scenarios + tree_node_to_network, database, configured_tree ) data = { @@ -305,7 +312,7 @@ def test_benders_decomposed_multi_time_block_single_scenario( id="D", ) - node = Node(model=NODE_WITH_SPILL_AND_ENS_MODEL, id="N") + node = Node(model=NODE_WITH_SPILL_AND_ENS, id="N") network = Network("test") network.add_node(node) network.add_component(demand) @@ -316,12 +323,13 @@ def test_benders_decomposed_multi_time_block_single_scenario( network.connect(PortRef(candidate, "balance_port"), PortRef(node, "balance_port")) scenarios = 1 + blocks = [TimeBlock(1, [0]), TimeBlock(2, [1])] + + configured_tree = create_single_node_decision_tree(blocks, scenarios) + tree_node_to_network = create_network_on_tree(network, configured_tree.root) xpansion = build_benders_decomposed_problem( - network, - database, - [TimeBlock(1, [0]), TimeBlock(2, [1])], - scenarios, + tree_node_to_network, database, configured_tree ) data = {