diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit')
5 files changed, 41 insertions, 13 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend index b79039cb..56beacfa 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend | |||
@@ -1,6 +1,7 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra |
2 | 2 | ||
3 | import com.google.common.collect.ImmutableMap | 3 | import com.google.common.collect.ImmutableMap |
4 | import com.google.common.collect.ImmutableSet | ||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem |
6 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery | 7 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery |
@@ -57,7 +58,7 @@ class ModelGenerationStatistics { | |||
57 | } | 58 | } |
58 | 59 | ||
59 | public var int transformationInvocations | 60 | public var int transformationInvocations |
60 | 61 | ||
61 | synchronized def incrementTransformationCount() { | 62 | synchronized def incrementTransformationCount() { |
62 | transformationInvocations++ | 63 | transformationInvocations++ |
63 | } | 64 | } |
@@ -67,7 +68,7 @@ class ModelGenerationStatistics { | |||
67 | synchronized def incrementScopePropagationCount() { | 68 | synchronized def incrementScopePropagationCount() { |
68 | scopePropagatorInvocations++ | 69 | scopePropagatorInvocations++ |
69 | } | 70 | } |
70 | 71 | ||
71 | public var int scopePropagatorSolverInvocations | 72 | public var int scopePropagatorSolverInvocations |
72 | 73 | ||
73 | synchronized def incrementScopePropagationSolverCount() { | 74 | synchronized def incrementScopePropagationSolverCount() { |
@@ -126,9 +127,7 @@ class ModelGenerationMethodProvider { | |||
126 | val relationConstraints = relationConstraintCalculator.calculateRelationConstraints(logicProblem) | 127 | val relationConstraints = relationConstraintCalculator.calculateRelationConstraints(logicProblem) |
127 | val queries = patternProvider.generateQueries(logicProblem, emptySolution, statistics, existingQueries, | 128 | val queries = patternProvider.generateQueries(logicProblem, emptySolution, statistics, existingQueries, |
128 | workspace, typeInferenceMethod, scopePropagatorStrategy, relationConstraints, hints, writeFiles) | 129 | workspace, typeInferenceMethod, scopePropagatorStrategy, relationConstraints, hints, writeFiles) |
129 | val queryEngine = ViatraQueryEngine.on(new EMFScope(emptySolution)) | 130 | |
130 | GenericQueryGroup.of(queries.allQueries).prepare(queryEngine) | ||
131 | |||
132 | val scopePropagator = createScopePropagator(scopePropagatorStrategy, emptySolution, hints, queries, statistics) | 131 | val scopePropagator = createScopePropagator(scopePropagatorStrategy, emptySolution, hints, queries, statistics) |
133 | scopePropagator.propagateAllScopeConstraints | 132 | scopePropagator.propagateAllScopeConstraints |
134 | val objectRefinementRules = refinementRuleProvider.createObjectRefinementRules(logicProblem, emptySolution, | 133 | val objectRefinementRules = refinementRuleProvider.createObjectRefinementRules(logicProblem, emptySolution, |
@@ -136,7 +135,8 @@ class ModelGenerationMethodProvider { | |||
136 | val relationRefinementRules = refinementRuleProvider.createRelationRefinementRules(queries, scopePropagator, | 135 | val relationRefinementRules = refinementRuleProvider.createRelationRefinementRules(queries, scopePropagator, |
137 | statistics) | 136 | statistics) |
138 | 137 | ||
139 | val unfinishedMultiplicities = goalConstraintProvider.getUnfinishedMultiplicityQueries(logicProblem,queries,calculateObjectCreationCosts) | 138 | val unfinishedMultiplicities = goalConstraintProvider.getUnfinishedMultiplicityQueries(logicProblem, queries, |
139 | calculateObjectCreationCosts) | ||
140 | 140 | ||
141 | val unfinishedWF = queries.getUnfinishedWFQueries.values | 141 | val unfinishedWF = queries.getUnfinishedWFQueries.values |
142 | 142 | ||
@@ -150,10 +150,18 @@ class ModelGenerationMethodProvider { | |||
150 | val modalRelationQueries = modalRelationQueriesBuilder.build | 150 | val modalRelationQueries = modalRelationQueriesBuilder.build |
151 | 151 | ||
152 | val invalidWF = queries.getInvalidWFQueries.values | 152 | val invalidWF = queries.getInvalidWFQueries.values |
153 | 153 | ||
154 | val mustUnitPropagationPreconditions = queries.getMustUnitPropagationPreconditionPatterns | 154 | val mustUnitPropagationPreconditions = queries.getMustUnitPropagationPreconditionPatterns |
155 | val currentUnitPropagationPreconditions = queries.getCurrentUnitPropagationPreconditionPatterns | 155 | val currentUnitPropagationPreconditions = queries.getCurrentUnitPropagationPreconditionPatterns |
156 | 156 | ||
157 | val queriesToPrepare = ImmutableSet.builder.addAll(queries.refineObjectQueries.values).addAll( | ||
158 | queries.refineTypeQueries.values).addAll(queries.refinerelationQueries.values).addAll(queries. | ||
159 | multiplicityConstraintQueries.values.flatMap[allQueries]).addAll(queries.unfinishedWFQueries.values).addAll( | ||
160 | queries.invalidWFQueries.values).addAll(queries.mustUnitPropagationPreconditionPatterns.values).addAll( | ||
161 | queries.currentUnitPropagationPreconditionPatterns.values).add(queries.hasElementInContainmentQuery).build | ||
162 | val queryEngine = ViatraQueryEngine.on(new EMFScope(emptySolution)) | ||
163 | GenericQueryGroup.of(queriesToPrepare).prepare(queryEngine) | ||
164 | |||
157 | return new ModelGenerationMethod( | 165 | return new ModelGenerationMethod( |
158 | statistics, | 166 | statistics, |
159 | objectRefinementRules.values, | 167 | objectRefinementRules.values, |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagator.xtend index db22b95c..c28d4caa 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronScopePropagator.xtend | |||
@@ -114,6 +114,10 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { | |||
114 | override isPropagationNeededAfterAdditionToRelation(Relation r) { | 114 | override isPropagationNeededAfterAdditionToRelation(Relation r) { |
115 | relevantRelations.contains(r) || super.isPropagationNeededAfterAdditionToRelation(r) | 115 | relevantRelations.contains(r) || super.isPropagationNeededAfterAdditionToRelation(r) |
116 | } | 116 | } |
117 | |||
118 | override isQueryEngineFlushRequiredBeforePropagation() { | ||
119 | true | ||
120 | } | ||
117 | 121 | ||
118 | def resetBounds() { | 122 | def resetBounds() { |
119 | for (dimension : polyhedron.dimensions) { | 123 | for (dimension : polyhedron.dimensions) { |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend index 3e95b2cc..93b83577 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend | |||
@@ -130,6 +130,10 @@ class ScopePropagator { | |||
130 | def isPropagationNeededAfterAdditionToRelation(Relation r) { | 130 | def isPropagationNeededAfterAdditionToRelation(Relation r) { |
131 | false | 131 | false |
132 | } | 132 | } |
133 | |||
134 | def isQueryEngineFlushRequiredBeforePropagation() { | ||
135 | false | ||
136 | } | ||
133 | 137 | ||
134 | private def removeOne(Scope scope) { | 138 | private def removeOne(Scope scope) { |
135 | if (scope.minNewElements > 0) { | 139 | if (scope.minNewElements > 0) { |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend index 2f7c9e2d..d57705ce 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend | |||
@@ -1,5 +1,6 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns |
2 | 2 | ||
3 | import com.google.common.collect.ImmutableSet | ||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | 4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation |
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration | 5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration |
5 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDefinition | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDefinition |
@@ -55,6 +56,17 @@ class ModalPatternQueries { | |||
55 | class UnifinishedMultiplicityQueries { | 56 | class UnifinishedMultiplicityQueries { |
56 | val IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> existingMultiplicityQuery | 57 | val IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> existingMultiplicityQuery |
57 | val IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> existingInverseMultiplicityQuery | 58 | val IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> existingInverseMultiplicityQuery |
59 | |||
60 | def Set<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> getAllQueries() { | ||
61 | val builder = ImmutableSet.builder | ||
62 | if (existingMultiplicityQuery !== null) { | ||
63 | builder.add(existingMultiplicityQuery) | ||
64 | } | ||
65 | if (existingInverseMultiplicityQuery !== null) { | ||
66 | builder.add(existingInverseMultiplicityQuery) | ||
67 | } | ||
68 | builder.build | ||
69 | } | ||
58 | } | 70 | } |
59 | 71 | ||
60 | class PatternProvider { | 72 | class PatternProvider { |
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 1d976e14..f7fe97a3 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 | |||
@@ -114,7 +114,7 @@ class RefinementRuleProvider { | |||
114 | ) | 114 | ) |
115 | statistics.addExecutionTime(System.nanoTime - startTime) | 115 | statistics.addExecutionTime(System.nanoTime - startTime) |
116 | 116 | ||
117 | flushQueryEngine | 117 | flushQueryEngine(scopePropagator) |
118 | 118 | ||
119 | // Scope propagation | 119 | // Scope propagation |
120 | val propagatorStartTime = System.nanoTime | 120 | val propagatorStartTime = System.nanoTime |
@@ -144,7 +144,7 @@ class RefinementRuleProvider { | |||
144 | ) | 144 | ) |
145 | statistics.addExecutionTime(System.nanoTime - startTime) | 145 | statistics.addExecutionTime(System.nanoTime - startTime) |
146 | 146 | ||
147 | flushQueryEngine | 147 | flushQueryEngine(scopePropagator) |
148 | 148 | ||
149 | // Scope propagation | 149 | // Scope propagation |
150 | val propagatorStartTime = System.nanoTime | 150 | val propagatorStartTime = System.nanoTime |
@@ -171,7 +171,7 @@ class RefinementRuleProvider { | |||
171 | ) | 171 | ) |
172 | statistics.addExecutionTime(System.nanoTime - startTime) | 172 | statistics.addExecutionTime(System.nanoTime - startTime) |
173 | 173 | ||
174 | flushQueryEngine | 174 | flushQueryEngine(scopePropagator) |
175 | 175 | ||
176 | // Scope propagation | 176 | // Scope propagation |
177 | val propagatorStartTime = System.nanoTime | 177 | val propagatorStartTime = System.nanoTime |
@@ -404,7 +404,7 @@ class RefinementRuleProvider { | |||
404 | 404 | ||
405 | // Scope propagation | 405 | // Scope propagation |
406 | if (scopePropagator.isPropagationNeededAfterAdditionToRelation(declaration)) { | 406 | if (scopePropagator.isPropagationNeededAfterAdditionToRelation(declaration)) { |
407 | flushQueryEngine | 407 | flushQueryEngine(scopePropagator) |
408 | 408 | ||
409 | val propagatorStartTime = System.nanoTime | 409 | val propagatorStartTime = System.nanoTime |
410 | scopePropagator.propagateAllScopeConstraints() | 410 | scopePropagator.propagateAllScopeConstraints() |
@@ -581,8 +581,8 @@ class RefinementRuleProvider { | |||
581 | inverseInterpretation.relationlinks += inverseLink | 581 | inverseInterpretation.relationlinks += inverseLink |
582 | } | 582 | } |
583 | 583 | ||
584 | protected def flushQueryEngine() { | 584 | protected def flushQueryEngine(ScopePropagator scopePropagator) { |
585 | if (queryEngine.updatePropagationDelayed) { | 585 | if (scopePropagator.queryEngineFlushRequiredBeforePropagation && queryEngine.updatePropagationDelayed) { |
586 | delayMessageDelivery.setBoolean(queryEngine, false) | 586 | delayMessageDelivery.setBoolean(queryEngine, false) |
587 | queryEngine.getQueryBackend(ReteBackendFactory.INSTANCE).flushUpdates | 587 | queryEngine.getQueryBackend(ReteBackendFactory.INSTANCE).flushUpdates |
588 | delayMessageDelivery.setBoolean(queryEngine, true) | 588 | delayMessageDelivery.setBoolean(queryEngine, true) |