diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend index 20d24b77..bf816de9 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend | |||
@@ -6,7 +6,7 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | |||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration |
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | 7 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type |
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationStatistics | 8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationStatistics |
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ScopePropagator | 9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagator |
10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.GeneratedPatterns | 10 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.GeneratedPatterns |
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.ObjectCreationPrecondition | 11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.ObjectCreationPrecondition |
12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | 12 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation |
@@ -98,10 +98,12 @@ class RefinementRuleProvider { | |||
98 | val newLink2 = factory2.createBinaryElementRelationLink => [it.param1 = newElement it.param2 = container] | 98 | val newLink2 = factory2.createBinaryElementRelationLink => [it.param1 = newElement it.param2 = container] |
99 | inverseRelationInterpretation.relationlinks+=newLink2 | 99 | inverseRelationInterpretation.relationlinks+=newLink2 |
100 | 100 | ||
101 | val propagatorStartTime = System.nanoTime | ||
102 | statistics.addExecutionTime(propagatorStartTime-startTime) | ||
103 | |||
101 | // Scope propagation | 104 | // Scope propagation |
102 | scopePropagator.propagateAdditionToType(typeInterpretation) | 105 | scopePropagator.propagateAdditionToType(typeInterpretation) |
103 | 106 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | |
104 | statistics.addExecutionTime(System.nanoTime-startTime) | ||
105 | ] | 107 | ] |
106 | } else { | 108 | } else { |
107 | ruleBuilder.action[match | | 109 | ruleBuilder.action[match | |
@@ -132,10 +134,12 @@ class RefinementRuleProvider { | |||
132 | val newLink = factory2.createBinaryElementRelationLink => [it.param1 = container it.param2 = newElement] | 134 | val newLink = factory2.createBinaryElementRelationLink => [it.param1 = container it.param2 = newElement] |
133 | relationInterpretation.relationlinks+=newLink | 135 | relationInterpretation.relationlinks+=newLink |
134 | 136 | ||
137 | val propagatorStartTime = System.nanoTime | ||
138 | statistics.addExecutionTime(propagatorStartTime-startTime) | ||
139 | |||
135 | // Scope propagation | 140 | // Scope propagation |
136 | scopePropagator.propagateAdditionToType(typeInterpretation) | 141 | scopePropagator.propagateAdditionToType(typeInterpretation) |
137 | 142 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | |
138 | statistics.addExecutionTime(System.nanoTime-startTime) | ||
139 | ] | 143 | ] |
140 | } | 144 | } |
141 | } else { | 145 | } else { |
@@ -162,29 +166,31 @@ class RefinementRuleProvider { | |||
162 | typeInterpretation.elements += newElement | 166 | typeInterpretation.elements += newElement |
163 | typeInterpretation.supertypeInterpretation.forEach[it.elements += newElement] | 167 | typeInterpretation.supertypeInterpretation.forEach[it.elements += newElement] |
164 | 168 | ||
169 | val propagatorStartTime = System.nanoTime | ||
170 | statistics.addExecutionTime(propagatorStartTime-startTime) | ||
171 | |||
165 | // Scope propagation | 172 | // Scope propagation |
166 | scopePropagator.propagateAdditionToType(typeInterpretation) | 173 | scopePropagator.propagateAdditionToType(typeInterpretation) |
167 | 174 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | |
168 | statistics.addExecutionTime(System.nanoTime-startTime) | ||
169 | ] | 175 | ] |
170 | } | 176 | } |
171 | return ruleBuilder.build | 177 | return ruleBuilder.build |
172 | } | 178 | } |
173 | 179 | ||
174 | def createRelationRefinementRules(GeneratedPatterns patterns, ModelGenerationStatistics statistics) { | 180 | def createRelationRefinementRules(GeneratedPatterns patterns, ScopePropagator scopePropagator, ModelGenerationStatistics statistics) { |
175 | val res = new LinkedHashMap | 181 | val res = new LinkedHashMap |
176 | for(LHSEntry: patterns.refinerelationQueries.entrySet) { | 182 | for(LHSEntry: patterns.refinerelationQueries.entrySet) { |
177 | val declaration = LHSEntry.key.key | 183 | val declaration = LHSEntry.key.key |
178 | val inverseReference = LHSEntry.key.value | 184 | val inverseReference = LHSEntry.key.value |
179 | val lhs = LHSEntry.value as IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> | 185 | val lhs = LHSEntry.value as IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> |
180 | val rule = createRelationRefinementRule(declaration,inverseReference,lhs,statistics) | 186 | val rule = createRelationRefinementRule(declaration,inverseReference,lhs,scopePropagator,statistics) |
181 | res.put(LHSEntry.key,rule) | 187 | res.put(LHSEntry.key,rule) |
182 | } | 188 | } |
183 | return res | 189 | return res |
184 | } | 190 | } |
185 | 191 | ||
186 | def private BatchTransformationRule<GenericPatternMatch, ViatraQueryMatcher<GenericPatternMatch>> | 192 | def private BatchTransformationRule<GenericPatternMatch, ViatraQueryMatcher<GenericPatternMatch>> |
187 | createRelationRefinementRule(RelationDeclaration declaration, Relation inverseRelation, IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> lhs, ModelGenerationStatistics statistics) | 193 | createRelationRefinementRule(RelationDeclaration declaration, Relation inverseRelation, IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> lhs, ScopePropagator scopePropagator, ModelGenerationStatistics statistics) |
188 | { | 194 | { |
189 | val name = '''addRelation_«declaration.name.canonizeName»«IF inverseRelation != null»_and_«inverseRelation.name.canonizeName»«ENDIF»''' | 195 | val name = '''addRelation_«declaration.name.canonizeName»«IF inverseRelation != null»_and_«inverseRelation.name.canonizeName»«ENDIF»''' |
190 | val ruleBuilder = factory.createRule | 196 | val ruleBuilder = factory.createRule |
@@ -201,7 +207,13 @@ class RefinementRuleProvider { | |||
201 | val trg = match.get(4) as DefinedElement | 207 | val trg = match.get(4) as DefinedElement |
202 | val link = createBinaryElementRelationLink => [it.param1 = src it.param2 = trg] | 208 | val link = createBinaryElementRelationLink => [it.param1 = src it.param2 = trg] |
203 | relationInterpretation.relationlinks += link | 209 | relationInterpretation.relationlinks += link |
204 | statistics.addExecutionTime(System.nanoTime-startTime) | 210 | |
211 | val propagatorStartTime = System.nanoTime | ||
212 | statistics.addExecutionTime(propagatorStartTime-startTime) | ||
213 | |||
214 | // Scope propagation | ||
215 | scopePropagator.propagateAdditionToRelation(declaration) | ||
216 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | ||
205 | ] | 217 | ] |
206 | } else { | 218 | } else { |
207 | ruleBuilder.action [ match | | 219 | ruleBuilder.action [ match | |
@@ -217,7 +229,13 @@ class RefinementRuleProvider { | |||
217 | relationInterpretation.relationlinks += link | 229 | relationInterpretation.relationlinks += link |
218 | val inverseLink = createBinaryElementRelationLink => [it.param1 = trg it.param2 = src] | 230 | val inverseLink = createBinaryElementRelationLink => [it.param1 = trg it.param2 = src] |
219 | inverseInterpretation.relationlinks += inverseLink | 231 | inverseInterpretation.relationlinks += inverseLink |
220 | statistics.addExecutionTime(System.nanoTime-startTime) | 232 | |
233 | val propagatorStartTime = System.nanoTime | ||
234 | statistics.addExecutionTime(propagatorStartTime-startTime) | ||
235 | |||
236 | // Scope propagation | ||
237 | scopePropagator.propagateAdditionToRelation(declaration) | ||
238 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | ||
221 | ] | 239 | ] |
222 | } | 240 | } |
223 | 241 | ||