diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner')
2 files changed, 73 insertions, 2 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend index 8aaaacb5..1a276090 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend | |||
@@ -40,7 +40,16 @@ class InstanceModel2PartialInterpretation { | |||
40 | return transform(metamodelTranslationResult,objects,withID) | 40 | return transform(metamodelTranslationResult,objects,withID) |
41 | } | 41 | } |
42 | 42 | ||
43 | public def transform( | 43 | public def transformWithTrace( |
44 | TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, | ||
45 | Resource resource, | ||
46 | boolean withID) | ||
47 | { | ||
48 | val objects = resource.allContents.toList | ||
49 | return transformWithTrace(metamodelTranslationResult,objects,withID) | ||
50 | } | ||
51 | |||
52 | public def transformWithTrace( | ||
44 | TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, | 53 | TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, |
45 | List<EObject> objects, | 54 | List<EObject> objects, |
46 | boolean withID) | 55 | boolean withID) |
@@ -130,7 +139,15 @@ class InstanceModel2PartialInterpretation { | |||
130 | } | 139 | } |
131 | } | 140 | } |
132 | 141 | ||
133 | return partialInterpretation | 142 | return new TracedOutput(partialInterpretation,object2DefinedElement) |
143 | } | ||
144 | |||
145 | public def transform( | ||
146 | TracedOutput<LogicProblem, Ecore2Logic_Trace> metamodelTranslationResult, | ||
147 | List<EObject> objects, | ||
148 | boolean withID) | ||
149 | { | ||
150 | return transformWithTrace(metamodelTranslationResult,objects,withID).output | ||
134 | } | 151 | } |
135 | 152 | ||
136 | private def createTypeScopesFromKnownAttributeValues(List<EObject> objects, Set<EAttribute> attributesUsed) { | 153 | private def createTypeScopesFromKnownAttributeValues(List<EObject> objects, Set<EAttribute> attributesUsed) { |
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 8b5d7f2c..080c3b79 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 | |||
@@ -92,6 +92,34 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
92 | 92 | ||
93 | return res; | 93 | return res; |
94 | } | 94 | } |
95 | |||
96 | /** | ||
97 | * Creates a neighbourhood representation with traces | ||
98 | * @param model The model to be represented. | ||
99 | * @param range The range of the neighbourhood. | ||
100 | * @param parallels The maximal number of parallel references to be differentiated. | ||
101 | * @param maxNumber The maximal number of elements in a equivalence class that can be differentiated. | ||
102 | * @param relevantTypes The set of types to include in the diversity calculations (when value is null, all types are considered) | ||
103 | * @param relevantRelations The set of relations to include in the diversity calculations (when value is null, all relations are considered) | ||
104 | * @param relevantPatterns The set of patterns to include in the diversity calculations | ||
105 | * (NOT the well-formedness constraints) - when value is null, NO patterns are considered | ||
106 | */ | ||
107 | def public createRepresentation(PartialInterpretation model, int range, int parallels, int maxNumber, | ||
108 | Map<String,List<List<DefinedElement>>> relevantPatterns) { | ||
109 | |||
110 | val Map<DefinedElement, Set<String>> types = new HashMap | ||
111 | fillTypes(model, types, null) | ||
112 | val Map<DefinedElement, List<IncomingRelation<DefinedElement>>> IncomingRelations = new HashMap; | ||
113 | val Map<DefinedElement, List<OutgoingRelation<DefinedElement>>> OutgoingRelations = new HashMap; | ||
114 | fillReferences(model, IncomingRelations, OutgoingRelations, null); | ||
115 | val Map<DefinedElement, List<PatternRelation<DefinedElement>>> PatternRelations = createPatternRelations(model, | ||
116 | relevantPatterns); | ||
117 | |||
118 | val res = doRecursiveNeighbourCalculation(model, types, IncomingRelations, OutgoingRelations, PatternRelations,range, parallels, | ||
119 | maxNumber); | ||
120 | |||
121 | return res; | ||
122 | } | ||
95 | 123 | ||
96 | /** | 124 | /** |
97 | * Collects all pattern relations for shaping | 125 | * Collects all pattern relations for shaping |
@@ -135,6 +163,32 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation<ModelRepresenta | |||
135 | return result; | 163 | return result; |
136 | 164 | ||
137 | } | 165 | } |
166 | |||
167 | def Map<DefinedElement, List<PatternRelation<DefinedElement>>> createPatternRelations( | ||
168 | PartialInterpretation model, Map<String,List<List<DefinedElement>>> relevantPatterns) { | ||
169 | val Map<DefinedElement, List<PatternRelation<DefinedElement>>> result=new HashMap; | ||
170 | |||
171 | for (element : model.elements) { | ||
172 | result.put(element,new LinkedList<PatternRelation<DefinedElement>>) | ||
173 | } | ||
174 | if (relevantPatterns===null) return result; | ||
175 | for (patternName : relevantPatterns.keySet) { | ||
176 | val allMatches=relevantPatterns.get(patternName) | ||
177 | |||
178 | for (match : allMatches) { | ||
179 | var id=0; | ||
180 | for (matchedElement:match) { | ||
181 | if (matchedElement!==null) { | ||
182 | result.get(matchedElement).add(new PatternRelation<DefinedElement>(patternName,id,match)) | ||
183 | } | ||
184 | id++ | ||
185 | } | ||
186 | } | ||
187 | } | ||
188 | |||
189 | return result; | ||
190 | |||
191 | } | ||
138 | 192 | ||
139 | def private isRelevant(TypeDeclaration t, Set<TypeDeclaration> relevantTypes) { | 193 | def private isRelevant(TypeDeclaration t, Set<TypeDeclaration> relevantTypes) { |
140 | if (relevantTypes === null) { | 194 | if (relevantTypes === null) { |