From 4a613f993791a7e4b4efcc09415eb70c19a20b3b Mon Sep 17 00:00:00 2001 From: maaikedieuwertje <maaikedieuwertje@gmail.com> Date: Fri, 9 Mar 2018 14:27:26 +0100 Subject: [PATCH] Issue #102: changed set up of relabel mapping to first checking the entire list for multiples and then add any specifics that change between them. Former-commit-id: f25d8628aed4aad9153a5a43f8a26dc4261bc8bd --- examples/scripts/ssbj/(X)DSM/RCG.pdf | Bin 35474 -> 35474 bytes examples/scripts/ssbj/CMDOWS/RCG.xml | 58 ++++++++++- .../(X)DSM/FPG_unconverged-MDA-GS.pdf | Bin 27367 -> 27367 bytes .../VISTOMS/VISTOMS.html.REMOVED.git-id | 2 +- kadmos/graph/graph_kadmos.py | 93 ++++++++++-------- 5 files changed, 111 insertions(+), 42 deletions(-) diff --git a/examples/scripts/ssbj/(X)DSM/RCG.pdf b/examples/scripts/ssbj/(X)DSM/RCG.pdf index 12d36744caf620839506cbbe65f0f09231fd7097..2d8bbc66b09626827ce5b83d4bd9152129986e26 100644 GIT binary patch delta 130 zcmbO<m1)vcrVT1>?3RWmMn(o^leODqVC>C)ZBLowElu5wEiFwA9nB4mT?`CdT+B_) x9bL^W%v_924V_#J?G$VXDv4FFv*Ri*Nh~U<C`wJ^GBz<WH|J7Sb@g}S0szmCArb%p delta 130 zcmbO<m1)vcrVT1>?8b&>Mka;^leODqVC>C)ZBLow-JD&`%*>rFO^nQ3ja>|#P0h?K xTun?}&0I~*-ApYk?G$VXDv4FFv*Ri*Nh~U<C`wJ^GBz<WH|J7Sb@g}S0s!PAA!Gmm diff --git a/examples/scripts/ssbj/CMDOWS/RCG.xml b/examples/scripts/ssbj/CMDOWS/RCG.xml index 1b9112aad..856fc8e23 100644 --- a/examples/scripts/ssbj/CMDOWS/RCG.xml +++ b/examples/scripts/ssbj/CMDOWS/RCG.xml @@ -3,14 +3,14 @@ <header> <creator>Lukas Mueller</creator> <description>RCG CMDOWS file of the super-sonic business jet test case optimization problem</description> - <timestamp>2018-03-03T16:24:07.415000</timestamp> + <timestamp>2018-03-09T14:22:04.103000</timestamp> <fileVersion>0.1</fileVersion> <cmdowsVersion>0.7</cmdowsVersion> <updates> <update> <modification>KADMOS export of a repository connectivity graph (RCG).</modification> <creator>Lukas Mueller</creator> - <timestamp>2018-03-03T16:24:07.415000</timestamp> + <timestamp>2018-03-09T14:22:04.103000</timestamp> <fileVersion>0.1</fileVersion> <cmdowsVersion>0.7</cmdowsVersion> </update> @@ -52,6 +52,60 @@ </header> <executableBlocks> <designCompetences> + <designCompetence uID="aerodynamics"> + <ID>aerodynamics</ID> + <modeID>main</modeID> + <instanceID>1</instanceID> + <version>1.0</version> + <label>aerodynamics</label> + <metadata> + <generalInfo> + <owner> + <contactUID>remilafage</contactUID> + </owner> + <description>Estimation of the aircraft lift and drag during cruise.</description> + <creator> + <contactUID>sylvaindubreuil</contactUID> + </creator> + </generalInfo> + </metadata> + </designCompetence> + <designCompetence uID="propulsion"> + <ID>propulsion</ID> + <modeID>main</modeID> + <instanceID>1</instanceID> + <version>1.0</version> + <label>propulsion</label> + <metadata> + <generalInfo> + <owner> + <contactUID>remilafage</contactUID> + </owner> + <description>Engine sizing and estimation of the engine thrust.</description> + <creator> + <contactUID>sylvaindubreuil</contactUID> + </creator> + </generalInfo> + </metadata> + </designCompetence> + <designCompetence uID="structure"> + <ID>structure</ID> + <modeID>main</modeID> + <instanceID>1</instanceID> + <version>1.0</version> + <label>structure</label> + <metadata> + <generalInfo> + <owner> + <contactUID>remilafage</contactUID> + </owner> + <description>Weight estimation of different aircraft parts.</description> + <creator> + <contactUID>sylvaindubreuil</contactUID> + </creator> + </generalInfo> + </metadata> + </designCompetence> <designCompetence uID="performance"> <ID>performance</ID> <modeID>main</modeID> diff --git a/examples/scripts/tu_delft_wing_design/(X)DSM/FPG_unconverged-MDA-GS.pdf b/examples/scripts/tu_delft_wing_design/(X)DSM/FPG_unconverged-MDA-GS.pdf index a7d8ae4dc19ec395c3187bb0132a0f203e217b4d..66774a714c7e3fda19859ebf96eea64710aab6b5 100644 GIT binary patch delta 106 zcmaEUmGSvi#tkRa*ewl>jVuh!CtpaDfw4D#PMgZ?Z0YD??qY7~;$-e-Vd89IVQ%5( a=Hh7VX6EAP=we`KW~X37NXg{WSuy|w03OBw delta 106 zcmaEUmGSvi#tkRa*o_S>jSNlACSORCfw4D#PMgZ?>}=v<YG`KRV&Z6IVQFk`Xl86| aV&dxJYG!U}Waj4TYNudBNXg{WSuz0K<{k6^ diff --git a/examples/scripts/tu_delft_wing_design/VISTOMS/VISTOMS.html.REMOVED.git-id b/examples/scripts/tu_delft_wing_design/VISTOMS/VISTOMS.html.REMOVED.git-id index 34d8e2bde..07df35e15 100644 --- a/examples/scripts/tu_delft_wing_design/VISTOMS/VISTOMS.html.REMOVED.git-id +++ b/examples/scripts/tu_delft_wing_design/VISTOMS/VISTOMS.html.REMOVED.git-id @@ -1 +1 @@ -da42e7213303c296dcf13856d6a8f07d7d74503c \ No newline at end of file +d48ef6e6cd61973c9dcd43a527959a317cd1df5f \ No newline at end of file diff --git a/kadmos/graph/graph_kadmos.py b/kadmos/graph/graph_kadmos.py index 4c53ce94a..22d0919bb 100644 --- a/kadmos/graph/graph_kadmos.py +++ b/kadmos/graph/graph_kadmos.py @@ -2897,53 +2897,68 @@ class KadmosGraph(nx.DiGraph, EquationMixin, VistomsMixin): if mapping is None: mapping = {} labels = [] - labels_set = set() + ids = [] + modes = [] + instances = [] + versions = [] + ids_set = set() + multiples = set() + ids_dict = {} + for design_competence in design_competences: id = self.node[design_competence].get('name', design_competence) mode = self.node[design_competence].get('mode', 'main') instance = self.node[design_competence].get('instance', '1') version = self.node[design_competence].get('version', '1.0') - labels_set.add(id) - - level = 0 - while len(labels)+1 != len(labels_set) and level<4: - level +=1 - if level==1: - labels_set.remove(id) - labels_set.add([id,mode]) - for label in labels: - if id in label: - labels_set.add([id, label[1]]) - - if level==2: - labels_set.remove([id,mode]) - labels_set.add([id,mode,instance]) - for label in labels: - if id in label: - if mode in label: - labels_set.add([id, mode, label[2]]) - - if level==3: - labels_set.remove([id,mode,instance]) - labels_set.add([id,mode,instance,version]) - for label in labels: - if id in label: - if mode in label: - if instance in label: - labels_set.add([id, mode, instance, label[3]]) - - labels.append([id,mode,instance,version,level]) + labels.append([id]) + ids.append(id) + modes.append(mode) + instances.append(instance) + versions.append(version) + ids_set.add(id) + + # check if there are IDs that are used multiple times + if len(ids_set) < len(ids): + # create a dictionary with index locations of all design competences + for i in range(len(ids)): + if ids[i] in ids_dict: + if isinstance(ids_dict[ids[i]],int): + ids_dict[ids[i]]=[ids_dict[ids[i]],i] + else: + update=[] + for index in ids_dict[ids[i]]: + update.append(index) + update.append(i) + ids_dict[ids[i]]=update + multiples.add(ids[i]) + else: + ids_dict[ids[i]]=i + # for the IDs that are used multiple times determine if there is a difference in mode/instance/version + for multiple in multiples: + indices = ids_dict[multiple] + modes_set = set() + instances_set = set() + versions_set = set() + for index in indices: + modes_set.add(modes[index]) + instances_set.add(instances[index]) + versions_set.add(versions[index]) + for index in indices: + if len(modes_set)>1: + labels[index].append(modes[index]) + if len(instances_set)>1: + labels[index].append(instances[index]) + if len(versions_set)>1: + labels[index].append(versions[index]) + + # create mapping using the correct labeling index = 0 for design_competence in design_competences: - if labels[index][4]==0: - mapping[design_competence] = id - elif labels[index][4]==1: - mapping[design_competence] = id + '[' + mode + ']' - elif labels[index][4]==2: - mapping[design_competence] = id + '[' + mode + ']' + '[' + instance + ']' - else: - mapping[design_competence] = id + '[' + mode + ']' + '[' + instance + ']' + '[' + version + ']' + label = labels[index][0] + for i in range(1,len(labels[index])): + label+='['+labels[index][i]+']' + mapping[design_competence] = label index+=1 # Do the relabeling -- GitLab