diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ScopePropagator.xtend | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ScopePropagator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ScopePropagator.xtend index abfa4554..8012776f 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ScopePropagator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ScopePropagator.xtend | |||
@@ -8,6 +8,7 @@ import java.util.Map | |||
8 | import java.util.Set | 8 | import java.util.Set |
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation | 9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation |
10 | import java.util.HashSet | 10 | import java.util.HashSet |
11 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation | ||
11 | 12 | ||
12 | class ScopePropagator { | 13 | class ScopePropagator { |
13 | PartialInterpretation partialInterpretation | 14 | PartialInterpretation partialInterpretation |
@@ -61,38 +62,42 @@ class ScopePropagator { | |||
61 | } | 62 | } |
62 | 63 | ||
63 | def public propagateAdditionToType(PartialTypeInterpratation t) { | 64 | def public propagateAdditionToType(PartialTypeInterpratation t) { |
64 | // println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') | 65 | val isPrimitive = t instanceof PartialPrimitiveInterpretation || t === null |
65 | val targetScope = type2Scope.get(t) | 66 | if(!isPrimitive) { |
66 | if(targetScope!==null) { | 67 | // println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') |
67 | targetScope.removeOne | 68 | val targetScope = type2Scope.get(t) |
68 | val sups = superScopes.get(targetScope) | 69 | if(targetScope!==null) { |
69 | sups.forEach[removeOne] | 70 | targetScope.removeOne |
70 | } | 71 | val sups = superScopes.get(targetScope) |
71 | 72 | sups.forEach[removeOne] | |
72 | if(this.partialInterpretation.minNewElements > 0) { | 73 | } |
73 | this.partialInterpretation.minNewElements = this.partialInterpretation.minNewElements-1 | 74 | |
74 | } | 75 | |
75 | if(this.partialInterpretation.maxNewElements > 0) { | 76 | if(this.partialInterpretation.minNewElements > 0 ) { |
76 | this.partialInterpretation.maxNewElements = this.partialInterpretation.maxNewElements-1 | 77 | this.partialInterpretation.minNewElements = this.partialInterpretation.minNewElements-1 |
77 | } else if(this.partialInterpretation.maxNewElements === 0) { | 78 | } |
78 | this.partialInterpretation.maxNewElements = 0 | 79 | if(this.partialInterpretation.maxNewElements > 0) { |
79 | //throw new IllegalArgumentException('''Inconsistent object creation: lower node limit is 0!''') | 80 | this.partialInterpretation.maxNewElements = this.partialInterpretation.maxNewElements-1 |
81 | } else if(this.partialInterpretation.maxNewElements === 0) { | ||
82 | this.partialInterpretation.maxNewElements = 0 | ||
83 | //throw new IllegalArgumentException('''Inconsistent object creation: lower node limit is 0!''') | ||
84 | } | ||
85 | |||
86 | // subScopes.get(targetScope).forEach[propagateUpperLimitDown(it,targetScope)] | ||
87 | // for(sup: sups) { | ||
88 | // subScopes.get(sup).forEach[propagateUpperLimitDown(it,sup)] | ||
89 | // } | ||
90 | // for(scope : type2Scope.values) { | ||
91 | // propagateUpperLimitDown(scope,partialInterpretation) | ||
92 | // } | ||
93 | |||
94 | propagateAllScopeConstraints | ||
95 | |||
96 | // println('''Target Scope: «targetScope.minNewElements» - «targetScope.maxNewElements»''') | ||
97 | // println(''' «this.partialInterpretation.minNewElements» - «this.partialInterpretation.maxNewElements»''') | ||
98 | // this.partialInterpretation.scopes.forEach[println(''' «(it.targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf.name»: «it.minNewElements»-«it.maxNewElements»''')] | ||
99 | // println('''All constraints are propagated upon increasing «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') | ||
80 | } | 100 | } |
81 | |||
82 | // subScopes.get(targetScope).forEach[propagateUpperLimitDown(it,targetScope)] | ||
83 | // for(sup: sups) { | ||
84 | // subScopes.get(sup).forEach[propagateUpperLimitDown(it,sup)] | ||
85 | // } | ||
86 | // for(scope : type2Scope.values) { | ||
87 | // propagateUpperLimitDown(scope,partialInterpretation) | ||
88 | // } | ||
89 | |||
90 | propagateAllScopeConstraints | ||
91 | |||
92 | // println('''Target Scope: «targetScope.minNewElements» - «targetScope.maxNewElements»''') | ||
93 | // println(''' «this.partialInterpretation.minNewElements» - «this.partialInterpretation.maxNewElements»''') | ||
94 | // this.partialInterpretation.scopes.forEach[println(''' «(it.targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf.name»: «it.minNewElements»-«it.maxNewElements»''')] | ||
95 | // println('''All constraints are propagated upon increasing «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') | ||
96 | } | 101 | } |
97 | 102 | ||
98 | private def propagateLowerLimitUp(Scope subScope, Scope superScope) { | 103 | private def propagateLowerLimitUp(Scope subScope, Scope superScope) { |