diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules')
2 files changed, 89 insertions, 64 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/GoalConstraintProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/GoalConstraintProvider.xtend index 238ade5b..d2ee80dc 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/GoalConstraintProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/GoalConstraintProvider.xtend | |||
@@ -15,9 +15,8 @@ class GoalConstraintProvider { | |||
15 | val queries = entry.value | 15 | val queries = entry.value |
16 | val targetRelationName = constraint.relation.name | 16 | val targetRelationName = constraint.relation.name |
17 | val query = queries.unfinishedMultiplicityQuery | 17 | val query = queries.unfinishedMultiplicityQuery |
18 | val minValue = constraint.lowerBound | ||
19 | val containment = constraint.containment | 18 | val containment = constraint.containment |
20 | res += new MultiplicityGoalConstraintCalculator(targetRelationName, query, minValue, containment, 1) | 19 | res += new MultiplicityGoalConstraintCalculator(targetRelationName, query, containment, 1) |
21 | } | 20 | } |
22 | } | 21 | } |
23 | return res | 22 | return res |
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 0b8a9019..863ee18b 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 | |||
@@ -32,9 +32,12 @@ import java.util.LinkedHashMap | |||
32 | import java.util.LinkedList | 32 | import java.util.LinkedList |
33 | import java.util.List | 33 | import java.util.List |
34 | import java.util.Map | 34 | import java.util.Map |
35 | import org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine | ||
35 | import org.eclipse.viatra.query.runtime.api.GenericPatternMatch | 36 | import org.eclipse.viatra.query.runtime.api.GenericPatternMatch |
36 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification | 37 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification |
38 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | ||
37 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | 39 | import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher |
40 | import org.eclipse.viatra.query.runtime.emf.EMFScope | ||
38 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRule | 41 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRule |
39 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRuleFactory | 42 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRuleFactory |
40 | import org.eclipse.xtend.lib.annotations.Data | 43 | import org.eclipse.xtend.lib.annotations.Data |
@@ -45,6 +48,8 @@ class RefinementRuleProvider { | |||
45 | val extension PartialinterpretationFactory factory2 = PartialinterpretationFactory.eINSTANCE | 48 | val extension PartialinterpretationFactory factory2 = PartialinterpretationFactory.eINSTANCE |
46 | val extension LogiclanguageFactory factory3 = LogiclanguageFactory.eINSTANCE | 49 | val extension LogiclanguageFactory factory3 = LogiclanguageFactory.eINSTANCE |
47 | 50 | ||
51 | var AdvancedViatraQueryEngine queryEngine | ||
52 | |||
48 | def canonizeName(String name) { | 53 | def canonizeName(String name) { |
49 | return name.replace(' ','_') | 54 | return name.replace(' ','_') |
50 | } | 55 | } |
@@ -60,6 +65,7 @@ class RefinementRuleProvider { | |||
60 | { | 65 | { |
61 | val res = new LinkedHashMap | 66 | val res = new LinkedHashMap |
62 | val recursiveObjectCreation = recursiveObjectCreation(p,i) | 67 | val recursiveObjectCreation = recursiveObjectCreation(p,i) |
68 | queryEngine = ViatraQueryEngine.on(new EMFScope(i)) as AdvancedViatraQueryEngine | ||
63 | for(LHSEntry: patterns.refineObjectQueries.entrySet) { | 69 | for(LHSEntry: patterns.refineObjectQueries.entrySet) { |
64 | val containmentRelation = LHSEntry.key.containmentRelation | 70 | val containmentRelation = LHSEntry.key.containmentRelation |
65 | val inverseRelation = LHSEntry.key.inverseContainment | 71 | val inverseRelation = LHSEntry.key.inverseContainment |
@@ -90,8 +96,7 @@ class RefinementRuleProvider { | |||
90 | if(inverseRelation!== null) { | 96 | if(inverseRelation!== null) { |
91 | ruleBuilder.action[match | | 97 | ruleBuilder.action[match | |
92 | statistics.incrementTransformationCount | 98 | statistics.incrementTransformationCount |
93 | // println(name) | 99 | // println(name) |
94 | val startTime = System.nanoTime | ||
95 | //val problem = match.get(0) as LogicProblem | 100 | //val problem = match.get(0) as LogicProblem |
96 | val interpretation = match.get(1) as PartialInterpretation | 101 | val interpretation = match.get(1) as PartialInterpretation |
97 | val relationInterpretation = match.get(2) as PartialRelationInterpretation | 102 | val relationInterpretation = match.get(2) as PartialRelationInterpretation |
@@ -99,79 +104,89 @@ class RefinementRuleProvider { | |||
99 | val typeInterpretation = match.get(4) as PartialComplexTypeInterpretation | 104 | val typeInterpretation = match.get(4) as PartialComplexTypeInterpretation |
100 | val container = match.get(5) as DefinedElement | 105 | val container = match.get(5) as DefinedElement |
101 | 106 | ||
102 | createObjectActionWithContainmentAndInverse( | 107 | queryEngine.delayUpdatePropagation [ |
103 | nameNewElement, | 108 | val startTime = System.nanoTime |
104 | interpretation, | 109 | createObjectActionWithContainmentAndInverse( |
105 | typeInterpretation, | 110 | nameNewElement, |
106 | container, | 111 | interpretation, |
107 | relationInterpretation, | 112 | typeInterpretation, |
108 | inverseRelationInterpretation, | 113 | container, |
109 | [createDefinedElement], | 114 | relationInterpretation, |
110 | recursiceObjectCreations, | 115 | inverseRelationInterpretation, |
111 | scopePropagator | 116 | [createDefinedElement], |
112 | ) | 117 | recursiceObjectCreations, |
113 | 118 | scopePropagator | |
114 | val propagatorStartTime = System.nanoTime | 119 | ) |
115 | statistics.addExecutionTime(propagatorStartTime-startTime) | 120 | statistics.addExecutionTime(System.nanoTime-startTime) |
121 | ] | ||
116 | 122 | ||
117 | // Scope propagation | 123 | // Scope propagation |
118 | scopePropagator.propagateAllScopeConstraints() | 124 | queryEngine.delayUpdatePropagation [ |
119 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | 125 | val propagatorStartTime = System.nanoTime |
126 | scopePropagator.propagateAllScopeConstraints() | ||
127 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | ||
128 | ] | ||
120 | ] | 129 | ] |
121 | } else { | 130 | } else { |
122 | ruleBuilder.action[match | | 131 | ruleBuilder.action[match | |
123 | statistics.incrementTransformationCount | 132 | statistics.incrementTransformationCount |
124 | // println(name) | 133 | // println(name) |
125 | val startTime = System.nanoTime | ||
126 | //val problem = match.get(0) as LogicProblem | 134 | //val problem = match.get(0) as LogicProblem |
127 | val interpretation = match.get(1) as PartialInterpretation | 135 | val interpretation = match.get(1) as PartialInterpretation |
128 | val relationInterpretation = match.get(2) as PartialRelationInterpretation | 136 | val relationInterpretation = match.get(2) as PartialRelationInterpretation |
129 | val typeInterpretation = match.get(3) as PartialComplexTypeInterpretation | 137 | val typeInterpretation = match.get(3) as PartialComplexTypeInterpretation |
130 | val container = match.get(4) as DefinedElement | 138 | val container = match.get(4) as DefinedElement |
131 | 139 | ||
132 | createObjectActionWithContainment( | 140 | queryEngine.delayUpdatePropagation [ |
133 | nameNewElement, | 141 | val startTime = System.nanoTime |
134 | interpretation, | 142 | createObjectActionWithContainment( |
135 | typeInterpretation, | 143 | nameNewElement, |
136 | container, | 144 | interpretation, |
137 | relationInterpretation, | 145 | typeInterpretation, |
138 | [createDefinedElement], | 146 | container, |
139 | recursiceObjectCreations, | 147 | relationInterpretation, |
140 | scopePropagator | 148 | [createDefinedElement], |
141 | ) | 149 | recursiceObjectCreations, |
142 | 150 | scopePropagator | |
143 | val propagatorStartTime = System.nanoTime | 151 | ) |
144 | statistics.addExecutionTime(propagatorStartTime-startTime) | 152 | statistics.addExecutionTime(System.nanoTime-startTime) |
153 | ] | ||
145 | 154 | ||
146 | // Scope propagation | 155 | // Scope propagation |
147 | scopePropagator.propagateAllScopeConstraints() | 156 | queryEngine.delayUpdatePropagation [ |
148 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | 157 | val propagatorStartTime = System.nanoTime |
158 | scopePropagator.propagateAllScopeConstraints() | ||
159 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | ||
160 | ] | ||
149 | ] | 161 | ] |
150 | } | 162 | } |
151 | } else { | 163 | } else { |
152 | ruleBuilder.action[match | | 164 | ruleBuilder.action[match | |
153 | statistics.incrementTransformationCount | 165 | statistics.incrementTransformationCount |
154 | // println(name) | 166 | // println(name) |
155 | val startTime = System.nanoTime | ||
156 | //val problem = match.get(0) as LogicProblem | 167 | //val problem = match.get(0) as LogicProblem |
157 | val interpretation = match.get(1) as PartialInterpretation | 168 | val interpretation = match.get(1) as PartialInterpretation |
158 | val typeInterpretation = match.get(2) as PartialComplexTypeInterpretation | 169 | val typeInterpretation = match.get(2) as PartialComplexTypeInterpretation |
159 | 170 | ||
160 | createObjectAction( | 171 | queryEngine.delayUpdatePropagation [ |
161 | nameNewElement, | 172 | val startTime = System.nanoTime |
162 | interpretation, | 173 | createObjectAction( |
163 | typeInterpretation, | 174 | nameNewElement, |
164 | [createDefinedElement], | 175 | interpretation, |
165 | recursiceObjectCreations, | 176 | typeInterpretation, |
166 | scopePropagator | 177 | [createDefinedElement], |
167 | ) | 178 | recursiceObjectCreations, |
168 | 179 | scopePropagator | |
169 | val propagatorStartTime = System.nanoTime | 180 | ) |
170 | statistics.addExecutionTime(propagatorStartTime-startTime) | 181 | statistics.addExecutionTime(System.nanoTime-startTime) |
182 | ] | ||
171 | 183 | ||
172 | // Scope propagation | 184 | // Scope propagation |
173 | scopePropagator.propagateAllScopeConstraints() | 185 | queryEngine.delayUpdatePropagation [ |
174 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | 186 | val propagatorStartTime = System.nanoTime |
187 | scopePropagator.propagateAllScopeConstraints() | ||
188 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | ||
189 | ] | ||
175 | ] | 190 | ] |
176 | } | 191 | } |
177 | return ruleBuilder.build | 192 | return ruleBuilder.build |
@@ -342,7 +357,7 @@ class RefinementRuleProvider { | |||
342 | if (inverseRelation === null) { | 357 | if (inverseRelation === null) { |
343 | ruleBuilder.action [ match | | 358 | ruleBuilder.action [ match | |
344 | statistics.incrementTransformationCount | 359 | statistics.incrementTransformationCount |
345 | val startTime = System.nanoTime | 360 | |
346 | // println(name) | 361 | // println(name) |
347 | // val problem = match.get(0) as LogicProblem | 362 | // val problem = match.get(0) as LogicProblem |
348 | // val interpretation = match.get(1) as PartialInterpretation | 363 | // val interpretation = match.get(1) as PartialInterpretation |
@@ -350,19 +365,24 @@ class RefinementRuleProvider { | |||
350 | val src = match.get(3) as DefinedElement | 365 | val src = match.get(3) as DefinedElement |
351 | val trg = match.get(4) as DefinedElement | 366 | val trg = match.get(4) as DefinedElement |
352 | 367 | ||
353 | createRelationLinkAction(src, trg, relationInterpretation) | 368 | queryEngine.delayUpdatePropagation [ |
354 | 369 | val startTime = System.nanoTime | |
355 | val propagatorStartTime = System.nanoTime | 370 | createRelationLinkAction(src, trg, relationInterpretation) |
356 | statistics.addExecutionTime(propagatorStartTime-startTime) | 371 | statistics.addExecutionTime(System.nanoTime-startTime) |
372 | ] | ||
357 | 373 | ||
358 | // Scope propagation | 374 | // Scope propagation |
359 | scopePropagator.propagateAdditionToRelation(declaration) | 375 | if (scopePropagator.isPropagationNeededAfterAdditionToRelation(declaration)) { |
360 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | 376 | queryEngine.delayUpdatePropagation [ |
377 | val propagatorStartTime = System.nanoTime | ||
378 | scopePropagator.propagateAllScopeConstraints() | ||
379 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | ||
380 | ] | ||
381 | } | ||
361 | ] | 382 | ] |
362 | } else { | 383 | } else { |
363 | ruleBuilder.action [ match | | 384 | ruleBuilder.action [ match | |
364 | statistics.incrementTransformationCount | 385 | statistics.incrementTransformationCount |
365 | val startTime = System.nanoTime | ||
366 | // println(name) | 386 | // println(name) |
367 | // val problem = match.get(0) as LogicProblem | 387 | // val problem = match.get(0) as LogicProblem |
368 | // val interpretation = match.get(1) as PartialInterpretation | 388 | // val interpretation = match.get(1) as PartialInterpretation |
@@ -371,14 +391,20 @@ class RefinementRuleProvider { | |||
371 | val src = match.get(4) as DefinedElement | 391 | val src = match.get(4) as DefinedElement |
372 | val trg = match.get(5) as DefinedElement | 392 | val trg = match.get(5) as DefinedElement |
373 | 393 | ||
374 | createRelationLinkWithInverse(src, trg, relationInterpretation, inverseInterpretation) | 394 | queryEngine.delayUpdatePropagation [ |
375 | 395 | val startTime = System.nanoTime | |
376 | val propagatorStartTime = System.nanoTime | 396 | createRelationLinkWithInverse(src, trg, relationInterpretation, inverseInterpretation) |
377 | statistics.addExecutionTime(propagatorStartTime-startTime) | 397 | statistics.addExecutionTime(System.nanoTime-startTime) |
398 | ] | ||
378 | 399 | ||
379 | // Scope propagation | 400 | // Scope propagation |
380 | scopePropagator.propagateAdditionToRelation(declaration) | 401 | if (scopePropagator.isPropagationNeededAfterAdditionToRelation(declaration)) { |
381 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | 402 | queryEngine.delayUpdatePropagation [ |
403 | val propagatorStartTime = System.nanoTime | ||
404 | scopePropagator.propagateAllScopeConstraints() | ||
405 | statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) | ||
406 | ] | ||
407 | } | ||
382 | ] | 408 | ] |
383 | } | 409 | } |
384 | 410 | ||