From 07ae9155ce0ab9407566b075356f9b7220ee8380 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sun, 28 Jun 2020 20:33:48 +0200 Subject: Fix scope + numerical solver interaction --- .../MultiplicityGoalConstraintCalculator.xtend | 22 ++-- .../cardinality/PolyhedronScopePropagator.xtend | 133 ++++++++------------- .../cardinality/RelationConstraintCalculator.xtend | 33 +++-- .../RemainingMultiplicityCalculator.xtend | 111 +++++++++++++++++ .../logic2viatra/cardinality/ScopePropagator.xtend | 5 + 5 files changed, 204 insertions(+), 100 deletions(-) create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RemainingMultiplicityCalculator.xtend (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality') diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/MultiplicityGoalConstraintCalculator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/MultiplicityGoalConstraintCalculator.xtend index b28cd584..392ab3ee 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/MultiplicityGoalConstraintCalculator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/MultiplicityGoalConstraintCalculator.xtend @@ -3,29 +3,31 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality import org.eclipse.emf.common.notify.Notifier import org.eclipse.viatra.query.runtime.api.IQuerySpecification import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine -import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher import org.eclipse.viatra.query.runtime.emf.EMFScope class MultiplicityGoalConstraintCalculator { val String targetRelationName val IQuerySpecification querySpecification - var ViatraQueryMatcher matcher + var MultiplicityCalculator calculator val boolean containment + val int lowerBound val int cost - public new(String targetRelationName, IQuerySpecification querySpecification, boolean containment, int cost) { + new(String targetRelationName, IQuerySpecification querySpecification, boolean containment, int lowerBound, int cost) { this.targetRelationName = targetRelationName this.querySpecification = querySpecification - this.matcher = null + this.calculator = null this.containment = containment + this.lowerBound = lowerBound this.cost = cost } new(MultiplicityGoalConstraintCalculator other) { this.targetRelationName = other.targetRelationName this.querySpecification = other.querySpecification - this.matcher = null + this.calculator = null this.containment = other.containment + this.lowerBound = other.lowerBound this.cost = other.cost } @@ -39,16 +41,12 @@ class MultiplicityGoalConstraintCalculator { def init(Notifier notifier) { val engine = ViatraQueryEngine.on(new EMFScope(notifier)) - matcher = querySpecification.getMatcher(engine) + val matcher = querySpecification.getMatcher(engine) + calculator = RemainingMultiplicityCalculator.of(matcher, lowerBound) } def calculateValue() { - var res = 0 - val allMatches = this.matcher.allMatches - for(match : allMatches) { - val missingMultiplicity = match.get(2) as Integer - res += missingMultiplicity - } + val res = calculator.multiplicity // if(res>0) // println(targetRelationName+ " all missing multiplicities: "+res + "*"+cost+"="+res*cost) return res*cost 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 9b4dff0f..db22b95c 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 @@ -33,7 +33,7 @@ import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { static val CACHE_SIZE = 10000 - + val boolean updateHeuristic val Map scopeBounds val LinearBoundedExpression topLevelBounds @@ -185,22 +185,6 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { if (bounds.upperBound !== null && bounds.upperBound < 0) { throw new IllegalArgumentException("Negative upper bound: " + bounds) } - } - - private static def getCalculatedMultiplicity(ViatraQueryMatcher matcher, - PartialInterpretation p) { - val match = matcher.newEmptyMatch - match.set(0, p.problem) - match.set(1, p) - val iterator = matcher.streamAllMatches(match).iterator - if (!iterator.hasNext) { - return null - } - val value = iterator.next.get(2) as Integer - if (iterator.hasNext) { - throw new IllegalArgumentException("Multiplicity calculation query has more than one match") - } - value } @FinalFieldsConstructor @@ -243,7 +227,12 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { IQuerySpecification> hasElementInContainmentQuery, Map>> allPatternsByName, Collection hints, int maximumNuberOfNewNodes) { - infinity = maximumNuberOfNewNodes * INFINITY_SCALE + infinity = if (maximumNuberOfNewNodes <= Integer.MAX_VALUE / INFINITY_SCALE) { + maximumNuberOfNewNodes * INFINITY_SCALE + } else { + Integer.MAX_VALUE + } + queryEngine = ViatraQueryEngine.on(new EMFScope(p)) this.allPatternsByName = allPatternsByName updatersBuilder = ImmutableList.builder @@ -254,7 +243,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { buildConstainmentRootConstraints(containmentConstraints.keySet, hasElementInContainmentQuery) for (pair : constraints.entrySet) { val constraint = pair.key - if (!constraint.containment) { + if (!constraint.containment && !constraint.container) { buildNonContainmentConstraints(constraint, pair.value) } } @@ -289,8 +278,8 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { val typeCoefficients = subtypeDimensions.get(containedType) val orphansLowerBoundCoefficients = new HashMap(typeCoefficients) val orphansUpperBoundCoefficients = new HashMap(typeCoefficients) - val unfinishedMultiplicitiesMatchersBuilder = ImmutableList.builder - val remainingContentsQueriesBuilder = ImmutableList.builder + val unfinishedMultiplicitiesBuilder = ImmutableList.builder + val remainingContentsBuilder = ImmutableList.builder for (pair : constraints) { val constraint = pair.key val containerCoefficients = subtypeDimensions.get(constraint.sourceType) @@ -301,23 +290,21 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { } orphansUpperBoundCoefficients.addCoefficients(-constraint.lowerBound, containerCoefficients) val queries = pair.value - if (constraint.constrainsUnfinished) { - if (queries.unfinishedMultiplicityQuery === null) { - throw new IllegalArgumentException( - "Containment constraints need unfinished multiplicity queries") + if (queries.existingMultiplicityQuery !== null) { + val matcher = queries.existingMultiplicityQuery.getMatcher(queryEngine) + if (constraint.constrainsUnfinished) { + unfinishedMultiplicitiesBuilder.add( + RemainingMultiplicityCalculator.of(matcher, constraint.lowerBound)) } - unfinishedMultiplicitiesMatchersBuilder.add( - queries.unfinishedMultiplicityQuery.getMatcher(queryEngine)) - } - if (queries.remainingContentsQuery === null) { - throw new IllegalArgumentException("Containment constraints need remaining contents queries") + remainingContentsBuilder.add(RemainingMultiplicityCalculator.of(matcher, constraint.upperBound)) + } else if (constraint.constrainsUnfinished) { + throw new IllegalArgumentException("Containment constraints need multiplicity queries") } - remainingContentsQueriesBuilder.add(queries.remainingContentsQuery.getMatcher(queryEngine)) } val orphanLowerBound = orphansLowerBoundCoefficients.toExpression val orphanUpperBound = orphansUpperBoundCoefficients.toExpression - val updater = new ContainmentConstraintUpdater(containedType.name, orphanLowerBound, orphanUpperBound, - unfinishedMultiplicitiesMatchersBuilder.build, remainingContentsQueriesBuilder.build) + val updater = new ContainmentConstraintUpdater(orphanLowerBound, orphanUpperBound, + unfinishedMultiplicitiesBuilder.build, remainingContentsBuilder.build) updatersBuilder.add(updater) } @@ -336,17 +323,21 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { private def buildNonContainmentConstraints(RelationMultiplicityConstraint constraint, UnifinishedMultiplicityQueries queries) { + if (!constraint.reference) { + return + } if (constraint.constrainsRemainingInverse) { - if (queries.unfinishedMultiplicityQuery === null) { - throw new IllegalArgumentException("Reference constraints need unfinished multiplicity queries") - } - val unfinishedMultiplicityMatcher = queries.unfinishedMultiplicityQuery.getMatcher(queryEngine) - if (queries.remainingInverseMultiplicityQuery === null) { - throw new IllegalArgumentException( - "Reference constraints need remaining inverse multiplicity queries") + if (queries.getExistingMultiplicityQuery === null) { + throw new IllegalArgumentException("Reference constraints need unfinished multiplicity queries: " + + constraint.relation) } - val remainingInverseMultiplicityMatcher = queries.remainingInverseMultiplicityQuery.getMatcher( + val existingMultiplicityMatcher = queries.getExistingMultiplicityQuery.getMatcher(queryEngine) + val unfinishedMultiplicityCalculator = RemainingMultiplicityCalculator.of(existingMultiplicityMatcher, + constraint.lowerBound) + val existingInverseMultiplicityMatcher = queries.existingInverseMultiplicityQuery.getMatcher( queryEngine) + val remainingInverseMultiplicityCalculator = new RemainingInverseMultiplicityCalculator( + existingInverseMultiplicityMatcher, constraint.upperBound) val availableMultiplicityCoefficients = new HashMap availableMultiplicityCoefficients.addCoefficients(constraint.inverseUpperBound, subtypeDimensions.get(constraint.targetType)) @@ -354,18 +345,18 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { subtypeDimensions.get(constraint.targetType)) val availableMultiplicity = availableMultiplicityCoefficients.toExpression updatersBuilder.add( - new UnfinishedMultiplicityConstraintUpdater(constraint.relation.name, availableMultiplicity, - unfinishedMultiplicityMatcher, remainingInverseMultiplicityMatcher)) + new UnfinishedMultiplicityConstraintUpdater(availableMultiplicity, unfinishedMultiplicityCalculator, + remainingInverseMultiplicityCalculator)) } if (constraint.constrainsUnrepairable) { - if (queries.unrepairableMultiplicityQuery === null) { - throw new IllegalArgumentException("Reference constraints need unrepairable multiplicity queries") + if (queries.existingMultiplicityQuery.parameters.size < 5) { + throw new IllegalArgumentException("Reference constraints need repairable multiplicity queries: " + + constraint.relation) } - val unrepairableMultiplicityMatcher = queries.unrepairableMultiplicityQuery.getMatcher(queryEngine) + val matcher = queries.existingMultiplicityQuery.getMatcher(queryEngine) + val calculator = new UnrepairableMultiplicityCalculator(matcher, constraint.lowerBound) val targetTypeCardinality = typeBounds.get(constraint.targetType) - updatersBuilder.add( - new UnrepairableMultiplicityConstraintUpdater(constraint.relation.name, targetTypeCardinality, - unrepairableMultiplicityMatcher)) + updatersBuilder.add(new UnrepairableMultiplicityConstraintUpdater(targetTypeCardinality, calculator)) } } @@ -470,11 +461,10 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { @FinalFieldsConstructor private static class ContainmentConstraintUpdater implements RelationConstraintUpdater { - val String name val LinearBoundedExpression orphansLowerBound val LinearBoundedExpression orphansUpperBound - val List> unfinishedMultiplicitiesMatchers - val List> remainingContentsQueries + val List> unfinishedMultiplicities + val List> remainingContents override update(PartialInterpretation p) { tightenLowerBound(p) @@ -483,12 +473,9 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { private def tightenLowerBound(PartialInterpretation p) { var int sum = 0 - for (matcher : remainingContentsQueries) { - val value = matcher.getCalculatedMultiplicity(p) - if (value === null) { - throw new IllegalArgumentException("Remaining contents count is missing for " + name) - } - if (value == -1) { + for (calculator : remainingContents) { + val value = calculator.getMultiplicity(p) + if (value < 0) { // Infinite upper bound, no need to tighten. return } @@ -499,11 +486,8 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { private def tightenUpperBound(PartialInterpretation p) { var int sum = 0 - for (matcher : unfinishedMultiplicitiesMatchers) { - val value = matcher.getCalculatedMultiplicity(p) - if (value === null) { - throw new IllegalArgumentException("Unfinished multiplicity is missing for " + name) - } + for (calculator : unfinishedMultiplicities) { + val value = calculator.getMultiplicity(p) sum += value } orphansUpperBound.tightenLowerBound(sum) @@ -531,20 +515,13 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { @FinalFieldsConstructor private static class UnfinishedMultiplicityConstraintUpdater implements RelationConstraintUpdater { - val String name val LinearBoundedExpression availableMultiplicityExpression - val ViatraQueryMatcher unfinishedMultiplicityMatcher - val ViatraQueryMatcher remainingInverseMultiplicityMatcher + val MultiplicityCalculator unfinishedMultiplicityCalculator + val MultiplicityCalculator remainingInverseMultiplcityCalculator override update(PartialInterpretation p) { - val unfinishedMultiplicity = unfinishedMultiplicityMatcher.getCalculatedMultiplicity(p) - if (unfinishedMultiplicity === null) { - throw new IllegalArgumentException("Unfinished multiplicity is missing for " + name) - } - val remainingInverseMultiplicity = remainingInverseMultiplicityMatcher.getCalculatedMultiplicity(p) - if (remainingInverseMultiplicity === null) { - throw new IllegalArgumentException("Remaining inverse multiplicity is missing for " + name) - } + val unfinishedMultiplicity = unfinishedMultiplicityCalculator.getMultiplicity(p) + val remainingInverseMultiplicity = remainingInverseMultiplcityCalculator.getMultiplicity(p) val int requiredMultiplicity = unfinishedMultiplicity - remainingInverseMultiplicity availableMultiplicityExpression.tightenLowerBound(requiredMultiplicity) } @@ -552,15 +529,11 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator { @FinalFieldsConstructor private static class UnrepairableMultiplicityConstraintUpdater implements RelationConstraintUpdater { - val String name val LinearBoundedExpression targetCardinalityExpression - val ViatraQueryMatcher unrepairableMultiplicityMatcher + val MultiplicityCalculator calculator override update(PartialInterpretation p) { - val value = unrepairableMultiplicityMatcher.getCalculatedMultiplicity(p) - if (value === null) { - throw new IllegalArgumentException("Unrepairable multiplicity is missing for " + name) - } + val value = calculator.getMultiplicity(p) targetCardinalityExpression.tightenLowerBound(value) } } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend index 3e4fea8a..7fec452f 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend @@ -46,11 +46,11 @@ class RelationMultiplicityConstraint { def constrainsUnrepairable() { // TODO Optimize the unrepairable matches computation, // or come up with a heuristic when does computing unrepairables worth the overhead. - constrainsUnfinished && canHaveMultipleSourcesPerTarget && false + constrainsUnfinished && canHaveMultipleSourcesPerTarget && reference } def constrainsRemainingInverse() { - lowerBound >= 1 && !containment && inverseUpperBoundFinite + lowerBound >= 1 && !containment && !container && inverseUpperBoundFinite && reference } def constrainsRemainingContents() { @@ -61,6 +61,18 @@ class RelationMultiplicityConstraint { constrainsUnfinished || constrainsUnrepairable || constrainsRemainingInverse || constrainsRemainingContents } + def isSourceTypeComplex() { + getParamTypeReference(0) instanceof ComplexTypeReference + } + + def isTargetTypeComplex() { + getParamTypeReference(1) instanceof ComplexTypeReference + } + + def isReference() { + sourceTypeComplex && targetTypeComplex + } + def getSourceType() { getParamType(0) } @@ -69,15 +81,20 @@ class RelationMultiplicityConstraint { getParamType(1) } - private def getParamType(int i) { + private def getParamTypeReference(int i) { val parameters = relation.parameters if (i < parameters.size) { - val firstParam = parameters.get(i) - if (firstParam instanceof ComplexTypeReference) { - return firstParam.referred - } + return parameters.get(i) + } + throw new IllegalArgumentException("Argument index out of range") + } + + private def getParamType(int i) { + val reference = getParamTypeReference(i) + if (reference instanceof ComplexTypeReference) { + return reference.referred } - throw new IllegalArgumentException("Constraint with unknown source type") + throw new IllegalArgumentException("Constraint with primitive type") } } diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RemainingMultiplicityCalculator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RemainingMultiplicityCalculator.xtend new file mode 100644 index 00000000..48b52d28 --- /dev/null +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RemainingMultiplicityCalculator.xtend @@ -0,0 +1,111 @@ +package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality + +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation +import java.util.Iterator +import org.eclipse.viatra.query.runtime.api.IPatternMatch +import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher +import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor + +@FinalFieldsConstructor +abstract class MultiplicityCalculator { + val ViatraQueryMatcher matcher + + def getMultiplicity() { + val iterator = matcher.streamAllMatches.iterator + getMultiplicity(iterator) + } + + def getMultiplicity(PartialInterpretation interpretation) { + val partialMatch = matcher.newEmptyMatch + partialMatch.set(0, interpretation.problem) + partialMatch.set(1, interpretation) + val iterator = matcher.streamAllMatches(partialMatch).iterator + getMultiplicity(iterator) + } + + protected def int getMultiplicity(Iterator iterator) +} + +class RemainingMultiplicityCalculator extends MultiplicityCalculator { + val int bound + + @FinalFieldsConstructor + private new() { + } + + protected override getMultiplicity(Iterator iterator) { + var res = 0 + while (iterator.hasNext) { + val match = iterator.next + val existingMultiplicity = match.get(3) as Integer + if (existingMultiplicity < bound) { + res += bound - existingMultiplicity + } + } + res + } + + static def of(ViatraQueryMatcher matcher, int bound) { + if (bound < 0) { + new RemainingInfiniteMultiplicityCalculator(matcher) + } else { + new RemainingMultiplicityCalculator(matcher, bound) + } + } +} + +package class RemainingInfiniteMultiplicityCalculator extends MultiplicityCalculator { + + @FinalFieldsConstructor + package new() { + } + + protected override getMultiplicity(Iterator iterator) { + if (iterator.hasNext) { + -1 + } else { + 0 + } + } +} + +@FinalFieldsConstructor +class UnrepairableMultiplicityCalculator extends MultiplicityCalculator { + val int lowerBound + + override protected getMultiplicity(Iterator iterator) { + var res = 0 + while (iterator.hasNext) { + val match = iterator.next + val existingMultiplicity = match.get(3) as Integer + if (existingMultiplicity < lowerBound) { + val missingMultiplcity = lowerBound - existingMultiplicity + val numerOfRepairMatches = match.get(4) as Integer + val unrepairableMultiplicty = missingMultiplcity - numerOfRepairMatches + if (unrepairableMultiplicty > res) { + res = unrepairableMultiplicty + } + } + } + res + } +} + +@FinalFieldsConstructor +class RemainingInverseMultiplicityCalculator extends MultiplicityCalculator { + val int upperBound + + override protected getMultiplicity(Iterator iterator) { + var res = 0 + while (iterator.hasNext) { + val match = iterator.next + val existingMultiplicity = match.get(3) as Integer + if (existingMultiplicity < upperBound) { + val availableMultiplicity = upperBound - existingMultiplicity + val numberOfRepairMatches = match.get(4) as Integer + res += Math.min(availableMultiplicity, numberOfRepairMatches) + } + } + res + } +} 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 8350c7f4..132ca8e8 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 @@ -4,6 +4,7 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationStatistics import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation +import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope import java.util.HashMap @@ -80,6 +81,10 @@ class ScopePropagator { } def decrementTypeScope(PartialTypeInterpratation t) { + val isPrimitive = t instanceof PartialPrimitiveInterpretation || t === null + if (isPrimitive) { + return + } // println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''') val targetScope = type2Scope.get(t) if (targetScope !== null) { -- cgit v1.2.3-70-g09d2