aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend
diff options
context:
space:
mode:
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend')
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend214
1 files changed, 214 insertions, 0 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
new file mode 100644
index 00000000..41482b28
--- /dev/null
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend
@@ -0,0 +1,214 @@
1package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood
2
3import java.util.HashMap
4import java.util.Map
5import java.util.Set
6import org.eclipse.xtend.lib.annotations.Data
7
8@Data abstract class AbstractNodeDescriptor {
9 long dataHash
10
11// @Pure
12// @Override
13// override public boolean equals(Object obj) {
14// if (this === obj)
15// return true;
16// if (obj === null)
17// return false;
18// if (getClass() != obj.getClass())
19// return false;
20// val AbstractNodeDescriptor other = obj as AbstractNodeDescriptor;
21// if (other.dataHash != this.dataHash)
22// return false;
23// return true;
24// }
25}
26
27@Data class LocalNodeDescriptor extends AbstractNodeDescriptor{
28 Set<String> types
29 String id;
30 new(String id, Set<String> types) {
31 super(calcualteDataHash(id,types))
32 this.types = types
33 this.id = id
34 }
35
36 def private static calcualteDataHash(String id, Set<String> types) {
37 val int prime = 31;
38 var result = 0
39 if(id !== null)
40 result = id.hashCode();
41 if(types !== null) {
42 result = prime * result + types.hashCode
43 }
44 return result
45 }
46
47 override hashCode() {
48 return this.dataHash.hashCode
49 }
50
51 override toString() {
52 return class.name + this.dataHash
53 }
54
55// @Pure
56// @Override
57// override public boolean equals(Object obj) {
58// if (this === obj)
59// return true;
60// if (obj === null)
61// return false;
62// if (getClass() != obj.getClass())
63// return false;
64// val AbstractNodeDescriptor other = obj as AbstractNodeDescriptor;
65// if (other.dataHash != this.dataHash)
66// return false;
67// return true;
68// }
69
70// @Pure
71// override public boolean equals(Object obj) {
72// if (this === obj)
73// return true;
74// if (obj === null)
75// return false;
76// if (getClass() != obj.getClass())
77// return false;
78// if (!super.equals(obj))
79// return false;
80// val LocalNodeDescriptor other = obj as LocalNodeDescriptor;
81// if (this.clazz === null) {
82// if (other.clazz != null)
83// return false;
84// } else if (!this.clazz.equals(other.clazz))
85// return false;
86// return true;
87// }
88}
89
90@Data class IncomingRelation<FROM> {
91 FROM from
92 String type
93}
94
95@Data class OutgoingRelation<TO> {
96 TO to
97 String type
98}
99
100@Data class FurtherNodeDescriptor<NodeRep> extends AbstractNodeDescriptor{
101
102 NodeRep previousRepresentation
103 Map<IncomingRelation<NodeRep>,Integer> incomingEdges
104 Map<OutgoingRelation<NodeRep>,Integer> outgoingEdges
105
106 new(
107 NodeRep previousRepresentation,
108 Map<IncomingRelation<NodeRep>,Integer> incomingEdges,
109 Map<OutgoingRelation<NodeRep>,Integer> outgoingEdges)
110 {
111 super(calculateDataHash(previousRepresentation,incomingEdges,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 }
134
135 override toString() {
136 return class.name + dataHash
137// return '''[«previousRepresentation»,(«FOR
138// in: incomingEdges.entrySet»(«in.key.type.name»=«in.key.from»,«in.value»)«ENDFOR»),(«FOR
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 }
142
143// @Pure
144// @Override
145// override public boolean equals(Object obj) {
146// if (this === obj)
147// return true;
148// if (obj === null)
149// return false;
150// if (getClass() != obj.getClass())
151// return false;
152// val AbstractNodeDescriptor other = obj as AbstractNodeDescriptor;
153// if (other.dataHash != this.dataHash)
154// return false;
155// return true;
156// }
157
158// @Pure
159// override public boolean equals(Object obj) {
160// if (this === obj)
161// return true;
162// if (obj === null)
163// return false;
164// if (getClass() != obj.getClass())
165// return false;
166// if (!super.equals(obj))
167// return false;
168// val FurtherNodeDescriptor<?> other = obj as FurtherNodeDescriptor<?>;
169// if (this.previousRepresentation === null) {
170// if (other.previousRepresentation != null)
171// return false;
172//
173// }
174//// } else if (!this.previousRepresentation.equals(other.previousRepresentation))
175//// return false;
176// if (this.incomingEdges === null) {
177// if (other.incomingEdges != null)
178// return false;
179// } else if (!this.incomingEdges.equals(other.incomingEdges))
180// return false;
181// if (this.outgoingEdges === null) {
182// if (other.outgoingEdges != null)
183// return false;
184// } else if (!this.outgoingEdges.equals(other.outgoingEdges))
185// return false;
186// if (this.attributeValues === null) {
187// if (other.attributeValues != null)
188// return false;
189// } else if (!this.attributeValues.equals(other.attributeValues))
190// return false;
191// return true;
192// }
193}
194
195/*
196@Data
197class ModelDescriptor {
198 int dataHash
199 int unknownElements
200 Map<? extends AbstractNodeDescriptor,Integer> knownElements
201
202 public new(Map<? extends AbstractNodeDescriptor,Integer> knownElements, int unknownElements) {
203 this.dataHash = calculateDataHash(knownElements,unknownElements)
204 this.unknownElements = unknownElements
205 this.knownElements = knownElements
206 }
207
208 def private static calculateDataHash(Map<? extends AbstractNodeDescriptor,Integer> knownElements, int unknownElements)
209 {
210 val int prime = 31;
211 return knownElements.hashCode * prime + unknownElements.hashCode
212 }
213}
214*/ \ No newline at end of file