diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu')
1 files changed, 70 insertions, 45 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Neighbourhood2Gml.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Neighbourhood2Gml.xtend index 174ffef0..6179c838 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Neighbourhood2Gml.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Neighbourhood2Gml.xtend | |||
@@ -29,9 +29,11 @@ class Neighbourhood2Gml { | |||
29 | val List<CharSequence> allEdgesText = newArrayList | 29 | val List<CharSequence> allEdgesText = newArrayList |
30 | val Map<AbstractNodeDescriptor, List<FurtherNodeDescriptor>> children = new HashMap | 30 | val Map<AbstractNodeDescriptor, List<FurtherNodeDescriptor>> children = new HashMap |
31 | 31 | ||
32 | val Map<String, Object> edgeName2targetNode = new HashMap | 32 | // TODO these should not be hashmaps, as a given node can have multiple sameNamed edges to different |
33 | val Map<String, List<Integer>> edgeName2inMultips = new HashMap | 33 | val Map<IncomingRelation, Object> edgeNameIn2targetNode = new HashMap |
34 | val Map<String, List<Integer>> edgeName2outMultips = new HashMap | 34 | val Map<OutgoingRelation, Object> edgeNameOut2targetNode = new HashMap |
35 | val Map<IncomingRelation, List<Integer>> edgeName2inMultips = new HashMap | ||
36 | val Map<OutgoingRelation, List<Integer>> edgeName2outMultips = new HashMap | ||
35 | 37 | ||
36 | val modRep = n.modelRepresentation as HashMap | 38 | val modRep = n.modelRepresentation as HashMap |
37 | // Store node text | 39 | // Store node text |
@@ -61,8 +63,8 @@ class Neighbourhood2Gml { | |||
61 | // edge transforming | 63 | // edge transforming |
62 | for (currentNode : children.keySet) { | 64 | for (currentNode : children.keySet) { |
63 | println(currentNode) | 65 | println(currentNode) |
64 | transformEdge(edgeName2targetNode, edgeName2inMultips, edgeName2outMultips, allEdgesText, currentNode, | 66 | transformEdge(edgeNameIn2targetNode, edgeNameOut2targetNode, edgeName2inMultips, edgeName2outMultips, |
65 | relevantObjectToID, children) | 67 | allEdgesText, currentNode, relevantObjectToID, children) |
66 | for (edgeText : allEdgesText) { | 68 | for (edgeText : allEdgesText) { |
67 | fullEdgeText.add(edgeText) | 69 | fullEdgeText.add(edgeText) |
68 | } | 70 | } |
@@ -83,17 +85,17 @@ class Neighbourhood2Gml { | |||
83 | '''.toString | 85 | '''.toString |
84 | } | 86 | } |
85 | 87 | ||
86 | protected def transformEdge(Map<String, Object> edgeName2targetNode, Map<String, List<Integer>> edgeName2inMultips, | 88 | protected def transformEdge(Map<IncomingRelation, Object> edgeNameIn2targetNode, |
87 | Map<String, List<Integer>> edgeName2outMultips, List<CharSequence> allEdgesText, | 89 | Map<OutgoingRelation, Object> edgeNameOut2targetNode, Map<IncomingRelation, List<Integer>> edgeName2inMultips, |
90 | Map<OutgoingRelation, List<Integer>> edgeName2outMultips, List<CharSequence> allEdgesText, | ||
88 | AbstractNodeDescriptor currentNode, Map<Object, Integer> relevantObjectToID, | 91 | AbstractNodeDescriptor currentNode, Map<Object, Integer> relevantObjectToID, |
89 | Map<AbstractNodeDescriptor, List<FurtherNodeDescriptor>> children) { | 92 | Map<AbstractNodeDescriptor, List<FurtherNodeDescriptor>> children) { |
90 | 93 | ||
91 | edgeName2targetNode.clear | 94 | edgeNameIn2targetNode.clear |
95 | edgeNameOut2targetNode.clear | ||
92 | edgeName2inMultips.clear | 96 | edgeName2inMultips.clear |
93 | edgeName2outMultips.clear | 97 | edgeName2outMultips.clear |
94 | val List<String> modifiedEdgeNames = newArrayList | 98 | val List<Object> modifiedEdgeNames = newArrayList |
95 | |||
96 | val sourceID = currentNode.lookup(relevantObjectToID) | ||
97 | 99 | ||
98 | val List<FurtherNodeDescriptor> subNodes = currentNode.lookup(children) | 100 | val List<FurtherNodeDescriptor> subNodes = currentNode.lookup(children) |
99 | for (subNode : subNodes) { | 101 | for (subNode : subNodes) { |
@@ -103,10 +105,9 @@ class Neighbourhood2Gml { | |||
103 | // mapPrinter(subNode.incomingEdges) | 105 | // mapPrinter(subNode.incomingEdges) |
104 | // println | 106 | // println |
105 | // println | 107 | // println |
106 | |||
107 | // handling outgoing edges | 108 | // handling outgoing edges |
108 | for (outEdge : subNode.outgoingEdges.keySet) { | 109 | for (outEdge : subNode.outgoingEdges.keySet) { |
109 | val edgeName = (outEdge as OutgoingRelation).type | 110 | val edgeName = (outEdge as OutgoingRelation) |
110 | val edgePointingTo = (outEdge as OutgoingRelation).to | 111 | val edgePointingTo = (outEdge as OutgoingRelation).to |
111 | val edgeOutMultip = outEdge.lookup(subNode.outgoingEdges) as Integer | 112 | val edgeOutMultip = outEdge.lookup(subNode.outgoingEdges) as Integer |
112 | 113 | ||
@@ -116,18 +117,18 @@ class Neighbourhood2Gml { | |||
116 | } else { | 117 | } else { |
117 | edgeName2outMultips.put(edgeName, newArrayList(edgeOutMultip)) | 118 | edgeName2outMultips.put(edgeName, newArrayList(edgeOutMultip)) |
118 | } | 119 | } |
119 | edgeName2targetNode.put(edgeName, edgePointingTo) | 120 | edgeNameOut2targetNode.put(edgeName, edgePointingTo) |
120 | 121 | ||
121 | } | 122 | } |
122 | 123 | ||
123 | } | 124 | } |
124 | 125 | ||
125 | // handling incoming edges | 126 | // handling incoming edges |
126 | for (outEdgeTarget : edgeName2targetNode.values) { | 127 | for (outEdgeTarget : edgeNameOut2targetNode.values) { |
127 | // currentNode = sourceParent | 128 | // currentNode = sourceParent |
128 | for (subNode : (outEdgeTarget as AbstractNodeDescriptor).lookup(children)) { | 129 | for (subNode : (outEdgeTarget as AbstractNodeDescriptor).lookup(children)) { |
129 | for (inEdge : subNode.incomingEdges.keySet) { | 130 | for (inEdge : subNode.incomingEdges.keySet) { |
130 | val edgeName = (inEdge as IncomingRelation).type | 131 | val edgeName = (inEdge as IncomingRelation) |
131 | val edgePointingFrom = (inEdge as IncomingRelation).from | 132 | val edgePointingFrom = (inEdge as IncomingRelation).from |
132 | val edgeInMultip = inEdge.lookup(subNode.incomingEdges) as Integer | 133 | val edgeInMultip = inEdge.lookup(subNode.incomingEdges) as Integer |
133 | 134 | ||
@@ -138,6 +139,7 @@ class Neighbourhood2Gml { | |||
138 | edgeName2inMultips.put(edgeName, newArrayList(edgeInMultip)) | 139 | edgeName2inMultips.put(edgeName, newArrayList(edgeInMultip)) |
139 | modifiedEdgeNames.add(edgeName) | 140 | modifiedEdgeNames.add(edgeName) |
140 | } | 141 | } |
142 | edgeNameIn2targetNode.put(edgeName, edgePointingFrom) | ||
141 | } | 143 | } |
142 | // edgeName2targetNode.put(edgeName, edgePointingFrom) | 144 | // edgeName2targetNode.put(edgeName, edgePointingFrom) |
143 | } | 145 | } |
@@ -146,75 +148,98 @@ class Neighbourhood2Gml { | |||
146 | // mapPrinter(edgeName2inMultips) | 148 | // mapPrinter(edgeName2inMultips) |
147 | // fill in the 0 multiplicities (INCOMING) | 149 | // fill in the 0 multiplicities (INCOMING) |
148 | for (edgeSoFar : modifiedEdgeNames) { | 150 | for (edgeSoFar : modifiedEdgeNames) { |
149 | var inEdgesNum = edgeSoFar.lookup(edgeName2inMultips).size | 151 | val edgeAsRelation = edgeSoFar as IncomingRelation |
152 | var inEdgesNum = edgeAsRelation.lookup(edgeName2inMultips).size | ||
150 | val targetNode = outEdgeTarget as AbstractNodeDescriptor | 153 | val targetNode = outEdgeTarget as AbstractNodeDescriptor |
151 | val targetChildrenNum = targetNode.lookup(children).size | 154 | val targetChildrenNum = targetNode.lookup(children).size |
152 | println("in " + edgeSoFar + "=>" + inEdgesNum + " != " + outEdgeTarget + "=>" + targetChildrenNum) | 155 | println("in " + edgeSoFar + "=>" + inEdgesNum + " != " + outEdgeTarget + "=>" + targetChildrenNum) |
153 | while (inEdgesNum != targetChildrenNum) { | 156 | while (inEdgesNum != targetChildrenNum) { |
154 | // println("in" + inEdgesNum + "!=" + targetChildrenNum) | 157 | // println("in" + inEdgesNum + "!=" + targetChildrenNum) |
155 | edgeSoFar.lookup(edgeName2inMultips).add(0) | 158 | edgeAsRelation.lookup(edgeName2inMultips).add(0) |
156 | inEdgesNum++ | 159 | inEdgesNum++ |
157 | } | 160 | } |
158 | } | 161 | } |
159 | modifiedEdgeNames.clear | 162 | modifiedEdgeNames.clear |
160 | 163 | ||
161 | } | 164 | } |
162 | 165 | ||
163 | mapPrinter(edgeName2outMultips) | 166 | mapPrinter(edgeName2outMultips) |
164 | |||
165 | //TODO | ||
166 | 167 | ||
167 | // fill in the 0 multiplicities (OUTGOING) | 168 | // fill in the 0 multiplicities (OUTGOING) |
168 | // for (edge : edgeName2outMultips.keySet) { | 169 | for (edge : edgeName2outMultips.keySet) { |
169 | // // handling outgoing edges | 170 | // handling outgoing edges |
170 | // var outEdgesNum = edge.lookup(edgeName2outMultips).size | 171 | var outEdgesNum = edge.lookup(edgeName2outMultips).size |
171 | // val sourceChildrenNum = currentNode.lookup(children).size | 172 | val sourceChildrenNum = currentNode.lookup(children).size |
172 | // | 173 | |
173 | // println("out" + outEdgesNum + "!=" + sourceChildrenNum) | 174 | println("out " + edge + "=>" + outEdgesNum + " != " + currentNode + "=>" + sourceChildrenNum) |
174 | // while (outEdgesNum != sourceChildrenNum) { | 175 | while (outEdgesNum != sourceChildrenNum) { |
175 | // edge.lookup(edgeName2outMultips).add(0) | 176 | edge.lookup(edgeName2outMultips).add(0) |
176 | // outEdgesNum++ | 177 | outEdgesNum++ |
177 | // } | 178 | } |
178 | // } | 179 | } |
179 | println("xxxxxxxx") | 180 | println("xxxxxxxx") |
180 | mapPrinter(edgeName2targetNode) | 181 | mapPrinter(edgeNameIn2targetNode) |
182 | mapPrinter(edgeNameOut2targetNode) | ||
183 | |||
184 | |||
181 | 185 | ||
182 | updateEdgeList(sourceID, relevantObjectToID, edgeName2targetNode, edgeName2inMultips, edgeName2outMultips, | 186 | updateEdgeList(currentNode, relevantObjectToID, edgeNameIn2targetNode, edgeNameOut2targetNode, edgeName2inMultips, edgeName2outMultips, |
183 | allEdgesText) | 187 | allEdgesText) |
184 | 188 | ||
185 | } | 189 | } |
186 | 190 | ||
187 | def updateEdgeList(Integer sourceID, Map<Object, Integer> relevantObjectToID, | 191 | def updateEdgeList(AbstractNodeDescriptor currentNode, Map<Object, Integer> relevantObjectToID, |
188 | Map<String, Object> edgeName2targetNode, Map<String, List<Integer>> edgeName2inMultips, | 192 | Map<IncomingRelation, Object> edgeNameIn2targetNode, |
189 | Map<String, List<Integer>> edgeName2outMultips, List<CharSequence> allEdgesTexts) { | 193 | Map<OutgoingRelation, Object> edgeNameOut2targetNode, |
194 | Map<IncomingRelation, List<Integer>> edgeName2inMultips, | ||
195 | Map<OutgoingRelation, List<Integer>> edgeName2outMultips, List<CharSequence> allEdgesTexts) { | ||
196 | |||
197 | for (outEdge : edgeNameOut2targetNode.keySet) { | ||
198 | // TODO | ||
199 | val sourceID = currentNode.lookup(relevantObjectToID) | ||
200 | val targetNode = outEdge.lookup(edgeNameOut2targetNode) | ||
201 | val targetID = targetNode.lookup(relevantObjectToID) | ||
202 | val edgeName = outEdge.type | ||
203 | |||
204 | //finding corresponding Incoming edge | ||
205 | var correspInEdgeSet = edgeNameIn2targetNode.keySet.filter[type.equals(edgeName) && lookup(edgeNameIn2targetNode).equals(currentNode)] | ||
206 | println("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy") | ||
207 | println(currentNode) | ||
208 | println(outEdge) | ||
209 | println(targetNode) | ||
210 | println(edgeNameIn2targetNode) | ||
211 | println(correspInEdgeSet.size) | ||
212 | val correspInEdge = correspInEdgeSet.get(0) | ||
213 | |||
190 | 214 | ||
191 | for (edge : edgeName2targetNode.keySet) { | ||
192 | val targetID = edge.lookup(edgeName2targetNode).lookup(relevantObjectToID) | ||
193 | allEdgesTexts.add( | 215 | allEdgesTexts.add( |
194 | ''' | 216 | ''' |
195 | edge | 217 | edge |
196 | [ | 218 | [ |
197 | source «sourceID» | 219 | source «sourceID» |
198 | target «targetID» | 220 | target «targetID» |
199 | label "«edge»" | 221 | label "«edgeName»" |
200 | graphics | 222 | graphics |
201 | [ | 223 | [ |
202 | fill "#000000" | 224 | fill "#000000" |
203 | targetArrow "standard" | 225 | targetArrow "standard" |
226 | Line | ||
227 | [ | ||
228 | ] | ||
204 | ] | 229 | ] |
205 | LabelGraphics | 230 | LabelGraphics |
206 | [ | 231 | [ |
207 | text "«edge»" | 232 | text "«edgeName»" |
208 | fontSize 12 | 233 | fontSize 12 |
209 | fontName "Dialog" | 234 | fontName "Dialog" |
210 | configuration "AutoFlippingLabel" | 235 | configuration "AutoFlippingLabel" |
211 | model "six_pos" | 236 | model "six_pos" |
212 | position "head" | 237 | position "head" |
213 | ] | 238 | ] |
214 | «IF edgeName2outMultips.containsKey(edge)» | 239 | «IF edgeName2outMultips.containsKey(outEdge)» |
215 | LabelGraphics | 240 | LabelGraphics |
216 | [ | 241 | [ |
217 | text "«edge.lookup(edgeName2outMultips).toString»" | 242 | text "«outEdge.lookup(edgeName2outMultips).toString»" |
218 | fontSize 12 | 243 | fontSize 12 |
219 | fontName "Dialog" | 244 | fontName "Dialog" |
220 | configuration "AutoFlippingLabel" | 245 | configuration "AutoFlippingLabel" |
@@ -222,10 +247,10 @@ class Neighbourhood2Gml { | |||
222 | position "stail" | 247 | position "stail" |
223 | ] | 248 | ] |
224 | «ENDIF» | 249 | «ENDIF» |
225 | «IF edgeName2inMultips.containsKey(edge)» | 250 | «IF edgeName2inMultips.containsKey(correspInEdge)» |
226 | LabelGraphics | 251 | LabelGraphics |
227 | [ | 252 | [ |
228 | text "«edge.lookup(edgeName2inMultips).toString»" | 253 | text "«correspInEdge.lookup(edgeName2inMultips).toString»" |
229 | fontSize 12 | 254 | fontSize 12 |
230 | fontName "Dialog" | 255 | fontName "Dialog" |
231 | configuration "AutoFlippingLabel" | 256 | configuration "AutoFlippingLabel" |