diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage')
5 files changed, 168 insertions, 101 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/PartialInterpretationInitialiser.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/PartialInterpretationInitialiser.xtend index ad9d882b..cdc79743 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/PartialInterpretationInitialiser.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/PartialInterpretationInitialiser.xtend | |||
@@ -4,130 +4,152 @@ import hu.bme.mit.inf.dslreasoner.logic.model.builder.TracedOutput | |||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes | 4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ConstantDeclaration | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ConstantDeclaration |
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.FunctionDeclaration | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.FunctionDeclaration |
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntLiteral | ||
8 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguageFactory | 7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.LogiclanguageFactory |
9 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealLiteral | ||
10 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration | 8 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration |
11 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.StringLiteral | ||
12 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | 9 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type |
13 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration | 10 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration |
14 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition | 11 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition |
15 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | 12 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem |
16 | import hu.bme.mit.inf.dslreasoner.logic.model.patterns.SupertypeStar | 13 | import hu.bme.mit.inf.dslreasoner.logic.model.patterns.SupertypeStar |
14 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partial2logicannotations.PartialModelRelation2Assertion | ||
15 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | ||
17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialConstantInterpretation | 16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialConstantInterpretation |
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialFunctionInterpretation | 17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialFunctionInterpretation |
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation | 19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation |
21 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation | ||
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationFactory | 20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationFactory |
21 | import java.math.BigDecimal | ||
23 | import java.util.HashMap | 22 | import java.util.HashMap |
24 | import java.util.Map | 23 | import java.util.Map |
24 | import java.util.SortedSet | ||
25 | import org.eclipse.emf.ecore.util.EcoreUtil | ||
25 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | 26 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine |
26 | import org.eclipse.viatra.query.runtime.emf.EMFScope | 27 | import org.eclipse.viatra.query.runtime.emf.EMFScope |
27 | import org.eclipse.xtend.lib.annotations.Data | 28 | import org.eclipse.xtend.lib.annotations.Data |
28 | 29 | ||
29 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 30 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
30 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partial2logicannotations.PartialModelRelation2Assertion | ||
31 | import org.eclipse.emf.ecore.util.EcoreUtil | ||
32 | 31 | ||
33 | @Data class Problem2PartialInterpretationTrace { | 32 | @Data class Problem2PartialInterpretationTrace { |
34 | Map<TypeDeclaration, PartialTypeInterpratation> type2Interpretation = new HashMap | 33 | Map<TypeDeclaration, PartialComplexTypeInterpretation> type2Interpretation = new HashMap |
35 | Map<RelationDeclaration, PartialRelationInterpretation> relation2Interpretation = new HashMap | 34 | Map<RelationDeclaration, PartialRelationInterpretation> relation2Interpretation = new HashMap |
36 | } | 35 | } |
37 | 36 | ||
37 | /** | ||
38 | * Initializer class for an empty partial interpretation. | ||
39 | */ | ||
38 | class PartialInterpretationInitialiser { | 40 | class PartialInterpretationInitialiser { |
39 | val extension PartialinterpretationFactory factory = PartialinterpretationFactory.eINSTANCE | 41 | val extension PartialinterpretationFactory factory = PartialinterpretationFactory.eINSTANCE |
40 | val extension LogiclanguageFactory factory2 = LogiclanguageFactory.eINSTANCE | 42 | val extension LogiclanguageFactory factory2 = LogiclanguageFactory.eINSTANCE |
41 | 43 | ||
42 | /** | 44 | /** |
43 | * Initialises an empty partial interpretation from a logic problem | 45 | * Initialises an empty partial interpretation from a logic problem and a scope. |
44 | */ | 46 | */ |
45 | def TracedOutput<PartialInterpretation,Problem2PartialInterpretationTrace> initialisePartialInterpretation( | 47 | def TracedOutput<PartialInterpretation,Problem2PartialInterpretationTrace> initialisePartialInterpretation( |
46 | LogicProblem problem, | 48 | LogicProblem problem, |
47 | TypeScopes typeScopes) | 49 | TypeScopes typeScopes) |
48 | { | 50 | { |
49 | val engine = ViatraQueryEngine.on(new EMFScope(problem)) | 51 | |
50 | val trace = new Problem2PartialInterpretationTrace | 52 | val trace = new Problem2PartialInterpretationTrace |
51 | 53 | ||
52 | val res = createPartialInterpretation => [ | 54 | val res = createPartialInterpretation => [ |
53 | it.problem = problem | 55 | it.problem = problem |
54 | 56 | ||
55 | // Elements | 57 | // Initialise primitive elements |
56 | it.minNewElements = typeScopes.maxNewElements | 58 | initBooleans(it) |
57 | it.maxNewElements = typeScopes.minNewElements | 59 | initIntegers(it, typeScopes.knownIntegers, typeScopes.minNewIntegers, typeScopes.maxNewIntegers) |
58 | // elements from problem are included | 60 | initReals(it, typeScopes.knownReals, typeScopes.minNewReals, typeScopes.maxNewReals) |
59 | if(maxNewElements>0) { | 61 | initStrings(it,typeScopes.knownStrings, typeScopes.minNewStrings, typeScopes.maxNewStrings) |
60 | it.openWorldElementPrototypes += createDefinedElement => [it.name = "Symbolic New Element"] | 62 | // Initialise complex elements |
61 | } | 63 | initElements(it, |
62 | 64 | typeScopes.minNewElementsByType, | |
63 | // Booleans | 65 | typeScopes.maxNewElementsByType, |
64 | it.booleanelements += createBooleanElement => [it.name = "true" it.value = true it.valueSet = true] | 66 | typeScopes.minNewElements, |
65 | it.booleanelements += createBooleanElement => [it.name = "false" it.value = false it.valueSet = true] | 67 | typeScopes.maxNewElements, |
68 | trace | ||
69 | ) | ||
66 | 70 | ||
67 | // Integers | 71 | // Initialise relations |
68 | it.maxNewIntegers = typeScopes.maxNewIntegers | 72 | initRelations(it,trace) |
69 | val knownIntegers = (typeScopes.knownIntegers + problem.eAllContents.toIterable.filter(IntLiteral).map[value]).toSet | ||
70 | for(integersInProblem : knownIntegers) { | ||
71 | it.integerelements += createIntegerElement => [it.name = '''«integersInProblem»''' it.value = integersInProblem it.valueSet = true] | ||
72 | } | ||
73 | if(maxNewIntegers>0) { | ||
74 | it.openWorldElementPrototypes += createIntegerElement => [it.name = "Symbolic New Integer" it.valueSet = false] | ||
75 | } | ||
76 | |||
77 | // Reals | ||
78 | it.maxNewReals = typeScopes.maxNewReals | ||
79 | val knownReals = (typeScopes.knownReals + problem.eAllContents.toIterable.filter(RealLiteral).map[value]).toSet | ||
80 | for(realsInProblem : knownReals) { | ||
81 | it.realelements += createRealElement => [it.name = '''«realsInProblem»''' it.value = realsInProblem it.valueSet = true] | ||
82 | } | ||
83 | if(maxNewReals>0) { | ||
84 | it.openWorldElementPrototypes += createRealElement => [it.name = "Symbolic New Real" it.valueSet = false] | ||
85 | } | ||
86 | |||
87 | // Strings | ||
88 | it.maxNewStrings = typeScopes.maxNewStrings | ||
89 | val knownStrings = (typeScopes.knownStrings + problem.eAllContents.toIterable.filter(StringLiteral).map[value]).toSet | ||
90 | for(stringsInProblem : knownStrings) { | ||
91 | it.stringelement += createStringElement => [it.name = '''"«stringsInProblem»"''' it.value=stringsInProblem it.valueSet = true] | ||
92 | } | ||
93 | if(maxNewStrings>0) { | ||
94 | it.openWorldElementPrototypes += createStringElement => [it.name = "Symbolic New String" it.valueSet = false] | ||
95 | } | ||
96 | |||
97 | for(typeDeclaration : problem.types.filter(TypeDeclaration)) { | ||
98 | it.partialtypeinterpratation += typeDeclaration.initialisePartialTypeInterpretation(engine,trace) | ||
99 | } | ||
100 | problem.connectSuperypes(trace) | ||
101 | |||
102 | it.partialrelationinterpretation += problem.relations.filter(RelationDeclaration) | ||
103 | .map[initialisePartialRelationInterpretation(trace)] | ||
104 | for(pMR2A : problem.annotations.filter(PartialModelRelation2Assertion)) { | ||
105 | val relation = pMR2A.targetRelation | ||
106 | val interpretation = relation.lookup(trace.relation2Interpretation) | ||
107 | interpretation.relationlinks+=pMR2A.links.map[EcoreUtil.copy(it)] | ||
108 | } | ||
109 | it.partialfunctioninterpretation += problem.functions.filter(FunctionDeclaration) | ||
110 | .map[initialisePartialFunctionInterpretation(trace)] | ||
111 | it.partialconstantinterpretation += problem.constants.filter(ConstantDeclaration) | ||
112 | .map[initialisePartialConstantDeclaration(trace)] | ||
113 | ] | 73 | ] |
114 | 74 | ||
115 | return new TracedOutput(res,trace) | 75 | return new TracedOutput(res,trace) |
116 | } | 76 | } |
117 | 77 | ||
118 | /** | 78 | def protected boolean initBooleans(PartialInterpretation partialInterpretation) { |
119 | * Initialize type with existing elements | 79 | val booleanInterpretation = createPartialBooleanInterpretation |
120 | */ | 80 | partialInterpretation.partialtypeinterpratation += booleanInterpretation |
121 | def private initialisePartialTypeInterpretation(TypeDeclaration t, ViatraQueryEngine engine, Problem2PartialInterpretationTrace trace) { | 81 | |
122 | val supertypeMatcher = SupertypeStar.Matcher.on(engine) | 82 | val trueElement = createBooleanElement => [it.name = "true" it.value = true it.valueSet = true] |
123 | val res = createPartialTypeInterpratation => [ | 83 | booleanInterpretation.elements += trueElement |
124 | it.interpretationOf = t | 84 | partialInterpretation.newElements+=trueElement |
125 | it.elements += supertypeMatcher.getAllValuesOfsubtype(t) | 85 | |
126 | .filter(TypeDefinition) | 86 | val falseElement = createBooleanElement => [it.name = "false" it.value = false it.valueSet = true] |
127 | .map[elements].flatten | 87 | booleanInterpretation.elements += falseElement |
128 | ] | 88 | partialInterpretation.newElements+=falseElement |
129 | trace.type2Interpretation.put(t,res) | 89 | } |
130 | return res | 90 | |
91 | def protected initIntegers(PartialInterpretation partialInterpretation, SortedSet<Integer> knownIntegers, int minNewIntegers, int maxNewIntegers) { | ||
92 | val integerInterpretation = createPartialIntegerInterpretation | ||
93 | partialInterpretation.partialtypeinterpratation += integerInterpretation | ||
94 | |||
95 | for(knownInteger : knownIntegers) { | ||
96 | val integerElement = createIntegerElement => [it.name = knownInteger.toString it.value = knownInteger it.valueSet = true] | ||
97 | integerInterpretation.elements += integerElement | ||
98 | partialInterpretation.newElements += integerElement | ||
99 | } | ||
100 | if(maxNewIntegers>0) { | ||
101 | throw new UnsupportedOperationException('''Unspecified Integers are currently not supported!''') | ||
102 | } | ||
103 | } | ||
104 | |||
105 | def protected initReals(PartialInterpretation partialInterpretation, SortedSet<BigDecimal> knownReals, int minNewReals, int maxNewReals) { | ||
106 | val realInterpretation = createPartialRealInterpretation | ||
107 | partialInterpretation.partialtypeinterpratation += realInterpretation | ||
108 | |||
109 | for(knownReal : knownReals) { | ||
110 | val realElement = createRealElement => [it.name = knownReal.toString it.value = knownReal it.valueSet = true] | ||
111 | realInterpretation.elements += realElement | ||
112 | partialInterpretation.newElements += realElement | ||
113 | } | ||
114 | if(maxNewReals>0) { | ||
115 | throw new UnsupportedOperationException('''Unspecified Real values are currently not supported!''') | ||
116 | } | ||
117 | } | ||
118 | |||
119 | def protected initStrings(PartialInterpretation partialInterpretation, SortedSet<String> knownStrings, int minNewStrings, int maxNewStrings) { | ||
120 | val stringInterpretation = createPartialStringInterpretation | ||
121 | partialInterpretation.partialtypeinterpratation += stringInterpretation | ||
122 | |||
123 | for(knownString : knownStrings) { | ||
124 | val stringElement = createStringElement => [it.name = '''"«knownString»"''' it.value = knownString it.valueSet = true] | ||
125 | stringInterpretation.elements += stringElement | ||
126 | partialInterpretation.newElements += stringElement | ||
127 | } | ||
128 | if(maxNewStrings>0) { | ||
129 | throw new UnsupportedOperationException('''Unspecified String values are currently not supported!''') | ||
130 | } | ||
131 | } | ||
132 | |||
133 | def protected initElements(PartialInterpretation interpretation, | ||
134 | Map<Type, Integer> minNewElementsByType, Map<Type, Integer> maxNewElementsByType, | ||
135 | int minNewElements, int maxNewElements, | ||
136 | Problem2PartialInterpretationTrace trace) | ||
137 | { | ||
138 | val engine = ViatraQueryEngine.on(new EMFScope(interpretation.problem)) | ||
139 | // Elements | ||
140 | interpretation.minNewElements = minNewElements | ||
141 | interpretation.maxNewElements = maxNewElements | ||
142 | // elements from problem are included | ||
143 | if(maxNewElements>0) { | ||
144 | val newElements = createDefinedElement => [it.name = "New Objects"] | ||
145 | interpretation.openWorldElements += newElements | ||
146 | } | ||
147 | |||
148 | for(typeDeclaration : interpretation.problem.types.filter(TypeDeclaration)) { | ||
149 | val typeInterpretation = typeDeclaration.initialisePartialTypeInterpretation(engine,trace) | ||
150 | interpretation.partialtypeinterpratation += typeInterpretation | ||
151 | } | ||
152 | interpretation.problem.connectSuperypes(trace) | ||
131 | } | 153 | } |
132 | 154 | ||
133 | def private connectSuperypes(LogicProblem problem, Problem2PartialInterpretationTrace trace) { | 155 | def private connectSuperypes(LogicProblem problem, Problem2PartialInterpretationTrace trace) { |
@@ -140,6 +162,32 @@ class PartialInterpretationInitialiser { | |||
140 | } | 162 | } |
141 | } | 163 | } |
142 | 164 | ||
165 | def private initRelations(PartialInterpretation interpretation, Problem2PartialInterpretationTrace trace) { | ||
166 | interpretation.partialrelationinterpretation += interpretation.problem.relations.filter(RelationDeclaration) | ||
167 | .map[initialisePartialRelationInterpretation(trace)] | ||
168 | for(pMR2A : interpretation.problem.annotations.filter(PartialModelRelation2Assertion)) { | ||
169 | val relation = pMR2A.targetRelation | ||
170 | val r = relation.lookup(trace.relation2Interpretation) | ||
171 | r.relationlinks+=pMR2A.links.map[EcoreUtil.copy(it)] | ||
172 | } | ||
173 | // interpretation.partialfunctioninterpretation += interpretation.problem.functions.filter(FunctionDeclaration) | ||
174 | // .map[initialisePartialFunctionInterpretation(trace)] | ||
175 | // interpretation.partialconstantinterpretation += interpretation.problem.constants.filter(ConstantDeclaration) | ||
176 | // .map[initialisePartialConstantDeclaration(trace)] | ||
177 | } | ||
178 | |||
179 | def private initialisePartialTypeInterpretation(TypeDeclaration t, ViatraQueryEngine engine, Problem2PartialInterpretationTrace trace) { | ||
180 | val supertypeMatcher = SupertypeStar.Matcher.on(engine) | ||
181 | val res = createPartialComplexTypeInterpretation => [ | ||
182 | it.interpretationOf = t | ||
183 | it.elements += supertypeMatcher.getAllValuesOfsubtype(t) | ||
184 | .filter(TypeDefinition) | ||
185 | .map[elements].flatten | ||
186 | ] | ||
187 | trace.type2Interpretation.put(t,res) | ||
188 | return res | ||
189 | } | ||
190 | |||
143 | def private initialisePartialRelationInterpretation(RelationDeclaration r, Problem2PartialInterpretationTrace trace) { | 191 | def private initialisePartialRelationInterpretation(RelationDeclaration r, Problem2PartialInterpretationTrace trace) { |
144 | val res = createPartialRelationInterpretation => [ | 192 | val res = createPartialRelationInterpretation => [ |
145 | it.interpretationOf = r | 193 | it.interpretationOf = r |
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 a5739edf..bf593add 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 | |||
@@ -13,6 +13,8 @@ import java.util.Map | |||
13 | import java.util.Set | 13 | import java.util.Set |
14 | 14 | ||
15 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 15 | 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 | ||
16 | 18 | ||
17 | abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresentation,NodeRepresentation> { | 19 | abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresentation,NodeRepresentation> { |
18 | private val boolean deepRepresentation | 20 | private val boolean deepRepresentation |
@@ -33,6 +35,7 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
33 | * @param model The model to be represented. | 35 | * @param model The model to be represented. |
34 | * @param range The range of the neighbourhood. | 36 | * @param range The range of the neighbourhood. |
35 | * @param parallels The maximal number of parallel references to be differentiated. | 37 | * @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. | ||
36 | */ | 39 | */ |
37 | def public createRepresentation(PartialInterpretation model, int range, int parallels, int maxNumber) { | 40 | def public createRepresentation(PartialInterpretation model, int range, int parallels, int maxNumber) { |
38 | return createRepresentation(model,range,parallels,maxNumber,null,null) | 41 | return createRepresentation(model,range,parallels,maxNumber,null,null) |
@@ -187,10 +190,7 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
187 | return | 190 | return |
188 | model.problem.elements + | 191 | model.problem.elements + |
189 | model.newElements + | 192 | model.newElements + |
190 | model.booleanelements+ | 193 | model.openWorldElements |
191 | model.integerelements+ | ||
192 | model.stringelement+ | ||
193 | model.realelements | ||
194 | } | 194 | } |
195 | 195 | ||
196 | def private fillTypes(PartialInterpretation model, Map<DefinedElement, Set<String>> node2Type, Set<TypeDeclaration> relevantTypes) { | 196 | def private fillTypes(PartialInterpretation model, Map<DefinedElement, Set<String>> node2Type, Set<TypeDeclaration> relevantTypes) { |
@@ -202,10 +202,14 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
202 | // // Dont need | 202 | // // Dont need |
203 | // } | 203 | // } |
204 | for(typeInterpretation : model.partialtypeinterpratation) { | 204 | for(typeInterpretation : model.partialtypeinterpratation) { |
205 | val type = typeInterpretation.interpretationOf | 205 | if(typeInterpretation instanceof PartialPrimitiveInterpretation) { |
206 | if(type.isRelevant(relevantTypes)) { | 206 | |
207 | for(element : typeInterpretation.elements) { | 207 | } else if(typeInterpretation instanceof PartialComplexTypeInterpretation) { |
208 | element.lookup(node2Type).add(type.name) | 208 | val type = typeInterpretation.interpretationOf |
209 | if(type.isRelevant(relevantTypes)) { | ||
210 | for(element : typeInterpretation.elements) { | ||
211 | element.lookup(node2Type).add(type.name) | ||
212 | } | ||
209 | } | 213 | } |
210 | } | 214 | } |
211 | } | 215 | } |
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 c421ace6..f55a501a 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 | |||
@@ -18,6 +18,8 @@ import org.eclipse.viatra.dse.statecode.IStateCoderFactory | |||
18 | import org.eclipse.viatra.query.runtime.api.IPatternMatch | 18 | import org.eclipse.viatra.query.runtime.api.IPatternMatch |
19 | import org.eclipse.xtend.lib.annotations.Accessors | 19 | import org.eclipse.xtend.lib.annotations.Accessors |
20 | import org.eclipse.xtend.lib.annotations.Data | 20 | import org.eclipse.xtend.lib.annotations.Data |
21 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation | ||
22 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | ||
21 | 23 | ||
22 | class IdentifierBasedStateCoderFactory implements IStateCoderFactory{ | 24 | class IdentifierBasedStateCoderFactory implements IStateCoderFactory{ |
23 | 25 | ||
@@ -116,7 +118,13 @@ class IdentifierBasedStateCoder implements IStateCoder{ | |||
116 | } else if(element instanceof PartialRelationInterpretation) { | 118 | } else if(element instanceof PartialRelationInterpretation) { |
117 | return element.interpretationOf.name.hashCode | 119 | return element.interpretationOf.name.hashCode |
118 | } else if(element instanceof PartialTypeInterpratation) { | 120 | } else if(element instanceof PartialTypeInterpratation) { |
119 | return element.interpretationOf.name.hashCode | 121 | if(element instanceof PartialPrimitiveInterpretation) { |
122 | element.class.simpleName.hashCode | ||
123 | } else if (element instanceof PartialComplexTypeInterpretation){ | ||
124 | return element.interpretationOf.name.hashCode | ||
125 | } else { | ||
126 | throw new UnsupportedOperationException('''Unsupported type: «element.class.simpleName»''') | ||
127 | } | ||
120 | } else { | 128 | } else { |
121 | println(element) | 129 | println(element) |
122 | throw new UnsupportedOperationException('''Unsupported type: «element.class.simpleName»''') | 130 | throw new UnsupportedOperationException('''Unsupported type: «element.class.simpleName»''') |
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 5fb85b0c..65a8207e 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 | |||
@@ -30,6 +30,8 @@ import java.util.Set | |||
30 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration | 30 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDeclaration |
31 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration | 31 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration |
32 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2NeighbourhoodRepresentation | 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 | ||
33 | 35 | ||
34 | class NeighbourhoodBasedStateCoderFactory implements IStateCoderFactory { | 36 | class NeighbourhoodBasedStateCoderFactory implements IStateCoderFactory { |
35 | val List<NeighbourhoodBasedPartialInterpretationStateCoder> statecoders = new LinkedList | 37 | val List<NeighbourhoodBasedPartialInterpretationStateCoder> statecoders = new LinkedList |
@@ -142,7 +144,13 @@ class NeighbourhoodBasedPartialInterpretationStateCoder implements IStateCoder{ | |||
142 | } else if(o instanceof PartialRelationInterpretation) { | 144 | } else if(o instanceof PartialRelationInterpretation) { |
143 | return o.interpretationOf.name | 145 | return o.interpretationOf.name |
144 | } else if(o instanceof PartialTypeInterpratation) { | 146 | } else if(o instanceof PartialTypeInterpratation) { |
145 | return o.interpretationOf.name | 147 | if(o instanceof PartialPrimitiveInterpretation) { |
148 | o.class.simpleName.hashCode | ||
149 | } else if (o instanceof PartialComplexTypeInterpretation){ | ||
150 | return o.interpretationOf.name.hashCode | ||
151 | } else { | ||
152 | throw new UnsupportedOperationException('''Unsupported type: «o.class.simpleName»''') | ||
153 | } | ||
146 | } else { | 154 | } else { |
147 | throw new UnsupportedOperationException('''Unsupported type: «o.class.simpleName»''') | 155 | throw new UnsupportedOperationException('''Unsupported type: «o.class.simpleName»''') |
148 | } | 156 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/visualisation/PartialInterpretation2Gml.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/visualisation/PartialInterpretation2Gml.xtend index 6e948827..2b42a8b1 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/visualisation/PartialInterpretation2Gml.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/visualisation/PartialInterpretation2Gml.xtend | |||
@@ -1,14 +1,15 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation |
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement | 3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement |
5 | import java.util.Map | 4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation |
6 | import java.util.HashMap | ||
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition | ||
8 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type |
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition |
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink | 7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink |
11 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | 8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation |
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialRelationInterpretation | ||
11 | import java.util.HashMap | ||
12 | import java.util.Map | ||
12 | import java.util.Set | 13 | import java.util.Set |
13 | 14 | ||
14 | class PartialInterpretation2Gml { | 15 | class PartialInterpretation2Gml { |
@@ -16,10 +17,7 @@ class PartialInterpretation2Gml { | |||
16 | return | 17 | return |
17 | model.problem.elements + | 18 | model.problem.elements + |
18 | model.newElements + | 19 | model.newElements + |
19 | model.booleanelements+ | 20 | model.openWorldElements |
20 | model.integerelements+ | ||
21 | model.stringelement+ | ||
22 | model.realelements | ||
23 | } | 21 | } |
24 | 22 | ||
25 | def public transform(PartialInterpretation i) { | 23 | def public transform(PartialInterpretation i) { |
@@ -41,8 +39,9 @@ class PartialInterpretation2Gml { | |||
41 | '''.toString | 39 | '''.toString |
42 | } | 40 | } |
43 | def typesOfElement(DefinedElement e, PartialInterpretation i) { | 41 | def typesOfElement(DefinedElement e, PartialInterpretation i) { |
44 | i.problem.types.filter(TypeDefinition).filter[it.elements.contains(e)] + | 42 | val typesElementDefinedIn= i.problem.types.filter(TypeDefinition).filter[it.elements.contains(e)] |
45 | i.partialtypeinterpratation.filter[it.elements.contains(e)].map[it.interpretationOf] | 43 | val typesElementAddedDuringGeneration = i.partialtypeinterpratation.filter(PartialComplexTypeInterpretation).filter[it.elements.contains(e)].map[it.interpretationOf] |
44 | return typesElementDefinedIn+typesElementAddedDuringGeneration | ||
46 | } | 45 | } |
47 | 46 | ||
48 | val protected titleSize = 16 | 47 | val protected titleSize = 16 |