From c420930fbd57421e8accaf3d6af9baa3e868213b Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sun, 14 Jul 2019 20:48:09 +0200 Subject: Transitive closure of type hierarchy in ScopePropagator This does not mappter for propagateAllScopeConstraints(), but propagateAdditionToType gets more exact this way. --- .../cardinality/PolyhedronScopePropagator.xtend | 1 + .../logic2viatra/cardinality/ScopePropagator.xtend | 14 ++++++++++++++ 2 files changed, 15 insertions(+) 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 8f210ffb..cebd89da 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 @@ -27,6 +27,7 @@ class PolyhedronScopePropagator extends ScopePropagator { // Dimensions for instantiable types were created according to the type analysis, // but for any possible primitive types, we create them on demand, // as there is no Type directly associated with a PartialPrimitiveInterpretation. + // Below we will assume that each PartialTypeInterpretation has at most one Scope. for (scope : p.scopes) { switch (targetTypeInterpretation : scope.targetTypeInterpretation) { PartialPrimitiveInterpretation: { 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 c8fb3409..f0494214 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 @@ -47,6 +47,20 @@ class ScopePropagator { } } } + var boolean changed + do { + changed = false + for (scope : p.scopes) { + val subScopeSet = subScopes.get(scope) + val superScopeSet = superScopes.get(scope) + for (subScope : subScopeSet) { + changed = changed || superScopes.get(subScope).addAll(superScopeSet) + } + for (superScope : superScopeSet) { + changed = changed || subScopes.get(superScope).addAll(subScopeSet) + } + } + } while (changed) } def propagateAllScopeConstraints() { -- cgit v1.2.3-54-g00ecf