diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src')
9 files changed, 731 insertions, 486 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend index 41482b28..e4bdb086 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend | |||
@@ -4,10 +4,21 @@ import java.util.HashMap | |||
4 | import java.util.Map | 4 | import java.util.Map |
5 | import java.util.Set | 5 | import java.util.Set |
6 | import org.eclipse.xtend.lib.annotations.Data | 6 | import org.eclipse.xtend.lib.annotations.Data |
7 | import org.eclipse.xtend2.lib.StringConcatenationClient | ||
7 | 8 | ||
8 | @Data abstract class AbstractNodeDescriptor { | 9 | @Data abstract class AbstractNodeDescriptor { |
9 | long dataHash | 10 | long dataHash |
10 | 11 | ||
12 | protected def StringConcatenationClient prettyPrint() { | ||
13 | '''(«dataHash»)[«class.simpleName»]''' | ||
14 | } | ||
15 | |||
16 | override toString() { | ||
17 | ''' | ||
18 | «prettyPrint» | ||
19 | ''' | ||
20 | } | ||
21 | |||
11 | // @Pure | 22 | // @Pure |
12 | // @Override | 23 | // @Override |
13 | // override public boolean equals(Object obj) { | 24 | // override public boolean equals(Object obj) { |
@@ -24,34 +35,45 @@ import org.eclipse.xtend.lib.annotations.Data | |||
24 | // } | 35 | // } |
25 | } | 36 | } |
26 | 37 | ||
27 | @Data class LocalNodeDescriptor extends AbstractNodeDescriptor{ | 38 | @Data class LocalNodeDescriptor extends AbstractNodeDescriptor { |
28 | Set<String> types | 39 | Set<String> types |
29 | String id; | 40 | String id; |
41 | |||
30 | new(String id, Set<String> types) { | 42 | new(String id, Set<String> types) { |
31 | super(calcualteDataHash(id,types)) | 43 | super(calcualteDataHash(id, types)) |
32 | this.types = types | 44 | this.types = types |
33 | this.id = id | 45 | this.id = id |
34 | } | 46 | } |
35 | 47 | ||
36 | def private static calcualteDataHash(String id, Set<String> types) { | 48 | def private static calcualteDataHash(String id, Set<String> types) { |
37 | val int prime = 31; | 49 | val int prime = 31; |
38 | var result = 0 | 50 | var result = 0 |
39 | if(id !== null) | 51 | if (id !== null) |
40 | result = id.hashCode(); | 52 | result = id.hashCode(); |
41 | if(types !== null) { | 53 | if (types !== null) { |
42 | result = prime * result + types.hashCode | 54 | result = prime * result + types.hashCode |
43 | } | 55 | } |
44 | return result | 56 | return result |
45 | } | 57 | } |
46 | 58 | ||
47 | override hashCode() { | 59 | override hashCode() { |
48 | return this.dataHash.hashCode | 60 | return this.dataHash.hashCode |
49 | } | 61 | } |
50 | 62 | ||
63 | override equals(Object other) { | ||
64 | other.class == LocalNodeDescriptor && (other as AbstractNodeDescriptor).hashCode == hashCode | ||
65 | } | ||
66 | |||
67 | override protected prettyPrint() { | ||
68 | '''(«dataHash»)[«IF id !== null»id = "«id»"«IF types === null || !types.empty», «ENDIF»«ENDIF»«IF types === null»TYPES = null«ELSE»«FOR type : types SEPARATOR ", "»«type»«ENDFOR»«ENDIF»]''' | ||
69 | } | ||
70 | |||
51 | override toString() { | 71 | override toString() { |
52 | return class.name + this.dataHash | 72 | ''' |
73 | «prettyPrint» | ||
74 | ''' | ||
53 | } | 75 | } |
54 | 76 | ||
55 | // @Pure | 77 | // @Pure |
56 | // @Override | 78 | // @Override |
57 | // override public boolean equals(Object obj) { | 79 | // override public boolean equals(Object obj) { |
@@ -66,7 +88,6 @@ import org.eclipse.xtend.lib.annotations.Data | |||
66 | // return false; | 88 | // return false; |
67 | // return true; | 89 | // return true; |
68 | // } | 90 | // } |
69 | |||
70 | // @Pure | 91 | // @Pure |
71 | // override public boolean equals(Object obj) { | 92 | // override public boolean equals(Object obj) { |
72 | // if (this === obj) | 93 | // if (this === obj) |
@@ -97,49 +118,74 @@ import org.eclipse.xtend.lib.annotations.Data | |||
97 | String type | 118 | String type |
98 | } | 119 | } |
99 | 120 | ||
100 | @Data class FurtherNodeDescriptor<NodeRep> extends AbstractNodeDescriptor{ | 121 | @Data class FurtherNodeDescriptor<NodeRep> extends AbstractNodeDescriptor { |
101 | 122 | ||
102 | NodeRep previousRepresentation | 123 | NodeRep previousRepresentation |
103 | Map<IncomingRelation<NodeRep>,Integer> incomingEdges | 124 | Map<IncomingRelation<NodeRep>, Integer> incomingEdges |
104 | Map<OutgoingRelation<NodeRep>,Integer> outgoingEdges | 125 | Map<OutgoingRelation<NodeRep>, Integer> outgoingEdges |
105 | 126 | ||
106 | new( | 127 | new(NodeRep previousRepresentation, Map<IncomingRelation<NodeRep>, Integer> incomingEdges, |
107 | NodeRep previousRepresentation, | 128 | Map<OutgoingRelation<NodeRep>, Integer> outgoingEdges) { |
108 | Map<IncomingRelation<NodeRep>,Integer> incomingEdges, | 129 | super(calculateDataHash(previousRepresentation, incomingEdges, outgoingEdges)) |
109 | Map<OutgoingRelation<NodeRep>,Integer> outgoingEdges) | 130 | this.previousRepresentation = previousRepresentation |
110 | { | 131 | this.incomingEdges = new HashMap(incomingEdges) |
111 | super(calculateDataHash(previousRepresentation,incomingEdges,outgoingEdges)) | 132 | this.outgoingEdges = new HashMap(outgoingEdges) |
112 | this.previousRepresentation = previousRepresentation | ||
113 | this.incomingEdges = new HashMap(incomingEdges) | ||
114 | this.outgoingEdges = new HashMap(outgoingEdges) | ||
115 | } | ||
116 | |||
117 | static def private <NodeRep> int calculateDataHash( | ||
118 | NodeRep previousRepresentation, | ||
119 | Map<IncomingRelation<NodeRep>,Integer> incomingEdges, | ||
120 | Map<OutgoingRelation<NodeRep>,Integer> outgoingEdges) | ||
121 | { | ||
122 | val int prime = 31; | ||
123 | var int result = previousRepresentation.hashCode; | ||
124 | if(incomingEdges !== null) | ||
125 | result = prime * result + incomingEdges.hashCode(); | ||
126 | if(outgoingEdges !== null) | ||
127 | result = prime * result + outgoingEdges.hashCode(); | ||
128 | return result; | ||
129 | } | ||
130 | |||
131 | override hashCode() { | ||
132 | return this.dataHash.hashCode | ||
133 | } | 133 | } |
134 | 134 | ||
135 | static def private <NodeRep> int calculateDataHash(NodeRep previousRepresentation, | ||
136 | Map<IncomingRelation<NodeRep>, Integer> incomingEdges, Map<OutgoingRelation<NodeRep>, Integer> outgoingEdges) { | ||
137 | val int prime = 31; | ||
138 | var int result = previousRepresentation.hashCode; | ||
139 | if (incomingEdges !== null) | ||
140 | result = prime * result + incomingEdges.hashCode(); | ||
141 | if (outgoingEdges !== null) | ||
142 | result = prime * result + outgoingEdges.hashCode(); | ||
143 | return result; | ||
144 | } | ||
145 | |||
146 | override hashCode() { | ||
147 | return this.dataHash.hashCode | ||
148 | } | ||
149 | |||
150 | override equals(Object other) { | ||
151 | other.class == FurtherNodeDescriptor && (other as AbstractNodeDescriptor).hashCode == hashCode | ||
152 | } | ||
153 | |||
154 | override prettyPrint() { | ||
155 | ''' | ||
156 | («dataHash»)[ | ||
157 | PREV = «previousRepresentation?.prettyPrint» | ||
158 | «IF incomingEdges === null» | ||
159 | IN null | ||
160 | «ELSE» | ||
161 | «FOR edge : incomingEdges.entrySet» | ||
162 | IN «edge.value» «edge.key.type» = «edge.key.from.prettyPrint» | ||
163 | «ENDFOR» | ||
164 | «ENDIF» | ||
165 | «IF outgoingEdges === null» | ||
166 | OUT null | ||
167 | «ELSE» | ||
168 | «FOR edge : outgoingEdges.entrySet» | ||
169 | OUT «edge.value» «edge.key.type» = «edge.key.to.prettyPrint» | ||
170 | «ENDFOR» | ||
171 | «ENDIF» | ||
172 | ]''' | ||
173 | } | ||
174 | |||
175 | private def StringConcatenationClient prettyPrint(NodeRep rep) { | ||
176 | if (rep instanceof AbstractNodeDescriptor) { | ||
177 | rep.prettyPrint | ||
178 | } else { | ||
179 | '''«rep»''' | ||
180 | } | ||
181 | } | ||
182 | |||
135 | override toString() { | 183 | override toString() { |
136 | return class.name + dataHash | 184 | ''' |
137 | // return '''[«previousRepresentation»,(«FOR | 185 | «prettyPrint» |
138 | // in: incomingEdges.entrySet»(«in.key.type.name»=«in.key.from»,«in.value»)«ENDFOR»),(«FOR | 186 | ''' |
139 | // out: outgoingEdges.entrySet»(«out.key.type.name»=«out.key.to»,«out.value»)«ENDFOR»),«FOR | ||
140 | // att: attributeValues»(«att.type.name»=«att.value»)«ENDFOR»]''' | ||
141 | } | 187 | } |
142 | 188 | ||
143 | // @Pure | 189 | // @Pure |
144 | // @Override | 190 | // @Override |
145 | // override public boolean equals(Object obj) { | 191 | // override public boolean equals(Object obj) { |
@@ -154,7 +200,6 @@ import org.eclipse.xtend.lib.annotations.Data | |||
154 | // return false; | 200 | // return false; |
155 | // return true; | 201 | // return true; |
156 | // } | 202 | // } |
157 | |||
158 | // @Pure | 203 | // @Pure |
159 | // override public boolean equals(Object obj) { | 204 | // override public boolean equals(Object obj) { |
160 | // if (this === obj) | 205 | // if (this === obj) |
@@ -191,24 +236,23 @@ import org.eclipse.xtend.lib.annotations.Data | |||
191 | // return true; | 236 | // return true; |
192 | // } | 237 | // } |
193 | } | 238 | } |
194 | |||
195 | /* | 239 | /* |
196 | @Data | 240 | * @Data |
197 | class ModelDescriptor { | 241 | * class ModelDescriptor { |
198 | int dataHash | 242 | * int dataHash |
199 | int unknownElements | 243 | * int unknownElements |
200 | Map<? extends AbstractNodeDescriptor,Integer> knownElements | 244 | * Map<? extends AbstractNodeDescriptor,Integer> knownElements |
201 | 245 | * | |
202 | public new(Map<? extends AbstractNodeDescriptor,Integer> knownElements, int unknownElements) { | 246 | * public new(Map<? extends AbstractNodeDescriptor,Integer> knownElements, int unknownElements) { |
203 | this.dataHash = calculateDataHash(knownElements,unknownElements) | 247 | * this.dataHash = calculateDataHash(knownElements,unknownElements) |
204 | this.unknownElements = unknownElements | 248 | * this.unknownElements = unknownElements |
205 | this.knownElements = knownElements | 249 | * this.knownElements = knownElements |
206 | } | 250 | * } |
207 | 251 | * | |
208 | def private static calculateDataHash(Map<? extends AbstractNodeDescriptor,Integer> knownElements, int unknownElements) | 252 | * def private static calculateDataHash(Map<? extends AbstractNodeDescriptor,Integer> knownElements, int unknownElements) |
209 | { | 253 | * { |
210 | val int prime = 31; | 254 | * val int prime = 31; |
211 | return knownElements.hashCode * prime + unknownElements.hashCode | 255 | * return knownElements.hashCode * prime + unknownElements.hashCode |
212 | } | 256 | * } |
213 | } | 257 | * } |
214 | */ \ No newline at end of file | 258 | */ |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend new file mode 100644 index 00000000..c6e03f75 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend | |||
@@ -0,0 +1,22 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration | ||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration | ||
5 | import java.util.Set | ||
6 | import org.eclipse.xtend.lib.annotations.Data | ||
7 | |||
8 | @Data | ||
9 | class NeighbourhoodOptions { | ||
10 | public static val FixPointRange = -1 | ||
11 | public static val GraphWidthRange = -2 | ||
12 | public static val FullParallels = Integer.MAX_VALUE | ||
13 | public static val MaxNumbers = Integer.MAX_VALUE | ||
14 | |||
15 | public static val DEFAULT = new NeighbourhoodOptions(FixPointRange, FullParallels, MaxNumbers, null, null) | ||
16 | |||
17 | val int range | ||
18 | val int parallels | ||
19 | val int maxNumber | ||
20 | val Set<TypeDeclaration> relevantTypes | ||
21 | val Set<RelationDeclaration> relevantRelations | ||
22 | } | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend index d474877d..ddf7d712 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend | |||
@@ -5,7 +5,7 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement | |||
5 | 5 | ||
6 | class PartialInterpretation2Hash extends PartialInterpretation2NeighbourhoodRepresentation<Integer, Integer>{ | 6 | class PartialInterpretation2Hash extends PartialInterpretation2NeighbourhoodRepresentation<Integer, Integer>{ |
7 | 7 | ||
8 | protected new() { | 8 | new() { |
9 | super(false, true) | 9 | super(false, true) |
10 | } | 10 | } |
11 | 11 | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2NeighbourhoodRepresentation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2NeighbourhoodRepresentation.xtend index d1bf0348..3048167e 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2NeighbourhoodRepresentation.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2NeighbourhoodRepresentation.xtend | |||
@@ -4,32 +4,34 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement | |||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration | 4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration |
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink | 6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink |
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation | ||
10 | import java.util.ArrayList | ||
8 | import java.util.HashMap | 11 | import java.util.HashMap |
9 | import java.util.HashSet | 12 | import java.util.HashSet |
10 | import java.util.LinkedList | ||
11 | import java.util.List | 13 | import java.util.List |
12 | import java.util.Map | 14 | import java.util.Map |
13 | import java.util.Set | 15 | import java.util.Set |
14 | 16 | ||
15 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 17 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation | ||
17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | ||
18 | 18 | ||
19 | abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresentation,NodeRepresentation> { | 19 | abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresentation, NodeRepresentation> { |
20 | private val boolean deepRepresentation | 20 | val boolean deepRepresentation |
21 | private val boolean mergeSimilarNeighbourhood | 21 | val boolean mergeSimilarNeighbourhood |
22 | 22 | ||
23 | protected new(boolean deeprepresentation, boolean mergeSimilarNeighbourhood) { | 23 | protected new(boolean deeprepresentation, boolean mergeSimilarNeighbourhood) { |
24 | this.deepRepresentation = deeprepresentation | 24 | this.deepRepresentation = deeprepresentation |
25 | this.mergeSimilarNeighbourhood = mergeSimilarNeighbourhood | 25 | this.mergeSimilarNeighbourhood = mergeSimilarNeighbourhood |
26 | } | 26 | } |
27 | 27 | ||
28 | public static val FixPointRage = -1 | 28 | public static val FixPointRange = NeighbourhoodOptions.FixPointRange |
29 | public static val GraphWidthRange = -2 | 29 | public static val GraphWidthRange = NeighbourhoodOptions.GraphWidthRange |
30 | public static val FullParallels = Integer.MAX_VALUE | 30 | public static val FullParallels = NeighbourhoodOptions.FullParallels |
31 | public static val MaxNumbers = Integer.MAX_VALUE | 31 | public static val MaxNumbers = NeighbourhoodOptions.MaxNumbers |
32 | 32 | ||
33 | static val FOCUSED_ELEMENT_NAME = "<<THIS>>" | ||
34 | |||
33 | /** | 35 | /** |
34 | * Creates a neighbourhood representation with traces | 36 | * Creates a neighbourhood representation with traces |
35 | * @param model The model to be represented. | 37 | * @param model The model to be represented. |
@@ -37,10 +39,15 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
37 | * @param parallels The maximal number of parallel references to be differentiated. | 39 | * @param parallels The maximal number of parallel references to be differentiated. |
38 | * @param maxNumber The maximal number of elements in a equivalence class that chan be differentiated. | 40 | * @param maxNumber The maximal number of elements in a equivalence class that chan be differentiated. |
39 | */ | 41 | */ |
40 | def public createRepresentation(PartialInterpretation model, int range, int parallels, int maxNumber) { | 42 | def createRepresentation(PartialInterpretation model, int range, int parallels, int maxNumber) { |
41 | return createRepresentation(model,range,parallels,maxNumber,null,null) | 43 | return createRepresentation(model, range, parallels, maxNumber, null, null) |
44 | } | ||
45 | |||
46 | def createRepresentation(PartialInterpretation model, NeighbourhoodOptions options) { | ||
47 | createRepresentation(model, options.range, options.parallels, options.maxNumber, options.relevantTypes, | ||
48 | options.relevantRelations) | ||
42 | } | 49 | } |
43 | 50 | ||
44 | /** | 51 | /** |
45 | * Creates a neighbourhood representation with traces | 52 | * Creates a neighbourhood representation with traces |
46 | * @param model The model to be represented. | 53 | * @param model The model to be represented. |
@@ -48,45 +55,50 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
48 | * @param parallels The maximal number of parallel references to be differentiated. | 55 | * @param parallels The maximal number of parallel references to be differentiated. |
49 | * @param maxNumber The maximal number of elements in a equivalence class that chan be differentiated. | 56 | * @param maxNumber The maximal number of elements in a equivalence class that chan be differentiated. |
50 | */ | 57 | */ |
51 | def public createRepresentation( | 58 | def createRepresentation(PartialInterpretation model, int range, int parallels, int maxNumber, |
52 | PartialInterpretation model, | 59 | Set<TypeDeclaration> relevantTypes, Set<RelationDeclaration> relevantRelations) { |
53 | int range, int parallels, int maxNumber, | 60 | createRepresentationWithFocus(model, range, parallels, maxNumber, relevantTypes, relevantRelations, null) |
54 | Set<TypeDeclaration> relevantTypes, Set<RelationDeclaration> relevantRelations) | 61 | } |
55 | { | 62 | |
63 | def createRepresentationWithFocus(PartialInterpretation model, NeighbourhoodOptions options, | ||
64 | DefinedElement focusedElement) { | ||
65 | createRepresentationWithFocus(model, options.range, options.parallels, options.maxNumber, options.relevantTypes, | ||
66 | options.relevantRelations, focusedElement) | ||
67 | } | ||
68 | |||
69 | def createRepresentationWithFocus(PartialInterpretation model, int range, int parallels, int maxNumber, | ||
70 | Set<TypeDeclaration> relevantTypes, Set<RelationDeclaration> relevantRelations, DefinedElement focusedElement) { | ||
56 | val Map<DefinedElement, Set<String>> types = new HashMap | 71 | val Map<DefinedElement, Set<String>> types = new HashMap |
57 | fillTypes(model,types,relevantTypes) | 72 | fillTypes(model, types, relevantTypes) |
58 | val Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations = new HashMap; | 73 | val Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations = new HashMap; |
59 | val Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations = new HashMap; | 74 | val Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations = new HashMap; |
60 | fillReferences(model,IncomingRelations,OutgoingRelations,relevantRelations) | 75 | fillReferences(model, IncomingRelations, OutgoingRelations, relevantRelations) |
61 | 76 | ||
62 | val res = doRecursiveNeighbourCalculation(model,types,IncomingRelations,OutgoingRelations,range,parallels,maxNumber); | 77 | val res = doRecursiveNeighbourCalculation(model, types, IncomingRelations, OutgoingRelations, range, parallels, |
63 | 78 | maxNumber, focusedElement); | |
79 | |||
64 | return res; | 80 | return res; |
65 | } | 81 | } |
66 | 82 | ||
67 | def private isRelevant(TypeDeclaration t, Set<TypeDeclaration> relevantTypes) { | 83 | def private isRelevant(TypeDeclaration t, Set<TypeDeclaration> relevantTypes) { |
68 | if(relevantTypes === null) { | 84 | if (relevantTypes === null) { |
69 | return true | 85 | return true |
70 | } else { | 86 | } else { |
71 | return relevantTypes.contains(t) | 87 | return relevantTypes.contains(t) |
72 | } | 88 | } |
73 | } | 89 | } |
90 | |||
74 | def private isRelevant(RelationDeclaration r, Set<RelationDeclaration> relevantRelations) { | 91 | def private isRelevant(RelationDeclaration r, Set<RelationDeclaration> relevantRelations) { |
75 | if(relevantRelations === null) { | 92 | if (relevantRelations === null) { |
76 | return true | 93 | return true |
77 | } else { | 94 | } else { |
78 | return relevantRelations.contains(r) | 95 | return relevantRelations.contains(r) |
79 | } | 96 | } |
80 | } | 97 | } |
81 | /** | ||
82 | * Gets the largest | ||
83 | */ | ||
84 | /** | ||
85 | 98 | ||
99 | /** | ||
86 | * Gets the minimal neighbourhood size such that every reachable node appears in the shape of every other at least once. | 100 | * Gets the minimal neighbourhood size such that every reachable node appears in the shape of every other at least once. |
87 | |||
88 | */ | 101 | */ |
89 | |||
90 | def private getWidth(Map<DefinedElement, Set<String>> types, | 102 | def private getWidth(Map<DefinedElement, Set<String>> types, |
91 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, | 103 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, |
92 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations) { | 104 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations) { |
@@ -99,6 +111,7 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
99 | reachable.put(element, new HashSet) | 111 | reachable.put(element, new HashSet) |
100 | newReachable.put(element, set) | 112 | newReachable.put(element, set) |
101 | } | 113 | } |
114 | |||
102 | var int width = 0 | 115 | var int width = 0 |
103 | var boolean newAdded | 116 | var boolean newAdded |
104 | do { | 117 | do { |
@@ -122,7 +135,6 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
122 | } while (newAdded) | 135 | } while (newAdded) |
123 | return width | 136 | return width |
124 | } | 137 | } |
125 | |||
126 | /** | 138 | /** |
127 | * Creates a neighbourhood representation with traces | 139 | * Creates a neighbourhood representation with traces |
128 | * @param model The model to be represented. | 140 | * @param model The model to be represented. |
@@ -131,68 +143,71 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
131 | * @param range The range of the neighbourhood. | 143 | * @param range The range of the neighbourhood. |
132 | * @param parallels The maximal number of parallel references to be differentiated. | 144 | * @param parallels The maximal number of parallel references to be differentiated. |
133 | */ | 145 | */ |
134 | def private NeighbourhoodWithTraces<ModelRepresentation,NodeRepresentation> doRecursiveNeighbourCalculation( | 146 | def private NeighbourhoodWithTraces<ModelRepresentation, NodeRepresentation> doRecursiveNeighbourCalculation( |
135 | PartialInterpretation model, | 147 | PartialInterpretation model, Map<DefinedElement, Set<String>> types, |
136 | Map<DefinedElement, Set<String>> types, | ||
137 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, | 148 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, |
138 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations, | 149 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations, int range, int parallels, |
139 | int range, int parallels, int maxNumber) | 150 | int maxNumber, DefinedElement focusedElement) { |
140 | { | 151 | if (range == 0) { |
141 | if(range == 0){ | 152 | val r = calculateLocalNodeDescriptors(model, types, maxNumber, focusedElement) |
142 | val r = calculateLocalNodeDescriptors(model,types,maxNumber) | 153 | val res = this.createLocalRepresentation(r.value, r.key) |
143 | val res = this.createLocalRepresentation(r.value,r.key) | 154 | if (res.modelRepresentation === null) { |
144 | if(res.modelRepresentation === null) { | ||
145 | throw new IllegalArgumentException('''Model representation is null''') | 155 | throw new IllegalArgumentException('''Model representation is null''') |
146 | } else if(res.nodeRepresentations === null || res.nodeRepresentations.empty) { | 156 | } else if (res.nodeRepresentations === null || res.nodeRepresentations.empty) { |
147 | throw new IllegalArgumentException('''No node representation''') | 157 | throw new IllegalArgumentException('''No node representation''') |
148 | } else if(res.previousRepresentation !== null) { | 158 | } else if (res.previousRepresentation !== null) { |
149 | throw new IllegalArgumentException('''The previous representation of the first neighbourhood have to be null''') | 159 | throw new IllegalArgumentException('''The previous representation of the first neighbourhood have to be null''') |
150 | } else return res | 160 | } else |
151 | } else if(range > 0) { | 161 | return res |
152 | val previous = doRecursiveNeighbourCalculation(model,types,IncomingRelations,OutgoingRelations,range-1,parallels,maxNumber) | 162 | } else if (range > 0) { |
153 | val r = calculateFurtherNodeDescriptors(model,previous,IncomingRelations,OutgoingRelations,parallels,maxNumber) | 163 | val previous = doRecursiveNeighbourCalculation(model, types, IncomingRelations, OutgoingRelations, |
154 | //println('''Level «range» finished.''') | 164 | range - 1, parallels, maxNumber, focusedElement) |
155 | val res = createFurtherRepresentation(r.key,r.value,previous,deepRepresentation) | 165 | val r = calculateFurtherNodeDescriptors(model, previous, IncomingRelations, OutgoingRelations, parallels, |
156 | if(res.modelRepresentation === null) { | 166 | maxNumber) |
167 | // println('''Level «range» finished.''') | ||
168 | val res = createFurtherRepresentation(r.key, r.value, previous, deepRepresentation) | ||
169 | if (res.modelRepresentation === null) { | ||
157 | throw new IllegalArgumentException('''Model representation is null''') | 170 | throw new IllegalArgumentException('''Model representation is null''') |
158 | } else if(res.nodeRepresentations === null || res.nodeRepresentations.empty) { | 171 | } else if (res.nodeRepresentations === null || res.nodeRepresentations.empty) { |
159 | throw new IllegalArgumentException('''No node representation''') | 172 | throw new IllegalArgumentException('''No node representation''') |
160 | } else if(res.previousRepresentation === null && deepRepresentation) { | 173 | } else if (res.previousRepresentation === null && deepRepresentation) { |
161 | throw new IllegalArgumentException('''Need previous representations''') | 174 | throw new IllegalArgumentException('''Need previous representations''') |
162 | } else return res | 175 | } else |
163 | } else if (range == FixPointRage) { | 176 | return res |
164 | return refineUntilFixpoint(model,types,IncomingRelations,OutgoingRelations,parallels,maxNumber) | 177 | } else if (range == FixPointRange) { |
178 | return refineUntilFixpoint(model, types, IncomingRelations, OutgoingRelations, parallels, maxNumber, | ||
179 | focusedElement) | ||
165 | } else if (range == GraphWidthRange) { | 180 | } else if (range == GraphWidthRange) { |
166 | val width = this.getWidth(types,IncomingRelations,OutgoingRelations) | 181 | val width = this.getWidth(types, IncomingRelations, OutgoingRelations) |
167 | //println(width) | 182 | // println(width) |
168 | return doRecursiveNeighbourCalculation(model,types,IncomingRelations,OutgoingRelations,width,parallels,maxNumber) | 183 | return doRecursiveNeighbourCalculation(model, types, IncomingRelations, OutgoingRelations, width, parallels, |
184 | maxNumber, focusedElement) | ||
169 | } | 185 | } |
170 | } | 186 | } |
171 | 187 | ||
172 | def private refineUntilFixpoint( | 188 | def private refineUntilFixpoint(PartialInterpretation model, Map<DefinedElement, Set<String>> types, |
173 | PartialInterpretation model, | ||
174 | Map<DefinedElement, Set<String>> types, | ||
175 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, | 189 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, |
176 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations, | 190 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations, int parallels, int maxNumbers, |
177 | int parallels, int maxNumbers) | 191 | DefinedElement focusedElement) { |
178 | { | ||
179 | var lastRange = 0 | 192 | var lastRange = 0 |
180 | val last = calculateLocalNodeDescriptors(model,types,maxNumbers) | 193 | val last = calculateLocalNodeDescriptors(model, types, maxNumbers, focusedElement) |
181 | var lastRepresentation = this.createLocalRepresentation(last.value,last.key) | 194 | var lastRepresentation = this.createLocalRepresentation(last.value, last.key) |
182 | //println('''Level 0 finished.''') | 195 | // println('''Level 0 finished.''') |
183 | var boolean hasRefined | 196 | var boolean hasRefined |
184 | do { | 197 | do { |
185 | val nextRange = lastRange+1 | 198 | val nextRange = lastRange + 1 |
186 | val next = calculateFurtherNodeDescriptors(model,lastRepresentation,IncomingRelations,OutgoingRelations,parallels,maxNumbers) | 199 | val next = calculateFurtherNodeDescriptors(model, lastRepresentation, IncomingRelations, OutgoingRelations, |
187 | val nextRepresentation = createFurtherRepresentation(next.key,next.value,lastRepresentation,deepRepresentation) | 200 | parallels, maxNumbers) |
188 | 201 | val nextRepresentation = createFurtherRepresentation(next.key, next.value, lastRepresentation, | |
189 | val previousNumberOfTypes =lastRepresentation.nodeRepresentations.values.toSet.size | 202 | deepRepresentation) |
203 | |||
204 | val previousNumberOfTypes = lastRepresentation.nodeRepresentations.values.toSet.size | ||
190 | val nextNumberOfTypes = nextRepresentation.nodeRepresentations.values.toSet.size | 205 | val nextNumberOfTypes = nextRepresentation.nodeRepresentations.values.toSet.size |
191 | hasRefined = nextNumberOfTypes > previousNumberOfTypes | 206 | hasRefined = nextNumberOfTypes > previousNumberOfTypes |
192 | 207 | ||
193 | lastRange = nextRange | 208 | lastRange = nextRange |
194 | lastRepresentation = nextRepresentation | 209 | lastRepresentation = nextRepresentation |
195 | 210 | ||
196 | // if(hasRefined) { | 211 | // if(hasRefined) { |
197 | // println('''Level «nextRange» is calculated, number of types is refined: «previousNumberOfTypes» -> «nextNumberOfTypes»''') | 212 | // println('''Level «nextRange» is calculated, number of types is refined: «previousNumberOfTypes» -> «nextNumberOfTypes»''') |
198 | // } else { | 213 | // } else { |
@@ -201,211 +216,219 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
201 | } while (hasRefined) | 216 | } while (hasRefined) |
202 | return lastRepresentation | 217 | return lastRepresentation |
203 | } | 218 | } |
204 | 219 | ||
205 | def private getElements(PartialInterpretation model) { | 220 | def private getElements(PartialInterpretation model) { |
206 | return | 221 | return model.problem.elements + model.newElements + model.openWorldElements |
207 | model.problem.elements + | ||
208 | model.newElements + | ||
209 | model.openWorldElements | ||
210 | } | 222 | } |
211 | 223 | ||
212 | def private fillTypes(PartialInterpretation model, Map<DefinedElement, Set<String>> node2Type, Set<TypeDeclaration> relevantTypes) { | 224 | def private fillTypes(PartialInterpretation model, Map<DefinedElement, Set<String>> node2Type, |
213 | for(element : model.elements) { | 225 | Set<TypeDeclaration> relevantTypes) { |
226 | for (element : model.elements) { | ||
214 | node2Type.put(element, new HashSet) | 227 | node2Type.put(element, new HashSet) |
215 | } | 228 | } |
216 | 229 | ||
217 | // for(typeDefinition : model.problem.types.filter(TypeDefinition)) { | 230 | // for(typeDefinition : model.problem.types.filter(TypeDefinition)) { |
218 | // // Dont need | 231 | // // Dont need |
219 | // } | 232 | // } |
220 | for(typeInterpretation : model.partialtypeinterpratation) { | 233 | for (typeInterpretation : model.partialtypeinterpratation) { |
221 | if(typeInterpretation instanceof PartialPrimitiveInterpretation) { | 234 | if (typeInterpretation instanceof PartialPrimitiveInterpretation) { |
222 | 235 | } else if (typeInterpretation instanceof PartialComplexTypeInterpretation) { | |
223 | } else if(typeInterpretation instanceof PartialComplexTypeInterpretation) { | ||
224 | val type = typeInterpretation.interpretationOf | 236 | val type = typeInterpretation.interpretationOf |
225 | if(type.isRelevant(relevantTypes)) { | 237 | if (type.isRelevant(relevantTypes)) { |
226 | for(element : typeInterpretation.elements) { | 238 | for (element : typeInterpretation.elements) { |
227 | element.lookup(node2Type).add(type.name) | 239 | element.lookup(node2Type).add(type.name) |
228 | } | 240 | } |
229 | } | 241 | } |
230 | } | 242 | } |
231 | } | 243 | } |
232 | } | 244 | } |
233 | 245 | ||
234 | /** | 246 | /** |
235 | * Indexes the references | 247 | * Indexes the references |
236 | */ | 248 | */ |
237 | def private fillReferences(PartialInterpretation model, | 249 | def private fillReferences(PartialInterpretation model, |
238 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, | 250 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, |
239 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations, | 251 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations, |
240 | Set<RelationDeclaration> relevantRelations) | 252 | Set<RelationDeclaration> relevantRelations) { |
241 | { | 253 | for (object : model.elements) { |
242 | for(object : model.elements) { | 254 | IncomingRelations.put(object, new ArrayList) |
243 | IncomingRelations.put(object,new LinkedList) | 255 | OutgoingRelations.put(object, new ArrayList) |
244 | OutgoingRelations.put(object,new LinkedList) | ||
245 | } | 256 | } |
246 | for(relationInterpretation : model.partialrelationinterpretation) { | 257 | for (relationInterpretation : model.partialrelationinterpretation) { |
247 | val type = relationInterpretation.interpretationOf | 258 | val type = relationInterpretation.interpretationOf |
248 | if(type.isRelevant(relevantRelations)) { | 259 | if (type.isRelevant(relevantRelations)) { |
249 | for(link : relationInterpretation.relationlinks) { | 260 | for (link : relationInterpretation.relationlinks) { |
250 | if(link instanceof BinaryElementRelationLink) { | 261 | if (link instanceof BinaryElementRelationLink) { |
251 | OutgoingRelations.get(link.param1) += new OutgoingRelation(link.param2,type.name) | 262 | OutgoingRelations.get(link.param1) += new OutgoingRelation(link.param2, type.name) |
252 | IncomingRelations.get(link.param2) += new IncomingRelation(link.param1,type.name) | 263 | IncomingRelations.get(link.param2) += new IncomingRelation(link.param1, type.name) |
253 | } else throw new UnsupportedOperationException | 264 | } else |
265 | throw new UnsupportedOperationException | ||
254 | } | 266 | } |
255 | } | 267 | } |
256 | } | 268 | } |
257 | } | 269 | } |
258 | 270 | ||
259 | /** | 271 | /** |
260 | * Creates a local representation of the objects (aka zero range neighbourhood) | 272 | * Creates a local representation of the objects (aka zero range neighbourhood) |
261 | */ | 273 | */ |
262 | def abstract protected NeighbourhoodWithTraces<ModelRepresentation,NodeRepresentation> createLocalRepresentation( | 274 | def abstract protected NeighbourhoodWithTraces<ModelRepresentation, NodeRepresentation> createLocalRepresentation( |
263 | Map<DefinedElement, LocalNodeDescriptor> node2Representation, | 275 | Map<DefinedElement, LocalNodeDescriptor> node2Representation, |
264 | Map<LocalNodeDescriptor, Integer> representation2Amount | 276 | Map<LocalNodeDescriptor, Integer> representation2Amount |
265 | ) | 277 | ) |
266 | 278 | ||
267 | /** | 279 | /** |
268 | * Creates a | 280 | * Creates a |
269 | */ | 281 | */ |
270 | def abstract protected NeighbourhoodWithTraces<ModelRepresentation,NodeRepresentation> createFurtherRepresentation( | 282 | def abstract protected NeighbourhoodWithTraces<ModelRepresentation, NodeRepresentation> createFurtherRepresentation( |
271 | Map<FurtherNodeDescriptor<NodeRepresentation>, Integer> nodeDescriptors, | 283 | Map<FurtherNodeDescriptor<NodeRepresentation>, Integer> nodeDescriptors, |
272 | Map<DefinedElement, FurtherNodeDescriptor<NodeRepresentation>> node2Representation, | 284 | Map<DefinedElement, FurtherNodeDescriptor<NodeRepresentation>> node2Representation, |
273 | NeighbourhoodWithTraces<ModelRepresentation,NodeRepresentation> previous, | 285 | NeighbourhoodWithTraces<ModelRepresentation, NodeRepresentation> previous, |
274 | boolean deepRepresentation | 286 | boolean deepRepresentation |
275 | ) | 287 | ) |
276 | 288 | ||
277 | def private addOne(int original, int max) { | 289 | def private addOne(int original, int max) { |
278 | if(original == Integer.MAX_VALUE) return Integer.MAX_VALUE | 290 | if(original == Integer.MAX_VALUE) return Integer.MAX_VALUE |
279 | if(original +1 > max) return Integer.MAX_VALUE | 291 | if(original + 1 > max) return Integer.MAX_VALUE else return original + 1 |
280 | else return original+1 | ||
281 | } | 292 | } |
282 | 293 | ||
283 | private def calculateIncomingEdges(Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, | 294 | private def calculateIncomingEdges(Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, |
284 | DefinedElement object, Map<DefinedElement, ? extends NodeRepresentation> previousNodeRepresentations, int parallel) | 295 | DefinedElement object, Map<DefinedElement, ? extends NodeRepresentation> previousNodeRepresentations, |
285 | { | 296 | int parallel) { |
286 | val Map<IncomingRelation<NodeRepresentation>, Integer> res = new HashMap | 297 | val Map<IncomingRelation<NodeRepresentation>, Integer> res = new HashMap |
287 | for (incomingConcreteEdge : IncomingRelations.get(object)) { | 298 | for (incomingConcreteEdge : IncomingRelations.get(object)) { |
288 | val IncomingRelation<NodeRepresentation> e = new IncomingRelation( | 299 | val IncomingRelation<NodeRepresentation> e = new IncomingRelation( |
289 | previousNodeRepresentations.get(incomingConcreteEdge.from), incomingConcreteEdge.type) | 300 | previousNodeRepresentations.get(incomingConcreteEdge.from), incomingConcreteEdge.type) |
290 | if (res.containsKey(e)) { | 301 | if (res.containsKey(e)) { |
291 | res.put(e, addOne(res.get(e),parallel)) | 302 | res.put(e, addOne(res.get(e), parallel)) |
292 | } else { | 303 | } else { |
293 | res.put(e, 1) | 304 | res.put(e, 1) |
294 | } | 305 | } |
295 | } | 306 | } |
296 | return res | 307 | return res |
297 | } | 308 | } |
298 | 309 | ||
299 | private def calcuateOutgoingEdges(Map<DefinedElement,List<OutgoingRelation<DefinedElement>>> OutgoingRelations, | 310 | private def calcuateOutgoingEdges(Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations, |
300 | DefinedElement object, Map<DefinedElement, ? extends NodeRepresentation> previousNodeRepresentations, int parallel) | 311 | DefinedElement object, Map<DefinedElement, ? extends NodeRepresentation> previousNodeRepresentations, |
301 | { | 312 | int parallel) { |
302 | val Map<OutgoingRelation<NodeRepresentation>,Integer> res= new HashMap | 313 | val Map<OutgoingRelation<NodeRepresentation>, Integer> res = new HashMap |
303 | for(outgoingConcreteEdge : OutgoingRelations.get(object)) { | 314 | for (outgoingConcreteEdge : OutgoingRelations.get(object)) { |
304 | val OutgoingRelation<NodeRepresentation> e = | 315 | val OutgoingRelation<NodeRepresentation> e = new OutgoingRelation( |
305 | new OutgoingRelation( | 316 | previousNodeRepresentations.get(outgoingConcreteEdge.to), outgoingConcreteEdge.type) |
306 | previousNodeRepresentations.get(outgoingConcreteEdge.to), | 317 | if (res.containsKey(e)) { |
307 | outgoingConcreteEdge.type) | 318 | res.put(e, addOne(res.get(e), parallel)) |
308 | if(res.containsKey(e)) { | ||
309 | res.put(e,addOne(res.get(e),parallel)) | ||
310 | } else { | 319 | } else { |
311 | res.put(e,1) | 320 | res.put(e, 1) |
312 | } | 321 | } |
313 | } | 322 | } |
314 | return res; | 323 | return res; |
315 | } | 324 | } |
316 | 325 | ||
317 | /*def private <KEY,VALUE> void addOrCreate_Set(Map<KEY,Set<VALUE>> map, KEY key, VALUE value) { | 326 | /*def private <KEY,VALUE> void addOrCreate_Set(Map<KEY,Set<VALUE>> map, KEY key, VALUE value) { |
318 | var Set<VALUE> s; | 327 | * var Set<VALUE> s; |
319 | if(map.containsKey(key)) { | 328 | * if(map.containsKey(key)) { |
320 | s = map.get(key); | 329 | * s = map.get(key); |
321 | } else { | 330 | * } else { |
322 | s = new HashSet | 331 | * s = new HashSet |
323 | map.put(key,s) | 332 | * map.put(key,s) |
324 | } | 333 | * } |
325 | s.add(value) | 334 | * s.add(value) |
326 | }*/ | 335 | }*/ |
327 | 336 | private def calculateFurtherNodeDescriptors(PartialInterpretation model, | |
328 | |||
329 | private def calculateFurtherNodeDescriptors( | ||
330 | PartialInterpretation model, | ||
331 | NeighbourhoodWithTraces<ModelRepresentation, NodeRepresentation> previous, | 337 | NeighbourhoodWithTraces<ModelRepresentation, NodeRepresentation> previous, |
332 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, | 338 | Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations, |
333 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations, | 339 | Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations, int parallels, int maxNumber) { |
334 | int parallels, int maxNumber) | ||
335 | { | ||
336 | val previousNodeRepresentations = previous.nodeRepresentations | 340 | val previousNodeRepresentations = previous.nodeRepresentations |
337 | val node2Representation = new HashMap<DefinedElement,FurtherNodeDescriptor<NodeRepresentation>> | 341 | val node2Representation = new HashMap<DefinedElement, FurtherNodeDescriptor<NodeRepresentation>> |
338 | val Map<FurtherNodeDescriptor<NodeRepresentation>,Integer> descriptor2Number = | 342 | val Map<FurtherNodeDescriptor<NodeRepresentation>, Integer> descriptor2Number = if (this. |
339 | if(this.mergeSimilarNeighbourhood){ new HashMap } else { null } | 343 | mergeSimilarNeighbourhood) { |
340 | val Map<FurtherNodeDescriptor<NodeRepresentation>,FurtherNodeDescriptor<NodeRepresentation>> uniqueDescription = | 344 | new HashMap |
341 | if(this.mergeSimilarNeighbourhood){ new HashMap } else { null } | 345 | } else { |
342 | 346 | null | |
343 | for(object: model.elements) { | 347 | } |
344 | val incomingEdges = this.calculateIncomingEdges(IncomingRelations, object, previousNodeRepresentations,parallels) | 348 | val Map<FurtherNodeDescriptor<NodeRepresentation>, FurtherNodeDescriptor<NodeRepresentation>> uniqueDescription = if (this. |
345 | val outgoingEdges = this.calcuateOutgoingEdges(OutgoingRelations,object, previousNodeRepresentations,parallels) | 349 | mergeSimilarNeighbourhood) { |
346 | 350 | new HashMap | |
351 | } else { | ||
352 | null | ||
353 | } | ||
354 | |||
355 | for (object : model.elements) { | ||
356 | val incomingEdges = this.calculateIncomingEdges(IncomingRelations, object, previousNodeRepresentations, | ||
357 | parallels) | ||
358 | val outgoingEdges = this.calcuateOutgoingEdges(OutgoingRelations, object, previousNodeRepresentations, | ||
359 | parallels) | ||
360 | |||
347 | val previousType = previousNodeRepresentations.get(object) | 361 | val previousType = previousNodeRepresentations.get(object) |
348 | 362 | ||
349 | if(previousType === null) { | 363 | if (previousType === null) { |
350 | println("Error in state coder") | 364 | println("Error in state coder") |
351 | } | 365 | } |
352 | 366 | ||
353 | val nodeDescriptor = new FurtherNodeDescriptor( | 367 | val nodeDescriptor = new FurtherNodeDescriptor(previousType, incomingEdges, outgoingEdges) |
354 | previousType, | 368 | |
355 | incomingEdges, | 369 | if (this.mergeSimilarNeighbourhood) { |
356 | outgoingEdges) | 370 | if (descriptor2Number.containsKey(nodeDescriptor)) { |
357 | |||
358 | if(this.mergeSimilarNeighbourhood) { | ||
359 | if(descriptor2Number.containsKey(nodeDescriptor)) { | ||
360 | descriptor2Number.put( | 371 | descriptor2Number.put( |
361 | nodeDescriptor, | 372 | nodeDescriptor, |
362 | addOne(descriptor2Number.get(nodeDescriptor),maxNumber) | 373 | addOne(descriptor2Number.get(nodeDescriptor), maxNumber) |
363 | ) | 374 | ) |
364 | node2Representation.put(object,uniqueDescription.get(nodeDescriptor)) | 375 | node2Representation.put(object, uniqueDescription.get(nodeDescriptor)) |
365 | } else { | 376 | } else { |
366 | descriptor2Number.put(nodeDescriptor,if(1>maxNumber){Integer.MAX_VALUE}else{1}) | 377 | descriptor2Number.put(nodeDescriptor, if (1 > maxNumber) { |
367 | uniqueDescription.put(nodeDescriptor,nodeDescriptor) | 378 | Integer.MAX_VALUE |
368 | node2Representation.put(object,nodeDescriptor) | 379 | } else { |
380 | 1 | ||
381 | }) | ||
382 | uniqueDescription.put(nodeDescriptor, nodeDescriptor) | ||
383 | node2Representation.put(object, nodeDescriptor) | ||
369 | } | 384 | } |
370 | } else { | 385 | } else { |
371 | node2Representation.put(object,nodeDescriptor) | 386 | node2Representation.put(object, nodeDescriptor) |
372 | } | 387 | } |
373 | } | 388 | } |
374 | 389 | ||
375 | return descriptor2Number -> node2Representation | 390 | return descriptor2Number -> node2Representation |
376 | } | 391 | } |
377 | 392 | ||
378 | private def calculateLocalNodeDescriptors( | 393 | private def calculateLocalNodeDescriptors(PartialInterpretation model, Map<DefinedElement, Set<String>> types, |
379 | PartialInterpretation model, | 394 | int maxNumber, DefinedElement focusedElement) { |
380 | Map<DefinedElement, Set<String>> types, | ||
381 | int maxNumber) | ||
382 | { | ||
383 | val Map<DefinedElement, LocalNodeDescriptor> node2Representation = new HashMap | 395 | val Map<DefinedElement, LocalNodeDescriptor> node2Representation = new HashMap |
384 | val Map<LocalNodeDescriptor, Integer> representation2Amount = | 396 | val Map<LocalNodeDescriptor, Integer> representation2Amount = if (mergeSimilarNeighbourhood) { |
385 | if(mergeSimilarNeighbourhood){ new HashMap } else { null } | 397 | new HashMap |
386 | val Map<LocalNodeDescriptor, LocalNodeDescriptor> uniqueRepresentation = | 398 | } else { |
387 | if(this.mergeSimilarNeighbourhood){ new HashMap } else { null } | 399 | null |
388 | 400 | } | |
389 | for(element : model.elements) { | 401 | val Map<LocalNodeDescriptor, LocalNodeDescriptor> uniqueRepresentation = if (this.mergeSimilarNeighbourhood) { |
390 | var newDescriptor = new LocalNodeDescriptor(element.name,element.lookup(types)) | 402 | new HashMap |
391 | if(this.mergeSimilarNeighbourhood){ | 403 | } else { |
392 | if(uniqueRepresentation.containsKey(newDescriptor)) { | 404 | null |
405 | } | ||
406 | |||
407 | for (element : model.elements) { | ||
408 | val name = if(element == focusedElement) FOCUSED_ELEMENT_NAME else element.name | ||
409 | var newDescriptor = new LocalNodeDescriptor(name, element.lookup(types)) | ||
410 | if (this.mergeSimilarNeighbourhood) { | ||
411 | if (uniqueRepresentation.containsKey(newDescriptor)) { | ||
393 | newDescriptor = newDescriptor.lookup(uniqueRepresentation) | 412 | newDescriptor = newDescriptor.lookup(uniqueRepresentation) |
394 | node2Representation.put(element,newDescriptor) | 413 | node2Representation.put(element, newDescriptor) |
395 | representation2Amount.put( | 414 | representation2Amount.put( |
396 | newDescriptor, | 415 | newDescriptor, |
397 | addOne(newDescriptor.lookup(representation2Amount),maxNumber) | 416 | addOne(newDescriptor.lookup(representation2Amount), maxNumber) |
398 | ) | 417 | ) |
399 | } else { | 418 | } else { |
400 | uniqueRepresentation.put(newDescriptor,newDescriptor) | 419 | uniqueRepresentation.put(newDescriptor, newDescriptor) |
401 | node2Representation.put(element,newDescriptor) | 420 | node2Representation.put(element, newDescriptor) |
402 | representation2Amount.put(newDescriptor, if(1>maxNumber){Integer.MAX_VALUE}else{1}) | 421 | representation2Amount.put(newDescriptor, if (1 > maxNumber) { |
422 | Integer.MAX_VALUE | ||
423 | } else { | ||
424 | 1 | ||
425 | }) | ||
403 | } | 426 | } |
404 | } else { | 427 | } else { |
405 | node2Representation.put(element,newDescriptor) | 428 | node2Representation.put(element, newDescriptor) |
406 | } | 429 | } |
407 | } | 430 | } |
408 | 431 | ||
409 | return representation2Amount -> node2Representation | 432 | return representation2Amount -> node2Representation |
410 | } | 433 | } |
411 | } \ No newline at end of file | 434 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2PairwiseNeighbourhoodRepresentation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2PairwiseNeighbourhoodRepresentation.xtend new file mode 100644 index 00000000..c10457b0 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2PairwiseNeighbourhoodRepresentation.xtend | |||
@@ -0,0 +1,68 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood | ||
2 | |||
3 | import com.google.common.collect.Maps | ||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
6 | import java.util.HashMap | ||
7 | import java.util.Map | ||
8 | import org.eclipse.xtend.lib.annotations.Data | ||
9 | import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor | ||
10 | |||
11 | @Data | ||
12 | class PairwiseNeighbourhoodRepresentation<BasicNodeRepresentation> { | ||
13 | val Map<?, Integer> modelRepresentation | ||
14 | val Map<DefinedElement, BasicNodeRepresentation> basicNodeRepresentations | ||
15 | val Map<DefinedElement, ? extends Map<DefinedElement, ? extends BasicNodeRepresentation>> pairwiseNodeRepresentations | ||
16 | |||
17 | def getBasicRepresentation(DefinedElement a) { | ||
18 | basicNodeRepresentations.get(a) | ||
19 | } | ||
20 | |||
21 | def getPairwiseRepresentation(DefinedElement a, DefinedElement b) { | ||
22 | pairwiseNodeRepresentations.get(a).get(b) | ||
23 | } | ||
24 | } | ||
25 | |||
26 | @FinalFieldsConstructor | ||
27 | class PartialInterpretation2PairwiseNeighbourhoodRepresentation<BasicNodeRepresentation> { | ||
28 | val PartialInterpretation2NeighbourhoodRepresentation<? extends Map<? extends BasicNodeRepresentation, Integer>, BasicNodeRepresentation> basicNeighbourhoodRepresenter | ||
29 | |||
30 | def createRepresentation(PartialInterpretation model, NeighbourhoodOptions options) { | ||
31 | val basicRepresentation = basicNeighbourhoodRepresenter.createRepresentation(model, options) | ||
32 | val basicModelRepresentation = basicRepresentation.modelRepresentation | ||
33 | val basicNodeRepresentations = basicRepresentation.nodeRepresentations | ||
34 | val pairwiseNodeRepresentations = Maps.newHashMapWithExpectedSize(basicNodeRepresentations.size) | ||
35 | val modelRepresentation = new HashMap<Object, Integer> | ||
36 | for (nodeWithBasicRepresentation : basicNodeRepresentations.entrySet) { | ||
37 | val node = nodeWithBasicRepresentation.key | ||
38 | val basicNodeRepresentation = nodeWithBasicRepresentation.value | ||
39 | val count = basicModelRepresentation.get(basicNodeRepresentation) | ||
40 | if (count == 1) { | ||
41 | pairwiseNodeRepresentations.put(node, basicNodeRepresentations) | ||
42 | modelRepresentation.put(basicNodeRepresentation, count) | ||
43 | } else { | ||
44 | val neighbourhoodRepresentation = basicNeighbourhoodRepresenter. | ||
45 | createRepresentationWithFocus(model, options, node) | ||
46 | pairwiseNodeRepresentations.put(node, neighbourhoodRepresentation.nodeRepresentations) | ||
47 | modelRepresentation.compute(neighbourhoodRepresentation.modelRepresentation) [ key, value | | ||
48 | if (value === null) { | ||
49 | if (1 > options.maxNumber) { | ||
50 | Integer.MAX_VALUE | ||
51 | } else { | ||
52 | 1 | ||
53 | } | ||
54 | } else { | ||
55 | addOne(value, options.maxNumber) | ||
56 | } | ||
57 | ] | ||
58 | } | ||
59 | } | ||
60 | new PairwiseNeighbourhoodRepresentation(modelRepresentation, basicNodeRepresentations, | ||
61 | pairwiseNodeRepresentations) | ||
62 | } | ||
63 | |||
64 | def private addOne(int original, int max) { | ||
65 | if(original == Integer.MAX_VALUE) return Integer.MAX_VALUE | ||
66 | if(original + 1 > max) return Integer.MAX_VALUE else return original + 1 | ||
67 | } | ||
68 | } | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/AbstractNeighborhoodBasedStateCoderFactory.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/AbstractNeighborhoodBasedStateCoderFactory.xtend new file mode 100644 index 00000000..089880b1 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/AbstractNeighborhoodBasedStateCoderFactory.xtend | |||
@@ -0,0 +1,137 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | ||
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.NeighbourhoodOptions | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage | ||
10 | import java.util.LinkedList | ||
11 | import java.util.List | ||
12 | import org.eclipse.emf.common.notify.Notifier | ||
13 | import org.eclipse.emf.ecore.EClass | ||
14 | import org.eclipse.emf.ecore.EObject | ||
15 | import org.eclipse.emf.ecore.EStructuralFeature | ||
16 | import org.eclipse.viatra.dse.statecode.IStateCoder | ||
17 | import org.eclipse.viatra.dse.statecode.IStateCoderFactory | ||
18 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
19 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | ||
20 | import org.eclipse.viatra.query.runtime.base.api.FeatureListener | ||
21 | import org.eclipse.viatra.query.runtime.base.api.IndexingLevel | ||
22 | import org.eclipse.viatra.query.runtime.base.api.InstanceListener | ||
23 | import org.eclipse.viatra.query.runtime.emf.EMFBaseIndexWrapper | ||
24 | import org.eclipse.viatra.query.runtime.emf.EMFScope | ||
25 | import org.eclipse.xtend.lib.annotations.Accessors | ||
26 | |||
27 | abstract class AbstractNeighbourhoodBasedStateCoderFactory implements IStateCoderFactory { | ||
28 | val List<AbstractNeighbourhoodBasedPartialInterpretationStateCoder> statecoders = new LinkedList | ||
29 | |||
30 | val NeighbourhoodOptions options | ||
31 | |||
32 | protected new() { | ||
33 | this(NeighbourhoodOptions.DEFAULT) | ||
34 | } | ||
35 | |||
36 | protected new(NeighbourhoodOptions options) { | ||
37 | this.options = options | ||
38 | } | ||
39 | |||
40 | synchronized override createStateCoder() { | ||
41 | val res = doCreateStateCoder(options) | ||
42 | statecoders += res | ||
43 | return res | ||
44 | } | ||
45 | |||
46 | protected def AbstractNeighbourhoodBasedPartialInterpretationStateCoder doCreateStateCoder( | ||
47 | NeighbourhoodOptions options) | ||
48 | |||
49 | def getSumStatecoderRuntime() { | ||
50 | statecoders.map[statecoderRuntime].reduce[p1, p2|p1 + p2] | ||
51 | } | ||
52 | } | ||
53 | |||
54 | abstract class AbstractNeighbourhoodBasedPartialInterpretationStateCoder implements IStateCoder { | ||
55 | val NeighbourhoodOptions options | ||
56 | |||
57 | var PartialInterpretation target | ||
58 | |||
59 | protected new(NeighbourhoodOptions options) { | ||
60 | this.options = options | ||
61 | } | ||
62 | |||
63 | @Accessors(PUBLIC_GETTER) var long statecoderRuntime = 0 | ||
64 | |||
65 | synchronized private def refreshStateCodes() { | ||
66 | if (refreshNeeded) { | ||
67 | val startTime = System.nanoTime | ||
68 | doRefreshStateCodes(target, options) | ||
69 | statecoderRuntime += (System.nanoTime - startTime) | ||
70 | } | ||
71 | } | ||
72 | |||
73 | protected def boolean isRefreshNeeded() | ||
74 | |||
75 | protected def void doRefreshStateCodes(PartialInterpretation target, NeighbourhoodOptions options) | ||
76 | |||
77 | synchronized override createActivationCode(IPatternMatch match) { | ||
78 | refreshStateCodes | ||
79 | val startTime = System.nanoTime | ||
80 | val code = doCreateActivationCode(match) | ||
81 | statecoderRuntime += (System.nanoTime - startTime) | ||
82 | code | ||
83 | } | ||
84 | |||
85 | protected def Object doCreateActivationCode(IPatternMatch match) | ||
86 | |||
87 | synchronized override createStateCode() { | ||
88 | refreshStateCodes | ||
89 | doCreateStateCode | ||
90 | } | ||
91 | |||
92 | protected def Object doCreateStateCode() | ||
93 | |||
94 | override init(Notifier notifier) { | ||
95 | this.target = notifier as PartialInterpretation | ||
96 | val queryEngine = ViatraQueryEngine.on(new EMFScope(notifier)) | ||
97 | val baseIndex = queryEngine.getBaseIndex() as EMFBaseIndexWrapper | ||
98 | val navigationHelper = baseIndex.getNavigationHelper(); | ||
99 | |||
100 | val classes = PartialinterpretationPackage.eINSTANCE.EClassifiers.filter(EClass).toSet | ||
101 | val features = classes.map[it.EAllStructuralFeatures].flatten.toSet | ||
102 | navigationHelper.registerObservedTypes(classes, null, features, IndexingLevel.FULL); | ||
103 | |||
104 | navigationHelper.addFeatureListener(features, new FeatureListener() { | ||
105 | override void featureInserted(EObject host, EStructuralFeature feature, Object value) { invalidate } | ||
106 | |||
107 | override void featureDeleted(EObject host, EStructuralFeature feature, Object value) { invalidate } | ||
108 | }) | ||
109 | navigationHelper.addInstanceListener(classes, new InstanceListener() { | ||
110 | override void instanceInserted(EClass clazz, EObject instance) { invalidate } | ||
111 | |||
112 | override void instanceDeleted(EClass clazz, EObject instance) { invalidate } | ||
113 | }) | ||
114 | } | ||
115 | |||
116 | synchronized def invalidate() { | ||
117 | doInvalidate | ||
118 | } | ||
119 | |||
120 | protected def void doInvalidate() | ||
121 | |||
122 | def protected getFallbackCode(Object o) { | ||
123 | switch (o) { | ||
124 | PartialInterpretation, | ||
125 | LogicProblem: | ||
126 | null | ||
127 | PartialRelationInterpretation: | ||
128 | o.interpretationOf.name | ||
129 | PartialPrimitiveInterpretation: | ||
130 | o.class.simpleName.hashCode | ||
131 | PartialComplexTypeInterpretation: | ||
132 | o.interpretationOf.name.hashCode | ||
133 | default: | ||
134 | throw new UnsupportedOperationException('''Unsupported type: «o.class.simpleName»''') | ||
135 | } | ||
136 | } | ||
137 | } | ||
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/IdentifierBasedStateCoderFactory.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/IdentifierBasedStateCoderFactory.xtend index f55a501a..c7b8ee37 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/IdentifierBasedStateCoderFactory.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/IdentifierBasedStateCoderFactory.xtend | |||
@@ -62,13 +62,13 @@ class IdentifierBasedStateCode { | |||
62 | int numberOfNewElement | 62 | int numberOfNewElement |
63 | SortedSet<RelationStatecoder> relationStatecoders | 63 | SortedSet<RelationStatecoder> relationStatecoders |
64 | 64 | ||
65 | private static val comparator = new Comparator<RelationStatecoder>() { | 65 | static val comparator = new Comparator<RelationStatecoder>() { |
66 | override compare(RelationStatecoder o1, RelationStatecoder o2) { | 66 | override compare(RelationStatecoder o1, RelationStatecoder o2) { |
67 | o1.relationName.compareTo(o2.relationName) | 67 | o1.relationName.compareTo(o2.relationName) |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | public new(int numberOfNewElements) { | 71 | new(int numberOfNewElements) { |
72 | this.numberOfNewElement = numberOfNewElements | 72 | this.numberOfNewElement = numberOfNewElements |
73 | this.relationStatecoders = new TreeSet(comparator) | 73 | this.relationStatecoders = new TreeSet(comparator) |
74 | } | 74 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/NeighbourhoodBasedStateCoderFactory.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/NeighbourhoodBasedStateCoderFactory.xtend index a86bcd1f..5e442ca7 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/NeighbourhoodBasedStateCoderFactory.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/NeighbourhoodBasedStateCoderFactory.xtend | |||
@@ -1,223 +1,99 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder |
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.AbstractNodeDescriptor | 3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement |
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.NeighbourhoodOptions | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2Hash | ||
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2ImmutableTypeLattice | 6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2ImmutableTypeLattice |
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2NeighbourhoodRepresentation | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage | ||
7 | import java.util.ArrayList | 9 | import java.util.ArrayList |
8 | import java.util.LinkedList | ||
9 | import java.util.List | ||
10 | import java.util.Map | 10 | import java.util.Map |
11 | import org.eclipse.emf.common.notify.Notifier | ||
12 | import org.eclipse.emf.ecore.EClass | ||
13 | import org.eclipse.emf.ecore.EObject | ||
14 | import org.eclipse.emf.ecore.EStructuralFeature | ||
15 | import org.eclipse.viatra.dse.statecode.IStateCoder | ||
16 | import org.eclipse.viatra.dse.statecode.IStateCoderFactory | ||
17 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | 11 | import org.eclipse.viatra.query.runtime.api.IPatternMatch |
18 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | 12 | |
19 | import org.eclipse.viatra.query.runtime.base.api.FeatureListener | 13 | class NeighbourhoodBasedStateCoderFactory extends AbstractNeighbourhoodBasedStateCoderFactory { |
20 | import org.eclipse.viatra.query.runtime.base.api.IndexingLevel | 14 | new() { |
21 | import org.eclipse.viatra.query.runtime.base.api.InstanceListener | 15 | } |
22 | import org.eclipse.viatra.query.runtime.emf.EMFBaseIndexWrapper | 16 | |
23 | import org.eclipse.viatra.query.runtime.emf.EMFScope | 17 | new(NeighbourhoodOptions options) { |
24 | import org.eclipse.xtend.lib.annotations.Accessors | 18 | super(options) |
25 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement | ||
26 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | ||
27 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation | ||
28 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation | ||
29 | import java.util.Set | ||
30 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration | ||
31 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration | ||
32 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2NeighbourhoodRepresentation | ||
33 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | ||
34 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation | ||
35 | |||
36 | class NeighbourhoodBasedStateCoderFactory implements IStateCoderFactory { | ||
37 | val List<NeighbourhoodBasedPartialInterpretationStateCoder> statecoders = new LinkedList | ||
38 | |||
39 | val int range | ||
40 | val int parallels | ||
41 | val int maxNumber | ||
42 | val Set<TypeDeclaration> relevantTypes | ||
43 | val Set<RelationDeclaration> relevantRelations | ||
44 | |||
45 | public new() { | ||
46 | this.range = PartialInterpretation2NeighbourhoodRepresentation::GraphWidthRange | ||
47 | this.parallels = PartialInterpretation2NeighbourhoodRepresentation::FullParallels | ||
48 | this.maxNumber = PartialInterpretation2NeighbourhoodRepresentation::MaxNumbers | ||
49 | this.relevantTypes = null | ||
50 | this.relevantRelations = null | ||
51 | } | 19 | } |
52 | 20 | ||
53 | public new(int range, int parallels, int maxNumber, Set<TypeDeclaration> relevantTypes, Set<RelationDeclaration> relevantRelations) { | 21 | override protected doCreateStateCoder(NeighbourhoodOptions options) { |
54 | this.range = range | 22 | new NeighbourhoodBasedPartialInterpretationStateCoder(new PartialInterpretation2ImmutableTypeLattice, options) |
55 | this.parallels = parallels | 23 | } |
56 | this.maxNumber = maxNumber | 24 | } |
57 | this.relevantTypes = relevantTypes | 25 | |
58 | this.relevantRelations = relevantRelations | 26 | class NeighbourhoodBasedHashStateCoderFactory extends AbstractNeighbourhoodBasedStateCoderFactory { |
27 | new() { | ||
28 | } | ||
29 | |||
30 | new(NeighbourhoodOptions options) { | ||
31 | super(options) | ||
32 | } | ||
33 | |||
34 | override protected doCreateStateCoder(NeighbourhoodOptions options) { | ||
35 | new NeighbourhoodBasedPartialInterpretationStateCoder(new PartialInterpretation2Hash, options) | ||
59 | } | 36 | } |
60 | |||
61 | synchronized override createStateCoder() { | ||
62 | val res = new NeighbourhoodBasedPartialInterpretationStateCoder(statecoders.size, | ||
63 | range,parallels,maxNumber,relevantTypes,relevantRelations) | ||
64 | statecoders += res | ||
65 | return res | ||
66 | } | ||
67 | def getSumStatecoderRuntime() { | ||
68 | statecoders.map[statecoderRuntime].reduce[p1, p2|p1+p2] | ||
69 | } | ||
70 | } | 37 | } |
71 | 38 | ||
72 | class NeighbourhoodBasedPartialInterpretationStateCoder implements IStateCoder{ | 39 | class NeighbourhoodBasedPartialInterpretationStateCoder<ModelRep, NodeRep> extends AbstractNeighbourhoodBasedPartialInterpretationStateCoder { |
73 | val int id; | 40 | val PartialInterpretation2NeighbourhoodRepresentation<ModelRep, NodeRep> calculator |
74 | val int range | 41 | var Map<DefinedElement, ? extends NodeRep> nodeRepresentations = null |
75 | val int parallels | 42 | var ModelRep modelRepresentation = null |
76 | val int maxNumber | 43 | |
77 | val Set<TypeDeclaration> relevantTypes | 44 | new(PartialInterpretation2NeighbourhoodRepresentation<ModelRep, NodeRep> calculator, NeighbourhoodOptions options) { |
78 | val Set<RelationDeclaration> relevantRelations | 45 | super(options) |
79 | 46 | this.calculator = calculator | |
80 | val calculator = | 47 | } |
81 | new PartialInterpretation2ImmutableTypeLattice | 48 | |
82 | var PartialInterpretation target | 49 | override protected isRefreshNeeded() { |
83 | 50 | nodeRepresentations === null || modelRepresentation === null | |
84 | private var Map<DefinedElement, ? extends AbstractNodeDescriptor> nodeRepresentations = null | 51 | } |
85 | private var Map<? extends AbstractNodeDescriptor, Integer> modelRepresentation = null | 52 | |
86 | 53 | override doRefreshStateCodes(PartialInterpretation target, NeighbourhoodOptions options) { | |
87 | /*public new(int id) { | 54 | val code = calculator.createRepresentation(target, options) |
88 | this.id = id | 55 | modelRepresentation = code.modelRepresentation |
89 | this.range = PartialInterpretation2NeighbourhoodRepresentation::FixPointRage | 56 | nodeRepresentations = code.nodeRepresentations |
90 | this.parallels = PartialInterpretation2NeighbourhoodRepresentation::FullParallels | ||
91 | this.maxNumber = maxNumber = PartialInterpretation2NeighbourhoodRepresentation::MaxNumbers | ||
92 | this.relevantTypes = relevantTypes | ||
93 | this.relevantRelations = relevantRelations | ||
94 | }*/ | ||
95 | |||
96 | public new(int id, int range, int parallels, int maxNumber, Set<TypeDeclaration> relevantTypes, Set<RelationDeclaration> relevantRelations) { | ||
97 | this.id = id | ||
98 | this.range = range | ||
99 | this.parallels = parallels | ||
100 | this.maxNumber = maxNumber | ||
101 | this.relevantTypes = relevantTypes | ||
102 | this.relevantRelations = relevantRelations | ||
103 | } | 57 | } |
104 | 58 | ||
105 | @Accessors(PUBLIC_GETTER) var long statecoderRuntime = 0 | 59 | override doCreateActivationCode(IPatternMatch match) { |
106 | 60 | val size = match.specification.parameters.size | |
107 | // val range = -1 | 61 | val res = new ArrayList(size) |
108 | // val par = Integer.MAX_VALUE | 62 | var int index = 0 |
109 | //val deeprepresentation = false | 63 | var int equivalenceHash = 0 |
110 | 64 | val prime = 31 | |
111 | ///////// | 65 | |
112 | // Caching version | 66 | while (index < size) { |
113 | ///////// | 67 | res.add(getCode(match.get(index))) |
114 | synchronized private def refreshStateCodes() { | 68 | index++ |
115 | if(this.nodeRepresentations === null || this.modelRepresentation === null) { | 69 | for (var i = 0; i < index; i++) { |
116 | val startTime = System.nanoTime | 70 | val number = if (match.get(index) === match.get(i)) { |
117 | //relevantObjects.forEach[println(it)] | 71 | 1 |
118 | val code = calculator.createRepresentation(target,range,parallels,maxNumber,relevantTypes,relevantRelations) | 72 | } else { |
119 | this.modelRepresentation = code.modelRepresentation | 73 | 0 |
120 | this.nodeRepresentations = code.nodeRepresentations | 74 | } |
121 | statecoderRuntime += (System.nanoTime - startTime) | 75 | equivalenceHash = prime * equivalenceHash + number |
122 | } | ||
123 | } | ||
124 | synchronized override createActivationCode(IPatternMatch match) { | ||
125 | refreshStateCodes | ||
126 | |||
127 | val startTime = System.nanoTime | ||
128 | val size = match.specification.parameters.size | ||
129 | val res = new ArrayList(size) | ||
130 | var int index = 0 | ||
131 | var int equivalenceHash = 0 | ||
132 | val prime = 31 | ||
133 | |||
134 | while(index < size) { | ||
135 | res.add(getCode(match.get(index))) | ||
136 | index++ | ||
137 | for(var i = 0; i<index; i++) { | ||
138 | val number = if(match.get(index) === match.get(i)){1}else{0} | ||
139 | equivalenceHash = prime * equivalenceHash + number | ||
140 | } | ||
141 | } | ||
142 | |||
143 | statecoderRuntime += (System.nanoTime - startTime) | ||
144 | return match.specification.fullyQualifiedName->(res->equivalenceHash).hashCode | ||
145 | } | ||
146 | |||
147 | |||
148 | def private getCode(Object o) { | ||
149 | if(o instanceof DefinedElement) { | ||
150 | this.nodeRepresentations.get(o) | ||
151 | } else if(o instanceof PartialInterpretation || o instanceof LogicProblem) { | ||
152 | return null | ||
153 | } else if(o instanceof PartialRelationInterpretation) { | ||
154 | return o.interpretationOf.name | ||
155 | } else if(o instanceof PartialTypeInterpratation) { | ||
156 | if(o instanceof PartialPrimitiveInterpretation) { | ||
157 | o.class.simpleName.hashCode | ||
158 | } else if (o instanceof PartialComplexTypeInterpretation){ | ||
159 | return o.interpretationOf.name.hashCode | ||
160 | } else { | ||
161 | throw new UnsupportedOperationException('''Unsupported type: «o.class.simpleName»''') | ||
162 | } | 76 | } |
163 | } else { | ||
164 | throw new UnsupportedOperationException('''Unsupported type: «o.class.simpleName»''') | ||
165 | } | 77 | } |
166 | } | 78 | |
167 | 79 | match.specification.fullyQualifiedName -> (res -> equivalenceHash).hashCode | |
168 | synchronized override createStateCode() { | 80 | } |
169 | refreshStateCodes | 81 | |
170 | return this.modelRepresentation.hashCode | 82 | def private getCode(Object o) { |
171 | } | 83 | switch (o) { |
172 | ///////// | 84 | DefinedElement: |
173 | // Caching version | 85 | nodeRepresentations.get(o) |
174 | ///////// | 86 | default: |
175 | 87 | getFallbackCode(o) | |
176 | ///////// | 88 | } |
177 | // Recalculating version | 89 | } |
178 | ///////// | 90 | |
179 | // synchronized override createActivationCode(IPatternMatch match) { | 91 | override doCreateStateCode() { |
180 | // val nodes = calculator.createRepresentation(getRelevantObjects().toList,range,par).nodeRepresentations | 92 | modelRepresentation.hashCode |
181 | // val res = match.toArray.map[objectInMatch | | 93 | } |
182 | // nodes.get(objectInMatch) | 94 | |
183 | // ] | 95 | override doInvalidate() { |
184 | // return res | 96 | nodeRepresentations = null |
185 | // } | 97 | modelRepresentation = null |
186 | // | ||
187 | // override createStateCode() { | ||
188 | // return this.calculator.createRepresentation(getRelevantObjects().toList,range,par).modelRepresentation | ||
189 | // } | ||
190 | ///////// | ||
191 | // Recalculating version | ||
192 | ///////// | ||
193 | |||
194 | override init(Notifier notifier) { | ||
195 | this.target = notifier as PartialInterpretation | ||
196 | val queryEngine = ViatraQueryEngine.on(new EMFScope(notifier)) | ||
197 | val baseIndex = queryEngine.getBaseIndex() as EMFBaseIndexWrapper | ||
198 | val navigationHelper = baseIndex.getNavigationHelper(); | ||
199 | |||
200 | val classes = PartialinterpretationPackage.eINSTANCE.EClassifiers.filter(EClass).toSet | ||
201 | val features = classes.map[it.EAllStructuralFeatures].flatten.toSet | ||
202 | navigationHelper.registerObservedTypes( | ||
203 | classes, | ||
204 | null, | ||
205 | features, | ||
206 | IndexingLevel.FULL); | ||
207 | |||
208 | |||
209 | navigationHelper.addFeatureListener(features, new FeatureListener() { | ||
210 | override public void featureInserted(EObject host, EStructuralFeature feature, Object value) { invalidate } | ||
211 | override public void featureDeleted(EObject host, EStructuralFeature feature, Object value) { invalidate } | ||
212 | }); | ||
213 | navigationHelper.addInstanceListener(classes, new InstanceListener() { | ||
214 | override public void instanceInserted(EClass clazz, EObject instance) { invalidate } | ||
215 | override public void instanceDeleted(EClass clazz, EObject instance) { invalidate } | ||
216 | }); | ||
217 | } | ||
218 | |||
219 | synchronized def public invalidate() { | ||
220 | this.nodeRepresentations = null | ||
221 | this.modelRepresentation = null | ||
222 | } | 98 | } |
223 | } | 99 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/PairwiseNeighbourhoodBasedStateCoderFactory.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/PairwiseNeighbourhoodBasedStateCoderFactory.xtend new file mode 100644 index 00000000..84e798f2 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/statecoder/PairwiseNeighbourhoodBasedStateCoderFactory.xtend | |||
@@ -0,0 +1,75 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement | ||
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.AbstractNodeDescriptor | ||
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.NeighbourhoodOptions | ||
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PairwiseNeighbourhoodRepresentation | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2ImmutableTypeLattice | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2PairwiseNeighbourhoodRepresentation | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
10 | import java.util.ArrayList | ||
11 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | ||
12 | |||
13 | class PairwiseNeighbourhoodBasedStateCoderFactory extends AbstractNeighbourhoodBasedStateCoderFactory { | ||
14 | new() { | ||
15 | } | ||
16 | |||
17 | new(NeighbourhoodOptions options) { | ||
18 | super(options) | ||
19 | } | ||
20 | |||
21 | override protected doCreateStateCoder(NeighbourhoodOptions options) { | ||
22 | new PairwiseNeighbourhoodBasedPartialInterpretationStateCoder(options) | ||
23 | } | ||
24 | } | ||
25 | |||
26 | class PairwiseNeighbourhoodBasedPartialInterpretationStateCoder extends AbstractNeighbourhoodBasedPartialInterpretationStateCoder { | ||
27 | val calculator = new PartialInterpretation2PairwiseNeighbourhoodRepresentation( | ||
28 | new PartialInterpretation2ImmutableTypeLattice) | ||
29 | var PairwiseNeighbourhoodRepresentation<? extends AbstractNodeDescriptor> representation | ||
30 | |||
31 | new(NeighbourhoodOptions options) { | ||
32 | super(options) | ||
33 | } | ||
34 | |||
35 | override protected isRefreshNeeded() { | ||
36 | representation === null | ||
37 | } | ||
38 | |||
39 | override protected doRefreshStateCodes(PartialInterpretation target, NeighbourhoodOptions options) { | ||
40 | representation = calculator.createRepresentation(target, options) | ||
41 | } | ||
42 | |||
43 | override protected doCreateActivationCode(IPatternMatch match) { | ||
44 | val size = match.specification.parameters.size | ||
45 | val res = new ArrayList(size * size) | ||
46 | for (var int i = 0; i < size; i++) { | ||
47 | val a = match.get(i) | ||
48 | for (var int j = 0; j < size; j++) { | ||
49 | val b = match.get(j) | ||
50 | res.add(getPairwiseRepresentation(a, b)) | ||
51 | } | ||
52 | } | ||
53 | match.specification.fullyQualifiedName -> res.hashCode | ||
54 | } | ||
55 | |||
56 | private def getPairwiseRepresentation(Object a, Object b) { | ||
57 | if (b instanceof DefinedElement) { | ||
58 | if (a instanceof DefinedElement) { | ||
59 | representation.getPairwiseRepresentation(a, b) | ||
60 | } else { | ||
61 | representation.getBasicRepresentation(b) | ||
62 | } | ||
63 | } else { | ||
64 | getFallbackCode(b) | ||
65 | } | ||
66 | } | ||
67 | |||
68 | override protected doCreateStateCode() { | ||
69 | representation.modelRepresentation.hashCode | ||
70 | } | ||
71 | |||
72 | override protected doInvalidate() { | ||
73 | representation = null | ||
74 | } | ||
75 | } | ||