From 1f64708b9f8c06056497f854438f272a3afa146c Mon Sep 17 00:00:00 2001 From: "christoph.von.oy" <christoph.von.oy@rwth-aachen.de> Date: Fri, 7 Jun 2024 14:03:23 +0200 Subject: [PATCH] Added capacity to connections --- topology.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/topology.py b/topology.py index 54d47e8..7b985e9 100644 --- a/topology.py +++ b/topology.py @@ -64,10 +64,11 @@ class Connector: class Connection: - def __init__(self, in_flows, out_flows, loss_factor): + def __init__(self, in_flows, out_flows, loss_factor, capacity): self.in_flows = in_flows self.out_flows = out_flows self.loss_factor = loss_factor + self.capacity = capacity # def replace_flow(self, flow, replacement): # if flow in self.in_flows: @@ -173,7 +174,13 @@ class Topology: loss_factor = connection["loss_factor"] else: loss_factor = 0.0 - self._connections.append(Connection(in_flows, out_flows, loss_factor)) + if "capacity" in connection: + capacity = connection["capacity"] + else: + capacity = None + self._connections.append( + Connection(in_flows, out_flows, loss_factor, capacity) + ) # self._removed_flows = dict() @@ -418,6 +425,20 @@ class Topology: o_block.add(str(i) + "_sum", pyo.Constraint(o_block.T, rule=rule)) + if connection.capacity is not None: + capacity = connection.capacity + + def rule(m, t): + return ( + pyo.quicksum( + o_block.component_dict[in_flow][t] + for in_flow in connection.in_flows + ) + <= capacity + ) + + o_block.add(str(i) + "_capacity", pyo.Constraint(o_block.T, rule=rule)) + for logic_name, logic in self._additional_model_logic.items(): if logic["type"] == "ConnectorEnable": enable = logic["enable"] -- GitLab