From 25fa57dad9e21aee9c8422c5ee0ac760e2ff3b99 Mon Sep 17 00:00:00 2001 From: imcovangent <I.vanGent@tudelft.nl> Date: Thu, 9 Aug 2018 13:50:26 +0200 Subject: [PATCH] Bug fix in CO concerning mathematical function edges. Former-commit-id: c3b3af90f7142c0a3469ab7f95e2e9252f1fb11d --- kadmos/graph/graph_data.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/kadmos/graph/graph_data.py b/kadmos/graph/graph_data.py index f7dce1f8f..67980dd70 100644 --- a/kadmos/graph/graph_data.py +++ b/kadmos/graph/graph_data.py @@ -5363,11 +5363,11 @@ class MdaoDataGraph(DataGraph, MdaoMixin): mapping[global_des_var] = local_des_var_copy for target in local_targets: + # Connect the local copy to the targets + self.copy_edge((global_des_var, target), (local_des_var_copy, target)) + # Remove the connection between the global design variable and the target self.remove_edge(global_des_var, target) - - # Connect the local copy to the targets - self.add_edge(local_des_var_copy, target) # The local design variables get copies at the global level and are connected accordingly for local_des_var in local_des_vars: # Find the functions outside the local level for which the design variable is input @@ -5383,12 +5383,11 @@ class MdaoDataGraph(DataGraph, MdaoMixin): mapping[local_des_var] = global_des_var_copy for target in external_targets: - # Remove the connection between the local design variable and the external target - self.remove_edge(local_des_var, target) - # Connect the global copy to the targets - self.add_edge(global_des_var_copy, target) + self.copy_edge((local_des_var, target), (global_des_var_copy, target)) + # Remove the connection between the local design variable and the external target + self.remove_edge(local_des_var, target) return local_des_var_copies, global_des_var_copies, mapping def localize_group_couplings(self, group_functions, external_couplings, local_couplings, @@ -5430,11 +5429,12 @@ class MdaoDataGraph(DataGraph, MdaoMixin): external_couplings_copies.append(external_coupling_copy) for target in local_targets: + # Connect the local copy to the targets + self.copy_edge((external_coupling, target), (external_coupling_copy, target)) + # Remove the connection between the global coupling variable and the target self.remove_edge(external_coupling, target) - # Connect the local copy to the targets - self.add_edge(external_coupling_copy, target) # Local couplings should only be handled by the functions inside the group, outside, they are handled by copies for local_coupling in local_couplings: # Find the external functions for which the coupling variable is input @@ -5459,12 +5459,11 @@ class MdaoDataGraph(DataGraph, MdaoMixin): mapping_locals[local_coupling] = local_coupling_copy for target in external_targets: - # Remove the connection between the local coupling variable and the target - self.remove_edge(local_coupling, target) - # Connect the local copy to the targets - self.add_edge(local_coupling_copy, target) + self.copy_edge((local_coupling, target), (local_coupling_copy, target)) + # Remove the connection between the local coupling variable and the target + self.remove_edge(local_coupling, target) return external_couplings_copies, local_couplings_copies, mapping_locals def connect_nodes_as_output(self, nodes, function): @@ -5479,7 +5478,6 @@ class MdaoDataGraph(DataGraph, MdaoMixin): for node in nodes: assert self.has_node(node) self.add_edge(function, node) - return def connect_coordinator(self, additional_inputs=[], additional_outputs=[]): -- GitLab