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 | 25 |
1 files changed, 21 insertions, 4 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 0bdb202e..2376fb38 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 | |||
@@ -14,7 +14,7 @@ import org.eclipse.xtend.lib.annotations.Accessors | |||
14 | 14 | ||
15 | class ScopePropagator { | 15 | class ScopePropagator { |
16 | @Accessors(PROTECTED_GETTER) val PartialInterpretation partialInterpretation | 16 | @Accessors(PROTECTED_GETTER) val PartialInterpretation partialInterpretation |
17 | val ModelGenerationStatistics statistics | 17 | @Accessors(PROTECTED_GETTER) val ModelGenerationStatistics statistics |
18 | val Map<PartialTypeInterpratation, Scope> type2Scope | 18 | val Map<PartialTypeInterpratation, Scope> type2Scope |
19 | @Accessors(PROTECTED_GETTER) val Map<Scope, Set<Scope>> superScopes | 19 | @Accessors(PROTECTED_GETTER) val Map<Scope, Set<Scope>> superScopes |
20 | @Accessors(PROTECTED_GETTER) val Map<Scope, Set<Scope>> subScopes | 20 | @Accessors(PROTECTED_GETTER) val Map<Scope, Set<Scope>> subScopes |
@@ -59,12 +59,21 @@ class ScopePropagator { | |||
59 | } | 59 | } |
60 | } | 60 | } |
61 | } while (changed) | 61 | } while (changed) |
62 | |||
63 | copyScopeBoundsToHeuristic() | ||
62 | } | 64 | } |
63 | 65 | ||
64 | def propagateAllScopeConstraints() { | 66 | def propagateAllScopeConstraints() { |
65 | statistics.incrementScopePropagationCount() | 67 | statistics.incrementScopePropagationCount() |
66 | doPropagateAllScopeConstraints() | 68 | doPropagateAllScopeConstraints() |
67 | } | 69 | } |
70 | |||
71 | protected def copyScopeBoundsToHeuristic() { | ||
72 | partialInterpretation.minNewElementsHeuristic = partialInterpretation.minNewElements | ||
73 | for (scope : partialInterpretation.scopes) { | ||
74 | scope.minNewElementsHeuristic = scope.minNewElements | ||
75 | } | ||
76 | } | ||
68 | 77 | ||
69 | protected def void doPropagateAllScopeConstraints() { | 78 | protected def void doPropagateAllScopeConstraints() { |
70 | // Nothing to propagate. | 79 | // Nothing to propagate. |
@@ -73,12 +82,17 @@ class ScopePropagator { | |||
73 | def propagateAdditionToType(PartialTypeInterpratation t) { | 82 | def propagateAdditionToType(PartialTypeInterpratation t) { |
74 | // println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') | 83 | // println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') |
75 | val targetScope = type2Scope.get(t) | 84 | val targetScope = type2Scope.get(t) |
76 | targetScope.removeOne | 85 | if (targetScope !== null) { |
77 | val sups = superScopes.get(targetScope) | 86 | targetScope.removeOne |
78 | sups.forEach[removeOne] | 87 | val sups = superScopes.get(targetScope) |
88 | sups.forEach[removeOne] | ||
89 | } | ||
79 | if (this.partialInterpretation.minNewElements > 0) { | 90 | if (this.partialInterpretation.minNewElements > 0) { |
80 | this.partialInterpretation.minNewElements = this.partialInterpretation.minNewElements - 1 | 91 | this.partialInterpretation.minNewElements = this.partialInterpretation.minNewElements - 1 |
81 | } | 92 | } |
93 | if (this.partialInterpretation.minNewElementsHeuristic > 0) { | ||
94 | this.partialInterpretation.minNewElementsHeuristic = this.partialInterpretation.minNewElementsHeuristic - 1 | ||
95 | } | ||
82 | if (this.partialInterpretation.maxNewElements > 0) { | 96 | if (this.partialInterpretation.maxNewElements > 0) { |
83 | this.partialInterpretation.maxNewElements = this.partialInterpretation.maxNewElements - 1 | 97 | this.partialInterpretation.maxNewElements = this.partialInterpretation.maxNewElements - 1 |
84 | } else if (this.partialInterpretation.maxNewElements === 0) { | 98 | } else if (this.partialInterpretation.maxNewElements === 0) { |
@@ -105,5 +119,8 @@ class ScopePropagator { | |||
105 | if (scope.minNewElements > 0) { | 119 | if (scope.minNewElements > 0) { |
106 | scope.minNewElements = scope.minNewElements - 1 | 120 | scope.minNewElements = scope.minNewElements - 1 |
107 | } | 121 | } |
122 | if (scope.minNewElementsHeuristic > 0) { | ||
123 | scope.minNewElementsHeuristic = scope.minNewElementsHeuristic - 1 | ||
124 | } | ||
108 | } | 125 | } |
109 | } | 126 | } |