diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagator.xtend | 22 |
1 files changed, 17 insertions, 5 deletions
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 3b442cd3..7be6635c 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 | |||
@@ -1,5 +1,7 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality |
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation | ||
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationStatistics | ||
3 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | 5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation |
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | 6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation |
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation | 7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation |
@@ -11,14 +13,15 @@ import java.util.Set | |||
11 | import org.eclipse.xtend.lib.annotations.Accessors | 13 | import org.eclipse.xtend.lib.annotations.Accessors |
12 | 14 | ||
13 | class ScopePropagator { | 15 | class ScopePropagator { |
14 | @Accessors(PROTECTED_GETTER) PartialInterpretation partialInterpretation | 16 | @Accessors(PROTECTED_GETTER) val PartialInterpretation partialInterpretation |
15 | Map<PartialTypeInterpratation, Scope> type2Scope | 17 | val ModelGenerationStatistics statistics |
16 | 18 | val Map<PartialTypeInterpratation, Scope> type2Scope | |
17 | val Map<Scope, Set<Scope>> superScopes | 19 | val Map<Scope, Set<Scope>> superScopes |
18 | val Map<Scope, Set<Scope>> subScopes | 20 | val Map<Scope, Set<Scope>> subScopes |
19 | 21 | ||
20 | new(PartialInterpretation p) { | 22 | new(PartialInterpretation p, ModelGenerationStatistics statistics) { |
21 | partialInterpretation = p | 23 | partialInterpretation = p |
24 | this.statistics = statistics | ||
22 | type2Scope = new HashMap | 25 | type2Scope = new HashMap |
23 | for (scope : p.scopes) { | 26 | for (scope : p.scopes) { |
24 | type2Scope.put(scope.targetTypeInterpretation, scope) | 27 | type2Scope.put(scope.targetTypeInterpretation, scope) |
@@ -57,8 +60,13 @@ class ScopePropagator { | |||
57 | } | 60 | } |
58 | } while (changed) | 61 | } while (changed) |
59 | } | 62 | } |
60 | 63 | ||
61 | def propagateAllScopeConstraints() { | 64 | def propagateAllScopeConstraints() { |
65 | statistics.incrementScopePropagationCount() | ||
66 | doPropagateAllScopeConstraints() | ||
67 | } | ||
68 | |||
69 | protected def doPropagateAllScopeConstraints() { | ||
62 | var boolean hadChanged | 70 | var boolean hadChanged |
63 | do { | 71 | do { |
64 | hadChanged = false | 72 | hadChanged = false |
@@ -95,6 +103,10 @@ class ScopePropagator { | |||
95 | // this.partialInterpretation.scopes.forEach[println(''' «(it.targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf.name»: «it.minNewElements»-«it.maxNewElements»''')] | 103 | // this.partialInterpretation.scopes.forEach[println(''' «(it.targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf.name»: «it.minNewElements»-«it.maxNewElements»''')] |
96 | // println('''All constraints are propagated upon increasing «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') | 104 | // println('''All constraints are propagated upon increasing «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') |
97 | } | 105 | } |
106 | |||
107 | def void propagateAdditionToRelation(Relation r) { | ||
108 | // Nothing to propagate. | ||
109 | } | ||
98 | 110 | ||
99 | private def propagateLowerLimitUp(Scope subScope, Scope superScope) { | 111 | private def propagateLowerLimitUp(Scope subScope, Scope superScope) { |
100 | if (subScope.minNewElements > superScope.minNewElements) { | 112 | if (subScope.minNewElements > superScope.minNewElements) { |