From d03c841f2e4114a442deb08946c391c823745953 Mon Sep 17 00:00:00 2001 From: Oszkar Semerath Date: Sun, 17 May 2020 01:35:57 +0200 Subject: detailed runtimes + counting defined objects only --- .../logic2viatra/ScopePropagator.xtend | 67 ++++++++++++---------- 1 file changed, 36 insertions(+), 31 deletions(-) (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf') 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 import java.util.Set import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation import java.util.HashSet +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation class ScopePropagator { PartialInterpretation partialInterpretation @@ -61,38 +62,42 @@ class ScopePropagator { } def public propagateAdditionToType(PartialTypeInterpratation t) { -// println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') - val targetScope = type2Scope.get(t) - if(targetScope!==null) { - targetScope.removeOne - val sups = superScopes.get(targetScope) - sups.forEach[removeOne] - } - - if(this.partialInterpretation.minNewElements > 0) { - this.partialInterpretation.minNewElements = this.partialInterpretation.minNewElements-1 - } - if(this.partialInterpretation.maxNewElements > 0) { - this.partialInterpretation.maxNewElements = this.partialInterpretation.maxNewElements-1 - } else if(this.partialInterpretation.maxNewElements === 0) { - this.partialInterpretation.maxNewElements = 0 - //throw new IllegalArgumentException('''Inconsistent object creation: lower node limit is 0!''') + val isPrimitive = t instanceof PartialPrimitiveInterpretation || t === null + if(!isPrimitive) { + // println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') + val targetScope = type2Scope.get(t) + if(targetScope!==null) { + targetScope.removeOne + val sups = superScopes.get(targetScope) + sups.forEach[removeOne] + } + + + if(this.partialInterpretation.minNewElements > 0 ) { + this.partialInterpretation.minNewElements = this.partialInterpretation.minNewElements-1 + } + if(this.partialInterpretation.maxNewElements > 0) { + this.partialInterpretation.maxNewElements = this.partialInterpretation.maxNewElements-1 + } else if(this.partialInterpretation.maxNewElements === 0) { + this.partialInterpretation.maxNewElements = 0 + //throw new IllegalArgumentException('''Inconsistent object creation: lower node limit is 0!''') + } + + // subScopes.get(targetScope).forEach[propagateUpperLimitDown(it,targetScope)] + // for(sup: sups) { + // subScopes.get(sup).forEach[propagateUpperLimitDown(it,sup)] + // } + // for(scope : type2Scope.values) { + // propagateUpperLimitDown(scope,partialInterpretation) + // } + + propagateAllScopeConstraints + + // println('''Target Scope: «targetScope.minNewElements» - «targetScope.maxNewElements»''') + // println(''' «this.partialInterpretation.minNewElements» - «this.partialInterpretation.maxNewElements»''') + // this.partialInterpretation.scopes.forEach[println(''' «(it.targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf.name»: «it.minNewElements»-«it.maxNewElements»''')] + // println('''All constraints are propagated upon increasing «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') } - -// subScopes.get(targetScope).forEach[propagateUpperLimitDown(it,targetScope)] -// for(sup: sups) { -// subScopes.get(sup).forEach[propagateUpperLimitDown(it,sup)] -// } -// for(scope : type2Scope.values) { -// propagateUpperLimitDown(scope,partialInterpretation) -// } - - propagateAllScopeConstraints - -// println('''Target Scope: «targetScope.minNewElements» - «targetScope.maxNewElements»''') -// println(''' «this.partialInterpretation.minNewElements» - «this.partialInterpretation.maxNewElements»''') -// this.partialInterpretation.scopes.forEach[println(''' «(it.targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf.name»: «it.minNewElements»-«it.maxNewElements»''')] -// println('''All constraints are propagated upon increasing «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') } private def propagateLowerLimitUp(Scope subScope, Scope superScope) { -- cgit v1.2.3-54-g00ecf