aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <marussy@mit.bme.hu>2020-07-08 02:33:06 +0200
committerLibravatar Kristóf Marussy <marussy@mit.bme.hu>2020-07-08 02:33:06 +0200
commitb0e3359574eb00e1eaab5a7286a6f8e163b7b87f (patch)
tree64632b059e57819cd982a4cc3abafb421e27fd79
parentRestore inverse punishSize (diff)
downloadVIATRA-Generator-b0e3359574eb00e1eaab5a7286a6f8e163b7b87f.tar.gz
VIATRA-Generator-b0e3359574eb00e1eaab5a7286a6f8e163b7b87f.tar.zst
VIATRA-Generator-b0e3359574eb00e1eaab5a7286a6f8e163b7b87f.zip
Fix event storm on EMF transaction finish
-rw-r--r--Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbinbin1701 -> 1701 bytes
-rw-r--r--Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbinbin2526 -> 2526 bytes
-rw-r--r--Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbinbin5334 -> 5334 bytes
-rw-r--r--Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbinbin4902 -> 4902 bytes
-rw-r--r--Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbinbin1717 -> 1717 bytes
-rw-r--r--Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbinbin2742 -> 2742 bytes
-rw-r--r--Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbinbin2758 -> 2758 bytes
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/META-INF/MANIFEST.MF11
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend516
-rw-r--r--Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/SolutionTrajectory.java9
-rw-r--r--Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/base/DesignSpaceManager.java18
11 files changed, 293 insertions, 261 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin
index 51a755e5..bd1eabaf 100644
--- a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin
+++ b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin
Binary files differ
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin
index 27588633..f4956ec0 100644
--- a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin
+++ b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin
Binary files differ
diff --git a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbin b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbin
index 816f1516..0ee6ab93 100644
--- a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbin
+++ b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticHighlightCalculator.xtendbin
Binary files differ
diff --git a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbin b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbin
index bc22802d..1fbc1b5a 100644
--- a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbin
+++ b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/ui/syntaxcoloring/.SolverSemanticTextAttributeProvider.xtendbin
Binary files differ
diff --git a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbin b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbin
index 6086ad61..6dfd9bdd 100644
--- a/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbin
+++ b/Application/org.eclipse.viatra.solver.language.ui/xtend-gen/org/eclipse/viatra/solver/language/validation/.SolverLanguageValidator.xtendbin
Binary files differ
diff --git a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbin b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbin
index 1fe63cb7..9e4a0e33 100644
--- a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbin
+++ b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/parser/antlr/.SolverLanguageTokenDefInjectingParser.xtendbin
Binary files differ
diff --git a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin
index 1c7b8eb2..2a1c8746 100644
--- a/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin
+++ b/Application/org.eclipse.viatra.solver.language/xtend-gen/org/eclipse/viatra/solver/language/serializer/.SolverLanguageSyntheticTokenSyntacticSequencer.xtendbin
Binary files differ
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/META-INF/MANIFEST.MF b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/META-INF/MANIFEST.MF
index f9090901..b9da0f0b 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/META-INF/MANIFEST.MF
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/META-INF/MANIFEST.MF
@@ -17,15 +17,16 @@ Require-Bundle: hu.bme.mit.inf.dslreasoner.logic.model;bundle-version="1.0.0",
17 org.eclipse.xtext.xbase.lib, 17 org.eclipse.xtext.xbase.lib,
18 org.eclipse.xtend.lib, 18 org.eclipse.xtend.lib,
19 org.eclipse.xtend.lib.macro, 19 org.eclipse.xtend.lib.macro,
20 org.eclipse.viatra.query.runtime;bundle-version="1.5.0", 20 org.eclipse.viatra.query.runtime;bundle-version="2.0.0",
21 org.eclipse.viatra.query.runtime.base.itc;bundle-version="1.5.0", 21 org.eclipse.viatra.query.runtime.base.itc;bundle-version="2.0.0",
22 org.eclipse.viatra.query.patternlanguage.emf;bundle-version="1.5.0", 22 org.eclipse.viatra.query.patternlanguage.emf;bundle-version="2.0.0",
23 com.google.inject;bundle-version="3.0.0", 23 com.google.inject;bundle-version="3.0.0",
24 org.eclipse.xtext;bundle-version="2.10.0", 24 org.eclipse.xtext;bundle-version="2.10.0",
25 org.eclipse.viatra.transformation.runtime.emf;bundle-version="1.5.0", 25 org.eclipse.viatra.transformation.runtime.emf;bundle-version="2.0.0",
26 org.eclipse.xtext.xbase;bundle-version="2.10.0", 26 org.eclipse.xtext.xbase;bundle-version="2.10.0",
27 com.microsoft.z3;bundle-version="4.8.5", 27 com.microsoft.z3;bundle-version="4.8.5",
28 hu.bme.mit.inf.dslreasoner.ilp.cbc;bundle-version="1.0.0" 28 hu.bme.mit.inf.dslreasoner.ilp.cbc;bundle-version="1.0.0",
29 org.eclipse.viatra.query.runtime.rete;bundle-version="2.0.0"
29Bundle-RequiredExecutionEnvironment: JavaSE-1.8 30Bundle-RequiredExecutionEnvironment: JavaSE-1.8
30Import-Package: org.apache.log4j 31Import-Package: org.apache.log4j
31Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatraquery 32Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatraquery
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 863ee18b..1d976e14 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
@@ -27,6 +27,7 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.par
27import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialStringInterpretation 27import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialStringInterpretation
28import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation 28import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation
29import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationFactory 29import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationFactory
30import java.lang.reflect.Field
30import java.util.HashMap 31import java.util.HashMap
31import java.util.LinkedHashMap 32import java.util.LinkedHashMap
32import java.util.LinkedList 33import java.util.LinkedList
@@ -38,6 +39,7 @@ import org.eclipse.viatra.query.runtime.api.IQuerySpecification
38import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine 39import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
39import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher 40import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher
40import org.eclipse.viatra.query.runtime.emf.EMFScope 41import org.eclipse.viatra.query.runtime.emf.EMFScope
42import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory
41import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRule 43import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRule
42import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRuleFactory 44import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRuleFactory
43import org.eclipse.xtend.lib.annotations.Data 45import org.eclipse.xtend.lib.annotations.Data
@@ -47,186 +49,180 @@ class RefinementRuleProvider {
47 val extension BatchTransformationRuleFactory factory = new BatchTransformationRuleFactory 49 val extension BatchTransformationRuleFactory factory = new BatchTransformationRuleFactory
48 val extension PartialinterpretationFactory factory2 = PartialinterpretationFactory.eINSTANCE 50 val extension PartialinterpretationFactory factory2 = PartialinterpretationFactory.eINSTANCE
49 val extension LogiclanguageFactory factory3 = LogiclanguageFactory.eINSTANCE 51 val extension LogiclanguageFactory factory3 = LogiclanguageFactory.eINSTANCE
50 52
51 var AdvancedViatraQueryEngine queryEngine 53 var AdvancedViatraQueryEngine queryEngine
52 54 var Field delayMessageDelivery
55
53 def canonizeName(String name) { 56 def canonizeName(String name) {
54 return name.replace(' ','_') 57 return name.replace(' ', '_')
55 } 58 }
56 59
57 def LinkedHashMap<ObjectCreationPrecondition, BatchTransformationRule<GenericPatternMatch, ViatraQueryMatcher<GenericPatternMatch>>> createObjectRefinementRules( 60 def LinkedHashMap<ObjectCreationPrecondition, BatchTransformationRule<GenericPatternMatch, ViatraQueryMatcher<GenericPatternMatch>>> createObjectRefinementRules(
58 LogicProblem p, 61 LogicProblem p,
59 PartialInterpretation i, 62 PartialInterpretation i,
60 GeneratedPatterns patterns, 63 GeneratedPatterns patterns,
61 ScopePropagator scopePropagator, 64 ScopePropagator scopePropagator,
62 boolean nameNewElement, 65 boolean nameNewElement,
63 ModelGenerationStatistics statistics 66 ModelGenerationStatistics statistics
64 ) 67 ) {
65 {
66 val res = new LinkedHashMap 68 val res = new LinkedHashMap
67 val recursiveObjectCreation = recursiveObjectCreation(p,i) 69 val recursiveObjectCreation = recursiveObjectCreation(p, i)
68 queryEngine = ViatraQueryEngine.on(new EMFScope(i)) as AdvancedViatraQueryEngine 70 queryEngine = ViatraQueryEngine.on(new EMFScope(i)) as AdvancedViatraQueryEngine
69 for(LHSEntry: patterns.refineObjectQueries.entrySet) { 71 delayMessageDelivery = queryEngine.class.getDeclaredField("delayMessageDelivery")
72 delayMessageDelivery.accessible = true
73 for (LHSEntry : patterns.refineObjectQueries.entrySet) {
70 val containmentRelation = LHSEntry.key.containmentRelation 74 val containmentRelation = LHSEntry.key.containmentRelation
71 val inverseRelation = LHSEntry.key.inverseContainment 75 val inverseRelation = LHSEntry.key.inverseContainment
72 val type = LHSEntry.key.newType 76 val type = LHSEntry.key.newType
73 val lhs = LHSEntry.value as IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> 77 val lhs = LHSEntry.value as IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>>
74 val rule = createObjectCreationRule(p,containmentRelation,inverseRelation,type,recursiveObjectCreation.get(type),lhs,nameNewElement,scopePropagator,statistics) 78 val rule = createObjectCreationRule(p, containmentRelation, inverseRelation, type,
75 res.put(LHSEntry.key,rule) 79 recursiveObjectCreation.get(type), lhs, nameNewElement, scopePropagator, statistics)
80 res.put(LHSEntry.key, rule)
76 } 81 }
77 return res 82 return res
78 } 83 }
79 84
80 def private createObjectCreationRule( 85 def private createObjectCreationRule(LogicProblem p, Relation containmentRelation, Relation inverseRelation,
81 LogicProblem p, 86 Type type, List<ObjectCreationInterpretationData> recursiceObjectCreations,
82 Relation containmentRelation, 87 IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> lhs, boolean nameNewElement,
83 Relation inverseRelation, 88 ScopePropagator scopePropagator, ModelGenerationStatistics statistics) {
84 Type type, 89 val name = '''addObject_«type.name.canonizeName»«IF containmentRelation!==null»_by_«containmentRelation.name.canonizeName»«ENDIF»'''
85 List<ObjectCreationInterpretationData> recursiceObjectCreations, 90 val ruleBuilder = factory.createRule(lhs).name(name)
86 IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> lhs, 91 if (containmentRelation !== null) {
87 boolean nameNewElement, 92 if (inverseRelation !== null) {
88 ScopePropagator scopePropagator, 93 ruleBuilder.action [ match |
89 ModelGenerationStatistics statistics)
90 {
91 val name = '''addObject_«type.name.canonizeName»«
92 IF containmentRelation!==null»_by_«containmentRelation.name.canonizeName»«ENDIF»'''
93 val ruleBuilder = factory.createRule(lhs)
94 .name(name)
95 if(containmentRelation !== null) {
96 if(inverseRelation!== null) {
97 ruleBuilder.action[match |
98 statistics.incrementTransformationCount 94 statistics.incrementTransformationCount
99// println(name) 95// println(name)
100 //val problem = match.get(0) as LogicProblem 96 // val problem = match.get(0) as LogicProblem
101 val interpretation = match.get(1) as PartialInterpretation 97 val interpretation = match.get(1) as PartialInterpretation
102 val relationInterpretation = match.get(2) as PartialRelationInterpretation 98 val relationInterpretation = match.get(2) as PartialRelationInterpretation
103 val inverseRelationInterpretation = match.get(3) as PartialRelationInterpretation 99 val inverseRelationInterpretation = match.get(3) as PartialRelationInterpretation
104 val typeInterpretation = match.get(4) as PartialComplexTypeInterpretation 100 val typeInterpretation = match.get(4) as PartialComplexTypeInterpretation
105 val container = match.get(5) as DefinedElement 101 val container = match.get(5) as DefinedElement
106 102
107 queryEngine.delayUpdatePropagation [ 103 val startTime = System.nanoTime
108 val startTime = System.nanoTime 104 createObjectActionWithContainmentAndInverse(
109 createObjectActionWithContainmentAndInverse( 105 nameNewElement,
110 nameNewElement, 106 interpretation,
111 interpretation, 107 typeInterpretation,
112 typeInterpretation, 108 container,
113 container, 109 relationInterpretation,
114 relationInterpretation, 110 inverseRelationInterpretation,
115 inverseRelationInterpretation, 111 [createDefinedElement],
116 [createDefinedElement], 112 recursiceObjectCreations,
117 recursiceObjectCreations, 113 scopePropagator
118 scopePropagator 114 )
119 ) 115 statistics.addExecutionTime(System.nanoTime - startTime)
120 statistics.addExecutionTime(System.nanoTime-startTime) 116
121 ] 117 flushQueryEngine
122 118
123 // Scope propagation 119 // Scope propagation
124 queryEngine.delayUpdatePropagation [ 120 val propagatorStartTime = System.nanoTime
125 val propagatorStartTime = System.nanoTime 121 scopePropagator.propagateAllScopeConstraints()
126 scopePropagator.propagateAllScopeConstraints() 122 statistics.addScopePropagationTime(System.nanoTime - propagatorStartTime)
127 statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime)
128 ]
129 ] 123 ]
130 } else { 124 } else {
131 ruleBuilder.action[match | 125 ruleBuilder.action [ match |
132 statistics.incrementTransformationCount 126 statistics.incrementTransformationCount
133// println(name) 127// println(name)
134 //val problem = match.get(0) as LogicProblem 128 // val problem = match.get(0) as LogicProblem
135 val interpretation = match.get(1) as PartialInterpretation 129 val interpretation = match.get(1) as PartialInterpretation
136 val relationInterpretation = match.get(2) as PartialRelationInterpretation 130 val relationInterpretation = match.get(2) as PartialRelationInterpretation
137 val typeInterpretation = match.get(3) as PartialComplexTypeInterpretation 131 val typeInterpretation = match.get(3) as PartialComplexTypeInterpretation
138 val container = match.get(4) as DefinedElement 132 val container = match.get(4) as DefinedElement
139
140 queryEngine.delayUpdatePropagation [
141 val startTime = System.nanoTime
142 createObjectActionWithContainment(
143 nameNewElement,
144 interpretation,
145 typeInterpretation,
146 container,
147 relationInterpretation,
148 [createDefinedElement],
149 recursiceObjectCreations,
150 scopePropagator
151 )
152 statistics.addExecutionTime(System.nanoTime-startTime)
153 ]
154
155 // Scope propagation
156 queryEngine.delayUpdatePropagation [
157 val propagatorStartTime = System.nanoTime
158 scopePropagator.propagateAllScopeConstraints()
159 statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime)
160 ]
161 ]
162 }
163 } else {
164 ruleBuilder.action[match |
165 statistics.incrementTransformationCount
166// println(name)
167 //val problem = match.get(0) as LogicProblem
168 val interpretation = match.get(1) as PartialInterpretation
169 val typeInterpretation = match.get(2) as PartialComplexTypeInterpretation
170 133
171 queryEngine.delayUpdatePropagation [
172 val startTime = System.nanoTime 134 val startTime = System.nanoTime
173 createObjectAction( 135 createObjectActionWithContainment(
174 nameNewElement, 136 nameNewElement,
175 interpretation, 137 interpretation,
176 typeInterpretation, 138 typeInterpretation,
139 container,
140 relationInterpretation,
177 [createDefinedElement], 141 [createDefinedElement],
178 recursiceObjectCreations, 142 recursiceObjectCreations,
179 scopePropagator 143 scopePropagator
180 ) 144 )
181 statistics.addExecutionTime(System.nanoTime-startTime) 145 statistics.addExecutionTime(System.nanoTime - startTime)
182 ] 146
183 147 flushQueryEngine
184 // Scope propagation 148
185 queryEngine.delayUpdatePropagation [ 149 // Scope propagation
186 val propagatorStartTime = System.nanoTime 150 val propagatorStartTime = System.nanoTime
187 scopePropagator.propagateAllScopeConstraints() 151 scopePropagator.propagateAllScopeConstraints()
188 statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) 152 statistics.addScopePropagationTime(System.nanoTime - propagatorStartTime)
189 ] 153 ]
154 }
155 } else {
156 ruleBuilder.action [ match |
157 statistics.incrementTransformationCount
158// println(name)
159 // val problem = match.get(0) as LogicProblem
160 val interpretation = match.get(1) as PartialInterpretation
161 val typeInterpretation = match.get(2) as PartialComplexTypeInterpretation
162
163 val startTime = System.nanoTime
164 createObjectAction(
165 nameNewElement,
166 interpretation,
167 typeInterpretation,
168 [createDefinedElement],
169 recursiceObjectCreations,
170 scopePropagator
171 )
172 statistics.addExecutionTime(System.nanoTime - startTime)
173
174 flushQueryEngine
175
176 // Scope propagation
177 val propagatorStartTime = System.nanoTime
178 scopePropagator.propagateAllScopeConstraints()
179 statistics.addScopePropagationTime(System.nanoTime - propagatorStartTime)
190 ] 180 ]
191 } 181 }
192 return ruleBuilder.build 182 return ruleBuilder.build
193 } 183 }
194 184
195 def private recursiveObjectCreation(LogicProblem p, PartialInterpretation i) { 185 def private recursiveObjectCreation(LogicProblem p, PartialInterpretation i) {
196 val Map<Type,List<ObjectCreationInterpretationData>> recursiveObjectCreation = new HashMap 186 val Map<Type, List<ObjectCreationInterpretationData>> recursiveObjectCreation = new HashMap
197 for(type : p.types) { 187 for (type : p.types) {
198 recursiveObjectCreation.put(type,new LinkedList) 188 recursiveObjectCreation.put(type, new LinkedList)
199 } 189 }
200 190
201 val containmentReferences = p.containmentHierarchies.head.containmentRelations 191 val containmentReferences = p.containmentHierarchies.head.containmentRelations
202 192
203 for(relationInterpretation : i.partialrelationinterpretation) { 193 for (relationInterpretation : i.partialrelationinterpretation) {
204 val relation = relationInterpretation.interpretationOf 194 val relation = relationInterpretation.interpretationOf
205 val lowermultiplicities = p.annotations.filter(LowerMultiplicityAssertion).filter[it.relation === relation] 195 val lowermultiplicities = p.annotations.filter(LowerMultiplicityAssertion).filter[it.relation === relation]
206 if((!lowermultiplicities.empty)) { 196 if ((!lowermultiplicities.empty)) {
207 val number = lowermultiplicities.head.lower 197 val number = lowermultiplicities.head.lower
208 if(number > 0) { 198 if (number > 0) {
209 val sourceTypeInterpretation = getTypeInterpretation(i, relation, 0) as PartialComplexTypeInterpretation 199 val sourceTypeInterpretation = getTypeInterpretation(i, relation,
210 val subtypeInterpretations = i.partialtypeinterpratation.filter(PartialComplexTypeInterpretation).filter[ 200 0) as PartialComplexTypeInterpretation
211 it === sourceTypeInterpretation || 201 val subtypeInterpretations = i.partialtypeinterpratation.filter(PartialComplexTypeInterpretation).
212 it.supertypeInterpretation.contains(sourceTypeInterpretation) 202 filter [
213 ] 203 it === sourceTypeInterpretation ||
214 204 it.supertypeInterpretation.contains(sourceTypeInterpretation)
215 if(containmentReferences.contains(relation)) { 205 ]
206
207 if (containmentReferences.contains(relation)) {
216 val targetTypeInterpretation = getTypeInterpretation(i, relation, 1) 208 val targetTypeInterpretation = getTypeInterpretation(i, relation, 1)
217 val targetType = (targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf 209 val targetType = (targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf
218 if((!targetType.isIsAbstract) && (targetType.supertypes.empty)) { 210 if ((!targetType.isIsAbstract) && (targetType.supertypes.empty)) {
219 val inverseAnnotation = p.annotations.filter(InverseRelationAssertion).filter[it.inverseA === relation || it.inverseB === relation] 211 val inverseAnnotation = p.annotations.filter(InverseRelationAssertion).filter [
220 if(!inverseAnnotation.empty) { 212 it.inverseA === relation || it.inverseB === relation
221 val onlyInverseAnnotation = if(inverseAnnotation.head.inverseA===relation) { 213 ]
222 inverseAnnotation.head.inverseB 214 if (!inverseAnnotation.empty) {
223 } else { 215 val onlyInverseAnnotation = if (inverseAnnotation.head.inverseA === relation) {
224 inverseAnnotation.head.inverseA 216 inverseAnnotation.head.inverseB
225 } 217 } else {
226 val inverseRelationInterpretation = i.partialrelationinterpretation.filter[it.interpretationOf === onlyInverseAnnotation].head 218 inverseAnnotation.head.inverseA
227 for(subTypeInterpretation : subtypeInterpretations) { 219 }
228 for(var times=0; times<number; times++) { 220 val inverseRelationInterpretation = i.partialrelationinterpretation.filter [
229 recursiveObjectCreation.get(subTypeInterpretation.interpretationOf) += 221 it.interpretationOf === onlyInverseAnnotation
222 ].head
223 for (subTypeInterpretation : subtypeInterpretations) {
224 for (var times = 0; times < number; times++) {
225 recursiveObjectCreation.get(subTypeInterpretation.interpretationOf) +=
230 new ObjectCreationInterpretationData( 226 new ObjectCreationInterpretationData(
231 i, 227 i,
232 targetTypeInterpretation, 228 targetTypeInterpretation,
@@ -237,9 +233,9 @@ class RefinementRuleProvider {
237 } 233 }
238 } 234 }
239 } else { 235 } else {
240 for(subTypeInterpretation : subtypeInterpretations) { 236 for (subTypeInterpretation : subtypeInterpretations) {
241 for(var times=0; times<number; times++) { 237 for (var times = 0; times < number; times++) {
242 recursiveObjectCreation.get(subTypeInterpretation.interpretationOf) += 238 recursiveObjectCreation.get(subTypeInterpretation.interpretationOf) +=
243 new ObjectCreationInterpretationData( 239 new ObjectCreationInterpretationData(
244 i, 240 i,
245 targetTypeInterpretation, 241 targetTypeInterpretation,
@@ -251,11 +247,11 @@ class RefinementRuleProvider {
251 } 247 }
252 } 248 }
253 } 249 }
254 } else if(relation.parameters.get(1) instanceof PrimitiveTypeReference) { 250 } else if (relation.parameters.get(1) instanceof PrimitiveTypeReference) {
255 val targetTypeInterpretation = getTypeInterpretation(i, relation, 1) 251 val targetTypeInterpretation = getTypeInterpretation(i, relation, 1)
256 for(subTypeInterpretation : subtypeInterpretations) { 252 for (subTypeInterpretation : subtypeInterpretations) {
257 for(var times=0; times<number; times++) { 253 for (var times = 0; times < number; times++) {
258 recursiveObjectCreation.get(subTypeInterpretation.interpretationOf) += 254 recursiveObjectCreation.get(subTypeInterpretation.interpretationOf) +=
259 new ObjectCreationInterpretationData( 255 new ObjectCreationInterpretationData(
260 i, 256 i,
261 targetTypeInterpretation, 257 targetTypeInterpretation,
@@ -269,114 +265,125 @@ class RefinementRuleProvider {
269 } 265 }
270 } 266 }
271 } 267 }
272 268
273 // Doing the recursion 269 // Doing the recursion
274 var objectCreations = new LinkedList(recursiveObjectCreation.values.flatten.toList) 270 var objectCreations = new LinkedList(recursiveObjectCreation.values.flatten.toList)
275 for(objectCreation : objectCreations) { 271 for (objectCreation : objectCreations) {
276 val newInterpretation = objectCreation.typeInterpretation 272 val newInterpretation = objectCreation.typeInterpretation
277 if(newInterpretation instanceof PartialComplexTypeInterpretation) { 273 if (newInterpretation instanceof PartialComplexTypeInterpretation) {
278 val newlyCreatedType = newInterpretation.interpretationOf 274 val newlyCreatedType = newInterpretation.interpretationOf
279 if(recursiveObjectCreation.containsKey(newlyCreatedType)) { 275 if (recursiveObjectCreation.containsKey(newlyCreatedType)) {
280 val actionsWhenTypeCreated = recursiveObjectCreation.get(newlyCreatedType) 276 val actionsWhenTypeCreated = recursiveObjectCreation.get(newlyCreatedType)
281 objectCreation.recursiveConstructors+=actionsWhenTypeCreated 277 objectCreation.recursiveConstructors += actionsWhenTypeCreated
282 } 278 }
283 } 279 }
284 } 280 }
285 281
286 // checking acyclicity 282 // checking acyclicity
287 for(objectCreation : objectCreations) { 283 for (objectCreation : objectCreations) {
288 var reachable = objectCreation.recursiveConstructors 284 var reachable = objectCreation.recursiveConstructors
289 do { 285 do {
290 if(reachable.contains(objectCreation)) { 286 if (reachable.contains(objectCreation)) {
291 throw new IllegalArgumentException('''Cicrle in the containment!''') 287 throw new IllegalArgumentException('''Cicrle in the containment!''')
292 } else { 288 } else {
293 reachable = reachable.map[it.recursiveConstructors].flatten.toList 289 reachable = reachable.map[it.recursiveConstructors].flatten.toList
294 } 290 }
295 } while(!reachable.empty) 291 } while (!reachable.empty)
296 } 292 }
297 293
298 return recursiveObjectCreation 294 return recursiveObjectCreation
299 } 295 }
300 296
301 private def getTypeInterpretation(PartialInterpretation i, RelationDeclaration relation, int index) { 297 private def getTypeInterpretation(PartialInterpretation i, RelationDeclaration relation, int index) {
302 val typeReference = relation.parameters.get(index) 298 val typeReference = relation.parameters.get(index)
303 return getTypeInterpretation(i,typeReference) 299 return getTypeInterpretation(i, typeReference)
304 300
305 } 301 }
302
306 private dispatch def getTypeInterpretation(PartialInterpretation i, ComplexTypeReference reference) { 303 private dispatch def getTypeInterpretation(PartialInterpretation i, ComplexTypeReference reference) {
307 return i.partialtypeinterpratation 304 return i.partialtypeinterpratation.filter(PartialComplexTypeInterpretation).filter [
308 .filter(PartialComplexTypeInterpretation) 305 it.getInterpretationOf == reference.referred
309 .filter[it.getInterpretationOf == reference.referred] 306 ].head
310 .head
311 } 307 }
308
312 private dispatch def getTypeInterpretation(PartialInterpretation i, BoolTypeReference reference) { 309 private dispatch def getTypeInterpretation(PartialInterpretation i, BoolTypeReference reference) {
313 return i.partialtypeinterpratation 310 return i.partialtypeinterpratation.filter(PartialBooleanInterpretation).head
314 .filter(PartialBooleanInterpretation)
315 .head
316 } 311 }
312
317 private dispatch def getTypeInterpretation(PartialInterpretation i, IntTypeReference reference) { 313 private dispatch def getTypeInterpretation(PartialInterpretation i, IntTypeReference reference) {
318 return i.partialtypeinterpratation 314 return i.partialtypeinterpratation.filter(PartialIntegerInterpretation).head
319 .filter(PartialIntegerInterpretation)
320 .head
321 } 315 }
316
322 private dispatch def getTypeInterpretation(PartialInterpretation i, RealTypeReference reference) { 317 private dispatch def getTypeInterpretation(PartialInterpretation i, RealTypeReference reference) {
323 return i.partialtypeinterpratation 318 return i.partialtypeinterpratation.filter(PartialRealInterpretation).head
324 .filter(PartialRealInterpretation)
325 .head
326 } 319 }
320
327 private dispatch def getTypeInterpretation(PartialInterpretation i, StringTypeReference reference) { 321 private dispatch def getTypeInterpretation(PartialInterpretation i, StringTypeReference reference) {
328 return i.partialtypeinterpratation 322 return i.partialtypeinterpratation.filter(PartialStringInterpretation).head
329 .filter(PartialStringInterpretation) 323 }
330 .head 324
325 private dispatch def Function0<DefinedElement> getTypeConstructor(PartialComplexTypeInterpretation reference) {
326 [createDefinedElement]
327 }
328
329 private dispatch def Function0<DefinedElement> getTypeConstructor(PartialBooleanInterpretation reference) {
330 [createBooleanElement]
331 } 331 }
332 private dispatch def Function0<DefinedElement> getTypeConstructor(PartialComplexTypeInterpretation reference) { [createDefinedElement] } 332
333 private dispatch def Function0<DefinedElement> getTypeConstructor(PartialBooleanInterpretation reference) { [createBooleanElement] } 333 private dispatch def Function0<DefinedElement> getTypeConstructor(PartialIntegerInterpretation reference) {
334 private dispatch def Function0<DefinedElement> getTypeConstructor(PartialIntegerInterpretation reference) { [createIntegerElement] } 334 [createIntegerElement]
335 private dispatch def Function0<DefinedElement> getTypeConstructor(PartialRealInterpretation reference) { [createRealElement] } 335 }
336 private dispatch def Function0<DefinedElement> getTypeConstructor(PartialStringInterpretation reference) { [createStringElement] } 336
337 337 private dispatch def Function0<DefinedElement> getTypeConstructor(PartialRealInterpretation reference) {
338 338 [createRealElement]
339 def createRelationRefinementRules(GeneratedPatterns patterns, ScopePropagator scopePropagator, ModelGenerationStatistics statistics) { 339 }
340
341 private dispatch def Function0<DefinedElement> getTypeConstructor(PartialStringInterpretation reference) {
342 [createStringElement]
343 }
344
345 def createRelationRefinementRules(GeneratedPatterns patterns, ScopePropagator scopePropagator,
346 ModelGenerationStatistics statistics) {
340 val res = new LinkedHashMap 347 val res = new LinkedHashMap
341 for(LHSEntry: patterns.refinerelationQueries.entrySet) { 348 for (LHSEntry : patterns.refinerelationQueries.entrySet) {
342 val declaration = LHSEntry.key.key 349 val declaration = LHSEntry.key.key
343 val inverseReference = LHSEntry.key.value 350 val inverseReference = LHSEntry.key.value
344 val lhs = LHSEntry.value as IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> 351 val lhs = LHSEntry.value as IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>>
345 val rule = createRelationRefinementRule(declaration,inverseReference,lhs,scopePropagator,statistics) 352 val rule = createRelationRefinementRule(declaration, inverseReference, lhs, scopePropagator, statistics)
346 res.put(LHSEntry.key,rule) 353 res.put(LHSEntry.key, rule)
347 } 354 }
348 return res 355 return res
349 } 356 }
350 357
351 def private BatchTransformationRule<GenericPatternMatch, ViatraQueryMatcher<GenericPatternMatch>> 358 def private BatchTransformationRule<GenericPatternMatch, ViatraQueryMatcher<GenericPatternMatch>> createRelationRefinementRule(
352 createRelationRefinementRule(RelationDeclaration declaration, Relation inverseRelation, IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> lhs, ScopePropagator scopePropagator, ModelGenerationStatistics statistics) 359 RelationDeclaration declaration, Relation inverseRelation,
353 { 360 IQuerySpecification<ViatraQueryMatcher<GenericPatternMatch>> lhs, ScopePropagator scopePropagator,
361 ModelGenerationStatistics statistics) {
354 val name = '''addRelation_«declaration.name.canonizeName»«IF inverseRelation !== null»_and_«inverseRelation.name.canonizeName»«ENDIF»''' 362 val name = '''addRelation_«declaration.name.canonizeName»«IF inverseRelation !== null»_and_«inverseRelation.name.canonizeName»«ENDIF»'''
355 val ruleBuilder = factory.createRule(lhs) 363 val ruleBuilder = factory.createRule(lhs).name(name)
356 .name(name)
357 if (inverseRelation === null) { 364 if (inverseRelation === null) {
358 ruleBuilder.action [ match | 365 ruleBuilder.action [ match |
359 statistics.incrementTransformationCount 366 statistics.incrementTransformationCount
360 367
361// println(name) 368// println(name)
362 // val problem = match.get(0) as LogicProblem 369 // val problem = match.get(0) as LogicProblem
363 // val interpretation = match.get(1) as PartialInterpretation 370 // val interpretation = match.get(1) as PartialInterpretation
364 val relationInterpretation = match.get(2) as PartialRelationInterpretation 371 val relationInterpretation = match.get(2) as PartialRelationInterpretation
365 val src = match.get(3) as DefinedElement 372 val src = match.get(3) as DefinedElement
366 val trg = match.get(4) as DefinedElement 373 val trg = match.get(4) as DefinedElement
367 374
368 queryEngine.delayUpdatePropagation [ 375 queryEngine.delayUpdatePropagation [
369 val startTime = System.nanoTime 376 val startTime = System.nanoTime
370 createRelationLinkAction(src, trg, relationInterpretation) 377 createRelationLinkAction(src, trg, relationInterpretation)
371 statistics.addExecutionTime(System.nanoTime-startTime) 378 statistics.addExecutionTime(System.nanoTime - startTime)
372 ] 379 ]
373 380
374 // Scope propagation 381 // Scope propagation
375 if (scopePropagator.isPropagationNeededAfterAdditionToRelation(declaration)) { 382 if (scopePropagator.isPropagationNeededAfterAdditionToRelation(declaration)) {
376 queryEngine.delayUpdatePropagation [ 383 queryEngine.delayUpdatePropagation [
377 val propagatorStartTime = System.nanoTime 384 val propagatorStartTime = System.nanoTime
378 scopePropagator.propagateAllScopeConstraints() 385 scopePropagator.propagateAllScopeConstraints()
379 statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) 386 statistics.addScopePropagationTime(System.nanoTime - propagatorStartTime)
380 ] 387 ]
381 } 388 }
382 ] 389 ]
@@ -391,33 +398,31 @@ class RefinementRuleProvider {
391 val src = match.get(4) as DefinedElement 398 val src = match.get(4) as DefinedElement
392 val trg = match.get(5) as DefinedElement 399 val trg = match.get(5) as DefinedElement
393 400
394 queryEngine.delayUpdatePropagation [ 401 val startTime = System.nanoTime
395 val startTime = System.nanoTime 402 createRelationLinkWithInverse(src, trg, relationInterpretation, inverseInterpretation)
396 createRelationLinkWithInverse(src, trg, relationInterpretation, inverseInterpretation) 403 statistics.addExecutionTime(System.nanoTime - startTime)
397 statistics.addExecutionTime(System.nanoTime-startTime) 404
398 ]
399
400 // Scope propagation 405 // Scope propagation
401 if (scopePropagator.isPropagationNeededAfterAdditionToRelation(declaration)) { 406 if (scopePropagator.isPropagationNeededAfterAdditionToRelation(declaration)) {
402 queryEngine.delayUpdatePropagation [ 407 flushQueryEngine
403 val propagatorStartTime = System.nanoTime 408
404 scopePropagator.propagateAllScopeConstraints() 409 val propagatorStartTime = System.nanoTime
405 statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime) 410 scopePropagator.propagateAllScopeConstraints()
406 ] 411 statistics.addScopePropagationTime(System.nanoTime - propagatorStartTime)
407 } 412 }
408 ] 413 ]
409 } 414 }
410 415
411 return ruleBuilder.build 416 return ruleBuilder.build
412 } 417 }
413 418
414 ///////////////////////// 419 // ///////////////////////
415 // Actions 420 // Actions
416 ///////////////////////// 421 // ///////////////////////
417 422 protected def void createObjectAction(boolean nameNewElement, ObjectCreationInterpretationData data,
418 protected def void createObjectAction(boolean nameNewElement, ObjectCreationInterpretationData data, DefinedElement container, ScopePropagator scopePropagator) { 423 DefinedElement container, ScopePropagator scopePropagator) {
419 if(data.containerInterpretation !== null) { 424 if (data.containerInterpretation !== null) {
420 if(data.containerInverseInterpretation !== null) { 425 if (data.containerInverseInterpretation !== null) {
421 createObjectActionWithContainmentAndInverse( 426 createObjectActionWithContainmentAndInverse(
422 nameNewElement, 427 nameNewElement,
423 data.interpretation, 428 data.interpretation,
@@ -451,9 +456,9 @@ class RefinementRuleProvider {
451 scopePropagator 456 scopePropagator
452 ) 457 )
453 } 458 }
454 459
455 } 460 }
456 461
457 protected def createObjectActionWithContainmentAndInverse( 462 protected def createObjectActionWithContainmentAndInverse(
458 boolean nameNewElement, 463 boolean nameNewElement,
459 PartialInterpretation interpretation, 464 PartialInterpretation interpretation,
@@ -466,36 +471,36 @@ class RefinementRuleProvider {
466 ScopePropagator scopePropagator 471 ScopePropagator scopePropagator
467 ) { 472 ) {
468 val newElement = constructor.apply 473 val newElement = constructor.apply
469 if(nameNewElement) { 474 if (nameNewElement) {
470 newElement.name = '''new «interpretation.newElements.size»''' 475 newElement.name = '''new «interpretation.newElements.size»'''
471 } 476 }
472 477
473 // Types 478 // Types
474 typeInterpretation.elements += newElement 479 typeInterpretation.elements += newElement
475 if(typeInterpretation instanceof PartialComplexTypeInterpretation) { 480 if (typeInterpretation instanceof PartialComplexTypeInterpretation) {
476 typeInterpretation.supertypeInterpretation.forEach[it.elements += newElement] 481 typeInterpretation.supertypeInterpretation.forEach[it.elements += newElement]
477 } 482 }
478 // ContainmentRelation 483 // ContainmentRelation
479 val newLink1 = factory2.createBinaryElementRelationLink => [it.param1 = container it.param2 = newElement] 484 val newLink1 = factory2.createBinaryElementRelationLink => [it.param1 = container it.param2 = newElement]
480 relationInterpretation.relationlinks+=newLink1 485 relationInterpretation.relationlinks += newLink1
481 // Inverse Containment 486 // Inverse Containment
482 val newLink2 = factory2.createBinaryElementRelationLink => [it.param1 = newElement it.param2 = container] 487 val newLink2 = factory2.createBinaryElementRelationLink => [it.param1 = newElement it.param2 = container]
483 inverseRelationInterpretation.relationlinks+=newLink2 488 inverseRelationInterpretation.relationlinks += newLink2
484 489
485 // Scope propagation 490 // Scope propagation
486 scopePropagator.decrementTypeScope(typeInterpretation) 491 scopePropagator.decrementTypeScope(typeInterpretation)
487 492
488 // Existence 493 // Existence
489 interpretation.newElements+=newElement 494 interpretation.newElements += newElement
490 495
491 // Do recursive object creation 496 // Do recursive object creation
492 for(newConstructor : recursiceObjectCreations) { 497 for (newConstructor : recursiceObjectCreations) {
493 createObjectAction(nameNewElement,newConstructor,newElement,scopePropagator) 498 createObjectAction(nameNewElement, newConstructor, newElement, scopePropagator)
494 } 499 }
495 500
496 return newElement 501 return newElement
497 } 502 }
498 503
499 protected def createObjectActionWithContainment( 504 protected def createObjectActionWithContainment(
500 boolean nameNewElement, 505 boolean nameNewElement,
501 PartialInterpretation interpretation, 506 PartialInterpretation interpretation,
@@ -507,77 +512,82 @@ class RefinementRuleProvider {
507 ScopePropagator scopePropagator 512 ScopePropagator scopePropagator
508 ) { 513 ) {
509 val newElement = constructor.apply 514 val newElement = constructor.apply
510 if(nameNewElement) { 515 if (nameNewElement) {
511 newElement.name = '''new «interpretation.newElements.size»''' 516 newElement.name = '''new «interpretation.newElements.size»'''
512 } 517 }
513 518
514 // Types 519 // Types
515 typeInterpretation.elements += newElement 520 typeInterpretation.elements += newElement
516 if(typeInterpretation instanceof PartialComplexTypeInterpretation) { 521 if (typeInterpretation instanceof PartialComplexTypeInterpretation) {
517 typeInterpretation.supertypeInterpretation.forEach[it.elements += newElement] 522 typeInterpretation.supertypeInterpretation.forEach[it.elements += newElement]
518 } 523 }
519 // ContainmentRelation 524 // ContainmentRelation
520 val newLink = factory2.createBinaryElementRelationLink => [it.param1 = container it.param2 = newElement] 525 val newLink = factory2.createBinaryElementRelationLink => [it.param1 = container it.param2 = newElement]
521 relationInterpretation.relationlinks+=newLink 526 relationInterpretation.relationlinks += newLink
522 527
523 // Scope propagation 528 // Scope propagation
524 scopePropagator.decrementTypeScope(typeInterpretation) 529 scopePropagator.decrementTypeScope(typeInterpretation)
525 530
526 // Existence 531 // Existence
527 interpretation.newElements+=newElement 532 interpretation.newElements += newElement
528 533
529 // Do recursive object creation 534 // Do recursive object creation
530 for(newConstructor : recursiceObjectCreations) { 535 for (newConstructor : recursiceObjectCreations) {
531 createObjectAction(nameNewElement,newConstructor,newElement,scopePropagator) 536 createObjectAction(nameNewElement, newConstructor, newElement, scopePropagator)
532 } 537 }
533 538
534 return newElement 539 return newElement
535 } 540 }
536 541
537 protected def createObjectAction( 542 protected def createObjectAction(boolean nameNewElement, PartialInterpretation interpretation,
538 boolean nameNewElement, 543 PartialTypeInterpratation typeInterpretation, Function0<DefinedElement> constructor,
539 PartialInterpretation interpretation, 544 List<ObjectCreationInterpretationData> recursiceObjectCreations, ScopePropagator scopePropagator) {
540 PartialTypeInterpratation typeInterpretation,
541 Function0<DefinedElement> constructor,
542 List<ObjectCreationInterpretationData> recursiceObjectCreations,
543 ScopePropagator scopePropagator)
544 {
545 val newElement = constructor.apply 545 val newElement = constructor.apply
546 if(nameNewElement) { 546 if (nameNewElement) {
547 newElement.name = '''new «interpretation.newElements.size»''' 547 newElement.name = '''new «interpretation.newElements.size»'''
548 } 548 }
549 549
550 // Types 550 // Types
551 typeInterpretation.elements += newElement 551 typeInterpretation.elements += newElement
552 if(typeInterpretation instanceof PartialComplexTypeInterpretation) { 552 if (typeInterpretation instanceof PartialComplexTypeInterpretation) {
553 typeInterpretation.supertypeInterpretation.forEach[it.elements += newElement] 553 typeInterpretation.supertypeInterpretation.forEach[it.elements += newElement]
554 } 554 }
555 555
556 // Scope propagation 556 // Scope propagation
557 scopePropagator.decrementTypeScope(typeInterpretation) 557 scopePropagator.decrementTypeScope(typeInterpretation)
558 558
559 // Existence 559 // Existence
560 interpretation.newElements+=newElement 560 interpretation.newElements += newElement
561 561
562 // Do recursive object creation 562 // Do recursive object creation
563 for(newConstructor : recursiceObjectCreations) { 563 for (newConstructor : recursiceObjectCreations) {
564 createObjectAction(nameNewElement,newConstructor,newElement,scopePropagator) 564 createObjectAction(nameNewElement, newConstructor, newElement, scopePropagator)
565 } 565 }
566 566
567 return newElement 567 return newElement
568 } 568 }
569 569
570 protected def boolean createRelationLinkAction(DefinedElement src, DefinedElement trg, PartialRelationInterpretation relationInterpretation) { 570 protected def boolean createRelationLinkAction(DefinedElement src, DefinedElement trg,
571 PartialRelationInterpretation relationInterpretation) {
571 val link = createBinaryElementRelationLink => [it.param1 = src it.param2 = trg] 572 val link = createBinaryElementRelationLink => [it.param1 = src it.param2 = trg]
572 relationInterpretation.relationlinks += link 573 relationInterpretation.relationlinks += link
573 } 574 }
574 575
575 protected def boolean createRelationLinkWithInverse(DefinedElement src, DefinedElement trg, PartialRelationInterpretation relationInterpretation, PartialRelationInterpretation inverseInterpretation) { 576 protected def boolean createRelationLinkWithInverse(DefinedElement src, DefinedElement trg,
577 PartialRelationInterpretation relationInterpretation, PartialRelationInterpretation inverseInterpretation) {
576 val link = createBinaryElementRelationLink => [it.param1 = src it.param2 = trg] 578 val link = createBinaryElementRelationLink => [it.param1 = src it.param2 = trg]
577 relationInterpretation.relationlinks += link 579 relationInterpretation.relationlinks += link
578 val inverseLink = createBinaryElementRelationLink => [it.param1 = trg it.param2 = src] 580 val inverseLink = createBinaryElementRelationLink => [it.param1 = trg it.param2 = src]
579 inverseInterpretation.relationlinks += inverseLink 581 inverseInterpretation.relationlinks += inverseLink
580 } 582 }
583
584 protected def flushQueryEngine() {
585 if (queryEngine.updatePropagationDelayed) {
586 delayMessageDelivery.setBoolean(queryEngine, false)
587 queryEngine.getQueryBackend(ReteBackendFactory.INSTANCE).flushUpdates
588 delayMessageDelivery.setBoolean(queryEngine, true)
589 }
590 }
581} 591}
582 592
583@Data 593@Data
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/SolutionTrajectory.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/SolutionTrajectory.java
index d1a41065..500dd7d2 100644
--- a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/SolutionTrajectory.java
+++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/api/SolutionTrajectory.java
@@ -206,7 +206,14 @@ public class SolutionTrajectory {
206 } 206 }
207 }; 207 };
208 long start = System.nanoTime(); 208 long start = System.nanoTime();
209 editingDomain.getCommandStack().execute(cc); 209 try {
210 ((AdvancedViatraQueryEngine) engine).delayUpdatePropagation(() -> {
211 editingDomain.getCommandStack().execute(cc);
212 return null;
213 });
214 } catch (InvocationTargetException e) {
215 throw new RuntimeException(e);
216 }
210 listener.forwardWorked(System.nanoTime() - start); 217 listener.forwardWorked(System.nanoTime() - start);
211 } 218 }
212 219
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/base/DesignSpaceManager.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/base/DesignSpaceManager.java
index 4c6b4097..7e7a6e51 100644
--- a/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/base/DesignSpaceManager.java
+++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.dse/src/org/eclipse/viatra/dse/base/DesignSpaceManager.java
@@ -151,7 +151,14 @@ public class DesignSpaceManager implements IBacktrackListener {
151 Object previousState = trajectory.getCurrentStateId(); 151 Object previousState = trajectory.getCurrentStateId();
152 152
153 long start = System.nanoTime(); 153 long start = System.nanoTime();
154 domain.getCommandStack().execute(rc); 154 try {
155 engine.delayUpdatePropagation(() -> {
156 domain.getCommandStack().execute(rc);
157 return null;
158 });
159 } catch (InvocationTargetException e) {
160 throw new RuntimeException(e);
161 }
155 forwardTime += System.nanoTime() - start; 162 forwardTime += System.nanoTime() - start;
156 163
157 Object newStateId = stateCoder.createStateCode(); 164 Object newStateId = stateCoder.createStateCode();
@@ -270,7 +277,14 @@ public class DesignSpaceManager implements IBacktrackListener {
270 }; 277 };
271 278
272 long start = System.nanoTime(); 279 long start = System.nanoTime();
273 domain.getCommandStack().execute(rc); 280 try {
281 engine.delayUpdatePropagation(() -> {
282 domain.getCommandStack().execute(rc);
283 return null;
284 });
285 } catch (InvocationTargetException e) {
286 throw new RuntimeException(e);
287 }
274 forwardTime += System.nanoTime() - start; 288 forwardTime += System.nanoTime() - start;
275 289
276 Object newStateId = null; 290 Object newStateId = null;