From 3f5aaab5025b8eb243f414b1c789085327df04f4 Mon Sep 17 00:00:00 2001
From: Kristóf Marussy
Date: Wed, 20 Mar 2019 16:09:09 +0100
Subject: Fault tree transformation for partial models WIP
---
.../logic2viatra/patterns/PatternProvider.xtend | 24 +++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
(limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend')
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
index 0e13a5e1..e87f52af 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
@@ -2,8 +2,10 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration
+import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDefinition
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationStatistics
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysis
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysisResult
@@ -11,7 +13,9 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.util.ParseUtil
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace
+import java.util.Collection
import java.util.Map
+import java.util.Set
import org.eclipse.viatra.query.runtime.api.IPatternMatch
import org.eclipse.viatra.query.runtime.api.IQuerySpecification
import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher
@@ -19,8 +23,6 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery
import org.eclipse.xtend.lib.annotations.Data
import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
-import java.util.Collection
-import java.util.Set
@Data class GeneratedPatterns {
public Map>> invalidWFQueries
@@ -29,9 +31,16 @@ import java.util.Set
public Map>> refineObjectQueries
public Map extends Type, IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>> refineTypeQueries
public Map, IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>> refinerelationQueries
+ public Map modalRelationQueries
public Collection>> allQueries
}
+@Data class ModalPatternQueries {
+ val IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> mayQuery
+ val IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> mustQuery
+ val IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> currentQuery
+}
+
class PatternProvider {
val TypeAnalysis typeAnalysis = new TypeAnalysis
@@ -71,7 +80,7 @@ class PatternProvider {
LogicProblem problem,
PartialInterpretation emptySolution,
TypeAnalysisResult typeAnalysisResult,
- Map>> queries
+ Map>> queries
) {
val Map>>
invalidWFQueries = patternGenerator.invalidIndexer.getInvalidateByWfQueryNames(problem).mapValues[it.lookup(queries)]
@@ -85,6 +94,14 @@ class PatternProvider {
refineTypeQueries = patternGenerator.typeRefinementGenerator.getRefineTypeQueryNames(problem,emptySolution,typeAnalysisResult).mapValues[it.lookup(queries)]
val Map, IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>>
refineRelationQueries = patternGenerator.relationRefinementGenerator.getRefineRelationQueries(problem).mapValues[it.lookup(queries)]
+ val Map modalRelationQueries = problem.relations.filter(RelationDefinition).toMap([it], [ relationDefinition |
+ val indexer = patternGenerator.relationDefinitionIndexer
+ new ModalPatternQueries(
+ indexer.relationDefinitionName(relationDefinition, Modality.MAY).lookup(queries),
+ indexer.relationDefinitionName(relationDefinition, Modality.MUST).lookup(queries),
+ indexer.relationDefinitionName(relationDefinition, Modality.CURRENT).lookup(queries)
+ )
+ ])
return new GeneratedPatterns(
invalidWFQueries,
unfinishedWFQueries,
@@ -92,6 +109,7 @@ class PatternProvider {
refineObjectsQueries,
refineTypeQueries,
refineRelationQueries,
+ modalRelationQueries,
queries.values
)
}
--
cgit v1.2.3-70-g09d2
From 64138e8d91bc8d7bb54d9b042f872b43550dec16 Mon Sep 17 00:00:00 2001
From: Kristóf Marussy
Date: Wed, 24 Jul 2019 10:59:02 +0200
Subject: Cardinality propagator WIP
---
.../ModelGenerationMethodProvider.xtend | 12 +-
.../MultiplicityGoalConstraintCalculator.xtend | 46 ---
.../MultiplicityGoalConstraintCalculator.xtend | 46 +++
.../cardinality/PolyhedronScopePropagator.xtend | 355 +++++++++++++++++----
.../cardinality/PolyhedronSolver.xtend | 32 +-
.../cardinality/RelationConstraintCalculator.xtend | 133 ++++++++
.../logic2viatra/cardinality/ScopePropagator.xtend | 5 -
.../cardinality/ScopePropagatorStrategy.java | 18 ++
.../logic2viatra/patterns/PatternGenerator.xtend | 150 +++++----
.../logic2viatra/patterns/PatternProvider.xtend | 115 ++++---
.../patterns/RelationRefinementGenerator.xtend | 102 +++---
.../patterns/TypeRefinementGenerator.xtend | 4 +-
.../logic2viatra/patterns/UnfinishedIndexer.xtend | 222 +++++++++----
.../rules/GoalConstraintProvider.xtend | 2 +-
.../reasoner/ViatraReasonerConfiguration.xtend | 2 +-
.../dse/UnfinishedMultiplicityObjective.xtend | 10 +-
.../tests/cardinality/PolyhedronSolverTest.xtend | 28 +-
17 files changed, 902 insertions(+), 380 deletions(-)
delete mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/MultiplicityGoalConstraintCalculator.xtend
create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/MultiplicityGoalConstraintCalculator.xtend
create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend
create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.java
(limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend')
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend
index 0ceb5b2e..3a99d3bf 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend
@@ -5,7 +5,9 @@ import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel
import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.CbcPolyhedronSolver
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.MultiplicityGoalConstraintCalculator
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronScopePropagator
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraintCalculator
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagator
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.GeneratedPatterns
@@ -61,6 +63,7 @@ class ModelGenerationMethodProvider {
val PatternProvider patternProvider = new PatternProvider
val RefinementRuleProvider refinementRuleProvider = new RefinementRuleProvider
val GoalConstraintProvider goalConstraintProvider = new GoalConstraintProvider
+ val relationConstraintCalculator = new RelationConstraintCalculator
def ModelGenerationMethod createModelGenerationMethod(
LogicProblem logicProblem,
@@ -77,8 +80,9 @@ class ModelGenerationMethodProvider {
val Set existingQueries = logicProblem.relations.map[annotations].flatten.filter(TransfomedViatraQuery).
map[it.patternPQuery as PQuery].toSet
+ val relationConstraints = relationConstraintCalculator.calculateRelationConstraints(logicProblem)
val queries = patternProvider.generateQueries(logicProblem, emptySolution, statistics, existingQueries,
- workspace, typeInferenceMethod, writeFiles)
+ workspace, typeInferenceMethod, scopePropagatorStrategy, relationConstraints, writeFiles)
val scopePropagator = createScopePropagator(scopePropagatorStrategy, emptySolution, queries)
scopePropagator.propagateAllScopeConstraints
val // LinkedHashMap, BatchTransformationRule>>
@@ -117,10 +121,12 @@ class ModelGenerationMethodProvider {
switch (scopePropagatorStrategy) {
case BasicTypeHierarchy:
new ScopePropagator(emptySolution)
- case PolyhedralTypeHierarchy: {
+ case PolyhedralTypeHierarchy,
+ case PolyhedralRelations: {
val types = queries.refineObjectQueries.keySet.map[newType].toSet
val solver = new CbcPolyhedronSolver
- new PolyhedronScopePropagator(emptySolution, types, solver)
+ new PolyhedronScopePropagator(emptySolution, types, queries.multiplicityConstraintQueries, solver,
+ scopePropagatorStrategy.requiresUpperBoundIndexing)
}
default:
throw new IllegalArgumentException("Unknown scope propagator strategy: " + scopePropagatorStrategy)
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/MultiplicityGoalConstraintCalculator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/MultiplicityGoalConstraintCalculator.xtend
deleted file mode 100644
index 4b9629df..00000000
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/MultiplicityGoalConstraintCalculator.xtend
+++ /dev/null
@@ -1,46 +0,0 @@
-package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra
-
-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;
-
- new(String targetRelationName, IQuerySpecification> querySpecification) {
- this.targetRelationName = targetRelationName
- this.querySpecification = querySpecification
- this.matcher = null
- }
-
- new(MultiplicityGoalConstraintCalculator other) {
- this.targetRelationName = other.targetRelationName
- this.querySpecification = other.querySpecification
- this.matcher = null
- }
-
- def getName() {
- targetRelationName
- }
-
- def init(Notifier notifier) {
- val engine = ViatraQueryEngine.on(new EMFScope(notifier))
- matcher = querySpecification.getMatcher(engine)
- }
-
- def calculateValue() {
- var res = 0
- val allMatches = this.matcher.allMatches
- for(match : allMatches) {
- //println(targetRelationName+ " missing multiplicity: "+match.get(3))
- val missingMultiplicity = match.get(4) as Integer
- res += missingMultiplicity
- }
- //println(targetRelationName+ " all missing multiplicities: "+res)
- return res
- }
-}
\ No newline at end of file
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
new file mode 100644
index 00000000..86a59aa1
--- /dev/null
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/MultiplicityGoalConstraintCalculator.xtend
@@ -0,0 +1,46 @@
+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;
+
+ new(String targetRelationName, IQuerySpecification> querySpecification) {
+ this.targetRelationName = targetRelationName
+ this.querySpecification = querySpecification
+ this.matcher = null
+ }
+
+ new(MultiplicityGoalConstraintCalculator other) {
+ this.targetRelationName = other.targetRelationName
+ this.querySpecification = other.querySpecification
+ this.matcher = null
+ }
+
+ def getName() {
+ targetRelationName
+ }
+
+ def init(Notifier notifier) {
+ val engine = ViatraQueryEngine.on(new EMFScope(notifier))
+ matcher = querySpecification.getMatcher(engine)
+ }
+
+ def calculateValue() {
+ var res = 0
+ val allMatches = this.matcher.allMatches
+ for(match : allMatches) {
+ //println(targetRelationName+ " missing multiplicity: "+match.get(3))
+ val missingMultiplicity = match.get(2) as Integer
+ res += missingMultiplicity
+ }
+ //println(targetRelationName+ " all missing multiplicities: "+res)
+ return res
+ }
+}
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 cebd89da..4f0c8f20 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
@@ -2,90 +2,60 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality
import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableMap
+import com.google.common.collect.Maps
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnifinishedMultiplicityQueries
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.Scope
import java.util.ArrayDeque
+import java.util.ArrayList
import java.util.HashMap
import java.util.HashSet
+import java.util.List
import java.util.Map
import java.util.Set
+import javax.naming.OperationNotSupportedException
+import org.eclipse.viatra.query.runtime.api.IPatternMatch
+import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
+import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher
+import org.eclipse.viatra.query.runtime.emf.EMFScope
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
class PolyhedronScopePropagator extends ScopePropagator {
val Map scopeBounds
- val LinearConstraint topLevelBounds
+ val LinearBoundedExpression topLevelBounds
+ val Polyhedron polyhedron
val PolyhedronSaturationOperator operator
+ List updaters = emptyList
- new(PartialInterpretation p, Set extends Type> possibleNewDynamicTypes, PolyhedronSolver solver) {
+ new(PartialInterpretation p, Set extends Type> possibleNewDynamicTypes,
+ Map unfinishedMultiplicityQueries,
+ PolyhedronSolver solver, boolean propagateRelations) {
super(p)
- val instanceCounts = possibleNewDynamicTypes.toInvertedMap[new Dimension(name, 0, null)]
- val primitiveDimensions = new HashMap
- val constraintsBuilder = ImmutableList.builder
- val scopeBoundsBuilder = ImmutableMap.builder
- // 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: {
- val dimension = primitiveDimensions.computeIfAbsent(targetTypeInterpretation) [ interpretation |
- new Dimension(interpretation.eClass.name, 0, null)
- ]
- scopeBoundsBuilder.put(scope, dimension)
- }
- PartialComplexTypeInterpretation: {
- val complexType = targetTypeInterpretation.interpretationOf
- val dimensions = findSubtypeDimensions(complexType, instanceCounts)
- switch (dimensions.size) {
- case 0:
- if (scope.minNewElements > 0) {
- throw new IllegalArgumentException("Found scope for " + complexType.name +
- ", but the type cannot be instantiated")
- }
- case 1:
- scopeBoundsBuilder.put(scope, dimensions.head)
- default: {
- val constraint = new LinearConstraint(dimensions.toInvertedMap[1], null, null)
- constraintsBuilder.add(constraint)
- scopeBoundsBuilder.put(scope, constraint)
- }
- }
- }
- default:
- throw new IllegalArgumentException("Unknown PartialTypeInterpretation: " + targetTypeInterpretation)
- }
- }
- val allDimensions = ImmutableList.builder.addAll(instanceCounts.values).addAll(primitiveDimensions.values).build
- scopeBounds = scopeBoundsBuilder.build
- topLevelBounds = new LinearConstraint(allDimensions.toInvertedMap[1], null, null)
- constraintsBuilder.add(topLevelBounds)
- val expressionsToSaturate = ImmutableList.builder.addAll(scopeBounds.values).add(topLevelBounds).build
- val polyhedron = new Polyhedron(allDimensions, constraintsBuilder.build, expressionsToSaturate)
+ val builder = new PolyhedronBuilder(p)
+ builder.buildPolyhedron(possibleNewDynamicTypes)
+ scopeBounds = builder.scopeBounds
+ topLevelBounds = builder.topLevelBounds
+ polyhedron = builder.polyhedron
operator = solver.createSaturationOperator(polyhedron)
- }
-
- private def findSubtypeDimensions(Type type, Map instanceCounts) {
- val subtypes = new HashSet
- val dimensions = new HashSet
- val stack = new ArrayDeque
- stack.addLast(type)
- while (!stack.empty) {
- val subtype = stack.removeLast
- if (subtypes.add(subtype)) {
- val dimension = instanceCounts.get(subtype)
- if (dimension !== null) {
- dimensions.add(dimension)
- }
- stack.addAll(subtype.subtypes)
+ if (propagateRelations) {
+ propagateAllScopeConstraints()
+ val maximumNumberOfNewNodes = topLevelBounds.upperBound
+ if (maximumNumberOfNewNodes === null) {
+ throw new IllegalStateException("Could not determine maximum number of new nodes, it may be unbounded")
+ }
+ if (maximumNumberOfNewNodes <= 0) {
+ throw new IllegalStateException("Maximum number of new nodes is negative")
}
+ builder.buildMultiplicityConstraints(unfinishedMultiplicityQueries, maximumNumberOfNewNodes)
+ updaters = builder.updaters
}
- dimensions
}
override void propagateAllScopeConstraints() {
+ resetBounds()
populatePolyhedronFromScope()
val result = operator.saturate()
if (result == PolyhedronSaturationResult.EMPTY) {
@@ -96,21 +66,36 @@ class PolyhedronScopePropagator extends ScopePropagator {
super.propagateAllScopeConstraints()
}
}
+ // println(polyhedron)
+ }
+
+ def resetBounds() {
+ for (dimension : polyhedron.dimensions) {
+ dimension.lowerBound = 0
+ dimension.upperBound = null
+ }
+ for (constraint : polyhedron.constraints) {
+ constraint.lowerBound = null
+ constraint.upperBound = null
+ }
}
private def populatePolyhedronFromScope() {
- topLevelBounds.lowerBound = partialInterpretation.minNewElements
+ topLevelBounds.tightenLowerBound(partialInterpretation.minNewElements)
if (partialInterpretation.maxNewElements >= 0) {
- topLevelBounds.upperBound = partialInterpretation.maxNewElements
+ topLevelBounds.tightenUpperBound(partialInterpretation.maxNewElements)
}
for (pair : scopeBounds.entrySet) {
val scope = pair.key
val bounds = pair.value
- bounds.lowerBound = scope.minNewElements
+ bounds.tightenLowerBound(scope.minNewElements)
if (scope.maxNewElements >= 0) {
- bounds.upperBound = scope.maxNewElements
+ bounds.tightenUpperBound(scope.maxNewElements)
}
}
+ for (updater : updaters) {
+ updater.update(partialInterpretation)
+ }
}
private def populateScopesFromPolyhedron() {
@@ -151,4 +136,242 @@ class PolyhedronScopePropagator extends ScopePropagator {
throw new IllegalArgumentException("Infinite 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
+ private static class PolyhedronBuilder {
+ static val INFINITY_SCALE = 10
+
+ val PartialInterpretation p
+
+ Map instanceCounts
+ Map> subtypeDimensions
+ Map, LinearBoundedExpression> expressionsCache
+ Map typeBounds
+ int infinity
+ ViatraQueryEngine queryEngine
+ ImmutableList.Builder updatersBuilder
+
+ Map scopeBounds
+ LinearBoundedExpression topLevelBounds
+ Polyhedron polyhedron
+ List updaters
+
+ def buildPolyhedron(Set extends Type> possibleNewDynamicTypes) {
+ instanceCounts = possibleNewDynamicTypes.toInvertedMap[new Dimension(name, 0, null)]
+ val types = p.problem.types
+ expressionsCache = Maps.newHashMapWithExpectedSize(types.size)
+ subtypeDimensions = types.toInvertedMap[findSubtypeDimensions.toInvertedMap[1]]
+ typeBounds = ImmutableMap.copyOf(subtypeDimensions.mapValues[toExpression])
+ scopeBounds = buildScopeBounds
+ topLevelBounds = instanceCounts.values.toInvertedMap[1].toExpression
+ val dimensions = ImmutableList.copyOf(instanceCounts.values)
+ val expressionsToSaturate = ImmutableList.copyOf(scopeBounds.values)
+ polyhedron = new Polyhedron(dimensions, new ArrayList, expressionsToSaturate)
+ addCachedConstraintsToPolyhedron()
+ }
+
+ def buildMultiplicityConstraints(
+ Map constraints,
+ int maximumNuberOfNewNodes) {
+ infinity = maximumNuberOfNewNodes * INFINITY_SCALE
+ queryEngine = ViatraQueryEngine.on(new EMFScope(p))
+ updatersBuilder = ImmutableList.builder
+ for (pair : constraints.entrySet.filter[key.containment].groupBy[key.targetType].entrySet) {
+ buildContainmentConstraints(pair.key, pair.value)
+ }
+ for (pair : constraints.entrySet) {
+ val constraint = pair.key
+ if (!constraint.containment) {
+ buildNonContainmentConstraints(constraint, pair.value)
+ }
+ }
+ updaters = updatersBuilder.build
+ addCachedConstraintsToPolyhedron()
+ }
+
+ private def addCachedConstraintsToPolyhedron() {
+ val constraints = new HashSet
+ constraints.addAll(expressionsCache.values.filter(LinearConstraint))
+ constraints.removeAll(polyhedron.constraints)
+ polyhedron.constraints.addAll(constraints)
+ }
+
+ private def buildContainmentConstraints(Type containedType,
+ List> constraints) {
+ val typeCoefficients = subtypeDimensions.get(containedType)
+ val orphansLowerBoundCoefficients = new HashMap(typeCoefficients)
+ val orphansUpperBoundCoefficients = new HashMap(typeCoefficients)
+ val unfinishedMultiplicitiesMatchersBuilder = ImmutableList.builder
+ val remainingContentsQueriesBuilder = ImmutableList.builder
+ for (pair : constraints) {
+ val constraint = pair.key
+ val containerCoefficients = subtypeDimensions.get(constraint.sourceType)
+ if (constraint.isUpperBoundFinite) {
+ orphansLowerBoundCoefficients.addCoefficients(-constraint.upperBound, containerCoefficients)
+ } else {
+ orphansLowerBoundCoefficients.addCoefficients(-infinity, containerCoefficients)
+ }
+ 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")
+ }
+ unfinishedMultiplicitiesMatchersBuilder.add(
+ queries.unfinishedMultiplicityQuery.getMatcher(queryEngine))
+ }
+ if (queries.remainingContentsQuery === null) {
+ throw new IllegalArgumentException("Containment constraints need remaining contents 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)
+ updatersBuilder.add(updater)
+ }
+
+ private def buildNonContainmentConstraints(RelationMultiplicityConstraint constraint,
+ UnifinishedMultiplicityQueries queries) {
+ }
+
+ private def addCoefficients(Map accumulator, int scale, Map a) {
+ for (pair : a.entrySet) {
+ val dimension = pair.key
+ val currentValue = accumulator.get(pair.key) ?: 0
+ val newValue = currentValue + scale * pair.value
+ if (newValue == 0) {
+ accumulator.remove(dimension)
+ } else {
+ accumulator.put(dimension, newValue)
+ }
+ }
+ }
+
+ private def findSubtypeDimensions(Type type) {
+ val subtypes = new HashSet
+ val dimensions = new HashSet
+ val stack = new ArrayDeque
+ stack.addLast(type)
+ while (!stack.empty) {
+ val subtype = stack.removeLast
+ if (subtypes.add(subtype)) {
+ val dimension = instanceCounts.get(subtype)
+ if (dimension !== null) {
+ dimensions.add(dimension)
+ }
+ stack.addAll(subtype.subtypes)
+ }
+ }
+ dimensions
+ }
+
+ private def toExpression(Map coefficients) {
+ expressionsCache.computeIfAbsent(coefficients) [ c |
+ if (c.size == 1 && c.entrySet.head.value == 1) {
+ c.entrySet.head.key
+ } else {
+ new LinearConstraint(c, null, null)
+ }
+ ]
+ }
+
+ private def buildScopeBounds() {
+ val scopeBoundsBuilder = ImmutableMap.builder
+ for (scope : p.scopes) {
+ switch (targetTypeInterpretation : scope.targetTypeInterpretation) {
+ PartialPrimitiveInterpretation:
+ throw new OperationNotSupportedException("Primitive type scopes are not yet implemented")
+ PartialComplexTypeInterpretation: {
+ val complexType = targetTypeInterpretation.interpretationOf
+ val typeBound = typeBounds.get(complexType)
+ if (typeBound === null) {
+ if (scope.minNewElements > 0) {
+ throw new IllegalArgumentException("Found scope for " + complexType.name +
+ ", but the type cannot be instantiated")
+ }
+ } else {
+ scopeBoundsBuilder.put(scope, typeBound)
+ }
+ }
+ default:
+ throw new IllegalArgumentException("Unknown PartialTypeInterpretation: " +
+ targetTypeInterpretation)
+ }
+ }
+ scopeBoundsBuilder.build
+ }
+ }
+
+ private static interface RelationConstraintUpdater {
+ def void update(PartialInterpretation p)
+ }
+
+ @FinalFieldsConstructor
+ static class ContainmentConstraintUpdater implements RelationConstraintUpdater {
+ val String name
+ val LinearBoundedExpression orphansLowerBound
+ val LinearBoundedExpression orphansUpperBound
+ val List> unfinishedMultiplicitiesMatchers
+ val List> remainingContentsQueries
+
+ override update(PartialInterpretation p) {
+ tightenLowerBound(p)
+ tightenUpperBound(p)
+ }
+
+ 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) {
+ // Infinite upper bound, no need to tighten.
+ return
+ }
+ sum += value
+ }
+ orphansLowerBound.tightenUpperBound(sum)
+ }
+
+ 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)
+ }
+ sum += value
+ }
+ orphansUpperBound.tightenLowerBound(sum)
+ }
+ }
+
+ @FinalFieldsConstructor
+ static class ContainmentRootConstraintUpdater implements RelationConstraintUpdater {
+
+ override update(PartialInterpretation p) {
+ throw new UnsupportedOperationException("TODO: auto-generated method stub")
+ }
+ }
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend
index 08bf25b9..9c6cb82e 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend
@@ -52,18 +52,14 @@ class Polyhedron {
val List expressionsToSaturate
override toString() '''
- Dimensions:
- «FOR dimension : dimensions»
- «dimension»
- «ENDFOR»
- Constraints:
- «FOR constraint : constraints»
- «constraint»
- «ENDFOR»
-««« Saturate:
-««« «FOR expression : expressionsToSaturate»
-««« «IF expression instanceof Dimension»dimension«ELSEIF expression instanceof LinearConstraint»constraint«ELSE»unknown«ENDIF» «expression»
-««« «ENDFOR»
+ Dimensions:
+ «FOR dimension : dimensions»
+ «dimension»
+ «ENDFOR»
+ Constraints:
+ «FOR constraint : constraints»
+ «constraint»
+ «ENDFOR»
'''
}
@@ -72,6 +68,18 @@ class Polyhedron {
abstract class LinearBoundedExpression {
var Integer lowerBound
var Integer upperBound
+
+ def void tightenLowerBound(Integer tighterBound) {
+ if (lowerBound === null || (tighterBound !== null && lowerBound < tighterBound)) {
+ lowerBound = tighterBound
+ }
+ }
+
+ def void tightenUpperBound(Integer tighterBound) {
+ if (upperBound === null || (tighterBound !== null && upperBound > tighterBound)) {
+ upperBound = tighterBound
+ }
+ }
}
@Accessors
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
new file mode 100644
index 00000000..ffa9e6e6
--- /dev/null
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/RelationConstraintCalculator.xtend
@@ -0,0 +1,133 @@
+package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality
+
+import com.google.common.collect.ImmutableList
+import com.google.common.collect.ImmutableSet
+import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion
+import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.LowerMultiplicityAssertion
+import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.UpperMultiplicityAssertion
+import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference
+import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation
+import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
+import java.util.HashMap
+import java.util.List
+import org.eclipse.xtend.lib.annotations.Data
+
+@Data
+class RelationConstraints {
+ val List multiplicityConstraints
+}
+
+@Data
+class RelationMultiplicityConstraint {
+ Relation relation
+ boolean containment
+ boolean container
+ int lowerBound
+ int upperBound
+ int inverseUpperBound
+
+ def isUpperBoundFinite() {
+ upperBound >= 0
+ }
+
+ private def isInverseUpperBoundFinite() {
+ inverseUpperBound >= 0
+ }
+
+ private def canHaveMultipleSourcesPerTarget() {
+ inverseUpperBound != 1
+ }
+
+ def constrainsUnfinished() {
+ lowerBound >= 1 && (!container || lowerBound >= 2)
+ }
+
+ def constrainsUnrepairable() {
+ constrainsUnfinished && canHaveMultipleSourcesPerTarget
+ }
+
+ def constrainsRemainingInverse() {
+ !containment && inverseUpperBoundFinite
+ }
+
+ def constrainsRemainingContents() {
+ containment
+ }
+
+ def isActive() {
+ constrainsUnfinished || constrainsUnrepairable || constrainsRemainingInverse || constrainsRemainingContents
+ }
+
+ def getSourceType() {
+ getParamType(0)
+ }
+
+ def getTargetType() {
+ getParamType(1)
+ }
+
+ private def getParamType(int i) {
+ val parameters = relation.parameters
+ if (i < parameters.size) {
+ val firstParam = parameters.get(i)
+ if (firstParam instanceof ComplexTypeReference) {
+ return firstParam.referred
+ }
+ }
+ throw new IllegalArgumentException("Constraint with unknown source type")
+ }
+}
+
+class RelationConstraintCalculator {
+ def calculateRelationConstraints(LogicProblem problem) {
+ val containmentRelations = switch (problem.containmentHierarchies.size) {
+ case 0:
+ emptySet
+ case 1:
+ ImmutableSet.copyOf(problem.containmentHierarchies.head.containmentRelations)
+ default:
+ throw new IllegalArgumentException("Only a single containment hierarchy is supported")
+ }
+ val inverseRelations = new HashMap
+ val lowerMultiplicities = new HashMap
+ val upperMultiplicities = new HashMap
+ for (relation : problem.relations) {
+ lowerMultiplicities.put(relation, 0)
+ upperMultiplicities.put(relation, -1)
+ }
+ for (annotation : problem.annotations) {
+ switch (annotation) {
+ InverseRelationAssertion: {
+ inverseRelations.put(annotation.inverseA, annotation.inverseB)
+ inverseRelations.put(annotation.inverseB, annotation.inverseA)
+ }
+ LowerMultiplicityAssertion:
+ lowerMultiplicities.put(annotation.relation, annotation.lower)
+ UpperMultiplicityAssertion:
+ upperMultiplicities.put(annotation.relation, annotation.upper)
+ }
+ }
+ val multiplicityConstraintsBuilder = ImmutableList.builder()
+ for (relation : problem.relations) {
+ val containment = containmentRelations.contains(relation)
+ val lowerMultiplicity = lowerMultiplicities.get(relation)
+ val upperMultiplicity = upperMultiplicities.get(relation)
+ var container = false
+ var inverseUpperMultiplicity = -1
+ val inverseRelation = inverseRelations.get(relation)
+ if (inverseRelation !== null) {
+ inverseUpperMultiplicity = upperMultiplicities.get(relation)
+ container = containmentRelations.contains(inverseRelation)
+ }
+ val constraint = new RelationMultiplicityConstraint(relation, containment, container, lowerMultiplicity,
+ upperMultiplicity, inverseUpperMultiplicity)
+ if (constraint.isActive) {
+ if (relation.parameters.size != 2) {
+ throw new IllegalArgumentException('''Relation «relation.name» has multiplicity or containment constraints, but it is not binary''')
+ }
+ multiplicityConstraintsBuilder.add(constraint)
+ }
+ }
+ new RelationConstraints(multiplicityConstraintsBuilder.build)
+ }
+}
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 f0494214..3b442cd3 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
@@ -10,11 +10,6 @@ import java.util.Map
import java.util.Set
import org.eclipse.xtend.lib.annotations.Accessors
-enum ScopePropagatorStrategy {
- BasicTypeHierarchy,
- PolyhedralTypeHierarchy
-}
-
class ScopePropagator {
@Accessors(PROTECTED_GETTER) PartialInterpretation partialInterpretation
Map type2Scope
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.java
new file mode 100644
index 00000000..b1c5a658
--- /dev/null
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.java
@@ -0,0 +1,18 @@
+package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality;
+
+public enum ScopePropagatorStrategy {
+ BasicTypeHierarchy,
+
+ PolyhedralTypeHierarchy,
+
+ PolyhedralRelations {
+ @Override
+ public boolean requiresUpperBoundIndexing() {
+ return true;
+ }
+ };
+
+ public boolean requiresUpperBoundIndexing() {
+ return false;
+ }
+}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend
index 24b3e870..1b0db90e 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend
@@ -1,7 +1,6 @@
package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns
import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.InverseRelationAssertion
-import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.LowerMultiplicityAssertion
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.BoolTypeReference
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntTypeReference
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealTypeReference
@@ -17,6 +16,7 @@ import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.Transform
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysisResult
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraints
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
import java.util.HashMap
import java.util.Map
@@ -26,22 +26,26 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery
import org.eclipse.xtend.lib.annotations.Accessors
import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy
class PatternGenerator {
- @Accessors(PUBLIC_GETTER) val TypeIndexer typeIndexer //= new TypeIndexer(this)
- @Accessors(PUBLIC_GETTER) val RelationDeclarationIndexer relationDeclarationIndexer = new RelationDeclarationIndexer(this)
- @Accessors(PUBLIC_GETTER) val RelationDefinitionIndexer relationDefinitionIndexer = new RelationDefinitionIndexer(this)
+ @Accessors(PUBLIC_GETTER) val TypeIndexer typeIndexer // = new TypeIndexer(this)
+ @Accessors(PUBLIC_GETTER) val RelationDeclarationIndexer relationDeclarationIndexer = new RelationDeclarationIndexer(
+ this)
+ @Accessors(PUBLIC_GETTER) val RelationDefinitionIndexer relationDefinitionIndexer = new RelationDefinitionIndexer(
+ this)
@Accessors(PUBLIC_GETTER) val ContainmentIndexer containmentIndexer = new ContainmentIndexer(this)
@Accessors(PUBLIC_GETTER) val InvalidIndexer invalidIndexer = new InvalidIndexer(this)
- @Accessors(PUBLIC_GETTER) val UnfinishedIndexer unfinishedIndexer = new UnfinishedIndexer(this)
- @Accessors(PUBLIC_GETTER) val TypeRefinementGenerator typeRefinementGenerator //= new RefinementGenerator(this)
- @Accessors(PUBLIC_GETTER) val RelationRefinementGenerator relationRefinementGenerator = new RelationRefinementGenerator(this)
-
- public new(TypeInferenceMethod typeInferenceMethod) {
- if(typeInferenceMethod == TypeInferenceMethod.Generic) {
+ @Accessors(PUBLIC_GETTER) val UnfinishedIndexer unfinishedIndexer
+ @Accessors(PUBLIC_GETTER) val TypeRefinementGenerator typeRefinementGenerator // = new RefinementGenerator(this)
+ @Accessors(PUBLIC_GETTER) val RelationRefinementGenerator relationRefinementGenerator = new RelationRefinementGenerator(
+ this)
+
+ new(TypeInferenceMethod typeInferenceMethod, ScopePropagatorStrategy scopePropagatorStrategy) {
+ if (typeInferenceMethod == TypeInferenceMethod.Generic) {
this.typeIndexer = new GenericTypeIndexer(this)
this.typeRefinementGenerator = new GenericTypeRefinementGenerator(this)
- } else if(typeInferenceMethod == TypeInferenceMethod.PreliminaryAnalysis) {
+ } else if (typeInferenceMethod == TypeInferenceMethod.PreliminaryAnalysis) {
this.typeIndexer = new TypeIndexerWithPreliminaryTypeAnalysis(this)
this.typeRefinementGenerator = new TypeRefinementWithPreliminaryTypeAnalysis(this)
} else {
@@ -49,112 +53,100 @@ class PatternGenerator {
this.typeRefinementGenerator = null
throw new IllegalArgumentException('''Unknown type indexing technique : «typeInferenceMethod.name»''')
}
+ this.unfinishedIndexer = new UnfinishedIndexer(this, scopePropagatorStrategy.requiresUpperBoundIndexing)
}
-
- public def requiresTypeAnalysis() {
+
+ def requiresTypeAnalysis() {
typeIndexer.requiresTypeAnalysis || typeRefinementGenerator.requiresTypeAnalysis
}
-
- public dispatch def CharSequence referRelation(
- RelationDeclaration referred,
- String sourceVariable,
- String targetVariable,
- Modality modality,
- Map fqn2PQuery)
- {
- return this.relationDeclarationIndexer.referRelation(referred,sourceVariable,targetVariable,modality)
+
+ dispatch def CharSequence referRelation(RelationDeclaration referred, String sourceVariable, String targetVariable,
+ Modality modality, Map fqn2PQuery) {
+ return this.relationDeclarationIndexer.referRelation(referred, sourceVariable, targetVariable, modality)
}
- public dispatch def CharSequence referRelation(
- RelationDefinition referred,
- String sourceVariable,
- String targetVariable,
- Modality modality,
- Map fqn2PQuery)
- {
- val pattern = referred.annotations.filter(TransfomedViatraQuery).head.patternFullyQualifiedName.lookup(fqn2PQuery)
- return this.relationDefinitionIndexer.referPattern(pattern,#[sourceVariable,targetVariable],modality,true,false)
+
+ dispatch def CharSequence referRelation(RelationDefinition referred, String sourceVariable, String targetVariable,
+ Modality modality, Map fqn2PQuery) {
+ val pattern = referred.annotations.filter(TransfomedViatraQuery).head.patternFullyQualifiedName.lookup(
+ fqn2PQuery)
+ return this.relationDefinitionIndexer.referPattern(pattern, #[sourceVariable, targetVariable], modality, true,
+ false)
}
-
- def public referRelationByName(EReference reference,
- String sourceVariable,
- String targetVariable,
- Modality modality)
- {
- '''find «modality.name.toLowerCase»InRelation«canonizeName('''«reference.name» reference «reference.EContainingClass.name»''')
- »(problem,interpretation,«sourceVariable»,«targetVariable»);'''
+
+ def referRelationByName(EReference reference, String sourceVariable, String targetVariable, Modality modality) {
+ '''find «modality.name.toLowerCase»InRelation«canonizeName('''«reference.name» reference «reference.EContainingClass.name»''')»(problem,interpretation,«sourceVariable»,«targetVariable»);'''
}
-
- def public CharSequence referAttributeByName(EAttribute attribute,
- String sourceVariable,
- String targetVariable,
- Modality modality)
- {
- '''find «modality.name.toLowerCase»InRelation«canonizeName('''«attribute.name» attribute «attribute.EContainingClass.name»''')
- »(problem,interpretation,«sourceVariable»,«targetVariable»);'''
+
+ def CharSequence referAttributeByName(EAttribute attribute, String sourceVariable, String targetVariable,
+ Modality modality) {
+ '''find «modality.name.toLowerCase»InRelation«canonizeName('''«attribute.name» attribute «attribute.EContainingClass.name»''')»(problem,interpretation,«sourceVariable»,«targetVariable»);'''
}
-
- public def canonizeName(String name) {
+
+ def canonizeName(String name) {
name.split(' ').join('_')
}
-
- public def lowerMultiplicities(LogicProblem problem) {
- problem.assertions.map[annotations].flatten.filter(LowerMultiplicityAssertion).filter[!it.relation.isDerived]
- }
- public def wfQueries(LogicProblem problem) {
- problem.assertions.map[it.annotations]
- .flatten
- .filter(TransformedViatraWellformednessConstraint)
- .map[it.query]
+
+ def wfQueries(LogicProblem problem) {
+ problem.assertions.map[it.annotations].flatten.filter(TransformedViatraWellformednessConstraint).map[it.query]
}
- public def getContainments(LogicProblem p) {
+
+ def getContainments(LogicProblem p) {
return p.containmentHierarchies.head.containmentRelations
}
- public def getInverseRelations(LogicProblem p) {
+
+ def getInverseRelations(LogicProblem p) {
val inverseRelations = new HashMap
- p.annotations.filter(InverseRelationAssertion).forEach[
- inverseRelations.put(it.inverseA,it.inverseB)
- inverseRelations.put(it.inverseB,it.inverseA)
+ p.annotations.filter(InverseRelationAssertion).forEach [
+ inverseRelations.put(it.inverseA, it.inverseB)
+ inverseRelations.put(it.inverseB, it.inverseA)
]
return inverseRelations
}
- public def isRepresentative(Relation relation, Relation inverse) {
- if(inverse == null) {
+
+ def isRepresentative(Relation relation, Relation inverse) {
+ if (inverse === null) {
return true
} else {
- relation.name.compareTo(inverse.name)<1
+ relation.name.compareTo(inverse.name) < 1
}
}
-
- public def isDerived(Relation relation) {
+
+ def isDerived(Relation relation) {
relation.annotations.exists[it instanceof DefinedByDerivedFeature]
}
- public def getDerivedDefinition(RelationDeclaration relation) {
+
+ def getDerivedDefinition(RelationDeclaration relation) {
relation.annotations.filter(DefinedByDerivedFeature).head.query
}
-
+
private def allTypeReferences(LogicProblem problem) {
problem.eAllContents.filter(TypeReference).toIterable
}
+
protected def hasBoolean(LogicProblem problem) {
problem.allTypeReferences.exists[it instanceof BoolTypeReference]
}
+
protected def hasInteger(LogicProblem problem) {
problem.allTypeReferences.exists[it instanceof IntTypeReference]
}
+
protected def hasReal(LogicProblem problem) {
problem.allTypeReferences.exists[it instanceof RealTypeReference]
}
+
protected def hasString(LogicProblem problem) {
problem.allTypeReferences.exists[it instanceof StringTypeReference]
}
-
- public def transformBaseProperties(
+
+ def transformBaseProperties(
LogicProblem problem,
PartialInterpretation emptySolution,
- Map fqn2PQuery,
- TypeAnalysisResult typeAnalysisResult
+ Map fqn2PQuery,
+ TypeAnalysisResult typeAnalysisResult,
+ RelationConstraints constraints
) {
-
+
return '''
import epackage "http://www.bme.hu/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage"
import epackage "http://www.bme.hu/mit/inf/dslreasoner/logic/model/problem"
@@ -188,7 +180,7 @@ class PatternGenerator {
private pattern elementCloseWorld(element:DefinedElement) {
PartialInterpretation.openWorldElements(i,element);
- PartialInterpretation.maxNewElements(i,0);
+ PartialInterpretation.maxNewElements(i,0);
} or {
Scope.targetTypeInterpretation(scope,interpretation);
PartialTypeInterpratation.elements(interpretation,element);
@@ -221,7 +213,7 @@ class PatternGenerator {
//////////
// 1.1.1 primitive Type Indexers
//////////
-««« pattern instanceofBoolean(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement) {
+ ««« pattern instanceofBoolean(problem:LogicProblem, interpretation:PartialInterpretation, element:DefinedElement) {
««« find interpretation(problem,interpretation);
««« PartialInterpretation.booleanelements(interpretation,element);
««« }
@@ -279,7 +271,7 @@ class PatternGenerator {
//////////
// 3.1 Unfinishedness Measured by Multiplicity
//////////
- «unfinishedIndexer.generateUnfinishedMultiplicityQueries(problem,fqn2PQuery)»
+ «unfinishedIndexer.generateUnfinishedMultiplicityQueries(constraints.multiplicityConstraints,fqn2PQuery)»
//////////
// 3.2 Unfinishedness Measured by WF Queries
@@ -302,6 +294,6 @@ class PatternGenerator {
// 4.3 Relation refinement
//////////
«relationRefinementGenerator.generateRefineReference(problem)»
- '''
+ '''
}
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
index e87f52af..90f79810 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
@@ -10,6 +10,8 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationStati
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysis
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysisResult
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraints
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationMultiplicityConstraint
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.util.ParseUtil
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace
@@ -23,78 +25,96 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery
import org.eclipse.xtend.lib.annotations.Data
import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy
-@Data class GeneratedPatterns {
- public Map>> invalidWFQueries
- public Map>> unfinishedWFQueries
- public Map>> unfinishedMulticiplicityQueries
- public Map>> refineObjectQueries
- public Map extends Type, IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>> refineTypeQueries
- public Map, IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>> refinerelationQueries
+@Data
+class GeneratedPatterns {
+ public Map>> invalidWFQueries
+ public Map>> unfinishedWFQueries
+ public Map multiplicityConstraintQueries
+ public Map>> unfinishedMulticiplicityQueries
+ public Map>> refineObjectQueries
+ public Map extends Type, IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>> refineTypeQueries
+ public Map, IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>> refinerelationQueries
public Map modalRelationQueries
public Collection>> allQueries
}
-@Data class ModalPatternQueries {
+@Data
+class ModalPatternQueries {
val IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> mayQuery
val IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> mustQuery
val IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> currentQuery
}
+@Data
+class UnifinishedMultiplicityQueries {
+ val IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> unfinishedMultiplicityQuery
+ val IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> unrepairableMultiplicityQuery
+ val IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> remainingInverseMultiplicityQuery
+ val IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> remainingContentsQuery
+}
+
class PatternProvider {
-
+
val TypeAnalysis typeAnalysis = new TypeAnalysis
-
- public def generateQueries(
- LogicProblem problem,
- PartialInterpretation emptySolution,
- ModelGenerationStatistics statistics,
- Set existingQueries,
- ReasonerWorkspace workspace,
- TypeInferenceMethod typeInferenceMethod,
- boolean writeToFile)
- {
+
+ def generateQueries(LogicProblem problem, PartialInterpretation emptySolution, ModelGenerationStatistics statistics,
+ Set existingQueries, ReasonerWorkspace workspace, TypeInferenceMethod typeInferenceMethod,
+ ScopePropagatorStrategy scopePropagatorStrategy, RelationConstraints relationConstraints, boolean writeToFile) {
val fqn2Query = existingQueries.toMap[it.fullyQualifiedName]
- val PatternGenerator patternGenerator = new PatternGenerator(typeInferenceMethod)
- val typeAnalysisResult = if(patternGenerator.requiresTypeAnalysis) {
- val startTime = System.nanoTime
- val result = typeAnalysis.performTypeAnalysis(problem,emptySolution)
- val typeAnalysisTime = System.nanoTime - startTime
- statistics.PreliminaryTypeAnalisisTime = typeAnalysisTime
- result
- } else {
- null
- }
- val baseIndexerFile = patternGenerator.transformBaseProperties(problem,emptySolution,fqn2Query,typeAnalysisResult)
- if(writeToFile) {
- workspace.writeText('''generated3valued.vql_deactivated''',baseIndexerFile)
+ val PatternGenerator patternGenerator = new PatternGenerator(typeInferenceMethod, scopePropagatorStrategy)
+ val typeAnalysisResult = if (patternGenerator.requiresTypeAnalysis) {
+ val startTime = System.nanoTime
+ val result = typeAnalysis.performTypeAnalysis(problem, emptySolution)
+ val typeAnalysisTime = System.nanoTime - startTime
+ statistics.PreliminaryTypeAnalisisTime = typeAnalysisTime
+ result
+ } else {
+ null
+ }
+ val baseIndexerFile = patternGenerator.transformBaseProperties(problem, emptySolution, fqn2Query,
+ typeAnalysisResult, relationConstraints)
+ if (writeToFile) {
+ workspace.writeText('''generated3valued.vql_deactivated''', baseIndexerFile)
}
val ParseUtil parseUtil = new ParseUtil
val generatedQueries = parseUtil.parse(baseIndexerFile)
- val runtimeQueries = calclulateRuntimeQueries(patternGenerator,problem,emptySolution,typeAnalysisResult,generatedQueries);
+ val runtimeQueries = calclulateRuntimeQueries(patternGenerator, problem, emptySolution, typeAnalysisResult,
+ relationConstraints, generatedQueries)
return runtimeQueries
}
-
+
private def GeneratedPatterns calclulateRuntimeQueries(
PatternGenerator patternGenerator,
LogicProblem problem,
PartialInterpretation emptySolution,
TypeAnalysisResult typeAnalysisResult,
+ RelationConstraints relationConstraints,
Map>> queries
) {
- val Map>>
- invalidWFQueries = patternGenerator.invalidIndexer.getInvalidateByWfQueryNames(problem).mapValues[it.lookup(queries)]
- val Map>>
- unfinishedWFQueries = patternGenerator.unfinishedIndexer.getUnfinishedWFQueryNames(problem).mapValues[it.lookup(queries)]
- val Map>>
- unfinishedMultiplicityQueries = patternGenerator.unfinishedIndexer.getUnfinishedMultiplicityQueries(problem).mapValues[it.lookup(queries)]
- val Map>>
- refineObjectsQueries = patternGenerator.typeRefinementGenerator.getRefineObjectQueryNames(problem,emptySolution,typeAnalysisResult).mapValues[it.lookup(queries)]
- val Map extends Type, IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>>
- refineTypeQueries = patternGenerator.typeRefinementGenerator.getRefineTypeQueryNames(problem,emptySolution,typeAnalysisResult).mapValues[it.lookup(queries)]
- val Map, IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>>
- refineRelationQueries = patternGenerator.relationRefinementGenerator.getRefineRelationQueries(problem).mapValues[it.lookup(queries)]
- val Map modalRelationQueries = problem.relations.filter(RelationDefinition).toMap([it], [ relationDefinition |
+ val invalidWFQueries = patternGenerator.invalidIndexer.getInvalidateByWfQueryNames(problem).mapValues [
+ it.lookup(queries)
+ ]
+ val unfinishedWFQueries = patternGenerator.unfinishedIndexer.getUnfinishedWFQueryNames(problem).mapValues [
+ it.lookup(queries)
+ ]
+ val multiplicityConstraintQueries = patternGenerator.unfinishedIndexer.getUnfinishedMultiplicityQueries(
+ relationConstraints.multiplicityConstraints).mapValues [
+ new UnifinishedMultiplicityQueries(unfinishedMultiplicityQueryName?.lookup(queries),
+ unrepairableMultiplicityQueryName?.lookup(queries),
+ remainingInverseMultiplicityQueryName?.lookup(queries), remainingContentsQueryName?.lookup(queries))
+ ]
+ val unfinishedMultiplicityQueries = multiplicityConstraintQueries.entrySet.filter [
+ value.unfinishedMultiplicityQuery !== null
+ ].toMap([key.relation], [value.unfinishedMultiplicityQuery])
+ val refineObjectsQueries = patternGenerator.typeRefinementGenerator.
+ getRefineObjectQueryNames(problem, emptySolution, typeAnalysisResult).mapValues[it.lookup(queries)]
+ val refineTypeQueries = patternGenerator.typeRefinementGenerator.getRefineTypeQueryNames(problem, emptySolution,
+ typeAnalysisResult).mapValues[it.lookup(queries)]
+ val refineRelationQueries = patternGenerator.relationRefinementGenerator.getRefineRelationQueries(problem).
+ mapValues[it.lookup(queries)]
+ val modalRelationQueries = problem.relations.filter(RelationDefinition).toMap([it], [ relationDefinition |
val indexer = patternGenerator.relationDefinitionIndexer
new ModalPatternQueries(
indexer.relationDefinitionName(relationDefinition, Modality.MAY).lookup(queries),
@@ -105,6 +125,7 @@ class PatternProvider {
return new GeneratedPatterns(
invalidWFQueries,
unfinishedWFQueries,
+ multiplicityConstraintQueries,
unfinishedMultiplicityQueries,
refineObjectsQueries,
refineTypeQueries,
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend
index f9e9baea..fa73c861 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend
@@ -9,77 +9,71 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference
class RelationRefinementGenerator {
PatternGenerator base;
+
public new(PatternGenerator base) {
this.base = base
}
-
- def CharSequence generateRefineReference(LogicProblem p) {
- return '''
- «FOR relationRefinement: this.getRelationRefinements(p)»
- pattern «relationRefinementQueryName(relationRefinement.key,relationRefinement.value)»(
- problem:LogicProblem, interpretation:PartialInterpretation,
- relationIterpretation:PartialRelationInterpretation«IF relationRefinement.value != null», oppositeInterpretation:PartialRelationInterpretation«ENDIF»,
- from: DefinedElement, to: DefinedElement)
- {
- find interpretation(problem,interpretation);
- PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation);
- PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"«relationRefinement.key.name»");
- «IF relationRefinement.value != null»
- PartialInterpretation.partialrelationinterpretation(interpretation,oppositeInterpretation);
- PartialRelationInterpretation.interpretationOf.name(oppositeInterpretation,"«relationRefinement.value.name»");
- «ENDIF»
- find mustExist(problem, interpretation, from);
- find mustExist(problem, interpretation, to);
- «base.typeIndexer.referInstanceOfByReference(relationRefinement.key.parameters.get(0), Modality::MUST,"from")»
- «base.typeIndexer.referInstanceOfByReference(relationRefinement.key.parameters.get(1), Modality::MUST,"to")»
- «base.relationDeclarationIndexer.referRelation(relationRefinement.key,"from","to",Modality.MAY)»
- neg «base.relationDeclarationIndexer.referRelation(relationRefinement.key,"from","to",Modality.MUST)»
- }
+
+ def CharSequence generateRefineReference(LogicProblem p) '''
+ «FOR relationRefinement : this.getRelationRefinements(p)»
+ pattern «relationRefinementQueryName(relationRefinement.key,relationRefinement.value)»(
+ problem:LogicProblem, interpretation:PartialInterpretation,
+ relationIterpretation:PartialRelationInterpretation«IF relationRefinement.value !== null», oppositeInterpretation:PartialRelationInterpretation«ENDIF»,
+ from: DefinedElement, to: DefinedElement)
+ {
+ find interpretation(problem,interpretation);
+ PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation);
+ PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"«relationRefinement.key.name»");
+ «IF relationRefinement.value !== null»
+ PartialInterpretation.partialrelationinterpretation(interpretation,oppositeInterpretation);
+ PartialRelationInterpretation.interpretationOf.name(oppositeInterpretation,"«relationRefinement.value.name»");
+ «ENDIF»
+ find mustExist(problem, interpretation, from);
+ find mustExist(problem, interpretation, to);
+ «base.typeIndexer.referInstanceOfByReference(relationRefinement.key.parameters.get(0), Modality::MUST,"from")»
+ «base.typeIndexer.referInstanceOfByReference(relationRefinement.key.parameters.get(1), Modality::MUST,"to")»
+ «base.relationDeclarationIndexer.referRelation(relationRefinement.key,"from","to",Modality.MAY)»
+ neg «base.relationDeclarationIndexer.referRelation(relationRefinement.key,"from","to",Modality.MUST)»
+ }
«ENDFOR»
- '''
- }
-
+ '''
+
def String relationRefinementQueryName(RelationDeclaration relation, Relation inverseRelation) {
- '''«IF inverseRelation != null
- »refineRelation_«base.canonizeName(relation.name)»_and_«base.canonizeName(inverseRelation.name)»«
- ELSE
- »refineRelation_«base.canonizeName(relation.name)»«ENDIF»'''
+ '''«IF inverseRelation !== null»refineRelation_«base.canonizeName(relation.name)»_and_«base.canonizeName(inverseRelation.name)»«ELSE»refineRelation_«base.canonizeName(relation.name)»«ENDIF»'''
}
-
+
def referRefinementQuery(RelationDeclaration relation, Relation inverseRelation, String relInterpretationName,
- String inverseInterpretationName, String sourceName, String targetName)
- '''find «this.relationRefinementQueryName(relation,inverseRelation)»(problem, interpretation, «relInterpretationName», «IF inverseRelation != null»inverseInterpretationName, «ENDIF»«sourceName», «targetName»);'''
-
+ String inverseInterpretationName, String sourceName,
+ String targetName) '''find «this.relationRefinementQueryName(relation,inverseRelation)»(problem, interpretation, «relInterpretationName», «IF inverseRelation !== null»inverseInterpretationName, «ENDIF»«sourceName», «targetName»);'''
+
def getRefineRelationQueries(LogicProblem p) {
// val containmentRelations = p.containmentHierarchies.map[containmentRelations].flatten.toSet
// p.relations.filter(RelationDeclaration).filter[!containmentRelations.contains(it)].toInvertedMap['''refineRelation_«base.canonizeName(it.name)»''']
/*
- val res = new LinkedHashMap
- for(relation: getRelationRefinements(p)) {
- if(inverseRelations.containsKey(relation)) {
- val name = '''refineRelation_«base.canonizeName(relation.name)»_and_«base.canonizeName(inverseRelations.get(relation).name)»'''
- res.put(relation -> inverseRelations.get(relation),name)
- } else {
- val name = '''refineRelation_«base.canonizeName(relation.name)»'''
- res.put(relation -> null,name)
- }
- }
- return res*/
-
- getRelationRefinements(p).toInvertedMap[relationRefinementQueryName(it.key,it.value)]
+ * val res = new LinkedHashMap
+ * for(relation: getRelationRefinements(p)) {
+ * if(inverseRelations.containsKey(relation)) {
+ * val name = '''refineRelation_«base.canonizeName(relation.name)»_and_«base.canonizeName(inverseRelations.get(relation).name)»'''
+ * res.put(relation -> inverseRelations.get(relation),name)
+ * } else {
+ * val name = '''refineRelation_«base.canonizeName(relation.name)»'''
+ * res.put(relation -> null,name)
+ * }
+ * }
+ return res*/
+ getRelationRefinements(p).toInvertedMap[relationRefinementQueryName(it.key, it.value)]
}
-
def getRelationRefinements(LogicProblem p) {
val inverses = base.getInverseRelations(p)
val containments = base.getContainments(p)
val list = new LinkedList
- for(relation : p.relations.filter(RelationDeclaration)) {
- if(!containments.contains(relation)) {
- if(inverses.containsKey(relation)) {
+ for (relation : p.relations.filter(RelationDeclaration)) {
+ if (!containments.contains(relation)) {
+ if (inverses.containsKey(relation)) {
val inverse = inverses.get(relation)
- if(!containments.contains(inverse)) {
- if(base.isRepresentative(relation,inverse)) {
+ if (!containments.contains(inverse)) {
+ if (base.isRepresentative(relation, inverse)) {
list += (relation -> inverse)
}
}
@@ -90,4 +84,4 @@ class RelationRefinementGenerator {
}
return list
}
-}
\ No newline at end of file
+}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementGenerator.xtend
index 7e3fad91..ee7299cd 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementGenerator.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementGenerator.xtend
@@ -86,8 +86,8 @@ abstract class TypeRefinementGenerator {
}
protected def String patternName(Relation containmentRelation, Relation inverseContainment, Type newType) {
- if(containmentRelation != null) {
- if(inverseContainment != null) {
+ if(containmentRelation !== null) {
+ if(inverseContainment !== null) {
'''createObject_«base.canonizeName(newType.name)»_by_«base.canonizeName(containmentRelation.name)»_with_«base.canonizeName(inverseContainment.name)»'''
} else {
'''createObject_«base.canonizeName(newType.name)»_by_«base.canonizeName(containmentRelation.name)»'''
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/UnfinishedIndexer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/UnfinishedIndexer.xtend
index ad1c9033..286756a8 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/UnfinishedIndexer.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/UnfinishedIndexer.xtend
@@ -1,85 +1,195 @@
package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns
-import hu.bme.mit.inf.dslreasoner.ecore2logic.ecore2logicannotations.LowerMultiplicityAssertion
import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
-import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransformedViatraWellformednessConstraint
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationMultiplicityConstraint
+import java.util.LinkedHashMap
+import java.util.List
import java.util.Map
import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery
+import org.eclipse.xtend.lib.annotations.Data
import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
-import java.util.LinkedHashMap
-import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality
-import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.ComplexTypeReference
+
+@Data
+class UnifinishedMultiplicityQueryNames {
+ val String unfinishedMultiplicityQueryName
+ val String unrepairableMultiplicityQueryName
+ val String remainingInverseMultiplicityQueryName
+ val String remainingContentsQueryName
+}
class UnfinishedIndexer {
val PatternGenerator base
-
- new(PatternGenerator patternGenerator) {
+ val boolean indexUpperMultiplicities
+
+ new(PatternGenerator patternGenerator, boolean indexUpperMultiplicities) {
this.base = patternGenerator
+ this.indexUpperMultiplicities = indexUpperMultiplicities
}
-
- def generateUnfinishedWfQueries(LogicProblem problem, Map fqn2PQuery) {
+
+ def generateUnfinishedWfQueries(LogicProblem problem, Map fqn2PQuery) {
val wfQueries = base.wfQueries(problem)
'''
- «FOR wfQuery: wfQueries»
- pattern unfinishedBy_«base.canonizeName(wfQuery.target.name)»(problem:LogicProblem, interpretation:PartialInterpretation,
- «FOR param : wfQuery.patternFullyQualifiedName.lookup(fqn2PQuery).parameters SEPARATOR ', '»var_«param.name»«ENDFOR»)
- {
- «base.relationDefinitionIndexer.referPattern(
+ «FOR wfQuery : wfQueries»
+ pattern unfinishedBy_«base.canonizeName(wfQuery.target.name)»(problem:LogicProblem, interpretation:PartialInterpretation,
+ «FOR param : wfQuery.patternFullyQualifiedName.lookup(fqn2PQuery).parameters SEPARATOR ', '»var_«param.name»«ENDFOR»)
+ {
+ «base.relationDefinitionIndexer.referPattern(
wfQuery.patternFullyQualifiedName.lookup(fqn2PQuery),
wfQuery.patternFullyQualifiedName.lookup(fqn2PQuery).parameters.map['''var_«it.name»'''],
Modality.CURRENT,
true,false)»
- }
- «ENDFOR»
+ }
+ «ENDFOR»
'''
}
+
def getUnfinishedWFQueryNames(LogicProblem problem) {
val wfQueries = base.wfQueries(problem)
val map = new LinkedHashMap
- for(wfQuery : wfQueries) {
- map.put(wfQuery.target,'''unfinishedBy_«base.canonizeName(wfQuery.target.name)»''')
+ for (wfQuery : wfQueries) {
+ map.put(wfQuery.target, '''unfinishedBy_«base.canonizeName(wfQuery.target.name)»''')
}
return map
}
- def generateUnfinishedMultiplicityQueries(LogicProblem problem, Map fqn2PQuery) {
- val lowerMultiplicities = base.lowerMultiplicities(problem)
- return '''
- «FOR lowerMultiplicity : lowerMultiplicities»
- pattern «unfinishedMultiplicityName(lowerMultiplicity)»(problem:LogicProblem, interpretation:PartialInterpretation, relationIterpretation:PartialRelationInterpretation, object:DefinedElement,missingMultiplicity) {
- find interpretation(problem,interpretation);
- PartialInterpretation.partialrelationinterpretation(interpretation,relationIterpretation);
- PartialRelationInterpretation.interpretationOf.name(relationIterpretation,"«lowerMultiplicity.relation.name»");
- «base.typeIndexer.referInstanceOf(lowerMultiplicity.firstParamTypeOfRelation,Modality::MUST,"object")»
- numberOfExistingReferences == count «base.referRelation(lowerMultiplicity.relation,"object","_",Modality.MUST,fqn2PQuery)»
- check(numberOfExistingReferences < «lowerMultiplicity.lower»);
- missingMultiplicity == eval(«lowerMultiplicity.lower»-numberOfExistingReferences);
- }
+
+ def generateUnfinishedMultiplicityQueries(List constraints,
+ Map fqn2PQuery) '''
+ «FOR constraint : constraints»
+ «IF constraint.constrainsUnfinished»
+ private pattern «unfinishedMultiplicityName(constraint)»_helper(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement, missingMultiplicity:java Integer) {
+ find interpretation(problem,interpretation);
+ find mustExist(problem,interpretation,object);
+ «base.typeIndexer.referInstanceOf(constraint.sourceType,Modality::MUST,"object")»
+ numberOfExistingReferences == count «base.referRelation(constraint.relation,"object","_",Modality.MUST,fqn2PQuery)»
+ check(numberOfExistingReferences < «constraint.lowerBound»);
+ missingMultiplicity == eval(«constraint.lowerBound»-numberOfExistingReferences);
+ }
+
+ pattern «unfinishedMultiplicityName(constraint)»(problem:LogicProblem, interpretation:PartialInterpretation, missingMultiplicity:java Integer) {
+ find interpretation(problem,interpretation);
+ missingMultiplicity == sum find «unfinishedMultiplicityName(constraint)»_helper(problem, interpretation, _, #_);
+ }
+ «ENDIF»
+
+ «IF indexUpperMultiplicities»
+ «IF constraint.constrainsUnrepairable»
+ private pattern «repairMatchName(constraint)»(problem:LogicProblem, interpretation:PartialInterpretation, source:DefinedElement, target:DefinedElement) {
+ find interpretation(problem,interpretation);
+ find mustExist(problem,interpretation,source);
+ «base.typeIndexer.referInstanceOf(constraint.sourceType,Modality::MUST,"source")»
+ find mustExist(problem,interpretation,target);
+ «base.typeIndexer.referInstanceOf(constraint.targetType,Modality::MUST,"target")»
+ neg «base.referRelation(constraint.relation,"source","target",Modality.MUST,fqn2PQuery)»
+ «base.referRelation(constraint.relation,"source","target",Modality.MAY,fqn2PQuery)»
+ }
+
+ private pattern «unrepairableMultiplicityName(constraint)»_helper(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement, unrepairableMultiplicity:java Integer) {
+ find interpretation(problem,interpretation);
+ find mustExist(problem,interpretation,object);
+ «base.typeIndexer.referInstanceOf(constraint.sourceType,Modality::MUST,"object")»
+ find «unfinishedMultiplicityName(constraint)»_helper(problem, interpretation, object, missingMultiplicity);
+ numerOfRepairMatches == count find «repairMatchName(constraint)»(problem, interpretation, object, _);
+ check(numerOfRepairMatches < missingMultiplicity);
+ unrepairableMultiplicity == eval(missingMultiplicity-numerOfRepairMatches);
+ }
+
+ private pattern «unrepairableMultiplicityName(constraint)»(problem:LogicProblem, interpretation:PartialInterpretation, unrepairableMultiplicity:java Integer) {
+ find interpretation(problem,interpretation);
+ unrepairableMultiplicity == max find «unrepairableMultiplicityName(constraint)»_helper(problem, interpretation, _, #_);
+ } or {
+ find interpretation(problem,interpretation);
+ neg find «unrepairableMultiplicityName(constraint)»_helper(problem, interpretation, _, _);
+ unrepairableMultiplicity == 0;
+ }
+ «ENDIF»
+
+ «IF constraint.constrainsRemainingInverse»
+ private pattern «remainingMultiplicityName(constraint)»_helper(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement, remainingMultiplicity:java Integer) {
+ find interpretation(problem,interpretation);
+ find mustExist(problem,interpretation,object);
+ «base.typeIndexer.referInstanceOf(constraint.targetType,Modality::MUST,"object")»
+ numberOfExistingReferences == count «base.referRelation(constraint.relation,"_","object",Modality.MUST,fqn2PQuery)»
+ check(numberOfExistingReferences < «constraint.inverseUpperBound»);
+ remainingMultiplicity == eval(«constraint.inverseUpperBound»-numberOfExistingReferences);
+ }
+
+ pattern «remainingMultiplicityName(constraint)»(problem:LogicProblem, interpretation:PartialInterpretation, remainingMultiplicity:java Integer) {
+ find interpretation(problem,interpretation);
+ remainingMultiplicity == sum find «remainingMultiplicityName(constraint)»_helper(problem, interpretation, _, #_);
+ }
+ «ENDIF»
+
+ «IF constraint.constrainsRemainingContents»
+ «IF constraint.upperBoundFinite»
+ private pattern «remainingContentsName(constraint)»_helper(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement, remainingMultiplicity:java Integer) {
+ find interpretation(problem,interpretation);
+ find mustExist(problem,interpretation,object);
+ «base.typeIndexer.referInstanceOf(constraint.sourceType,Modality::MUST,"object")»
+ numberOfExistingReferences == count «base.referRelation(constraint.relation,"object","_",Modality.MUST,fqn2PQuery)»
+ check(numberOfExistingReferences < «constraint.upperBound»);
+ remainingMultiplicity == eval(«constraint.upperBound»-numberOfExistingReferences);
+ }
+
+ pattern «remainingContentsName(constraint)»(problem:LogicProblem, interpretation:PartialInterpretation, remainingMultiplicity:java Integer) {
+ find interpretation(problem,interpretation);
+ remainingMultiplicity == sum find «remainingContentsName(constraint)»_helper(problem, interpretation, _, #_);
+ }
+ «ELSE»
+ pattern «remainingContentsName(constraint)»_helper(problem:LogicProblem, interpretation:PartialInterpretation) {
+ find interpretation(problem,interpretation);
+ find mustExist(problem,interpretation,object);
+ «base.typeIndexer.referInstanceOf(constraint.sourceType,Modality::MUST,"object")»
+ }
+
+ pattern «remainingContentsName(constraint)»(problem:LogicProblem, interpretation:PartialInterpretation, remainingMultiplicity:java Integer) {
+ find interpretation(problem,interpretation);
+ find «remainingContentsName(constraint)»_helper(problem, interpretation);
+ remainingMultiplicity == -1;
+ } or {
+ find interpretation(problem,interpretation);
+ neg find «remainingContentsName(constraint)»_helper(problem, interpretation);
+ remainingMultiplicity == 0;
+ }
+ «ENDIF»
+ «ENDIF»
+ «ENDIF»
«ENDFOR»
- '''
- }
- def String unfinishedMultiplicityName(LowerMultiplicityAssertion lowerMultiplicityAssertion)
- '''unfinishedLowerMultiplicity_«base.canonizeName(lowerMultiplicityAssertion.relation.name)»'''
-
- def public referUnfinishedMultiplicityQuery(LowerMultiplicityAssertion lowerMultiplicityAssertion)
- '''find «unfinishedMultiplicityName(lowerMultiplicityAssertion)»(problem, interpretation ,object, missingMultiplicity);'''
-
- def getFirstParamTypeOfRelation(LowerMultiplicityAssertion lowerMultiplicityAssertion) {
- val parameters = lowerMultiplicityAssertion.relation.parameters
- if(parameters.size == 2) {
- val firstParam = parameters.get(0)
- if(firstParam instanceof ComplexTypeReference) {
- return firstParam.referred
- }
- }
- }
-
- def getUnfinishedMultiplicityQueries(LogicProblem problem) {
- val lowerMultiplicities = base.lowerMultiplicities(problem)
- val map = new LinkedHashMap
- for(lowerMultiplicity : lowerMultiplicities) {
- map.put(lowerMultiplicity.relation,unfinishedMultiplicityName(lowerMultiplicity))
- }
- return map
+ '''
+
+ def String unfinishedMultiplicityName(
+ RelationMultiplicityConstraint constraint) '''unfinishedLowerMultiplicity_«base.canonizeName(constraint.relation.name)»'''
+
+ def String unrepairableMultiplicityName(
+ RelationMultiplicityConstraint constraint) '''unrepairableLowerMultiplicity_«base.canonizeName(constraint.relation.name)»'''
+
+ private def String repairMatchName(
+ RelationMultiplicityConstraint constraint) '''repair_«base.canonizeName(constraint.relation.name)»'''
+
+ def String remainingMultiplicityName(
+ RelationMultiplicityConstraint constraint) '''remainingInverseUpperMultiplicity_«base.canonizeName(constraint.relation.name)»'''
+
+ def String remainingContentsName(
+ RelationMultiplicityConstraint constraint) '''remainingContents_«base.canonizeName(constraint.relation.name)»'''
+
+ def getUnfinishedMultiplicityQueries(List constraints) {
+ constraints.toInvertedMap [ constraint |
+ new UnifinishedMultiplicityQueryNames(
+ if(constraint.constrainsUnfinished) unfinishedMultiplicityName(constraint) else null,
+ if (indexUpperMultiplicities && constraint.constrainsUnrepairable)
+ unrepairableMultiplicityName(constraint)
+ else
+ null,
+ if (indexUpperMultiplicities && constraint.constrainsRemainingInverse)
+ remainingMultiplicityName(constraint)
+ else
+ null,
+ if (indexUpperMultiplicities && constraint.constrainsRemainingContents)
+ remainingContentsName(constraint)
+ else
+ null
+ )
+ ]
}
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/GoalConstraintProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/GoalConstraintProvider.xtend
index e1be2742..b6fdbe06 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/GoalConstraintProvider.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/GoalConstraintProvider.xtend
@@ -1,6 +1,6 @@
package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules
-import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.MultiplicityGoalConstraintCalculator
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.MultiplicityGoalConstraintCalculator
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.GeneratedPatterns
import java.util.ArrayList
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend
index 7a3a2d67..3c9ef74c 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend
@@ -51,7 +51,7 @@ class ViatraReasonerConfiguration extends LogicSolverConfiguration {
*/
public var SearchSpaceConstraint searchSpaceConstraints = new SearchSpaceConstraint
- public var ScopePropagatorStrategy scopePropagatorStrategy = ScopePropagatorStrategy.PolyhedralTypeHierarchy
+ public var ScopePropagatorStrategy scopePropagatorStrategy = ScopePropagatorStrategy.PolyhedralRelations
public var List costObjectives = newArrayList
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/UnfinishedMultiplicityObjective.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/UnfinishedMultiplicityObjective.xtend
index 7d0a7884..9f0c642f 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/UnfinishedMultiplicityObjective.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/UnfinishedMultiplicityObjective.xtend
@@ -1,10 +1,10 @@
package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse
-import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.MultiplicityGoalConstraintCalculator
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.MultiplicityGoalConstraintCalculator
import java.util.Comparator
import org.eclipse.viatra.dse.base.ThreadContext
-import org.eclipse.viatra.dse.objectives.IObjective
import org.eclipse.viatra.dse.objectives.Comparators
+import org.eclipse.viatra.dse.objectives.IObjective
class UnfinishedMultiplicityObjective implements IObjective {
val MultiplicityGoalConstraintCalculator unfinishedMultiplicity;
@@ -29,9 +29,9 @@ class UnfinishedMultiplicityObjective implements IObjective {
override satisifiesHardObjective(Double fitness) { return fitness <=0.01 }
override setComparator(Comparator comparator) {
- throw new UnsupportedOperationException("TODO: auto-generated method stub")
+ throw new UnsupportedOperationException
}
override setLevel(int level) {
- throw new UnsupportedOperationException("TODO: auto-generated method stub")
+ throw new UnsupportedOperationException
}
-}
\ No newline at end of file
+}
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.tests/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/tests/cardinality/PolyhedronSolverTest.xtend b/Tests/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.tests/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/tests/cardinality/PolyhedronSolverTest.xtend
index 789018cb..15758985 100644
--- a/Tests/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.tests/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/tests/cardinality/PolyhedronSolverTest.xtend
+++ b/Tests/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.tests/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/tests/cardinality/PolyhedronSolverTest.xtend
@@ -17,7 +17,7 @@ abstract class PolyhedronSolverTest {
var PolyhedronSaturationOperator operator
protected def PolyhedronSolver createSolver()
-
+
@Before
def void setUp() {
solver = createSolver()
@@ -183,7 +183,7 @@ abstract class PolyhedronSolverTest {
assertEquals(PolyhedronSaturationResult.EMPTY, result)
}
-
+
@Test
def void unboundedRelaxationWithNoIntegerSolutionTest() {
val x = new Dimension("x", 0, 1)
@@ -193,7 +193,29 @@ abstract class PolyhedronSolverTest {
#[new LinearConstraint(#{x -> 2}, 1, 1)],
#[x, y]
))
-
+
+ val result = saturate()
+
+ assertEquals(PolyhedronSaturationResult.EMPTY, result)
+ }
+
+ @Test
+ def void emptyConstraintTest() {
+ val constraint = new LinearConstraint(emptyMap, 0, 1)
+ createSaturationOperator(new Polyhedron(#[], #[constraint], #[constraint]))
+
+ val result = saturate()
+
+ assertEquals(PolyhedronSaturationResult.SATURATED, result)
+ assertEquals(0, constraint.lowerBound)
+ assertEquals(0, constraint.upperBound)
+ }
+
+ @Test
+ def void emptyConstraintUnsatisfiableTest() {
+ val constraint = new LinearConstraint(emptyMap, 1, 0)
+ createSaturationOperator(new Polyhedron(#[], #[constraint], #[constraint]))
+
val result = saturate()
assertEquals(PolyhedronSaturationResult.EMPTY, result)
--
cgit v1.2.3-70-g09d2
From e3e8c7810679acebb3418dd355ca6732b9b117d2 Mon Sep 17 00:00:00 2001
From: Kristóf Marussy
Date: Wed, 24 Jul 2019 14:17:45 +0200
Subject: Containment root constraint propagator
---
.../ModelGenerationMethodProvider.xtend | 5 +-
.../cardinality/PolyhedronScopePropagator.xtend | 44 ++++++++++--
.../patterns/GenericTypeRefinementGenerator.xtend | 6 +-
.../logic2viatra/patterns/PatternProvider.xtend | 6 +-
.../patterns/TypeRefinementGenerator.xtend | 83 ++++++++++++----------
...TypeRefinementWithPreliminaryTypeAnalysis.xtend | 6 +-
6 files changed, 99 insertions(+), 51 deletions(-)
(limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend')
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend
index 3a99d3bf..4b278188 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend
@@ -45,6 +45,7 @@ class ModelGenerationStatistics {
Collection extends BatchTransformationRule, ?>> relationRefinementRules
List unfinishedMultiplicities
+
Collection extends IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>> unfinishedWF
Collection extends IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>> invalidWF
@@ -125,8 +126,8 @@ class ModelGenerationMethodProvider {
case PolyhedralRelations: {
val types = queries.refineObjectQueries.keySet.map[newType].toSet
val solver = new CbcPolyhedronSolver
- new PolyhedronScopePropagator(emptySolution, types, queries.multiplicityConstraintQueries, solver,
- scopePropagatorStrategy.requiresUpperBoundIndexing)
+ new PolyhedronScopePropagator(emptySolution, types, queries.multiplicityConstraintQueries,
+ queries.hasElementInContainmentQuery, solver, scopePropagatorStrategy.requiresUpperBoundIndexing)
}
default:
throw new IllegalArgumentException("Unknown scope propagator strategy: " + scopePropagatorStrategy)
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 4f0c8f20..ce357272 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
@@ -3,6 +3,7 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality
import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableMap
import com.google.common.collect.Maps
+import com.google.common.collect.Sets
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnifinishedMultiplicityQueries
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation
@@ -18,6 +19,7 @@ import java.util.Map
import java.util.Set
import javax.naming.OperationNotSupportedException
import org.eclipse.viatra.query.runtime.api.IPatternMatch
+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
@@ -32,6 +34,7 @@ class PolyhedronScopePropagator extends ScopePropagator {
new(PartialInterpretation p, Set extends Type> possibleNewDynamicTypes,
Map unfinishedMultiplicityQueries,
+ IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> hasElementInContainmentQuery,
PolyhedronSolver solver, boolean propagateRelations) {
super(p)
val builder = new PolyhedronBuilder(p)
@@ -49,7 +52,8 @@ class PolyhedronScopePropagator extends ScopePropagator {
if (maximumNumberOfNewNodes <= 0) {
throw new IllegalStateException("Maximum number of new nodes is negative")
}
- builder.buildMultiplicityConstraints(unfinishedMultiplicityQueries, maximumNumberOfNewNodes)
+ builder.buildMultiplicityConstraints(unfinishedMultiplicityQueries, hasElementInContainmentQuery,
+ maximumNumberOfNewNodes)
updaters = builder.updaters
}
}
@@ -57,6 +61,7 @@ class PolyhedronScopePropagator extends ScopePropagator {
override void propagateAllScopeConstraints() {
resetBounds()
populatePolyhedronFromScope()
+ println(polyhedron)
val result = operator.saturate()
if (result == PolyhedronSaturationResult.EMPTY) {
throw new IllegalStateException("Scope bounds cannot be satisfied")
@@ -66,7 +71,7 @@ class PolyhedronScopePropagator extends ScopePropagator {
super.propagateAllScopeConstraints()
}
}
- // println(polyhedron)
+ println(polyhedron)
}
def resetBounds() {
@@ -188,13 +193,16 @@ class PolyhedronScopePropagator extends ScopePropagator {
def buildMultiplicityConstraints(
Map constraints,
+ IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> hasElementInContainmentQuery,
int maximumNuberOfNewNodes) {
infinity = maximumNuberOfNewNodes * INFINITY_SCALE
queryEngine = ViatraQueryEngine.on(new EMFScope(p))
updatersBuilder = ImmutableList.builder
- for (pair : constraints.entrySet.filter[key.containment].groupBy[key.targetType].entrySet) {
+ val containmentConstraints = constraints.entrySet.filter[key.containment].groupBy[key.targetType]
+ for (pair : containmentConstraints.entrySet) {
buildContainmentConstraints(pair.key, pair.value)
}
+ buildConstainmentRootConstraints(containmentConstraints.keySet, hasElementInContainmentQuery)
for (pair : constraints.entrySet) {
val constraint = pair.key
if (!constraint.containment) {
@@ -249,6 +257,19 @@ class PolyhedronScopePropagator extends ScopePropagator {
updatersBuilder.add(updater)
}
+ private def buildConstainmentRootConstraints(Set containedTypes,
+ IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> hasElementInContainmentQuery) {
+ val matcher = hasElementInContainmentQuery.getMatcher(queryEngine)
+ val rootDimensions = Sets.newHashSet(instanceCounts.values)
+ for (type : containedTypes) {
+ val containedDimensions = subtypeDimensions.get(type).keySet
+ rootDimensions.removeAll(containedDimensions)
+ }
+ for (dimension : rootDimensions) {
+ updatersBuilder.add(new ContainmentRootConstraintUpdater(dimension, matcher))
+ }
+ }
+
private def buildNonContainmentConstraints(RelationMultiplicityConstraint constraint,
UnifinishedMultiplicityQueries queries) {
}
@@ -366,12 +387,23 @@ class PolyhedronScopePropagator extends ScopePropagator {
orphansUpperBound.tightenLowerBound(sum)
}
}
-
+
@FinalFieldsConstructor
static class ContainmentRootConstraintUpdater implements RelationConstraintUpdater {
-
+ val LinearBoundedExpression typeCardinality
+ val ViatraQueryMatcher extends IPatternMatch> hasElementInContainmentMatcher
+
override update(PartialInterpretation p) {
- throw new UnsupportedOperationException("TODO: auto-generated method stub")
+ if (hasElementInContainmentMatcher.hasMatch(p)) {
+ typeCardinality.tightenUpperBound(0)
+ } else {
+ typeCardinality.tightenUpperBound(1)
+ }
+ }
+
+ private static def hasMatch(ViatraQueryMatcher matcher, PartialInterpretation p) {
+ val match = matcher.newMatch(p.problem, p)
+ matcher.countMatches(match) != 0
}
}
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/GenericTypeRefinementGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/GenericTypeRefinementGenerator.xtend
index 2e03d6ed..c9f6abce 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/GenericTypeRefinementGenerator.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/GenericTypeRefinementGenerator.xtend
@@ -11,7 +11,7 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.par
import java.util.HashMap
class GenericTypeRefinementGenerator extends TypeRefinementGenerator {
- public new(PatternGenerator base) {
+ new(PatternGenerator base) {
super(base)
}
override requiresTypeAnalysis() { false }
@@ -25,7 +25,7 @@ class GenericTypeRefinementGenerator extends TypeRefinementGenerator {
inverseRelations.put(it.inverseB,it.inverseA)
]
return '''
- private pattern hasElementInContainment(problem:LogicProblem, interpretation:PartialInterpretation)
+ pattern «hasElementInContainmentName»(problem:LogicProblem, interpretation:PartialInterpretation)
«FOR type :containment.typesOrderedInHierarchy SEPARATOR "or"»{
find interpretation(problem,interpretation);
«base.typeIndexer.referInstanceOf(type,Modality.MUST,"root")»
@@ -77,7 +77,7 @@ class GenericTypeRefinementGenerator extends TypeRefinementGenerator {
typeInterpretation:PartialComplexTypeInterpretation)
{
find interpretation(problem,interpretation);
- neg find hasElementInContainment(problem,interpretation);
+ neg find «hasElementInContainmentName»(problem,interpretation);
PartialInterpretation.partialtypeinterpratation(interpretation,typeInterpretation);
PartialComplexTypeInterpretation.interpretationOf.name(type,"«type.name»");
«base.typeIndexer.referInstanceOf(type,Modality.MAY,"newObject")»
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
index 90f79810..b10c8e88 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
@@ -12,6 +12,7 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysisResult
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraints
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationMultiplicityConstraint
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.util.ParseUtil
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace
@@ -25,13 +26,13 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery
import org.eclipse.xtend.lib.annotations.Data
import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
-import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy
@Data
class GeneratedPatterns {
public Map>> invalidWFQueries
public Map>> unfinishedWFQueries
public Map multiplicityConstraintQueries
+ public IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> hasElementInContainmentQuery
public Map>> unfinishedMulticiplicityQueries
public Map>> refineObjectQueries
public Map extends Type, IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>> refineTypeQueries
@@ -105,6 +106,8 @@ class PatternProvider {
unrepairableMultiplicityQueryName?.lookup(queries),
remainingInverseMultiplicityQueryName?.lookup(queries), remainingContentsQueryName?.lookup(queries))
]
+ val hasElementInContainmentQuery = patternGenerator.typeRefinementGenerator.hasElementInContainmentName.lookup(
+ queries)
val unfinishedMultiplicityQueries = multiplicityConstraintQueries.entrySet.filter [
value.unfinishedMultiplicityQuery !== null
].toMap([key.relation], [value.unfinishedMultiplicityQuery])
@@ -126,6 +129,7 @@ class PatternProvider {
invalidWFQueries,
unfinishedWFQueries,
multiplicityConstraintQueries,
+ hasElementInContainmentQuery,
unfinishedMultiplicityQueries,
refineObjectsQueries,
refineTypeQueries,
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementGenerator.xtend
index ee7299cd..4ef336ae 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementGenerator.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementGenerator.xtend
@@ -25,69 +25,76 @@ class ObjectCreationPrecondition {
abstract class TypeRefinementGenerator {
val protected PatternGenerator base;
- public new(PatternGenerator base) {
+
+ new(PatternGenerator base) {
this.base = base
}
-
- public def boolean requiresTypeAnalysis()
- public def CharSequence generateRefineObjectQueries(LogicProblem p, PartialInterpretation emptySolution, TypeAnalysisResult typeAnalysisResult)
- public def CharSequence generateRefineTypeQueries(LogicProblem p, PartialInterpretation emptySolution, TypeAnalysisResult typeAnalysisResult)
- public def Map extends Type, String> getRefineTypeQueryNames(LogicProblem p, PartialInterpretation emptySolution, TypeAnalysisResult typeAnalysisResult)
-
- public def getRefineObjectQueryNames(LogicProblem p, PartialInterpretation emptySolution, TypeAnalysisResult typeAnalysisResult) {
- val Map objectCreationQueries = new LinkedHashMap
+
+ def boolean requiresTypeAnalysis()
+
+ def CharSequence generateRefineObjectQueries(LogicProblem p, PartialInterpretation emptySolution,
+ TypeAnalysisResult typeAnalysisResult)
+
+ def CharSequence generateRefineTypeQueries(LogicProblem p, PartialInterpretation emptySolution,
+ TypeAnalysisResult typeAnalysisResult)
+
+ def Map extends Type, String> getRefineTypeQueryNames(LogicProblem p, PartialInterpretation emptySolution,
+ TypeAnalysisResult typeAnalysisResult)
+
+ def getRefineObjectQueryNames(LogicProblem p, PartialInterpretation emptySolution,
+ TypeAnalysisResult typeAnalysisResult) {
+ val Map objectCreationQueries = new LinkedHashMap
val containment = p.containmentHierarchies.head
val inverseRelations = new HashMap
- p.annotations.filter(InverseRelationAssertion).forEach[
- inverseRelations.put(it.inverseA,it.inverseB)
- inverseRelations.put(it.inverseB,it.inverseA)
+ p.annotations.filter(InverseRelationAssertion).forEach [
+ inverseRelations.put(it.inverseA, it.inverseB)
+ inverseRelations.put(it.inverseB, it.inverseA)
]
- for(type: p.types.filter(TypeDeclaration).filter[!it.isAbstract]) {
- if(containment.typeInContainment(type)) {
- for(containmentRelation : containment.containmentRelations.filter[canBeContainedByRelation(it,type)]) {
- if(inverseRelations.containsKey(containmentRelation)) {
+ for (type : p.types.filter(TypeDeclaration).filter[!it.isAbstract]) {
+ if (containment.typeInContainment(type)) {
+ for (containmentRelation : containment.containmentRelations.
+ filter[canBeContainedByRelation(it, type)]) {
+ if (inverseRelations.containsKey(containmentRelation)) {
objectCreationQueries.put(
- new ObjectCreationPrecondition(containmentRelation,inverseRelations.get(containmentRelation),type),
- this.patternName(containmentRelation,inverseRelations.get(containmentRelation),type))
+ new ObjectCreationPrecondition(containmentRelation,
+ inverseRelations.get(containmentRelation), type),
+ this.patternName(containmentRelation, inverseRelations.get(containmentRelation), type))
} else {
- objectCreationQueries.put(
- new ObjectCreationPrecondition(containmentRelation,null,type),
- patternName(containmentRelation,null,type))
+ objectCreationQueries.put(new ObjectCreationPrecondition(containmentRelation, null, type),
+ patternName(containmentRelation, null, type))
}
}
- objectCreationQueries.put(
- new ObjectCreationPrecondition(null,null,type),
- patternName(null,null,type))
+ objectCreationQueries.put(new ObjectCreationPrecondition(null, null, type),
+ patternName(null, null, type))
} else {
- objectCreationQueries.put(
- new ObjectCreationPrecondition(null,null,type),
- this.patternName(null,null,type))
+ objectCreationQueries.put(new ObjectCreationPrecondition(null, null, type),
+ this.patternName(null, null, type))
}
}
return objectCreationQueries
}
-
+
protected def canBeContainedByRelation(Relation r, Type t) {
- if(r.parameters.size==2) {
+ if (r.parameters.size == 2) {
val param = r.parameters.get(1)
- if(param instanceof ComplexTypeReference) {
+ if (param instanceof ComplexTypeReference) {
val allSuperTypes = t.transitiveClosureStar[it.supertypes]
- for(superType : allSuperTypes) {
+ for (superType : allSuperTypes) {
if(param.referred == superType) return true
}
}
}
return false
}
-
+
private def typeInContainment(ContainmentHierarchy hierarchy, Type type) {
val allSuperTypes = type.transitiveClosureStar[it.supertypes]
return allSuperTypes.exists[hierarchy.typesOrderedInHierarchy.contains(it)]
}
-
+
protected def String patternName(Relation containmentRelation, Relation inverseContainment, Type newType) {
- if(containmentRelation !== null) {
- if(inverseContainment !== null) {
+ if (containmentRelation !== null) {
+ if (inverseContainment !== null) {
'''createObject_«base.canonizeName(newType.name)»_by_«base.canonizeName(containmentRelation.name)»_with_«base.canonizeName(inverseContainment.name)»'''
} else {
'''createObject_«base.canonizeName(newType.name)»_by_«base.canonizeName(containmentRelation.name)»'''
@@ -96,4 +103,8 @@ abstract class TypeRefinementGenerator {
'''createObject_«base.canonizeName(newType.name)»'''
}
}
-}
\ No newline at end of file
+
+ def hasElementInContainmentName() {
+ "hasElementInContainment"
+ }
+}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementWithPreliminaryTypeAnalysis.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementWithPreliminaryTypeAnalysis.xtend
index cbbbcb08..1a81695e 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementWithPreliminaryTypeAnalysis.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeRefinementWithPreliminaryTypeAnalysis.xtend
@@ -10,7 +10,7 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.par
import java.util.HashMap
class TypeRefinementWithPreliminaryTypeAnalysis extends TypeRefinementGenerator{
- public new(PatternGenerator base) {
+ new(PatternGenerator base) {
super(base)
}
override requiresTypeAnalysis() { true }
@@ -24,7 +24,7 @@ class TypeRefinementWithPreliminaryTypeAnalysis extends TypeRefinementGenerator{
inverseRelations.put(it.inverseB,it.inverseA)
]
return '''
- private pattern hasElementInContainment(problem:LogicProblem, interpretation:PartialInterpretation)
+ pattern «hasElementInContainmentName»(problem:LogicProblem, interpretation:PartialInterpretation)
«FOR type :containment.typesOrderedInHierarchy SEPARATOR "or"»{
find interpretation(problem,interpretation);
«base.typeIndexer.referInstanceOf(type,Modality.MUST,"root")»
@@ -76,7 +76,7 @@ class TypeRefinementWithPreliminaryTypeAnalysis extends TypeRefinementGenerator{
typeInterpretation:PartialComplexTypeInterpretation)
{
find interpretation(problem,interpretation);
- neg find hasElementInContainment(problem,interpretation);
+ neg find «hasElementInContainmentName»(problem,interpretation);
PartialInterpretation.partialtypeinterpratation(interpretation,typeInterpretation);
PartialComplexTypeInterpretation.interpretationOf.name(typeInterpretation,"«type.name»");
«base.typeIndexer.referInstanceOf(type,Modality.MAY,"newObject")»
--
cgit v1.2.3-70-g09d2
From 7021a4d1f2805ebf3145cbc3893761d12f23361f Mon Sep 17 00:00:00 2001
From: Kristóf Marussy
Date: Thu, 1 Aug 2019 01:00:12 +0200
Subject: Configurability and better statistics for measurements
---
.../execution/GenerationTaskExecutor.xtend | 2 +-
.../ModelGenerationMethodProvider.xtend | 54 ++++++++++++++----
.../cardinality/PolyhedronScopePropagator.xtend | 33 ++++++++++-
.../cardinality/RelationConstraintCalculator.xtend | 7 ++-
.../logic2viatra/cardinality/ScopePropagator.xtend | 22 ++++++--
.../cardinality/ScopePropagatorStrategy.java | 18 ------
.../cardinality/ScopePropagatorStrategy.xtend | 64 ++++++++++++++++++++++
.../logic2viatra/patterns/PatternProvider.xtend | 2 +-
.../rules/RefinementRuleProvider.xtend | 40 ++++++++++----
.../viatrasolver/reasoner/ViatraReasoner.xtend | 28 ++++++++--
.../reasoner/ViatraReasonerConfiguration.xtend | 8 ++-
.../dse/BestFirstStrategyForModelGeneration.java | 1 +
12 files changed, 218 insertions(+), 61 deletions(-)
delete mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.java
create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.xtend
(limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend')
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend
index 8ea674d3..807d217a 100644
--- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend
+++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend
@@ -293,7 +293,7 @@ class GenerationTaskExecutor {
statistics.put("Domain to logic transformation time",domain2LogicTransformationTime/1000000)
statistics.put("Logic to solver transformation time",solution.statistics.transformationTime)
statistics.put("Solver time",solution.statistics.solverTime)
- statistics.put("Postprocessing time",solutionVisualisationTime)
+ statistics.put("Postprocessing time",solutionVisualisationTime/1000000)
for(entry: solution.statistics.entries) {
statistics.put(entry.name,statisticsUtil.readValue(entry))
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend
index 4b278188..8e061b63 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend
@@ -27,6 +27,7 @@ import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher
import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery
import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRule
import org.eclipse.xtend.lib.annotations.Data
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.Z3PolyhedronSolver
class ModelGenerationStatistics {
public var long transformationExecutionTime = 0
@@ -35,7 +36,25 @@ class ModelGenerationStatistics {
transformationExecutionTime += amount
}
- public var long PreliminaryTypeAnalisisTime = 0
+ public var long scopePropagationTime = 0
+
+ synchronized def addScopePropagationTime(long amount) {
+ scopePropagationTime += amount
+ }
+
+ public var long preliminaryTypeAnalisisTime = 0
+
+ public var int decisionsTried = 0
+
+ synchronized def incrementDecisionCount() {
+ decisionsTried++
+ }
+
+ public var int scopePropagatorInvocations
+
+ synchronized def incrementScopePropagationCount() {
+ scopePropagatorInvocations++
+ }
}
@Data class ModelGenerationMethod {
@@ -84,12 +103,12 @@ class ModelGenerationMethodProvider {
val relationConstraints = relationConstraintCalculator.calculateRelationConstraints(logicProblem)
val queries = patternProvider.generateQueries(logicProblem, emptySolution, statistics, existingQueries,
workspace, typeInferenceMethod, scopePropagatorStrategy, relationConstraints, writeFiles)
- val scopePropagator = createScopePropagator(scopePropagatorStrategy, emptySolution, queries)
+ val scopePropagator = createScopePropagator(scopePropagatorStrategy, emptySolution, queries, statistics)
scopePropagator.propagateAllScopeConstraints
- val // LinkedHashMap, BatchTransformationRule>>
- objectRefinementRules = refinementRuleProvider.createObjectRefinementRules(queries, scopePropagator,
+ val objectRefinementRules = refinementRuleProvider.createObjectRefinementRules(queries, scopePropagator,
nameNewElements, statistics)
- val relationRefinementRules = refinementRuleProvider.createRelationRefinementRules(queries, statistics)
+ val relationRefinementRules = refinementRuleProvider.createRelationRefinementRules(queries, scopePropagator,
+ statistics)
val unfinishedMultiplicities = goalConstraintProvider.getUnfinishedMultiplicityQueries(queries)
val unfinishedWF = queries.getUnfinishedWFQueries.values
@@ -118,15 +137,26 @@ class ModelGenerationMethodProvider {
}
private def createScopePropagator(ScopePropagatorStrategy scopePropagatorStrategy,
- PartialInterpretation emptySolution, GeneratedPatterns queries) {
+ PartialInterpretation emptySolution, GeneratedPatterns queries, ModelGenerationStatistics statistics) {
switch (scopePropagatorStrategy) {
- case BasicTypeHierarchy:
- new ScopePropagator(emptySolution)
- case PolyhedralTypeHierarchy,
- case PolyhedralRelations: {
+ case ScopePropagatorStrategy.BasicTypeHierarchy:
+ new ScopePropagator(emptySolution, statistics)
+ ScopePropagatorStrategy.Polyhedral: {
val types = queries.refineObjectQueries.keySet.map[newType].toSet
- val solver = new CbcPolyhedronSolver
- new PolyhedronScopePropagator(emptySolution, types, queries.multiplicityConstraintQueries,
+ val solver = switch (scopePropagatorStrategy.solver) {
+ case Z3Integer:
+ new Z3PolyhedronSolver(false, scopePropagatorStrategy.timeoutSeconds)
+ case Z3Real:
+ new Z3PolyhedronSolver(true, scopePropagatorStrategy.timeoutSeconds)
+ case Cbc:
+ new CbcPolyhedronSolver(false, scopePropagatorStrategy.timeoutSeconds, true)
+ case Clp:
+ new CbcPolyhedronSolver(true, scopePropagatorStrategy.timeoutSeconds, true)
+ default:
+ throw new IllegalArgumentException("Unknown polyhedron solver: " +
+ scopePropagatorStrategy.solver)
+ }
+ new PolyhedronScopePropagator(emptySolution, statistics, types, queries.multiplicityConstraintQueries,
queries.hasElementInContainmentQuery, solver, scopePropagatorStrategy.requiresUpperBoundIndexing)
}
default:
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 f6b101b6..e7e40ab0 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
@@ -2,9 +2,12 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality
import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableMap
+import com.google.common.collect.ImmutableSet
import com.google.common.collect.Maps
import com.google.common.collect.Sets
+import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Relation
import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationStatistics
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.UnifinishedMultiplicityQueries
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialComplexTypeInterpretation
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
@@ -30,13 +33,14 @@ class PolyhedronScopePropagator extends ScopePropagator {
val LinearBoundedExpression topLevelBounds
val Polyhedron polyhedron
val PolyhedronSaturationOperator operator
+ val Set relevantRelations
List updaters = emptyList
- new(PartialInterpretation p, Set extends Type> possibleNewDynamicTypes,
+ new(PartialInterpretation p, ModelGenerationStatistics statistics, Set extends Type> possibleNewDynamicTypes,
Map unfinishedMultiplicityQueries,
IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> hasElementInContainmentQuery,
PolyhedronSolver solver, boolean propagateRelations) {
- super(p)
+ super(p, statistics)
val builder = new PolyhedronBuilder(p)
builder.buildPolyhedron(possibleNewDynamicTypes)
scopeBounds = builder.scopeBounds
@@ -54,11 +58,14 @@ class PolyhedronScopePropagator extends ScopePropagator {
}
builder.buildMultiplicityConstraints(unfinishedMultiplicityQueries, hasElementInContainmentQuery,
maximumNumberOfNewNodes)
+ relevantRelations = builder.relevantRelations
updaters = builder.updaters
+ } else {
+ relevantRelations = emptySet
}
}
- override void propagateAllScopeConstraints() {
+ override void doPropagateAllScopeConstraints() {
resetBounds()
populatePolyhedronFromScope()
// println(polyhedron)
@@ -73,6 +80,13 @@ class PolyhedronScopePropagator extends ScopePropagator {
}
}
}
+
+ override propagateAdditionToRelation(Relation r) {
+ super.propagateAdditionToRelation(r)
+ if (relevantRelations.contains(r)) {
+ propagateAllScopeConstraints()
+ }
+ }
def resetBounds() {
for (dimension : polyhedron.dimensions) {
@@ -188,6 +202,7 @@ class PolyhedronScopePropagator extends ScopePropagator {
Map scopeBounds
LinearBoundedExpression topLevelBounds
Polyhedron polyhedron
+ Set relevantRelations
List updaters
def buildPolyhedron(Set extends Type> possibleNewDynamicTypes) {
@@ -222,9 +237,21 @@ class PolyhedronScopePropagator extends ScopePropagator {
buildNonContainmentConstraints(constraint, pair.value)
}
}
+ buildRelevantRelations(constraints.keySet)
updaters = updatersBuilder.build
addCachedConstraintsToPolyhedron()
}
+
+ private def buildRelevantRelations(Set constraints) {
+ val builder = ImmutableSet.builder
+ for (constraint : constraints) {
+ builder.add(constraint.relation)
+ if (constraint.inverseRelation !== null) {
+ builder.add(constraint.inverseRelation)
+ }
+ }
+ relevantRelations = builder.build
+ }
private def addCachedConstraintsToPolyhedron() {
val constraints = new HashSet
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 ffa9e6e6..52a390a8 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
@@ -20,6 +20,7 @@ class RelationConstraints {
@Data
class RelationMultiplicityConstraint {
Relation relation
+ Relation inverseRelation
boolean containment
boolean container
int lowerBound
@@ -47,7 +48,7 @@ class RelationMultiplicityConstraint {
}
def constrainsRemainingInverse() {
- !containment && inverseUpperBoundFinite
+ lowerBound >= 1 && !containment && inverseUpperBoundFinite
}
def constrainsRemainingContents() {
@@ -119,8 +120,8 @@ class RelationConstraintCalculator {
inverseUpperMultiplicity = upperMultiplicities.get(relation)
container = containmentRelations.contains(inverseRelation)
}
- val constraint = new RelationMultiplicityConstraint(relation, containment, container, lowerMultiplicity,
- upperMultiplicity, inverseUpperMultiplicity)
+ val constraint = new RelationMultiplicityConstraint(relation, inverseRelation, containment, container,
+ lowerMultiplicity, upperMultiplicity, inverseUpperMultiplicity)
if (constraint.isActive) {
if (relation.parameters.size != 2) {
throw new IllegalArgumentException('''Relation «relation.name» has multiplicity or containment constraints, but it is not binary''')
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 3b442cd3..7be6635c 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
@@ -1,5 +1,7 @@
package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality
+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.PartialTypeInterpratation
@@ -11,14 +13,15 @@ import java.util.Set
import org.eclipse.xtend.lib.annotations.Accessors
class ScopePropagator {
- @Accessors(PROTECTED_GETTER) PartialInterpretation partialInterpretation
- Map type2Scope
-
+ @Accessors(PROTECTED_GETTER) val PartialInterpretation partialInterpretation
+ val ModelGenerationStatistics statistics
+ val Map type2Scope
val Map> superScopes
val Map> subScopes
- new(PartialInterpretation p) {
+ new(PartialInterpretation p, ModelGenerationStatistics statistics) {
partialInterpretation = p
+ this.statistics = statistics
type2Scope = new HashMap
for (scope : p.scopes) {
type2Scope.put(scope.targetTypeInterpretation, scope)
@@ -57,8 +60,13 @@ class ScopePropagator {
}
} while (changed)
}
-
+
def propagateAllScopeConstraints() {
+ statistics.incrementScopePropagationCount()
+ doPropagateAllScopeConstraints()
+ }
+
+ protected def doPropagateAllScopeConstraints() {
var boolean hadChanged
do {
hadChanged = false
@@ -95,6 +103,10 @@ class ScopePropagator {
// 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»''')
}
+
+ def void propagateAdditionToRelation(Relation r) {
+ // Nothing to propagate.
+ }
private def propagateLowerLimitUp(Scope subScope, Scope superScope) {
if (subScope.minNewElements > superScope.minNewElements) {
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.java
deleted file mode 100644
index b1c5a658..00000000
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality;
-
-public enum ScopePropagatorStrategy {
- BasicTypeHierarchy,
-
- PolyhedralTypeHierarchy,
-
- PolyhedralRelations {
- @Override
- public boolean requiresUpperBoundIndexing() {
- return true;
- }
- };
-
- public boolean requiresUpperBoundIndexing() {
- return false;
- }
-}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.xtend
new file mode 100644
index 00000000..37e56c9a
--- /dev/null
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.xtend
@@ -0,0 +1,64 @@
+package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality
+
+import org.eclipse.xtend.lib.annotations.Data
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
+
+enum PolyhedralScopePropagatorConstraints {
+ TypeHierarchy,
+ Relational
+}
+
+enum PolyhedralScopePropagatorSolver {
+ Z3Real,
+ Z3Integer,
+ Cbc,
+ Clp
+}
+
+abstract class ScopePropagatorStrategy {
+ public static val BasicCount = new Simple("BasicCount")
+
+ public static val BasicTypeHierarchy = new Simple("BasicTypeHierarchy")
+
+ private new() {
+ }
+
+ def boolean requiresUpperBoundIndexing()
+
+ static class Simple extends ScopePropagatorStrategy {
+ val String name
+
+ @FinalFieldsConstructor
+ private new() {
+ }
+
+ override requiresUpperBoundIndexing() {
+ false
+ }
+
+ override toString() {
+ name
+ }
+ }
+
+ @Data
+ static class Polyhedral extends ScopePropagatorStrategy {
+ public static val UNLIMITED_TIME = -1
+
+ val PolyhedralScopePropagatorConstraints constraints
+ val PolyhedralScopePropagatorSolver solver
+ val double timeoutSeconds
+
+ @FinalFieldsConstructor
+ new() {
+ }
+
+ new(PolyhedralScopePropagatorConstraints constraints, PolyhedralScopePropagatorSolver solver) {
+ this(constraints, solver, UNLIMITED_TIME)
+ }
+
+ override requiresUpperBoundIndexing() {
+ constraints == PolyhedralScopePropagatorConstraints.Relational
+ }
+ }
+}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
index b10c8e88..eadf0ae0 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
@@ -69,7 +69,7 @@ class PatternProvider {
val startTime = System.nanoTime
val result = typeAnalysis.performTypeAnalysis(problem, emptySolution)
val typeAnalysisTime = System.nanoTime - startTime
- statistics.PreliminaryTypeAnalisisTime = typeAnalysisTime
+ statistics.preliminaryTypeAnalisisTime = typeAnalysisTime
result
} else {
null
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend
index 5fefa551..bf816de9 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend
@@ -98,10 +98,12 @@ class RefinementRuleProvider {
val newLink2 = factory2.createBinaryElementRelationLink => [it.param1 = newElement it.param2 = container]
inverseRelationInterpretation.relationlinks+=newLink2
+ val propagatorStartTime = System.nanoTime
+ statistics.addExecutionTime(propagatorStartTime-startTime)
+
// Scope propagation
scopePropagator.propagateAdditionToType(typeInterpretation)
-
- statistics.addExecutionTime(System.nanoTime-startTime)
+ statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime)
]
} else {
ruleBuilder.action[match |
@@ -132,10 +134,12 @@ class RefinementRuleProvider {
val newLink = factory2.createBinaryElementRelationLink => [it.param1 = container it.param2 = newElement]
relationInterpretation.relationlinks+=newLink
+ val propagatorStartTime = System.nanoTime
+ statistics.addExecutionTime(propagatorStartTime-startTime)
+
// Scope propagation
scopePropagator.propagateAdditionToType(typeInterpretation)
-
- statistics.addExecutionTime(System.nanoTime-startTime)
+ statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime)
]
}
} else {
@@ -162,29 +166,31 @@ class RefinementRuleProvider {
typeInterpretation.elements += newElement
typeInterpretation.supertypeInterpretation.forEach[it.elements += newElement]
+ val propagatorStartTime = System.nanoTime
+ statistics.addExecutionTime(propagatorStartTime-startTime)
+
// Scope propagation
scopePropagator.propagateAdditionToType(typeInterpretation)
-
- statistics.addExecutionTime(System.nanoTime-startTime)
+ statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime)
]
}
return ruleBuilder.build
}
- def createRelationRefinementRules(GeneratedPatterns patterns, ModelGenerationStatistics statistics) {
+ def createRelationRefinementRules(GeneratedPatterns patterns, ScopePropagator scopePropagator, ModelGenerationStatistics statistics) {
val res = new LinkedHashMap
for(LHSEntry: patterns.refinerelationQueries.entrySet) {
val declaration = LHSEntry.key.key
val inverseReference = LHSEntry.key.value
val lhs = LHSEntry.value as IQuerySpecification>
- val rule = createRelationRefinementRule(declaration,inverseReference,lhs,statistics)
+ val rule = createRelationRefinementRule(declaration,inverseReference,lhs,scopePropagator,statistics)
res.put(LHSEntry.key,rule)
}
return res
}
def private BatchTransformationRule>
- createRelationRefinementRule(RelationDeclaration declaration, Relation inverseRelation, IQuerySpecification> lhs, ModelGenerationStatistics statistics)
+ createRelationRefinementRule(RelationDeclaration declaration, Relation inverseRelation, IQuerySpecification> lhs, ScopePropagator scopePropagator, ModelGenerationStatistics statistics)
{
val name = '''addRelation_«declaration.name.canonizeName»«IF inverseRelation != null»_and_«inverseRelation.name.canonizeName»«ENDIF»'''
val ruleBuilder = factory.createRule
@@ -201,7 +207,13 @@ class RefinementRuleProvider {
val trg = match.get(4) as DefinedElement
val link = createBinaryElementRelationLink => [it.param1 = src it.param2 = trg]
relationInterpretation.relationlinks += link
- statistics.addExecutionTime(System.nanoTime-startTime)
+
+ val propagatorStartTime = System.nanoTime
+ statistics.addExecutionTime(propagatorStartTime-startTime)
+
+ // Scope propagation
+ scopePropagator.propagateAdditionToRelation(declaration)
+ statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime)
]
} else {
ruleBuilder.action [ match |
@@ -217,7 +229,13 @@ class RefinementRuleProvider {
relationInterpretation.relationlinks += link
val inverseLink = createBinaryElementRelationLink => [it.param1 = trg it.param2 = src]
inverseInterpretation.relationlinks += inverseLink
- statistics.addExecutionTime(System.nanoTime-startTime)
+
+ val propagatorStartTime = System.nanoTime
+ statistics.addExecutionTime(propagatorStartTime-startTime)
+
+ // Scope propagation
+ scopePropagator.propagateAdditionToRelation(declaration)
+ statistics.addScopePropagationTime(System.nanoTime-propagatorStartTime)
]
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend
index a8db5e43..1abde0a8 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend
@@ -39,6 +39,7 @@ import org.eclipse.viatra.dse.api.DesignSpaceExplorer
import org.eclipse.viatra.dse.api.DesignSpaceExplorer.DseLoggingLevel
import org.eclipse.viatra.dse.solutionstore.SolutionStore
import org.eclipse.viatra.dse.statecode.IStateCoderFactory
+import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.NeighbourhoodBasedStateCoderFactory
class ViatraReasoner extends LogicReasoner {
val PartialInterpretationInitialiser initialiser = new PartialInterpretationInitialiser()
@@ -137,11 +138,14 @@ class ViatraReasoner extends LogicReasoner {
dse.setInitialModel(emptySolution, false)
- val IStateCoderFactory statecoder = if (viatraConfig.stateCoderStrategy == StateCoderStrategy.Neighbourhood) {
+ val IStateCoderFactory statecoder = switch (viatraConfig.stateCoderStrategy) {
+ case Neighbourhood:
+ new NeighbourhoodBasedStateCoderFactory
+ case PairwiseNeighbourhood:
new PairwiseNeighbourhoodBasedStateCoderFactory
- } else {
+ default:
new IdentifierBasedStateCoderFactory
- }
+ }
dse.stateCoderFactory = statecoder
dse.maxNumberOfThreads = 1
@@ -183,9 +187,13 @@ class ViatraReasoner extends LogicReasoner {
it.name = "TransformationExecutionTime"
it.value = (method.statistics.transformationExecutionTime / 1000000) as int
]
+ it.entries += createIntStatisticEntry => [
+ it.name = "ScopePropagationTime"
+ it.value = (method.statistics.scopePropagationTime / 1000000) as int
+ ]
it.entries += createIntStatisticEntry => [
it.name = "TypeAnalysisTime"
- it.value = (method.statistics.PreliminaryTypeAnalisisTime / 1000000) as int
+ it.value = (method.statistics.preliminaryTypeAnalisisTime / 1000000) as int
]
it.entries += createIntStatisticEntry => [
it.name = "StateCoderTime"
@@ -199,6 +207,18 @@ class ViatraReasoner extends LogicReasoner {
it.name = "SolutionCopyTime"
it.value = (solutionCopier.getTotalCopierRuntime / 1000000) as int
]
+ it.entries += createIntStatisticEntry => [
+ it.name = "States"
+ it.value = dse.numberOfStates as int
+ ]
+ it.entries += createIntStatisticEntry => [
+ it.name = "Decisions"
+ it.value = method.statistics.decisionsTried
+ ]
+ it.entries += createIntStatisticEntry => [
+ it.name = "ScopePropagations"
+ it.value = method.statistics.scopePropagatorInvocations
+ ]
if (diversityChecker.isActive) {
it.entries += createIntStatisticEntry => [
it.name = "SolutionDiversityCheckTime"
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend
index 7a3a2d67..a2f9cebe 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend
@@ -14,9 +14,12 @@ import java.util.LinkedList
import java.util.List
import java.util.Set
import org.eclipse.xtext.xbase.lib.Functions.Function1
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver
enum StateCoderStrategy {
Neighbourhood,
+ PairwiseNeighbourhood,
NeighbourhoodWithEquivalence,
IDBased,
DefinedByDiversity
@@ -25,7 +28,7 @@ enum StateCoderStrategy {
class ViatraReasonerConfiguration extends LogicSolverConfiguration {
// public var Iterable existingQueries
public var nameNewElements = false
- public var StateCoderStrategy stateCoderStrategy = StateCoderStrategy.Neighbourhood
+ public var StateCoderStrategy stateCoderStrategy = StateCoderStrategy.PairwiseNeighbourhood
public var TypeInferenceMethod typeInferenceMethod = TypeInferenceMethod.PreliminaryAnalysis
/**
* Once per 1/randomBacktrackChance the search selects a random state.
@@ -50,9 +53,8 @@ class ViatraReasonerConfiguration extends LogicSolverConfiguration {
* Configuration for cutting search space.
*/
public var SearchSpaceConstraint searchSpaceConstraints = new SearchSpaceConstraint
-
- public var ScopePropagatorStrategy scopePropagatorStrategy = ScopePropagatorStrategy.PolyhedralTypeHierarchy
+ public var ScopePropagatorStrategy scopePropagatorStrategy = ScopePropagatorStrategy.BasicTypeHierarchy
public var List costObjectives = newArrayList
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java
index 144e7484..5af7fc69 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java
@@ -189,6 +189,7 @@ public class BestFirstStrategyForModelGeneration implements IStrategy {
// }
logger.debug("Executing new activation: " + nextActivation);
context.executeAcitvationId(nextActivation);
+ method.getStatistics().incrementDecisionCount();
visualiseCurrentState();
// for(ViatraQueryMatcher extends IPatternMatch> matcher : matchers) {
--
cgit v1.2.3-70-g09d2
From fc84d3fe670331bc89fb1e4c44104bc1fc811438 Mon Sep 17 00:00:00 2001
From: Kristóf Marussy
Date: Wed, 14 Aug 2019 18:26:33 +0200
Subject: Measurements WIP
---
.../.ApplicationConfigurationIdeModule.xtendbin | Bin 1701 -> 1701 bytes
.../ide/.ApplicationConfigurationIdeSetup.xtendbin | Bin 2570 -> 2570 bytes
.../domains/transima/fam/FamPatterns.vql | 2 +-
.../domains/cps/dse/RuleBasedCpsSolver.xtend | 6 +-
.../.classpath | 7 +-
.../.project | 1 +
.../.settings/org.eclipse.core.resources.prefs | 3 -
.../META-INF/MANIFEST.MF | 16 +-
.../configs/generation.vsconfig | 2 +-
.../ecore-gen/satellite/CommSubsystem.java | 20 +-
.../ecore-gen/satellite/ConstellationMission.java | 2 +-
.../ecore-gen/satellite/InterferometryMission.java | 28 --
.../ecore-gen/satellite/SatellitePackage.java | 88 +-----
.../satellite/impl/CommSubsystemImpl.java | 115 +------
.../satellite/impl/InterferometryMissionImpl.java | 130 --------
.../satellite/impl/SatellitePackageImpl.java | 37 +--
.../inputs/SatelliteInstance.xmi | 9 +-
.../model/satellite.ecore | 12 +-
.../model/satellite.genmodel | 5 +-
.../model/satellite.henshin | 61 ----
.../model/satellite.henshin_diagram | 131 --------
.../model/satellite_fixup.henshin | 61 ----
.../plugin.xml | 1 +
.../representations.aird | 2 +
.../domains/satellite/mdeo/CostObjective.xtend | 13 -
.../satellite/mdeo/LocalSearchEngineManager.xtend | 31 --
.../mdeo/MetricBasedGuidanceFunction.xtend | 47 ---
.../satellite/mdeo/PatternMatchConstraint.xtend | 29 --
.../satellite/mdeo/SatelliteMdeOptimiserMain.xtend | 51 ---
.../domains/satellite/mdeo/satellite.mopt | 36 ---
.../domains/satellite/queries/SatelliteQueries.vql | 11 +-
.../META-INF/MANIFEST.MF | 3 +-
.../plugin.xml | 74 +----
.../yakindu/mutated/mutated.vql | 270 ----------------
.../partialsnapshot_mavo/yakindu/patterns.vql | 64 ++--
.../ModelGenerationMethodProvider.xtend | 35 +-
.../cardinality/LinearTypeConstraintHint.xtend | 30 ++
.../cardinality/PolyhedronScopePropagator.xtend | 106 +++++--
.../cardinality/PolyhedronSolver.xtend | 72 ++++-
.../cardinality/RelationConstraintCalculator.xtend | 5 +-
.../logic2viatra/cardinality/ScopePropagator.xtend | 25 +-
.../cardinality/ScopePropagatorStrategy.xtend | 11 +-
.../cardinality/TypeHierarchyScopePropagator.xtend | 20 +-
.../cardinality/Z3PolyhedronSolver.xtend | 32 +-
.../logic2viatra/patterns/PatternGenerator.xtend | 18 +-
.../logic2viatra/patterns/PatternProvider.xtend | 6 +-
.../patterns/RelationRefinementGenerator.xtend | 2 +-
.../logic2viatra/patterns/UnfinishedIndexer.xtend | 26 +-
.../rules/RefinementRuleProvider.xtend | 15 +-
.../PartialInterpretation.java | 24 ++
.../PartialinterpretationPackage.java | 60 +++-
.../partialinterpretation/Scope.java | 24 ++
.../impl/BinaryElementRelationLinkImpl.java | 4 +
.../impl/BooleanElementImpl.java | 4 +-
.../impl/IntegerElementImpl.java | 4 +-
.../impl/NaryRelationLinkElementImpl.java | 6 +-
.../impl/NaryRelationLinkImpl.java | 1 +
.../impl/PartialComplexTypeInterpretationImpl.java | 3 +
.../impl/PartialConstantInterpretationImpl.java | 2 +
.../impl/PartialFunctionInterpretationImpl.java | 2 +
.../impl/PartialInterpretationImpl.java | 73 ++++-
.../impl/PartialRelationInterpretationImpl.java | 7 +
.../impl/PartialTypeInterpratationImpl.java | 2 +
.../impl/PartialinterpretationFactoryImpl.java | 19 ++
.../impl/PartialinterpretationPackageImpl.java | 88 +++++-
.../impl/PrimitiveElementImpl.java | 4 +-
.../impl/RealElementImpl.java | 4 +-
.../partialinterpretation/impl/ScopeImpl.java | 64 +++-
.../impl/StringElementImpl.java | 4 +-
.../impl/UnaryElementRelationLinkImpl.java | 2 +
.../model/PartialInterpretation.ecore | 6 +
.../model/PartialInterpretation.genmodel | 14 +-
.../neighbourhood/Descriptor.xtend | 8 +
.../neighbourhood/NeighbourhoodOptions.xtend | 4 +-
.../neighbourhood/PartialInterpretation2Hash.xtend | 2 +-
...nterpretation2NeighbourhoodRepresentation.xtend | 4 +-
.../NeighbourhoodBasedStateCoderFactory.xtend | 29 +-
.../viatrasolver/reasoner/ViatraReasoner.xtend | 25 +-
.../reasoner/ViatraReasonerConfiguration.xtend | 3 +
.../reasoner/dse/BasicScopeGlobalConstraint.xtend | 103 ++++++
.../dse/BestFirstStrategyForModelGeneration.java | 2 +-
.../dse/ModelGenerationCompositeObjective.xtend | 2 +-
.../viatrasolver/reasoner/dse/ScopeObjective.xtend | 4 +-
.../reasoner/dse/UnfinishedWFObjective.xtend | 34 +-
.../reasoner/dse/ViatraReasonerSolutionSaver.xtend | 11 +-
.../META-INF/MANIFEST.MF | 8 +-
..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 13 +
..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 16 +
..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 15 +
..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 15 +
..._ViatraSolver_polyhedral_typeHierarchy_Clp.json | 17 +
.../initialModels/satellite.xmi | 14 +
.../bme/mit/inf/dslreasoner/run/CountMatches.xtend | 176 -----------
.../run/Ecore2LogicTraceBasedHint.xtend | 56 ++++
.../mit/inf/dslreasoner/run/MetamodelLoader.xtend | 302 +++++++++++++-----
.../bme/mit/inf/dslreasoner/run/SGraphHint.xtend | 46 +++
.../mit/inf/dslreasoner/run/SatelliteHint.xtend | 86 +++++
.../run/TypeDistributionCalculator.xtend | 35 ++
.../dslreasoner/run/script/MeasurementScript.xtend | 70 ++++
.../run/script/MeasurementScriptRunner.xtend | 351 +++++++++++++++++++++
100 files changed, 1976 insertions(+), 1667 deletions(-)
delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.settings/org.eclipse.core.resources.prefs
delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin
delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin_diagram
delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite_fixup.henshin
create mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/representations.aird
delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/CostObjective.xtend
delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/LocalSearchEngineManager.xtend
delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.xtend
delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend
delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend
delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt
delete mode 100644 Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/mutated/mutated.vql
create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/LinearTypeConstraintHint.xtend
create mode 100644 Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BasicScopeGlobalConstraint.xtend
create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/FAM_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/fs_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/initialModels/satellite.xmi
delete mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/CountMatches.xtend
create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/Ecore2LogicTraceBasedHint.xtend
create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphHint.xtend
create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend
create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend
create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend
create mode 100644 Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend
(limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend')
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin
index 069bd953..22db4093 100644
Binary files a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin and b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeModule.xtendbin differ
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin
index 624846d6..3ad5d167 100644
Binary files a/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin and b/Application/hu.bme.mit.inf.dslreasoner.application.ide/xtend-gen/hu/bme/mit/inf/dslreasoner/application/ide/.ApplicationConfigurationIdeSetup.xtendbin differ
diff --git a/Domains/Examples/ModelGenExampleFAM_plugin/src/hu/bme/mit/inf/dslreasoner/domains/transima/fam/FamPatterns.vql b/Domains/Examples/ModelGenExampleFAM_plugin/src/hu/bme/mit/inf/dslreasoner/domains/transima/fam/FamPatterns.vql
index f0e48d42..1d9a6b6d 100644
--- a/Domains/Examples/ModelGenExampleFAM_plugin/src/hu/bme/mit/inf/dslreasoner/domains/transima/fam/FamPatterns.vql
+++ b/Domains/Examples/ModelGenExampleFAM_plugin/src/hu/bme/mit/inf/dslreasoner/domains/transima/fam/FamPatterns.vql
@@ -10,7 +10,7 @@ pattern terminatorAndInformation(T : FAMTerminator, I : InformationLink) = {
InformationLink.to(I,In);
FunctionalInput.terminator(In,T);
}
-
+/*
@QueryBasedFeature
pattern type(This : Function, Target : FunctionType) = {
find rootElements(_Model, This);
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend
index e4c758f0..503c06ea 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/dse/RuleBasedCpsSolver.xtend
@@ -35,18 +35,18 @@ class RuleBasedCpsSolver {
val dse = new DesignSpaceExplorer
dse.addMetaModelPackage(CpsPackage.eINSTANCE)
dse.initialModel = problem.eResource.resourceSet
- dse.addTransformationRule(createRule(RequirementNotSatisfied.instance).action [
+ dse.addTransformationRule(createRule.precondition(RequirementNotSatisfied.instance).action [
val app = createApplicationInstance
req.type.instances += app
req.instances += app
].build)
- dse.addTransformationRule(createRule(Allocate.instance).action [
+ dse.addTransformationRule(createRule.precondition(Allocate.instance).action [
app.allocatedTo = host
].build)
// dse.addTransformationRule(createRule(UnallocateAppInstance.instance).action [
// app.allocatedTo = null
// ].build)
- dse.addTransformationRule(createRule(CreateHostInstance.instance).action [
+ dse.addTransformationRule(createRule.precondition(CreateHostInstance.instance).action [
hostType.instances += createHostInstance
].build)
// dse.addTransformationRule(createRule(RemoveHostInstance.instance).action [
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.classpath b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.classpath
index e5e58475..6781ea8f 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.classpath
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.classpath
@@ -3,9 +3,12 @@
-
+
+
+
+
+
-
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.project b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.project
index 16db5fc5..e594a173 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.project
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.project
@@ -32,6 +32,7 @@
+ org.eclipse.sirius.nature.modelingproject
org.eclipse.jdt.core.javanature
org.eclipse.pde.PluginNature
org.eclipse.viatra.query.projectnature
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.settings/org.eclipse.core.resources.prefs b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 4a3e59e4..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-eclipse.preferences.version=1
-encoding//model/satellite.henshin=UTF-8
-encoding//model/satellite.henshin_diagram=UTF-8
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/META-INF/MANIFEST.MF
index 36d729b4..966fc660 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/META-INF/MANIFEST.MF
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/META-INF/MANIFEST.MF
@@ -7,6 +7,7 @@ Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: hu.bme.mit.inf.dslreasoner.domains.satellite.queries,
+ hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal,
satellite,
satellite.impl,
satellite.util
@@ -22,20 +23,7 @@ Require-Bundle: org.eclipse.viatra.addon.querybasedfeatures.runtime,
org.eclipse.viatra.dse.genetic,
hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner;bundle-version="1.0.0",
org.eclipse.emf.ecore.xmi;bundle-version="2.15.0",
- uk.ac.kcl.inf.mdeoptimiser.libraries.core;bundle-version="1.0.0",
- uk.ac.kcl.inf.mdeoptimiser.interfaces.cli;bundle-version="1.0.0",
- org.eclipse.emf.henshin.interpreter;bundle-version="1.5.0",
- uk.ac.kcl.inf.mdeoptimiser.libraries.rulegen;bundle-version="1.0.0",
- org.sidiff.common;bundle-version="1.0.0",
- org.sidiff.common.emf;bundle-version="1.0.0",
- org.sidiff.common.emf.extensions;bundle-version="1.0.0",
- org.moeaframework;bundle-version="2.13.0",
- org.apache.commons.math3;bundle-version="3.6.1",
- org.apache.commons.lang3;bundle-version="3.8.1",
- com.google.inject;bundle-version="3.0.0",
- org.sidiff.common.henshin;bundle-version="1.0.0",
- org.sidiff.serge;bundle-version="1.0.0",
- org.eclipse.viatra.query.runtime.rete;bundle-version="2.2.0"
+ org.eclipse.viatra.query.runtime.rete;bundle-version="2.0.0"
Import-Package: org.apache.log4j
Automatic-Module-Name: hu.bme.mit.inf.dslreasoner.domains.satellite
Bundle-ActivationPolicy: lazy
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/configs/generation.vsconfig b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/configs/generation.vsconfig
index 66c468d0..2fb246c9 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/configs/generation.vsconfig
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/configs/generation.vsconfig
@@ -2,7 +2,7 @@ import epackage "model/satellite.ecore"
import viatra "src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql"
generate {
- metamodel = { package satellite excluding { InterferometryMission.observationTime } }
+ metamodel = { package satellite }
constraints = { package hu.bme.mit.inf.dslreasoner.domains.satellite.queries }
partial-model = { "inputs/SatelliteInstance.xmi"}
solver = ViatraSolver
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/CommSubsystem.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/CommSubsystem.java
index 90bca78c..3b9d7ecf 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/CommSubsystem.java
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/CommSubsystem.java
@@ -2,7 +2,6 @@
*/
package satellite;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
/**
@@ -15,7 +14,6 @@ import org.eclipse.emf.ecore.EObject;
*
*
* {@link satellite.CommSubsystem#getTarget Target }
- * {@link satellite.CommSubsystem#getSource Source }
*
*
* @see satellite.SatellitePackage#getCommSubsystem()
@@ -26,14 +24,12 @@ public interface CommSubsystem extends EObject {
/**
* Returns the value of the 'Target ' reference.
- * It is bidirectional and its opposite is '{@link satellite.CommSubsystem#getSource Source }'.
*
*
* @return the value of the 'Target ' reference.
* @see #setTarget(CommSubsystem)
* @see satellite.SatellitePackage#getCommSubsystem_Target()
- * @see satellite.CommSubsystem#getSource
- * @model opposite="source"
+ * @model
* @generated
*/
CommSubsystem getTarget();
@@ -48,18 +44,4 @@ public interface CommSubsystem extends EObject {
*/
void setTarget(CommSubsystem value);
- /**
- * Returns the value of the 'Source ' reference list.
- * The list contents are of type {@link satellite.CommSubsystem}.
- * It is bidirectional and its opposite is '{@link satellite.CommSubsystem#getTarget Target }'.
- *
- *
- * @return the value of the 'Source ' reference list.
- * @see satellite.SatellitePackage#getCommSubsystem_Source()
- * @see satellite.CommSubsystem#getTarget
- * @model opposite="target"
- * @generated
- */
- EList getSource();
-
} // CommSubsystem
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/ConstellationMission.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/ConstellationMission.java
index 6182d7ad..8ff69955 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/ConstellationMission.java
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/ConstellationMission.java
@@ -53,7 +53,7 @@ public interface ConstellationMission extends EObject {
*
* @return the value of the 'Spacecraft ' containment reference list.
* @see satellite.SatellitePackage#getConstellationMission_Spacecraft()
- * @model containment="true" lower="2" upper="50"
+ * @model containment="true" lower="2"
* @generated
*/
EList getSpacecraft();
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/InterferometryMission.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/InterferometryMission.java
index eb4ea064..4e28df38 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/InterferometryMission.java
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/InterferometryMission.java
@@ -7,39 +7,11 @@ package satellite;
* A representation of the model object 'Interferometry Mission '.
*
*
- *
- * The following features are supported:
- *
- *
- * {@link satellite.InterferometryMission#getObservationTime Observation Time }
- *
*
* @see satellite.SatellitePackage#getInterferometryMission()
* @model
* @generated
*/
public interface InterferometryMission extends ConstellationMission {
- /**
- * Returns the value of the 'Observation Time ' attribute.
- * The default value is "2.0"
.
- *
- *
- * @return the value of the 'Observation Time ' attribute.
- * @see #setObservationTime(float)
- * @see satellite.SatellitePackage#getInterferometryMission_ObservationTime()
- * @model default="2.0" required="true"
- * @generated
- */
- float getObservationTime();
-
- /**
- * Sets the value of the '{@link satellite.InterferometryMission#getObservationTime Observation Time }' attribute.
- *
- *
- * @param value the new value of the 'Observation Time ' attribute.
- * @see #getObservationTime()
- * @generated
- */
- void setObservationTime(float value);
} // InterferometryMission
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/SatellitePackage.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/SatellitePackage.java
index 7be4ef84..9ca99311 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/SatellitePackage.java
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/SatellitePackage.java
@@ -2,7 +2,6 @@
*/
package satellite;
-import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
@@ -130,15 +129,6 @@ public interface SatellitePackage extends EPackage {
*/
int INTERFEROMETRY_MISSION__SPACECRAFT = CONSTELLATION_MISSION__SPACECRAFT;
- /**
- * The feature id for the 'Observation Time ' attribute.
- *
- *
- * @generated
- * @ordered
- */
- int INTERFEROMETRY_MISSION__OBSERVATION_TIME = CONSTELLATION_MISSION_FEATURE_COUNT + 0;
-
/**
* The number of structural features of the 'Interferometry Mission ' class.
*
@@ -146,7 +136,7 @@ public interface SatellitePackage extends EPackage {
* @generated
* @ordered
*/
- int INTERFEROMETRY_MISSION_FEATURE_COUNT = CONSTELLATION_MISSION_FEATURE_COUNT + 1;
+ int INTERFEROMETRY_MISSION_FEATURE_COUNT = CONSTELLATION_MISSION_FEATURE_COUNT + 0;
/**
* The number of operations of the 'Interferometry Mission ' class.
@@ -296,15 +286,6 @@ public interface SatellitePackage extends EPackage {
*/
int COMM_SUBSYSTEM__TARGET = 0;
- /**
- * The feature id for the 'Source ' reference list.
- *
- *
- * @generated
- * @ordered
- */
- int COMM_SUBSYSTEM__SOURCE = 1;
-
/**
* The number of structural features of the 'Comm Subsystem ' class.
*
@@ -312,7 +293,7 @@ public interface SatellitePackage extends EPackage {
* @generated
* @ordered
*/
- int COMM_SUBSYSTEM_FEATURE_COUNT = 2;
+ int COMM_SUBSYSTEM_FEATURE_COUNT = 1;
/**
* The number of operations of the 'Comm Subsystem ' class.
@@ -582,15 +563,6 @@ public interface SatellitePackage extends EPackage {
*/
int UHF_COMM_SUBSYSTEM__TARGET = COMM_SUBSYSTEM__TARGET;
- /**
- * The feature id for the 'Source ' reference list.
- *
- *
- * @generated
- * @ordered
- */
- int UHF_COMM_SUBSYSTEM__SOURCE = COMM_SUBSYSTEM__SOURCE;
-
/**
* The number of structural features of the 'UHF Comm Subsystem ' class.
*
@@ -628,15 +600,6 @@ public interface SatellitePackage extends EPackage {
*/
int XCOMM_SUBSYSTEM__TARGET = COMM_SUBSYSTEM__TARGET;
- /**
- * The feature id for the 'Source ' reference list.
- *
- *
- * @generated
- * @ordered
- */
- int XCOMM_SUBSYSTEM__SOURCE = COMM_SUBSYSTEM__SOURCE;
-
/**
* The number of structural features of the 'XComm Subsystem ' class.
*
@@ -674,15 +637,6 @@ public interface SatellitePackage extends EPackage {
*/
int KA_COMM_SUBSYSTEM__TARGET = COMM_SUBSYSTEM__TARGET;
- /**
- * The feature id for the 'Source ' reference list.
- *
- *
- * @generated
- * @ordered
- */
- int KA_COMM_SUBSYSTEM__SOURCE = COMM_SUBSYSTEM__SOURCE;
-
/**
* The number of structural features of the 'Ka Comm Subsystem ' class.
*
@@ -743,17 +697,6 @@ public interface SatellitePackage extends EPackage {
*/
EClass getInterferometryMission();
- /**
- * Returns the meta object for the attribute '{@link satellite.InterferometryMission#getObservationTime Observation Time }'.
- *
- *
- * @return the meta object for the attribute 'Observation Time '.
- * @see satellite.InterferometryMission#getObservationTime()
- * @see #getInterferometryMission()
- * @generated
- */
- EAttribute getInterferometryMission_ObservationTime();
-
/**
* Returns the meta object for class '{@link satellite.CommunicatingElement Communicating Element }'.
*
@@ -827,17 +770,6 @@ public interface SatellitePackage extends EPackage {
*/
EReference getCommSubsystem_Target();
- /**
- * Returns the meta object for the reference list '{@link satellite.CommSubsystem#getSource Source }'.
- *
- *
- * @return the meta object for the reference list 'Source '.
- * @see satellite.CommSubsystem#getSource()
- * @see #getCommSubsystem()
- * @generated
- */
- EReference getCommSubsystem_Source();
-
/**
* Returns the meta object for class '{@link satellite.Payload Payload }'.
*
@@ -988,14 +920,6 @@ public interface SatellitePackage extends EPackage {
*/
EClass INTERFEROMETRY_MISSION = eINSTANCE.getInterferometryMission();
- /**
- * The meta object literal for the 'Observation Time ' attribute feature.
- *
- *
- * @generated
- */
- EAttribute INTERFEROMETRY_MISSION__OBSERVATION_TIME = eINSTANCE.getInterferometryMission_ObservationTime();
-
/**
* The meta object literal for the '{@link satellite.impl.CommunicatingElementImpl Communicating Element }' class.
*
@@ -1060,14 +984,6 @@ public interface SatellitePackage extends EPackage {
*/
EReference COMM_SUBSYSTEM__TARGET = eINSTANCE.getCommSubsystem_Target();
- /**
- * The meta object literal for the 'Source ' reference list feature.
- *
- *
- * @generated
- */
- EReference COMM_SUBSYSTEM__SOURCE = eINSTANCE.getCommSubsystem_Source();
-
/**
* The meta object literal for the '{@link satellite.impl.PayloadImpl Payload }' class.
*
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/CommSubsystemImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/CommSubsystemImpl.java
index 21e385a8..d39abd4d 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/CommSubsystemImpl.java
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/CommSubsystemImpl.java
@@ -2,16 +2,11 @@
*/
package satellite.impl;
-import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.NotificationChain;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
-import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
-import org.eclipse.emf.ecore.util.InternalEList;
import satellite.CommSubsystem;
import satellite.SatellitePackage;
@@ -24,7 +19,6 @@ import satellite.SatellitePackage;
*
*
* {@link satellite.impl.CommSubsystemImpl#getTarget Target }
- * {@link satellite.impl.CommSubsystemImpl#getSource Source }
*
*
* @generated
@@ -40,16 +34,6 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp
*/
protected CommSubsystem target;
- /**
- * The cached value of the '{@link #getSource() Source }' reference list.
- *
- *
- * @see #getSource()
- * @generated
- * @ordered
- */
- protected EList source;
-
/**
*
*
@@ -97,25 +81,6 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp
return target;
}
- /**
- *
- *
- * @generated
- */
- public NotificationChain basicSetTarget(CommSubsystem newTarget, NotificationChain msgs) {
- CommSubsystem oldTarget = target;
- target = newTarget;
- if (eNotificationRequired()) {
- ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
- SatellitePackage.COMM_SUBSYSTEM__TARGET, oldTarget, newTarget);
- if (msgs == null)
- msgs = notification;
- else
- msgs.add(notification);
- }
- return msgs;
- }
-
/**
*
*
@@ -123,70 +88,11 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp
*/
@Override
public void setTarget(CommSubsystem newTarget) {
- if (newTarget != target) {
- NotificationChain msgs = null;
- if (target != null)
- msgs = ((InternalEObject) target).eInverseRemove(this, SatellitePackage.COMM_SUBSYSTEM__SOURCE,
- CommSubsystem.class, msgs);
- if (newTarget != null)
- msgs = ((InternalEObject) newTarget).eInverseAdd(this, SatellitePackage.COMM_SUBSYSTEM__SOURCE,
- CommSubsystem.class, msgs);
- msgs = basicSetTarget(newTarget, msgs);
- if (msgs != null)
- msgs.dispatch();
- } else if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, SatellitePackage.COMM_SUBSYSTEM__TARGET, newTarget,
- newTarget));
- }
-
- /**
- *
- *
- * @generated
- */
- @Override
- public EList getSource() {
- if (source == null) {
- source = new EObjectWithInverseResolvingEList(CommSubsystem.class, this,
- SatellitePackage.COMM_SUBSYSTEM__SOURCE, SatellitePackage.COMM_SUBSYSTEM__TARGET);
- }
- return source;
- }
-
- /**
- *
- *
- * @generated
- */
- @SuppressWarnings("unchecked")
- @Override
- public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
- switch (featureID) {
- case SatellitePackage.COMM_SUBSYSTEM__TARGET:
- if (target != null)
- msgs = ((InternalEObject) target).eInverseRemove(this, SatellitePackage.COMM_SUBSYSTEM__SOURCE,
- CommSubsystem.class, msgs);
- return basicSetTarget((CommSubsystem) otherEnd, msgs);
- case SatellitePackage.COMM_SUBSYSTEM__SOURCE:
- return ((InternalEList) (InternalEList>) getSource()).basicAdd(otherEnd, msgs);
- }
- return super.eInverseAdd(otherEnd, featureID, msgs);
- }
-
- /**
- *
- *
- * @generated
- */
- @Override
- public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
- switch (featureID) {
- case SatellitePackage.COMM_SUBSYSTEM__TARGET:
- return basicSetTarget(null, msgs);
- case SatellitePackage.COMM_SUBSYSTEM__SOURCE:
- return ((InternalEList>) getSource()).basicRemove(otherEnd, msgs);
- }
- return super.eInverseRemove(otherEnd, featureID, msgs);
+ CommSubsystem oldTarget = target;
+ target = newTarget;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, SatellitePackage.COMM_SUBSYSTEM__TARGET, oldTarget,
+ target));
}
/**
@@ -201,8 +107,6 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp
if (resolve)
return getTarget();
return basicGetTarget();
- case SatellitePackage.COMM_SUBSYSTEM__SOURCE:
- return getSource();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -219,10 +123,6 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp
case SatellitePackage.COMM_SUBSYSTEM__TARGET:
setTarget((CommSubsystem) newValue);
return;
- case SatellitePackage.COMM_SUBSYSTEM__SOURCE:
- getSource().clear();
- getSource().addAll((Collection extends CommSubsystem>) newValue);
- return;
}
super.eSet(featureID, newValue);
}
@@ -238,9 +138,6 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp
case SatellitePackage.COMM_SUBSYSTEM__TARGET:
setTarget((CommSubsystem) null);
return;
- case SatellitePackage.COMM_SUBSYSTEM__SOURCE:
- getSource().clear();
- return;
}
super.eUnset(featureID);
}
@@ -255,8 +152,6 @@ public abstract class CommSubsystemImpl extends MinimalEObjectImpl.Container imp
switch (featureID) {
case SatellitePackage.COMM_SUBSYSTEM__TARGET:
return target != null;
- case SatellitePackage.COMM_SUBSYSTEM__SOURCE:
- return source != null && !source.isEmpty();
}
return super.eIsSet(featureID);
}
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/InterferometryMissionImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/InterferometryMissionImpl.java
index 3401ad51..450f8a9a 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/InterferometryMissionImpl.java
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/InterferometryMissionImpl.java
@@ -2,12 +2,7 @@
*/
package satellite.impl;
-import org.eclipse.emf.common.notify.Notification;
-
import org.eclipse.emf.ecore.EClass;
-
-import org.eclipse.emf.ecore.impl.ENotificationImpl;
-
import satellite.InterferometryMission;
import satellite.SatellitePackage;
@@ -15,36 +10,10 @@ import satellite.SatellitePackage;
*
* An implementation of the model object 'Interferometry Mission '.
*
- *
- * The following features are implemented:
- *
- *
- * {@link satellite.impl.InterferometryMissionImpl#getObservationTime Observation Time }
- *
*
* @generated
*/
public class InterferometryMissionImpl extends ConstellationMissionImpl implements InterferometryMission {
- /**
- * The default value of the '{@link #getObservationTime() Observation Time }' attribute.
- *
- *
- * @see #getObservationTime()
- * @generated
- * @ordered
- */
- protected static final float OBSERVATION_TIME_EDEFAULT = 2.0F;
-
- /**
- * The cached value of the '{@link #getObservationTime() Observation Time }' attribute.
- *
- *
- * @see #getObservationTime()
- * @generated
- * @ordered
- */
- protected float observationTime = OBSERVATION_TIME_EDEFAULT;
-
/**
*
*
@@ -64,103 +33,4 @@ public class InterferometryMissionImpl extends ConstellationMissionImpl implemen
return SatellitePackage.Literals.INTERFEROMETRY_MISSION;
}
- /**
- *
- *
- * @generated
- */
- @Override
- public float getObservationTime() {
- return observationTime;
- }
-
- /**
- *
- *
- * @generated
- */
- @Override
- public void setObservationTime(float newObservationTime) {
- float oldObservationTime = observationTime;
- observationTime = newObservationTime;
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET,
- SatellitePackage.INTERFEROMETRY_MISSION__OBSERVATION_TIME, oldObservationTime, observationTime));
- }
-
- /**
- *
- *
- * @generated
- */
- @Override
- public Object eGet(int featureID, boolean resolve, boolean coreType) {
- switch (featureID) {
- case SatellitePackage.INTERFEROMETRY_MISSION__OBSERVATION_TIME:
- return getObservationTime();
- }
- return super.eGet(featureID, resolve, coreType);
- }
-
- /**
- *
- *
- * @generated
- */
- @Override
- public void eSet(int featureID, Object newValue) {
- switch (featureID) {
- case SatellitePackage.INTERFEROMETRY_MISSION__OBSERVATION_TIME:
- setObservationTime((Float) newValue);
- return;
- }
- super.eSet(featureID, newValue);
- }
-
- /**
- *
- *
- * @generated
- */
- @Override
- public void eUnset(int featureID) {
- switch (featureID) {
- case SatellitePackage.INTERFEROMETRY_MISSION__OBSERVATION_TIME:
- setObservationTime(OBSERVATION_TIME_EDEFAULT);
- return;
- }
- super.eUnset(featureID);
- }
-
- /**
- *
- *
- * @generated
- */
- @Override
- public boolean eIsSet(int featureID) {
- switch (featureID) {
- case SatellitePackage.INTERFEROMETRY_MISSION__OBSERVATION_TIME:
- return observationTime != OBSERVATION_TIME_EDEFAULT;
- }
- return super.eIsSet(featureID);
- }
-
- /**
- *
- *
- * @generated
- */
- @Override
- public String toString() {
- if (eIsProxy())
- return super.toString();
-
- StringBuilder result = new StringBuilder(super.toString());
- result.append(" (observationTime: ");
- result.append(observationTime);
- result.append(')');
- return result.toString();
- }
-
} //InterferometryMissionImpl
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/SatellitePackageImpl.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/SatellitePackageImpl.java
index 17212a96..f6dc1e30 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/SatellitePackageImpl.java
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/ecore-gen/satellite/impl/SatellitePackageImpl.java
@@ -2,7 +2,6 @@
*/
package satellite.impl;
-import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
@@ -242,16 +241,6 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka
return interferometryMissionEClass;
}
- /**
- *
- *
- * @generated
- */
- @Override
- public EAttribute getInterferometryMission_ObservationTime() {
- return (EAttribute) interferometryMissionEClass.getEStructuralFeatures().get(0);
- }
-
/**
*
*
@@ -322,16 +311,6 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka
return (EReference) commSubsystemEClass.getEStructuralFeatures().get(0);
}
- /**
- *
- *
- * @generated
- */
- @Override
- public EReference getCommSubsystem_Source() {
- return (EReference) commSubsystemEClass.getEStructuralFeatures().get(1);
- }
-
/**
*
*
@@ -457,7 +436,6 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka
createEReference(constellationMissionEClass, CONSTELLATION_MISSION__SPACECRAFT);
interferometryMissionEClass = createEClass(INTERFEROMETRY_MISSION);
- createEAttribute(interferometryMissionEClass, INTERFEROMETRY_MISSION__OBSERVATION_TIME);
communicatingElementEClass = createEClass(COMMUNICATING_ELEMENT);
createEReference(communicatingElementEClass, COMMUNICATING_ELEMENT__COMM_SUBSYSTEM);
@@ -469,7 +447,6 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka
commSubsystemEClass = createEClass(COMM_SUBSYSTEM);
createEReference(commSubsystemEClass, COMM_SUBSYSTEM__TARGET);
- createEReference(commSubsystemEClass, COMM_SUBSYSTEM__SOURCE);
payloadEClass = createEClass(PAYLOAD);
@@ -537,15 +514,12 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka
initEReference(getConstellationMission_GroundStationNetwork(), this.getGroundStationNetwork(), null,
"groundStationNetwork", null, 1, 1, ConstellationMission.class, !IS_TRANSIENT, !IS_VOLATILE,
IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getConstellationMission_Spacecraft(), this.getSpacecraft(), null, "spacecraft", null, 2, 50,
+ initEReference(getConstellationMission_Spacecraft(), this.getSpacecraft(), null, "spacecraft", null, 2, -1,
ConstellationMission.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE,
!IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(interferometryMissionEClass, InterferometryMission.class, "InterferometryMission", !IS_ABSTRACT,
!IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
- initEAttribute(getInterferometryMission_ObservationTime(), ecorePackage.getEFloat(), "observationTime", "2.0",
- 1, 1, InterferometryMission.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID,
- IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(communicatingElementEClass, CommunicatingElement.class, "CommunicatingElement", IS_ABSTRACT,
!IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
@@ -564,12 +538,9 @@ public class SatellitePackageImpl extends EPackageImpl implements SatellitePacka
initEClass(commSubsystemEClass, CommSubsystem.class, "CommSubsystem", IS_ABSTRACT, !IS_INTERFACE,
IS_GENERATED_INSTANCE_CLASS);
- initEReference(getCommSubsystem_Target(), this.getCommSubsystem(), this.getCommSubsystem_Source(), "target",
- null, 0, 1, CommSubsystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
- IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getCommSubsystem_Source(), this.getCommSubsystem(), this.getCommSubsystem_Target(), "source",
- null, 0, -1, CommSubsystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE,
- IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getCommSubsystem_Target(), this.getCommSubsystem(), null, "target", null, 0, 1,
+ CommSubsystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES,
+ !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(payloadEClass, Payload.class, "Payload", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/inputs/SatelliteInstance.xmi b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/inputs/SatelliteInstance.xmi
index 7b8e355a..3d07a199 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/inputs/SatelliteInstance.xmi
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/inputs/SatelliteInstance.xmi
@@ -4,11 +4,4 @@
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:satellite="http://www.example.org/satellite"
- xsi:schemaLocation="http://www.example.org/satellite ../model/satellite.ecore">
-
-
-
-
-
+ xsi:schemaLocation="http://www.example.org/satellite ../model/satellite.ecore"/>
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.ecore b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.ecore
index 1685c756..9f17d43c 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.ecore
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.ecore
@@ -5,12 +5,9 @@
-
-
-
+ upperBound="-1" eType="#//Spacecraft" containment="true"/>
+
@@ -21,10 +18,7 @@
containment="true"/>
-
-
+
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.genmodel b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.genmodel
index 09b5f64c..bc98abd6 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.genmodel
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.genmodel
@@ -15,9 +15,7 @@
-
-
-
+
@@ -27,7 +25,6 @@
-
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin
deleted file mode 100644
index 33059424..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin_diagram b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin_diagram
deleted file mode 100644
index a5c675d8..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite.henshin_diagram
+++ /dev/null
@@ -1,131 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite_fixup.henshin b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite_fixup.henshin
deleted file mode 100644
index 224ced8f..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/model/satellite_fixup.henshin
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml
index a07867dc..b0b77996 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/plugin.xml
@@ -8,6 +8,7 @@
+
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/representations.aird b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/representations.aird
new file mode 100644
index 00000000..efa8e366
--- /dev/null
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/representations.aird
@@ -0,0 +1,2 @@
+
+
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/CostObjective.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/CostObjective.xtend
deleted file mode 100644
index 43b2902f..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/CostObjective.xtend
+++ /dev/null
@@ -1,13 +0,0 @@
-package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo
-
-//import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.CostMetric
-//
-//class CostObjective extends MetricBasedGuidanceFunction {
-// new() {
-// super(CostMetric.instance)
-// }
-//
-// override getName() {
-// "Cost"
-// }
-//}
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/LocalSearchEngineManager.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/LocalSearchEngineManager.xtend
deleted file mode 100644
index ee7f0060..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/LocalSearchEngineManager.xtend
+++ /dev/null
@@ -1,31 +0,0 @@
-package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo
-
-import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.SatelliteQueries
-import java.util.WeakHashMap
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions
-import org.eclipse.viatra.query.runtime.emf.EMFScope
-import org.eclipse.viatra.query.runtime.localsearch.matcher.integration.LocalSearchHints
-
-class LocalSearchEngineManager {
- public static val INSTANCE = new LocalSearchEngineManager
-
- val WeakHashMap engineMap = new WeakHashMap
-
- private new() {
- }
-
- def getEngine(EObject eObject) {
- engineMap.computeIfAbsent(eObject) [
- val scope = new EMFScope(it)
- val localSearchHints = LocalSearchHints.^default.build
- val options = ViatraQueryEngineOptions.defineOptions.withDefaultHint(localSearchHints).withDefaultBackend(
- localSearchHints.queryBackendFactory).build
- val engine = AdvancedViatraQueryEngine.on(scope, options)
- SatelliteQueries.instance.prepare(engine)
- engine
- ]
- }
-}
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.xtend
deleted file mode 100644
index 1529794f..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/MetricBasedGuidanceFunction.xtend
+++ /dev/null
@@ -1,47 +0,0 @@
-package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo
-
-import org.eclipse.viatra.query.runtime.api.IPatternMatch
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification
-import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher
-import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction
-import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution
-
-abstract class MetricBasedGuidanceFunction implements IGuidanceFunction {
- val IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> querySpecification
-
- protected new(IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> querySpecification) {
- this.querySpecification = querySpecification
- if (querySpecification.parameters.size != 1) {
- throw new IllegalArgumentException("Metric must have a single parameter")
- }
- }
-
- override computeFitness(Solution model) {
- val value = getMetricValue(model)
- computeFitness(value)
- }
-
- protected def double computeFitness(double metricValue) {
- metricValue
- }
-
- private def getMetricValue(Solution solution) {
- val model = solution.model
- val queryEngine = LocalSearchEngineManager.INSTANCE.getEngine(model)
- val matcher = querySpecification.getMatcher(queryEngine)
- val iterator = matcher.allMatches.iterator
- if (!iterator.hasNext) {
- throw new IllegalStateException("Too few matches")
- }
- val objectValue = iterator.next.get(0)
- if (objectValue instanceof Number) {
- val doubleValue = objectValue.doubleValue
- if (iterator.hasNext) {
- throw new IllegalStateException("Too many matches")
- }
- doubleValue
- } else {
- throw new IllegalStateException("Metric value must be a number")
- }
- }
-}
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend
deleted file mode 100644
index b238e64f..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/PatternMatchConstraint.xtend
+++ /dev/null
@@ -1,29 +0,0 @@
-package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo
-
-import com.google.common.collect.ImmutableList
-import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.SatelliteQueries
-import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.IGuidanceFunction
-import uk.ac.kcl.inf.mdeoptimiser.libraries.core.optimisation.interpreter.guidance.Solution
-
-class PatternMatchConstraint implements IGuidanceFunction {
- static val CONSTRAINT_ANNOTATION_NAME = "Constraint"
-
- val queries = ImmutableList.copyOf(SatelliteQueries.instance.specifications.filter [
- allAnnotations.exists[name == CONSTRAINT_ANNOTATION_NAME]
- ])
-
- override getName() {
- "PatternMatch"
- }
-
- override computeFitness(Solution solution) {
- val model = solution.model
- val queryEngine = LocalSearchEngineManager.INSTANCE.getEngine(model)
- var int matchCount = 0
- for (query : queries) {
- val matcher = query.getMatcher(queryEngine)
- matchCount += matcher.countMatches
- }
- matchCount
- }
-}
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend
deleted file mode 100644
index 58034c43..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/SatelliteMdeOptimiserMain.xtend
+++ /dev/null
@@ -1,51 +0,0 @@
-package hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo
-
-import java.io.BufferedReader
-import java.io.BufferedWriter
-import java.io.FileReader
-import java.io.FileWriter
-import java.util.Map
-import org.eclipse.emf.ecore.EPackage
-import org.eclipse.emf.ecore.resource.Resource
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
-import satellite.SatellitePackage
-import uk.ac.kcl.inf.mdeoptimiser.interfaces.cli.Run
-
-class SatelliteMdeOptimiserMain {
- static val PROJECT_PATH = "."
- static val MOPT_PATH = "src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt"
-
- private new() {
- new IllegalStateException("This is a static utility class and should not be instantiated directly.")
- }
-
- public static def void main(String[] args) {
- Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put(Resource.Factory.Registry.DEFAULT_EXTENSION,
- new XMIResourceFactoryImpl)
- EPackage.Registry.INSTANCE.put(SatellitePackage.eNS_URI, SatellitePackage.eINSTANCE)
- fixupHenshinModel("model/satellite.henshin", "model/satellite_fixup.henshin",
- #{"satellite.ecore" -> SatellitePackage.eNS_URI})
- Run.main(#["-p", PROJECT_PATH, "-m", MOPT_PATH])
- }
-
- private def static void fixupHenshinModel(String originalPath, String outputPath, Map remapMap) {
- val reader = new BufferedReader(new FileReader(originalPath))
- try {
- val writer = new BufferedWriter(new FileWriter(outputPath))
- try {
- var String line
- while ((line = reader.readLine) !== null) {
- for (entry : remapMap.entrySet) {
- line = line.replace(entry.key, entry.value)
- }
- writer.write(line)
- writer.write("\n")
- }
- } finally {
- writer.close
- }
- } finally {
- reader.close
- }
- }
-}
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt
deleted file mode 100644
index e9bd1a64..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/mdeo/satellite.mopt
+++ /dev/null
@@ -1,36 +0,0 @@
-problem {
- basepath
- metamodel
- model <../inputs/SatelliteInstance.xmi>
-}
-
-goal {
- objective Cost minimise java { "hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo.CostObjective" }
- constraint PatternMatch java { "hu.bme.mit.inf.dslreasoner.domains.satellite.mdeo.PatternMatchConstraint" }
-}
-
-search {
-// mutate using unit "addCubeSat3U"
- mutate { "CubeSat3U" }
- mutate { "CubeSat6U" }
- mutate { "SmallSat" }
- mutate { "InterferometryPayload" }
- mutate { "UHFCommSubsystem" }
- mutate { "XCommSubsystem" }
- mutate { "KaCommSubsystem" }
-}
-
-solver {
- optimisation provider moea algorithm NSGAII {
- variation: mutation
- population: 25
- mutation.step: 3
- mutation.strategy: random
- }
-
- termination {
- time: 120
- }
-
- batches 1
-}
\ No newline at end of file
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql
index c1d3f7d3..1f83a3b0 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql
@@ -21,6 +21,13 @@ pattern transmittingGroundStationNetwork(Station : GroundStationNetwork) {
find transmittingCommSubsystem(Station, _);
}
+@Constraint(severity = "error", key = {Station},
+ message = "The ground station network may not have UHF communication subsystems.")
+pattern roundStationNetworkUHF(Station : GroundStationNetwork) {
+ CommunicatingElement.commSubsystem(Station, Comm);
+ UHFCommSubsystem(Comm);
+}
+
// At least two spacecraft must have the interferometry payload configured
@Constraint(severity = "error", key = {Mission},
@@ -97,10 +104,6 @@ private pattern cubeSat3U(Sat : CubeSat3U) {
CubeSat3U(Sat);
}
-private pattern cubeSat6U(Sat : CubeSat6U) {
- CubeSat6U(Sat);
-}
-
// No communication loops may exist
// No spacecraft may directly communicate with itself
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF
index 81ee8677..2666dc5e 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/META-INF/MANIFEST.MF
@@ -9,8 +9,7 @@ Bundle-Localization: plugin
Export-Package: hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm,
hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl,
hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.util,
- hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu,
- hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated
+ hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu
Require-Bundle: org.eclipse.viatra.query.runtime,
org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport,
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml
index 993ec75d..7bf4a20b 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/plugin.xml
@@ -9,6 +9,8 @@
+
+
@@ -21,10 +23,14 @@
+
+
+
+
@@ -32,72 +38,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/mutated/mutated.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/mutated/mutated.vql
deleted file mode 100644
index 58f66fe2..00000000
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/mutated/mutated.vql
+++ /dev/null
@@ -1,270 +0,0 @@
-package hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated
-
-import epackage "hu.bme.mit.inf.yakindumm"
-
-/////////
-// Entry
-/////////
-
-pattern entryInRegion_M0(r1 : Region, e1 : Entry) {
- Region.vertices(r1, e1);
-}
-pattern entryInRegion_M1(r1 : Region, e1) {
- Region.vertices(r1, e1);
-}
-pattern entryInRegion_M2(r1 : Region, e1: Entry) {
- // For positive constraint
- Region(r1);Entry(e1);
-}
-
-
-//@Constraint(severity="error", message="error", key = {r1})
-pattern noEntryInRegion_M0(r1 : Region) {
- neg find entryInRegion_M0(r1, _);
-}
-pattern noEntryInRegion_M1(r1 : Region) {
- neg find entryInRegion_M1(r1, _);
-}
-pattern noEntryInRegion_M2(r1 : Region) {
- neg find entryInRegion_M2(r1, _);
-}
-pattern noEntryInRegion_M3(r1 : Region) {
- find entryInRegion_M0(r1, _);
-}
-pattern noEntryInRegion_M4(r1 : Region) {
- find entryInRegion_M1(r1, _);
-}
-pattern noEntryInRegion_M5(r1 : Region) {
- find entryInRegion_M2(r1, _);
-}
-
-//@Constraint(severity="error", message="error", key = {r})
-pattern multipleEntryInRegion_M0(r : Region) {
- find entryInRegion_M0(r, e1);
- find entryInRegion_M0(r, e2);
- e1 != e2;
-}
-pattern multipleEntryInRegion_M1(r : Region) {
- find entryInRegion_M1(r, e1);
- find entryInRegion_M0(r, e2);
- e1 != e2;
-}
-pattern multipleEntryInRegion_M2(r : Region) {
- find entryInRegion_M2(r, e1);
- find entryInRegion_M0(r, e2);
- e1 != e2;
-}
-pattern multipleEntryInRegion_M3(r : Region) {
- find entryInRegion_M0(r, e1);
- find entryInRegion_M1(r, e2);
- e1 != e2;
-}
-pattern multipleEntryInRegion_M4(r : Region) {
- find entryInRegion_M2(r, e1);
- find entryInRegion_M2(r, e2);
- e1 != e2;
-}
-pattern multipleEntryInRegion_M5(r : Region) {
- find entryInRegion_M0(r, e1);
- find entryInRegion_M0(r, e2);
-}
-
-
-pattern transition_M0(t : Transition, src : Vertex, trg : Vertex) {
- Transition.source(t, src);
- Transition.target(t, trg);
-}
-pattern transition_M1(t : Transition, src : Vertex, trg : Vertex) {
- Transition.source(t, src);
- Vertex(trg);
-}
-pattern transition_M2(t : Transition, src : Vertex, trg : Vertex) {
- Vertex(src);
- Transition.target(t, trg);
-}
-pattern transition_M3(t : Transition, src : Vertex, trg : Vertex) {
- Transition.source(t_x, src);
- Transition.target(t, trg);
-}
-pattern transition_M4(t : Transition, src : Vertex, trg : Vertex) {
- Transition.source(t, src);
- Transition.target(t_x, trg);
-}
-
-//@Constraint(severity="error", message="error", key = {e})
-pattern incomingToEntry_M0(t : Transition, e : Entry) {
- find transition_M0(t, _, e);
-}
-pattern incomingToEntry_1(t : Transition, e) {
- find transition_M0(t, _, e);
-}
-pattern incomingToEntry_2(t : Transition, e : Entry) {
- find transition_M1(t, _, e);
-}
-pattern incomingToEntry_3(t : Transition, e : Entry) {
- find transition_M2(t, _, e);
-}
-pattern incomingToEntry_4(t : Transition, e : Entry) {
- find transition_M3(t, _, e);
-}
-pattern incomingToEntry_5(t : Transition, e : Entry) {
- find transition_M4(t, _, e);
-}
-
-pattern noOutgoingTransitionFromEntry_M0(e : Entry) {
- neg find transition_M0(_, e, _);
-}
-
-pattern noOutgoingTransitionFromEntry_M1(e) {
- Vertex(e);
- neg find transition_M0(_, e, _);
-}
-pattern noOutgoingTransitionFromEntry_M2(e : Entry) {
- neg find transition_M1(_, e, _);
-}
-pattern noOutgoingTransitionFromEntry_M3(e : Entry) {
- neg find transition_M2(_, e, _);
-}
-pattern noOutgoingTransitionFromEntry_M4(e : Entry) {
- neg find transition_M3(_, e, _);
-}
-pattern noOutgoingTransitionFromEntry_M5(e : Entry) {
- neg find transition_M4(_, e, _);
-}
-
-
-//@Constraint(severity="error", message="error", key = {e})
-pattern multipleTransitionFromEntry_M0(e : Entry, t1 : Transition, t2: Transition) {
- Entry.outgoingTransitions(e,t1);
- Entry.outgoingTransitions(e,t2);
- t1!=t2;
-}
-pattern multipleTransitionFromEntry_M1(e, t1 : Transition, t2: Transition) {
- Entry.outgoingTransitions(e,t1);
- Entry.outgoingTransitions(e,t2);
- t1!=t2;
-}
-pattern multipleTransitionFromEntry_M2(e : Entry, t1 : Transition, t2: Transition) {
- Transition(t1);
- Entry.outgoingTransitions(e,t2);
- t1!=t2;
-}
-pattern multipleTransitionFromEntry_M3(e : Entry, t1 : Transition, t2: Transition) {
- Entry.outgoingTransitions(e,t1);
- Transition(t2);
- t1!=t2;
-}
-pattern multipleTransitionFromEntry_M4(e : Entry, t1 : Transition, t2: Transition) {
- Entry.outgoingTransitions(e,t1);
- Entry.outgoingTransitions(e,t2);
-}
-
-/////////
-// Exit
-/////////
-
-//@Constraint(severity="error", message="error", key = {e})
-pattern outgoingFromExit_M0(t : Transition, e : Exit) {
- Exit.outgoingTransitions(e,t);
-}
-pattern outgoingFromExit_M1(t : Transition, e) {
- Vertex.outgoingTransitions(e,t);
-}
-pattern outgoingFromExit_M2(t : Transition, e : Exit) {
- Transition(t);
- Exit(e);
-}
-
-/////////
-// Final
-/////////
-
-//@Constraint(severity="error", message="error", key = {f})
-pattern outgoingFromFinal_M0(t : Transition, f : FinalState) {
- FinalState.outgoingTransitions(f,t);
-}
-pattern outgoingFromFinal_M1(t : Transition, f) {
- Vertex.outgoingTransitions(f,t);
-}
-pattern outgoingFromFinal_M2(t : Transition, f : FinalState) {
- Transition(t);
- FinalState(f);
-}
-
-/////////
-// State vs Region
-/////////
-
-//@Constraint(severity="error", message="error", key = {region})
-pattern noStateInRegion_M0(region: Region) {
- neg find StateInRegion_M0(region,_);
-}
-pattern noStateInRegion_M1(region: Region) {
- neg find StateInRegion_M1(region,_);
-}
-pattern noStateInRegion_M2(region: Region) {
- neg find StateInRegion_M2(region,_);
-}
-pattern noStateInRegion_M3(region: Region) {
- find StateInRegion_M0(region,_);
-}
-
-pattern StateInRegion_M0(region: Region, state: State) {
- Region.vertices(region,state);
-}
-pattern StateInRegion_M1(region: Region, state) {
- Region.vertices(region,state);
-}
-pattern StateInRegion_M2(region: Region, state:State) {
- Region(region);State(state);
-}
-
-/////////
-// Choice
-/////////
-
-@Constraint(severity="error", message="error", key = {c})
-pattern choiceHasNoOutgoing_M0(c : Choice) {
- neg find transition_M0(_, c, _);
-}
-pattern choiceHasNoOutgoing_M1(c:Vertex) {
- neg find transition_M0(_, c, _);
-}
-pattern choiceHasNoOutgoing_M2(c : Choice) {
- neg find transition_M1(_, c, _);
-}
-pattern choiceHasNoOutgoing_M3(c : Choice) {
- neg find transition_M2(_, c, _);
-}
-pattern choiceHasNoOutgoing_M4(c : Choice) {
- neg find transition_M3(_, c, _);
-}
-pattern choiceHasNoOutgoing_M5(c : Choice) {
- neg find transition_M4(_, c, _);
-}
-pattern choiceHasNoOutgoing_M6(c : Choice) {
- find transition_M0(_, c, _);
-}
-
-@Constraint(severity="error", message="error", key = {c})
-pattern choiceHasNoIncoming_M0(c: Choice) {
- neg find transition_M0(_, _, c);
-}
-pattern choiceHasNoIncoming_M1(c:Vertex) {
- neg find transition_M0(_, _, c);
-}
-pattern choiceHasNoIncoming_M2(c: Choice) {
- neg find transition_M1(_, _, c);
-}
-pattern choiceHasNoIncoming_M3(c: Choice) {
- neg find transition_M2(_, _, c);
-}
-pattern choiceHasNoIncoming_M4(c: Choice) {
- neg find transition_M3(_, _, c);
-}
-pattern choiceHasNoIncoming_M5(c: Choice) {
- neg find transition_M4(_, _, c);
-}
-pattern choiceHasNoIncoming_M6(c: Choice) {
- find transition_M0(_, _, c);
-}
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
index f4bfa3c1..98a10cde 100644
--- a/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
@@ -27,14 +27,22 @@ pattern transition(t : Transition, src : Vertex, trg : Vertex) {
Transition.target(t, trg);
}
+pattern transitionFrom(t : Transition, src : Vertex) {
+ Transition.source(t, src);
+}
+
+pattern transitionTo(t : Transition, trg : Vertex) {
+ Transition.target(t, trg);
+}
+
@Constraint(severity="error", message="error", key = {e})
pattern incomingToEntry(t : Transition, e : Entry) {
- find transition(t, _, e);
+ find transitionTo(t, e);
}
@Constraint(severity="error", message="error", key = {e})
pattern noOutgoingTransitionFromEntry(e : Entry) {
- neg find transition(_, e, _);
+ neg find transitionFrom(_, e);
}
@Constraint(severity="error", message="error", key = {e})
@@ -80,12 +88,12 @@ pattern StateInRegion(region: Region, state: State) {
@Constraint(severity="error", message="error", key = {c})
pattern choiceHasNoOutgoing(c : Choice) {
- neg find transition(_, c, _);
+ neg find transitionFrom(_, c);
}
@Constraint(severity="error", message="error", key = {c})
pattern choiceHasNoIncoming(c: Choice) {
- neg find transition(_, _, c);
+ neg find transitionTo(_, c);
}
/////////
@@ -94,27 +102,33 @@ pattern choiceHasNoIncoming(c: Choice) {
@Constraint(severity="error", message="error", key = {s})
pattern synchHasNoOutgoing(s : Synchronization) {
- neg find transition(_, s, _);
+ neg find transitionFrom(_, s);
}
@Constraint(severity="error", message="error", key = {s})
pattern synchHasNoIncoming(s : Synchronization) {
- neg find transition(_, _, s);
+ neg find transitionTo(_, s);
}
@Constraint(severity="error", message="error", key = {s})
-pattern SynchronizedIncomingInSameRegion(s : Synchronization, v1 : Vertex, v2 : Vertex) {
- find transition(t1, v1, s);
- find transition(t2, v2, s);
+pattern SynchronizedIncomingInSameRegion(s : Synchronization, t1 : Transition, t2 : Transition) {
+ find SynchronizedIncomingInSameRegionHelper1(r, s, t1);
+ find SynchronizedIncomingInSameRegionHelper1(r, s, t2);
t1!=t2;
- Region.vertices(r, v1);
- Region.vertices(r, v2);
} or {
- find transition(t1, s, v1);
- find transition(t2, s, v2);
+ find SynchronizedIncomingInSameRegionHelper2(r, s, t1);
+ find SynchronizedIncomingInSameRegionHelper2(r, s, t2);
t1!=t2;
+}
+
+pattern SynchronizedIncomingInSameRegionHelper1(r : Region, s : Synchronization, t1 : Transition) {
+ find transition(t1, v1, s);
+ Region.vertices(r, v1);
+}
+
+pattern SynchronizedIncomingInSameRegionHelper2(r : Region, s : Synchronization, t1 : Transition) {
+ find transition(t1, s, v1);
Region.vertices(r, v1);
- Region.vertices(r, v2);
}
@Constraint(severity="error", message="error", key = {s})
@@ -136,18 +150,24 @@ pattern hasMultipleIncomingTrainsition(v : Synchronization) {
}
@Constraint(severity="error", message="error", key = {s})
-pattern SynchronizedRegionsAreNotSiblings(s : Synchronization, v1 : Vertex, v2 : Vertex) {
- find transition(_, v1, s);
- find transition(_, v2, s);
- CompositeElement.regions.vertices(r1, v1);
- CompositeElement.regions.vertices(r2, v2);
+pattern SynchronizedRegionsAreNotSiblings(s : Synchronization, r1 : CompositeElement, r2 : CompositeElement) {
+ find SynchronizedRegionsAreNotSiblingsHelper1(s, r1);
+ find SynchronizedRegionsAreNotSiblingsHelper1(s, r2);
r1 != r2;
} or {
+ find SynchronizedRegionsAreNotSiblingsHelper2(s, r1);
+ find SynchronizedRegionsAreNotSiblingsHelper2(s, r2);
+ r1 != r2;
+}
+
+pattern SynchronizedRegionsAreNotSiblingsHelper1(s : Synchronization, r1 : CompositeElement) {
find transition(_, s, v1);
- find transition(_, s, v2);
CompositeElement.regions.vertices(r1, v1);
- CompositeElement.regions.vertices(r2, v2);
- r1 != r2;
+}
+
+pattern SynchronizedRegionsAreNotSiblingsHelper2(s : Synchronization, r1 : CompositeElement) {
+ find transition(_, v1, s);
+ CompositeElement.regions.vertices(r1, v1);
}
///////////////////////////////
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend
index 23632d4d..e45ec1c8 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/ModelGenerationMethodProvider.xtend
@@ -5,6 +5,7 @@ import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel
import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.CbcPolyhedronSolver
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.MultiplicityGoalConstraintCalculator
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedronScopePropagator
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraintCalculator
@@ -46,16 +47,28 @@ class ModelGenerationStatistics {
public var long preliminaryTypeAnalisisTime = 0
public var int decisionsTried = 0
-
+
synchronized def incrementDecisionCount() {
decisionsTried++
}
+
+ public var int transformationInvocations
+ synchronized def incrementTransformationCount() {
+ transformationInvocations++
+ }
+
public var int scopePropagatorInvocations
-
+
synchronized def incrementScopePropagationCount() {
scopePropagatorInvocations++
}
+
+ public var int scopePropagatorSolverInvocations
+
+ synchronized def incrementScopePropagationSolverCount() {
+ scopePropagatorSolverInvocations++
+ }
}
@Data class ModelGenerationMethod {
@@ -93,6 +106,7 @@ class ModelGenerationMethodProvider {
boolean nameNewElements,
TypeInferenceMethod typeInferenceMethod,
ScopePropagatorStrategy scopePropagatorStrategy,
+ Collection hints,
DocumentationLevel debugLevel
) {
val statistics = new ModelGenerationStatistics
@@ -103,8 +117,8 @@ class ModelGenerationMethodProvider {
val relationConstraints = relationConstraintCalculator.calculateRelationConstraints(logicProblem)
val queries = patternProvider.generateQueries(logicProblem, emptySolution, statistics, existingQueries,
- workspace, typeInferenceMethod, scopePropagatorStrategy, relationConstraints, writeFiles)
- val scopePropagator = createScopePropagator(scopePropagatorStrategy, emptySolution, queries, statistics)
+ workspace, typeInferenceMethod, scopePropagatorStrategy, relationConstraints, hints, writeFiles)
+ val scopePropagator = createScopePropagator(scopePropagatorStrategy, emptySolution, hints, queries, statistics)
scopePropagator.propagateAllScopeConstraints
val objectRefinementRules = refinementRuleProvider.createObjectRefinementRules(queries, scopePropagator,
nameNewElements, statistics)
@@ -138,14 +152,20 @@ class ModelGenerationMethodProvider {
}
private def createScopePropagator(ScopePropagatorStrategy scopePropagatorStrategy,
- PartialInterpretation emptySolution, GeneratedPatterns queries, ModelGenerationStatistics statistics) {
+ PartialInterpretation emptySolution, Collection hints, GeneratedPatterns queries,
+ ModelGenerationStatistics statistics) {
+ if (!hints.empty && !(scopePropagatorStrategy instanceof ScopePropagatorStrategy.Polyhedral)) {
+ throw new IllegalArgumentException("Only the Polyhedral scope propagator strategy can use hints.")
+ }
switch (scopePropagatorStrategy) {
- case ScopePropagatorStrategy.Count:
+ case ScopePropagatorStrategy.None,
+ case ScopePropagatorStrategy.Basic:
new ScopePropagator(emptySolution, statistics)
case ScopePropagatorStrategy.BasicTypeHierarchy:
new TypeHierarchyScopePropagator(emptySolution, statistics)
ScopePropagatorStrategy.Polyhedral: {
val types = queries.refineObjectQueries.keySet.map[newType].toSet
+ val allPatternsByName = queries.allQueries.toMap[fullyQualifiedName]
val solver = switch (scopePropagatorStrategy.solver) {
case Z3Integer:
new Z3PolyhedronSolver(false, scopePropagatorStrategy.timeoutSeconds)
@@ -160,7 +180,8 @@ class ModelGenerationMethodProvider {
scopePropagatorStrategy.solver)
}
new PolyhedronScopePropagator(emptySolution, statistics, types, queries.multiplicityConstraintQueries,
- queries.hasElementInContainmentQuery, solver, scopePropagatorStrategy.requiresUpperBoundIndexing)
+ queries.hasElementInContainmentQuery, allPatternsByName, hints, solver,
+ scopePropagatorStrategy.requiresUpperBoundIndexing, scopePropagatorStrategy.updateHeuristic)
}
default:
throw new IllegalArgumentException("Unknown scope propagator strategy: " + scopePropagatorStrategy)
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/LinearTypeConstraintHint.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/LinearTypeConstraintHint.xtend
new file mode 100644
index 00000000..8c21ca1d
--- /dev/null
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/LinearTypeConstraintHint.xtend
@@ -0,0 +1,30 @@
+package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality
+
+import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator
+import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
+import org.eclipse.viatra.query.runtime.api.IPatternMatch
+import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher
+
+interface LinearTypeExpressionBuilderFactory {
+ def ViatraQueryMatcher extends IPatternMatch> createMatcher(String queryName)
+
+ def LinearTypeExpressionBuilder createBuilder()
+}
+
+interface LinearTypeExpressionBuilder {
+ def LinearTypeExpressionBuilder add(int scale, Type type)
+
+ def LinearBoundedExpression build()
+}
+
+@FunctionalInterface
+interface RelationConstraintUpdater {
+ def void update(PartialInterpretation p)
+}
+
+interface LinearTypeConstraintHint {
+ def CharSequence getAdditionalPatterns(PatternGenerator patternGenerator)
+
+ def RelationConstraintUpdater createConstraintUpdater(LinearTypeExpressionBuilderFactory builderFactory)
+}
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 7c05e818..51dba244 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
@@ -1,5 +1,7 @@
package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality
+import com.google.common.cache.Cache
+import com.google.common.cache.CacheBuilder
import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableMap
import com.google.common.collect.ImmutableSet
@@ -15,6 +17,7 @@ import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.par
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope
import java.util.ArrayDeque
import java.util.ArrayList
+import java.util.Collection
import java.util.HashMap
import java.util.HashSet
import java.util.List
@@ -29,26 +32,33 @@ import org.eclipse.viatra.query.runtime.emf.EMFScope
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
val Polyhedron polyhedron
val PolyhedronSaturationOperator operator
val Set relevantRelations
+ val Cache cache = CacheBuilder.newBuilder.maximumSize(CACHE_SIZE).build
List updaters = emptyList
new(PartialInterpretation p, ModelGenerationStatistics statistics, Set extends Type> possibleNewDynamicTypes,
Map unfinishedMultiplicityQueries,
IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> hasElementInContainmentQuery,
- PolyhedronSolver solver, boolean propagateRelations) {
+ Map>> allPatternsByName,
+ Collection hints, PolyhedronSolver solver, boolean propagateRelations,
+ boolean updateHeuristic) {
super(p, statistics)
+ this.updateHeuristic = updateHeuristic
val builder = new PolyhedronBuilder(p)
builder.buildPolyhedron(possibleNewDynamicTypes)
scopeBounds = builder.scopeBounds
topLevelBounds = builder.topLevelBounds
polyhedron = builder.polyhedron
operator = solver.createSaturationOperator(polyhedron)
+ propagateAllScopeConstraints()
if (propagateRelations) {
- propagateAllScopeConstraints()
val maximumNumberOfNewNodes = topLevelBounds.upperBound
if (maximumNumberOfNewNodes === null) {
throw new IllegalStateException("Could not determine maximum number of new nodes, it may be unbounded")
@@ -57,7 +67,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator {
throw new IllegalStateException("Maximum number of new nodes is not positive")
}
builder.buildMultiplicityConstraints(unfinishedMultiplicityQueries, hasElementInContainmentQuery,
- maximumNumberOfNewNodes)
+ allPatternsByName, hints, maximumNumberOfNewNodes)
relevantRelations = builder.relevantRelations
updaters = builder.updaters
} else {
@@ -66,21 +76,40 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator {
}
override void doPropagateAllScopeConstraints() {
+ super.doPropagateAllScopeConstraints()
resetBounds()
populatePolyhedronFromScope()
// println(polyhedron)
- val result = operator.saturate()
-// println(polyhedron)
- if (result == PolyhedronSaturationResult.EMPTY) {
- setScopesInvalid()
- } else {
- populateScopesFromPolyhedron()
- if (result != PolyhedronSaturationResult.SATURATED) {
- super.propagateAllScopeConstraints()
+ val signature = polyhedron.createSignature
+ val cachedSignature = cache.getIfPresent(signature)
+ switch (cachedSignature) {
+ case null: {
+ statistics.incrementScopePropagationSolverCount
+ val result = operator.saturate()
+ if (result == PolyhedronSaturationResult.EMPTY) {
+ cache.put(signature, PolyhedronSignature.EMPTY)
+ setScopesInvalid()
+ } else {
+ val resultSignature = polyhedron.createSignature
+ cache.put(signature, resultSignature)
+ populateScopesFromPolyhedron()
+ }
}
+ case PolyhedronSignature.EMPTY:
+ setScopesInvalid()
+ PolyhedronSignature.Bounds: {
+ polyhedron.applySignature(signature)
+ populateScopesFromPolyhedron()
+ }
+ default:
+ throw new IllegalStateException("Unknown polyhedron signature: " + signature)
+ }
+// println(polyhedron)
+ if (updateHeuristic) {
+ copyScopeBoundsToHeuristic()
}
}
-
+
override propagateAdditionToRelation(Relation r) {
super.propagateAdditionToRelation(r)
if (relevantRelations.contains(r)) {
@@ -186,7 +215,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator {
}
@FinalFieldsConstructor
- private static class PolyhedronBuilder {
+ private static class PolyhedronBuilder implements LinearTypeExpressionBuilderFactory {
static val INFINITY_SCALE = 10
val PartialInterpretation p
@@ -197,6 +226,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator {
Map typeBounds
int infinity
ViatraQueryEngine queryEngine
+ Map>> allPatternsByName
ImmutableList.Builder updatersBuilder
Map scopeBounds
@@ -222,9 +252,11 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator {
def buildMultiplicityConstraints(
Map constraints,
IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>> hasElementInContainmentQuery,
- int maximumNuberOfNewNodes) {
+ Map>> allPatternsByName,
+ Collection hints, int maximumNuberOfNewNodes) {
infinity = maximumNuberOfNewNodes * INFINITY_SCALE
queryEngine = ViatraQueryEngine.on(new EMFScope(p))
+ this.allPatternsByName = allPatternsByName
updatersBuilder = ImmutableList.builder
val containmentConstraints = constraints.entrySet.filter[key.containment].groupBy[key.targetType]
for (pair : containmentConstraints.entrySet) {
@@ -238,10 +270,13 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator {
}
}
buildRelevantRelations(constraints.keySet)
+ for (hint : hints) {
+ updatersBuilder.add(hint.createConstraintUpdater(this))
+ }
updaters = updatersBuilder.build
addCachedConstraintsToPolyhedron()
}
-
+
private def buildRelevantRelations(Set constraints) {
val builder = ImmutableSet.builder
for (constraint : constraints) {
@@ -345,7 +380,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator {
}
}
- private def addCoefficients(Map accumulator, int scale, Map a) {
+ private static def addCoefficients(Map accumulator, int scale, Map a) {
for (pair : a.entrySet) {
val dimension = pair.key
val currentValue = accumulator.get(pair.key) ?: 0
@@ -411,14 +446,41 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator {
}
scopeBoundsBuilder.build
}
+
+ override createMatcher(String queryName) {
+ val querySpecification = allPatternsByName.get(queryName)
+ if (querySpecification === null) {
+ throw new IllegalArgumentException("Unknown pattern: " + queryName)
+ }
+ querySpecification.getMatcher(queryEngine)
+ }
+
+ override createBuilder() {
+ new PolyhedronBuilderLinearTypeExpressionBuilder(this)
+ }
}
- private static interface RelationConstraintUpdater {
- def void update(PartialInterpretation p)
+ @FinalFieldsConstructor
+ private static class PolyhedronBuilderLinearTypeExpressionBuilder implements LinearTypeExpressionBuilder {
+ val PolyhedronBuilder polyhedronBuilder
+ val Map coefficients = new HashMap
+
+ override add(int scale, Type type) {
+ val typeCoefficients = polyhedronBuilder.subtypeDimensions.get(type)
+ if (typeCoefficients === null) {
+ throw new IllegalArgumentException("Unknown type: " + type)
+ }
+ PolyhedronBuilder.addCoefficients(coefficients, scale, typeCoefficients)
+ this
+ }
+
+ override build() {
+ polyhedronBuilder.toExpression(coefficients)
+ }
}
@FinalFieldsConstructor
- static class ContainmentConstraintUpdater implements RelationConstraintUpdater {
+ private static class ContainmentConstraintUpdater implements RelationConstraintUpdater {
val String name
val LinearBoundedExpression orphansLowerBound
val LinearBoundedExpression orphansUpperBound
@@ -460,7 +522,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator {
}
@FinalFieldsConstructor
- static class ContainmentRootConstraintUpdater implements RelationConstraintUpdater {
+ private static class ContainmentRootConstraintUpdater implements RelationConstraintUpdater {
val LinearBoundedExpression typeCardinality
val ViatraQueryMatcher extends IPatternMatch> hasElementInContainmentMatcher
@@ -479,7 +541,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator {
}
@FinalFieldsConstructor
- static class UnfinishedMultiplicityConstraintUpdater implements RelationConstraintUpdater {
+ private static class UnfinishedMultiplicityConstraintUpdater implements RelationConstraintUpdater {
val String name
val LinearBoundedExpression availableMultiplicityExpression
val ViatraQueryMatcher extends IPatternMatch> unfinishedMultiplicityMatcher
@@ -500,7 +562,7 @@ class PolyhedronScopePropagator extends TypeHierarchyScopePropagator {
}
@FinalFieldsConstructor
- static class UnrepairableMultiplicityConstraintUpdater implements RelationConstraintUpdater {
+ private static class UnrepairableMultiplicityConstraintUpdater implements RelationConstraintUpdater {
val String name
val LinearBoundedExpression targetCardinalityExpression
val ViatraQueryMatcher extends IPatternMatch> unrepairableMultiplicityMatcher
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend
index 9c6cb82e..4e046190 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/PolyhedronSolver.xtend
@@ -3,6 +3,7 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality
import java.util.List
import java.util.Map
import org.eclipse.xtend.lib.annotations.Accessors
+import org.eclipse.xtend.lib.annotations.Data
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
interface PolyhedronSolver {
@@ -52,16 +53,66 @@ class Polyhedron {
val List expressionsToSaturate
override toString() '''
- Dimensions:
- «FOR dimension : dimensions»
- «dimension»
- «ENDFOR»
- Constraints:
- «FOR constraint : constraints»
- «constraint»
- «ENDFOR»
+ Dimensions:
+ «FOR dimension : dimensions»
+ «dimension»
+ «ENDFOR»
+ Constraints:
+ «FOR constraint : constraints»
+ «constraint»
+ «ENDFOR»
'''
+ def createSignature() {
+ val size = dimensions.size + constraints.size
+ val lowerBounds = newArrayOfSize(size)
+ val upperBounds = newArrayOfSize(size)
+ var int i = 0
+ for (dimension : dimensions) {
+ lowerBounds.set(i, dimension.lowerBound)
+ upperBounds.set(i, dimension.upperBound)
+ i++
+ }
+ for (constraint : constraints) {
+ lowerBounds.set(i, constraint.lowerBound)
+ upperBounds.set(i, constraint.upperBound)
+ i++
+ }
+ new PolyhedronSignature.Bounds(lowerBounds, upperBounds)
+ }
+
+ def applySignature(PolyhedronSignature.Bounds signature) {
+ val lowerBounds = signature.lowerBounds
+ val upperBounds = signature.upperBounds
+ var int i = 0
+ for (dimension : dimensions) {
+ dimension.lowerBound = lowerBounds.get(i)
+ dimension.upperBound = upperBounds.get(i)
+ i++
+ }
+ for (constraint : constraints) {
+ constraint.lowerBound = lowerBounds.get(i)
+ constraint.upperBound = upperBounds.get(i)
+ i++
+ }
+ }
+}
+
+abstract class PolyhedronSignature {
+ public static val EMPTY = new PolyhedronSignature {
+ override toString() {
+ "PolyhedronSignature.EMPTY"
+ }
+ }
+
+ private new() {
+ }
+
+ @Data
+ static class Bounds extends PolyhedronSignature {
+ val Integer[] lowerBounds
+ val Integer[] upperBounds
+ }
}
@Accessors
@@ -80,6 +131,11 @@ abstract class LinearBoundedExpression {
upperBound = tighterBound
}
}
+
+ def void assertEqualsTo(int bound) {
+ tightenLowerBound(bound)
+ tightenUpperBound(bound)
+ }
}
@Accessors
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 52a390a8..013e53e1 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
@@ -117,9 +117,12 @@ class RelationConstraintCalculator {
var inverseUpperMultiplicity = -1
val inverseRelation = inverseRelations.get(relation)
if (inverseRelation !== null) {
- inverseUpperMultiplicity = upperMultiplicities.get(relation)
+ inverseUpperMultiplicity = upperMultiplicities.get(inverseRelation)
container = containmentRelations.contains(inverseRelation)
}
+ if (containment) {
+ inverseUpperMultiplicity = 1
+ }
val constraint = new RelationMultiplicityConstraint(relation, inverseRelation, containment, container,
lowerMultiplicity, upperMultiplicity, inverseUpperMultiplicity)
if (constraint.isActive) {
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
class ScopePropagator {
@Accessors(PROTECTED_GETTER) val PartialInterpretation partialInterpretation
- val ModelGenerationStatistics statistics
+ @Accessors(PROTECTED_GETTER) val ModelGenerationStatistics statistics
val Map type2Scope
@Accessors(PROTECTED_GETTER) val Map> superScopes
@Accessors(PROTECTED_GETTER) val Map> subScopes
@@ -59,12 +59,21 @@ class ScopePropagator {
}
}
} while (changed)
+
+ copyScopeBoundsToHeuristic()
}
def propagateAllScopeConstraints() {
statistics.incrementScopePropagationCount()
doPropagateAllScopeConstraints()
}
+
+ protected def copyScopeBoundsToHeuristic() {
+ partialInterpretation.minNewElementsHeuristic = partialInterpretation.minNewElements
+ for (scope : partialInterpretation.scopes) {
+ scope.minNewElementsHeuristic = scope.minNewElements
+ }
+ }
protected def void doPropagateAllScopeConstraints() {
// Nothing to propagate.
@@ -73,12 +82,17 @@ class ScopePropagator {
def propagateAdditionToType(PartialTypeInterpratation t) {
// println('''Adding to «(t as PartialComplexTypeInterpretation).interpretationOf.name»''')
val targetScope = type2Scope.get(t)
- targetScope.removeOne
- val sups = superScopes.get(targetScope)
- sups.forEach[removeOne]
+ 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.minNewElementsHeuristic > 0) {
+ this.partialInterpretation.minNewElementsHeuristic = this.partialInterpretation.minNewElementsHeuristic - 1
+ }
if (this.partialInterpretation.maxNewElements > 0) {
this.partialInterpretation.maxNewElements = this.partialInterpretation.maxNewElements - 1
} else if (this.partialInterpretation.maxNewElements === 0) {
@@ -105,5 +119,8 @@ class ScopePropagator {
if (scope.minNewElements > 0) {
scope.minNewElements = scope.minNewElements - 1
}
+ if (scope.minNewElementsHeuristic > 0) {
+ scope.minNewElementsHeuristic = scope.minNewElementsHeuristic - 1
+ }
}
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.xtend
index b0ed75cb..3165917a 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/ScopePropagatorStrategy.xtend
@@ -16,7 +16,9 @@ enum PolyhedralScopePropagatorSolver {
}
abstract class ScopePropagatorStrategy {
- public static val Count = new Simple("Count")
+ public static val None = new Simple("None")
+
+ public static val Basic = new Simple("Basic")
public static val BasicTypeHierarchy = new Simple("BasicTypeHierarchy")
@@ -47,14 +49,19 @@ abstract class ScopePropagatorStrategy {
val PolyhedralScopePropagatorConstraints constraints
val PolyhedralScopePropagatorSolver solver
+ val boolean updateHeuristic
val double timeoutSeconds
@FinalFieldsConstructor
new() {
}
+ new(PolyhedralScopePropagatorConstraints constraints, PolyhedralScopePropagatorSolver solver, boolean updateHeuristic) {
+ this(constraints, solver, updateHeuristic, UNLIMITED_TIME)
+ }
+
new(PolyhedralScopePropagatorConstraints constraints, PolyhedralScopePropagatorSolver solver) {
- this(constraints, solver, UNLIMITED_TIME)
+ this(constraints, solver, true)
}
override requiresUpperBoundIndexing() {
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/TypeHierarchyScopePropagator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/TypeHierarchyScopePropagator.xtend
index be8ef00a..d1704b39 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/TypeHierarchyScopePropagator.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/TypeHierarchyScopePropagator.xtend
@@ -27,12 +27,16 @@ class TypeHierarchyScopePropagator extends ScopePropagator {
}
private def propagateLowerLimitUp(Scope subScope, Scope superScope) {
+ var changed = false
if (subScope.minNewElements > superScope.minNewElements) {
superScope.minNewElements = subScope.minNewElements
- return true
- } else {
- return false
+ changed = true
+ }
+ if (subScope.minNewElementsHeuristic > superScope.minNewElementsHeuristic) {
+ superScope.minNewElementsHeuristic = subScope.minNewElementsHeuristic
+ changed = true
}
+ changed
}
private def propagateUpperLimitDown(Scope subScope, Scope superScope) {
@@ -50,16 +54,20 @@ class TypeHierarchyScopePropagator extends ScopePropagator {
}
private def propagateLowerLimitUp(Scope subScope, PartialInterpretation p) {
+ var changed = false
if (subScope.minNewElements > p.minNewElements) {
// println('''
// «(subScope.targetTypeInterpretation as PartialComplexTypeInterpretation).interpretationOf.name» -> nodes
// p.minNewElements «p.minNewElements» = subScope.minNewElements «subScope.minNewElements»
// ''')
p.minNewElements = subScope.minNewElements
- return true
- } else {
- return false
+ changed = true
+ }
+ if (subScope.minNewElementsHeuristic > p.minNewElementsHeuristic) {
+ p.minNewElementsHeuristic = subScope.minNewElementsHeuristic
+ changed = true
}
+ changed
}
private def propagateUpperLimitDown(Scope subScope, PartialInterpretation p) {
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/Z3PolyhedronSolver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/Z3PolyhedronSolver.xtend
index 23444956..3b831433 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/Z3PolyhedronSolver.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/cardinality/Z3PolyhedronSolver.xtend
@@ -13,6 +13,7 @@ import java.math.BigDecimal
import java.math.MathContext
import java.math.RoundingMode
import java.util.Map
+import org.eclipse.xtend.lib.annotations.Accessors
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
class Z3PolyhedronSolver implements PolyhedronSolver {
@@ -28,10 +29,33 @@ class Z3PolyhedronSolver implements PolyhedronSolver {
}
override createSaturationOperator(Polyhedron polyhedron) {
+ new DisposingZ3SaturationOperator(this, polyhedron)
+ }
+
+ def createPersistentSaturationOperator(Polyhedron polyhedron) {
new Z3SaturationOperator(polyhedron, lpRelaxation, timeoutSeconds)
}
}
+@FinalFieldsConstructor
+class DisposingZ3SaturationOperator implements PolyhedronSaturationOperator {
+ val Z3PolyhedronSolver solver
+ @Accessors val Polyhedron polyhedron
+
+ override saturate() {
+ val persistentOperator = solver.createPersistentSaturationOperator(polyhedron)
+ try {
+ persistentOperator.saturate
+ } finally {
+ persistentOperator.close
+ }
+ }
+
+ override close() throws Exception {
+ // Nothing to close.
+ }
+}
+
class Z3SaturationOperator extends AbstractPolyhedronSaturationOperator {
static val INFINITY_SYMBOL_NAME = "oo"
static val MULT_SYMBOL_NAME = "*"
@@ -106,9 +130,9 @@ class Z3SaturationOperator extends AbstractPolyhedronSaturationOperator {
IntNum:
resultExpr.getInt()
RatNum:
- floor(resultExpr)
+ ceil(resultExpr)
AlgebraicNum:
- floor(resultExpr.toLower(ALGEBRAIC_NUMBER_ROUNDING))
+ ceil(resultExpr.toUpper(ALGEBRAIC_NUMBER_ROUNDING))
default:
if (isNegativeInfinity(resultExpr)) {
null
@@ -136,9 +160,9 @@ class Z3SaturationOperator extends AbstractPolyhedronSaturationOperator {
IntNum:
resultExpr.getInt()
RatNum:
- ceil(resultExpr)
+ floor(resultExpr)
AlgebraicNum:
- ceil(resultExpr.toUpper(ALGEBRAIC_NUMBER_ROUNDING))
+ floor(resultExpr.toLower(ALGEBRAIC_NUMBER_ROUNDING))
default:
if (isPositiveInfinity(resultExpr)) {
null
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend
index 1b0db90e..5c35fb54 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend
@@ -16,8 +16,11 @@ import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.Transform
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeAnalysisResult
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.TypeInferenceMethod
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationConstraints
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
+import java.util.Collection
import java.util.HashMap
import java.util.Map
import org.eclipse.emf.ecore.EAttribute
@@ -26,7 +29,6 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery
import org.eclipse.xtend.lib.annotations.Accessors
import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
-import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy
class PatternGenerator {
@Accessors(PUBLIC_GETTER) val TypeIndexer typeIndexer // = new TypeIndexer(this)
@@ -104,7 +106,9 @@ class PatternGenerator {
}
def isRepresentative(Relation relation, Relation inverse) {
- if (inverse === null) {
+ if (relation === null) {
+ return false
+ } else if (inverse === null) {
return true
} else {
relation.name.compareTo(inverse.name) < 1
@@ -144,7 +148,8 @@ class PatternGenerator {
PartialInterpretation emptySolution,
Map fqn2PQuery,
TypeAnalysisResult typeAnalysisResult,
- RelationConstraints constraints
+ RelationConstraints constraints,
+ Collection hints
) {
return '''
@@ -294,6 +299,13 @@ class PatternGenerator {
// 4.3 Relation refinement
//////////
«relationRefinementGenerator.generateRefineReference(problem)»
+
+ //////////
+ // 5 Hints
+ //////////
+ «FOR hint : hints»
+ «hint.getAdditionalPatterns(this)»
+ «ENDFOR»
'''
}
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
index eadf0ae0..f5c85524 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternProvider.xtend
@@ -26,6 +26,7 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery
import org.eclipse.xtend.lib.annotations.Data
import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint
@Data
class GeneratedPatterns {
@@ -62,7 +63,8 @@ class PatternProvider {
def generateQueries(LogicProblem problem, PartialInterpretation emptySolution, ModelGenerationStatistics statistics,
Set existingQueries, ReasonerWorkspace workspace, TypeInferenceMethod typeInferenceMethod,
- ScopePropagatorStrategy scopePropagatorStrategy, RelationConstraints relationConstraints, boolean writeToFile) {
+ ScopePropagatorStrategy scopePropagatorStrategy, RelationConstraints relationConstraints,
+ Collection hints, boolean writeToFile) {
val fqn2Query = existingQueries.toMap[it.fullyQualifiedName]
val PatternGenerator patternGenerator = new PatternGenerator(typeInferenceMethod, scopePropagatorStrategy)
val typeAnalysisResult = if (patternGenerator.requiresTypeAnalysis) {
@@ -75,7 +77,7 @@ class PatternProvider {
null
}
val baseIndexerFile = patternGenerator.transformBaseProperties(problem, emptySolution, fqn2Query,
- typeAnalysisResult, relationConstraints)
+ typeAnalysisResult, relationConstraints, hints)
if (writeToFile) {
workspace.writeText('''generated3valued.vql_deactivated''', baseIndexerFile)
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend
index fa73c861..d915d47e 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationRefinementGenerator.xtend
@@ -44,7 +44,7 @@ class RelationRefinementGenerator {
def referRefinementQuery(RelationDeclaration relation, Relation inverseRelation, String relInterpretationName,
String inverseInterpretationName, String sourceName,
- String targetName) '''find «this.relationRefinementQueryName(relation,inverseRelation)»(problem, interpretation, «relInterpretationName», «IF inverseRelation !== null»inverseInterpretationName, «ENDIF»«sourceName», «targetName»);'''
+ String targetName) '''find «this.relationRefinementQueryName(relation,inverseRelation)»(problem, interpretation, «relInterpretationName», «IF inverseRelation !== null»«inverseInterpretationName», «ENDIF»«sourceName», «targetName»);'''
def getRefineRelationQueries(LogicProblem p) {
// val containmentRelations = p.containmentHierarchies.map[containmentRelations].flatten.toSet
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/UnfinishedIndexer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/UnfinishedIndexer.xtend
index 15b5a047..a8a07756 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/UnfinishedIndexer.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/UnfinishedIndexer.xtend
@@ -1,5 +1,6 @@
package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns
+import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration
import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.RelationMultiplicityConstraint
@@ -76,21 +77,26 @@ class UnfinishedIndexer {
«IF indexUpperMultiplicities»
«IF constraint.constrainsUnrepairable || constraint.constrainsRemainingInverse»
private pattern «repairMatchName(constraint)»(problem:LogicProblem, interpretation:PartialInterpretation, source:DefinedElement, target:DefinedElement) {
- find interpretation(problem,interpretation);
- find mustExist(problem,interpretation,source);
- «base.typeIndexer.referInstanceOf(constraint.sourceType,Modality::MUST,"source")»
- find mustExist(problem,interpretation,target);
- «base.typeIndexer.referInstanceOf(constraint.targetType,Modality::MUST,"target")»
- neg «base.referRelation(constraint.relation,"source","target",Modality.MUST,fqn2PQuery)»
- «base.referRelation(constraint.relation,"source","target",Modality.MAY,fqn2PQuery)»
+ «IF base.isRepresentative(constraint.relation, constraint.inverseRelation) && constraint.relation instanceof RelationDeclaration»
+ «base.relationRefinementGenerator.referRefinementQuery(constraint.relation as RelationDeclaration, constraint.inverseRelation, "_", "_", "source", "target")»
+ «ELSE»
+ «IF base.isRepresentative(constraint.inverseRelation, constraint.relation) && constraint.inverseRelation instanceof RelationDeclaration»
+ «base.relationRefinementGenerator.referRefinementQuery(constraint.inverseRelation as RelationDeclaration, constraint.relation, "_", "_", "target", "source")»
+ «ELSE»
+ find interpretation(problem,interpretation);
+ find mustExist(problem,interpretation,source);
+ «base.typeIndexer.referInstanceOf(constraint.sourceType,Modality::MUST,"source")»
+ find mustExist(problem,interpretation,target);
+ «base.typeIndexer.referInstanceOf(constraint.targetType,Modality::MUST,"target")»
+ neg «base.referRelation(constraint.relation,"source","target",Modality.MUST,fqn2PQuery)»
+ «base.referRelation(constraint.relation,"source","target",Modality.MAY,fqn2PQuery)»
+ «ENDIF»
+ «ENDIF»
}
«ENDIF»
«IF constraint.constrainsUnrepairable»
private pattern «unrepairableMultiplicityName(constraint)»_helper(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement, unrepairableMultiplicity:java Integer) {
- find interpretation(problem,interpretation);
- find mustExist(problem,interpretation,object);
- «base.typeIndexer.referInstanceOf(constraint.sourceType,Modality::MUST,"object")»
find «unfinishedMultiplicityName(constraint)»_helper(problem, interpretation, object, missingMultiplicity);
numberOfRepairMatches == count find «repairMatchName(constraint)»(problem, interpretation, object, _);
check(numberOfRepairMatches < missingMultiplicity);
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend
index bf816de9..7891ebd8 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/rules/RefinementRuleProvider.xtend
@@ -67,7 +67,8 @@ class RefinementRuleProvider {
if(containmentRelation != null) {
if(inverseRelation!= null) {
ruleBuilder.action[match |
- //println(name)
+ statistics.incrementTransformationCount
+// println(name)
val startTime = System.nanoTime
//val problem = match.get(0) as LogicProblem
val interpretation = match.get(1) as PartialInterpretation
@@ -107,7 +108,8 @@ class RefinementRuleProvider {
]
} else {
ruleBuilder.action[match |
- //println(name)
+ statistics.incrementTransformationCount
+// println(name)
val startTime = System.nanoTime
//val problem = match.get(0) as LogicProblem
val interpretation = match.get(1) as PartialInterpretation
@@ -144,6 +146,9 @@ class RefinementRuleProvider {
}
} else {
ruleBuilder.action[match |
+ statistics.incrementTransformationCount
+// println(name)
+
val startTime = System.nanoTime
//val problem = match.get(0) as LogicProblem
val interpretation = match.get(1) as PartialInterpretation
@@ -198,8 +203,9 @@ class RefinementRuleProvider {
.precondition(lhs)
if (inverseRelation == null) {
ruleBuilder.action [ match |
+ statistics.incrementTransformationCount
val startTime = System.nanoTime
- //println(name)
+// println(name)
// val problem = match.get(0) as LogicProblem
// val interpretation = match.get(1) as PartialInterpretation
val relationInterpretation = match.get(2) as PartialRelationInterpretation
@@ -217,8 +223,9 @@ class RefinementRuleProvider {
]
} else {
ruleBuilder.action [ match |
+ statistics.incrementTransformationCount
val startTime = System.nanoTime
- //println(name)
+// println(name)
// val problem = match.get(0) as LogicProblem
// val interpretation = match.get(1) as PartialInterpretation
val relationInterpretation = match.get(2) as PartialRelationInterpretation
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialInterpretation.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialInterpretation.java
index 098cc15b..9d0c3fea 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialInterpretation.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialInterpretation.java
@@ -30,6 +30,7 @@ import org.eclipse.emf.ecore.EObject;
* {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getScopes Scopes }
* {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getMinNewElements Min New Elements }
* {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getMaxNewElements Max New Elements }
+ * {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getMinNewElementsHeuristic Min New Elements Heuristic }
*
*
* @see hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage#getPartialInterpretation()
@@ -255,4 +256,27 @@ public interface PartialInterpretation extends EObject {
*/
void setMaxNewElements(int value);
+ /**
+ * Returns the value of the 'Min New Elements Heuristic ' attribute.
+ * The default value is "0"
.
+ *
+ *
+ * @return the value of the 'Min New Elements Heuristic ' attribute.
+ * @see #setMinNewElementsHeuristic(int)
+ * @see hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage#getPartialInterpretation_MinNewElementsHeuristic()
+ * @model default="0" required="true"
+ * @generated
+ */
+ int getMinNewElementsHeuristic();
+
+ /**
+ * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getMinNewElementsHeuristic Min New Elements Heuristic }' attribute.
+ *
+ *
+ * @param value the new value of the 'Min New Elements Heuristic ' attribute.
+ * @see #getMinNewElementsHeuristic()
+ * @generated
+ */
+ void setMinNewElementsHeuristic(int value);
+
} // PartialInterpretation
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialinterpretationPackage.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialinterpretationPackage.java
index 4f34b9b7..f462ebe4 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialinterpretationPackage.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/PartialinterpretationPackage.java
@@ -166,6 +166,15 @@ public interface PartialinterpretationPackage extends EPackage {
*/
int PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS = 10;
+ /**
+ * The feature id for the 'Min New Elements Heuristic ' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ int PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC = 11;
+
/**
* The number of structural features of the 'Partial Interpretation ' class.
*
@@ -173,7 +182,7 @@ public interface PartialinterpretationPackage extends EPackage {
* @generated
* @ordered
*/
- int PARTIAL_INTERPRETATION_FEATURE_COUNT = 11;
+ int PARTIAL_INTERPRETATION_FEATURE_COUNT = 12;
/**
* The number of operations of the 'Partial Interpretation ' class.
@@ -912,6 +921,15 @@ public interface PartialinterpretationPackage extends EPackage {
*/
int SCOPE__TARGET_TYPE_INTERPRETATION = 2;
+ /**
+ * The feature id for the 'Min New Elements Heuristic ' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ int SCOPE__MIN_NEW_ELEMENTS_HEURISTIC = 3;
+
/**
* The number of structural features of the 'Scope ' class.
*
@@ -919,7 +937,7 @@ public interface PartialinterpretationPackage extends EPackage {
* @generated
* @ordered
*/
- int SCOPE_FEATURE_COUNT = 3;
+ int SCOPE_FEATURE_COUNT = 4;
/**
* The number of operations of the 'Scope ' class.
@@ -1357,6 +1375,17 @@ public interface PartialinterpretationPackage extends EPackage {
*/
EAttribute getPartialInterpretation_MaxNewElements();
+ /**
+ * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getMinNewElementsHeuristic Min New Elements Heuristic }'.
+ *
+ *
+ * @return the meta object for the attribute 'Min New Elements Heuristic '.
+ * @see hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation#getMinNewElementsHeuristic()
+ * @see #getPartialInterpretation()
+ * @generated
+ */
+ EAttribute getPartialInterpretation_MinNewElementsHeuristic();
+
/**
* Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialConstantInterpretation Partial Constant Interpretation }'.
*
@@ -1749,6 +1778,17 @@ public interface PartialinterpretationPackage extends EPackage {
*/
EReference getScope_TargetTypeInterpretation();
+ /**
+ * Returns the meta object for the attribute '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getMinNewElementsHeuristic Min New Elements Heuristic }'.
+ *
+ *
+ * @return the meta object for the attribute 'Min New Elements Heuristic '.
+ * @see hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getMinNewElementsHeuristic()
+ * @see #getScope()
+ * @generated
+ */
+ EAttribute getScope_MinNewElementsHeuristic();
+
/**
* Returns the meta object for class '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialPrimitiveInterpretation Partial Primitive Interpretation }'.
*
@@ -1952,6 +1992,14 @@ public interface PartialinterpretationPackage extends EPackage {
*/
EAttribute PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS = eINSTANCE.getPartialInterpretation_MaxNewElements();
+ /**
+ * The meta object literal for the 'Min New Elements Heuristic ' attribute feature.
+ *
+ *
+ * @generated
+ */
+ EAttribute PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC = eINSTANCE.getPartialInterpretation_MinNewElementsHeuristic();
+
/**
* The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialConstantInterpretationImpl Partial Constant Interpretation }' class.
*
@@ -2278,6 +2326,14 @@ public interface PartialinterpretationPackage extends EPackage {
*/
EReference SCOPE__TARGET_TYPE_INTERPRETATION = eINSTANCE.getScope_TargetTypeInterpretation();
+ /**
+ * The meta object literal for the 'Min New Elements Heuristic ' attribute feature.
+ *
+ *
+ * @generated
+ */
+ EAttribute SCOPE__MIN_NEW_ELEMENTS_HEURISTIC = eINSTANCE.getScope_MinNewElementsHeuristic();
+
/**
* The meta object literal for the '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialPrimitiveInterpretationImpl Partial Primitive Interpretation }' class.
*
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/Scope.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/Scope.java
index 155b9f00..a0b58615 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/Scope.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/Scope.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.ecore.EObject;
* {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getMinNewElements Min New Elements }
* {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getMaxNewElements Max New Elements }
* {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getTargetTypeInterpretation Target Type Interpretation }
+ * {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getMinNewElementsHeuristic Min New Elements Heuristic }
*
*
* @see hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage#getScope()
@@ -105,4 +106,27 @@ public interface Scope extends EObject {
*/
void setTargetTypeInterpretation(PartialTypeInterpratation value);
+ /**
+ * Returns the value of the 'Min New Elements Heuristic ' attribute.
+ * The default value is "0"
.
+ *
+ *
+ * @return the value of the 'Min New Elements Heuristic ' attribute.
+ * @see #setMinNewElementsHeuristic(int)
+ * @see hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage#getScope_MinNewElementsHeuristic()
+ * @model default="0" required="true"
+ * @generated
+ */
+ int getMinNewElementsHeuristic();
+
+ /**
+ * Sets the value of the '{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.Scope#getMinNewElementsHeuristic Min New Elements Heuristic }' attribute.
+ *
+ *
+ * @param value the new value of the 'Min New Elements Heuristic ' attribute.
+ * @see #getMinNewElementsHeuristic()
+ * @generated
+ */
+ void setMinNewElementsHeuristic(int value);
+
} // Scope
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BinaryElementRelationLinkImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BinaryElementRelationLinkImpl.java
index f5efe02a..ca33dd65 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BinaryElementRelationLinkImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BinaryElementRelationLinkImpl.java
@@ -73,6 +73,7 @@ public class BinaryElementRelationLinkImpl extends RelationLinkImpl implements B
*
* @generated
*/
+ @Override
public DefinedElement getParam1() {
if (param1 != null && param1.eIsProxy()) {
InternalEObject oldParam1 = (InternalEObject)param1;
@@ -99,6 +100,7 @@ public class BinaryElementRelationLinkImpl extends RelationLinkImpl implements B
*
* @generated
*/
+ @Override
public void setParam1(DefinedElement newParam1) {
DefinedElement oldParam1 = param1;
param1 = newParam1;
@@ -111,6 +113,7 @@ public class BinaryElementRelationLinkImpl extends RelationLinkImpl implements B
*
* @generated
*/
+ @Override
public DefinedElement getParam2() {
if (param2 != null && param2.eIsProxy()) {
InternalEObject oldParam2 = (InternalEObject)param2;
@@ -137,6 +140,7 @@ public class BinaryElementRelationLinkImpl extends RelationLinkImpl implements B
*
* @generated
*/
+ @Override
public void setParam2(DefinedElement newParam2) {
DefinedElement oldParam2 = param2;
param2 = newParam2;
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BooleanElementImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BooleanElementImpl.java
index e906e07d..5f12d9e4 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BooleanElementImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/BooleanElementImpl.java
@@ -69,6 +69,7 @@ public class BooleanElementImpl extends PrimitiveElementImpl implements BooleanE
*
* @generated
*/
+ @Override
public boolean isValue() {
return value;
}
@@ -78,6 +79,7 @@ public class BooleanElementImpl extends PrimitiveElementImpl implements BooleanE
*
* @generated
*/
+ @Override
public void setValue(boolean newValue) {
boolean oldValue = value;
value = newValue;
@@ -152,7 +154,7 @@ public class BooleanElementImpl extends PrimitiveElementImpl implements BooleanE
public String toString() {
if (eIsProxy()) return super.toString();
- StringBuffer result = new StringBuffer(super.toString());
+ StringBuilder result = new StringBuilder(super.toString());
result.append(" (value: ");
result.append(value);
result.append(')');
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/IntegerElementImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/IntegerElementImpl.java
index ef1a4b96..c8fbe1dd 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/IntegerElementImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/IntegerElementImpl.java
@@ -69,6 +69,7 @@ public class IntegerElementImpl extends PrimitiveElementImpl implements IntegerE
*
* @generated
*/
+ @Override
public int getValue() {
return value;
}
@@ -78,6 +79,7 @@ public class IntegerElementImpl extends PrimitiveElementImpl implements IntegerE
*
* @generated
*/
+ @Override
public void setValue(int newValue) {
int oldValue = value;
value = newValue;
@@ -152,7 +154,7 @@ public class IntegerElementImpl extends PrimitiveElementImpl implements IntegerE
public String toString() {
if (eIsProxy()) return super.toString();
- StringBuffer result = new StringBuffer(super.toString());
+ StringBuilder result = new StringBuilder(super.toString());
result.append(" (value: ");
result.append(value);
result.append(')');
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkElementImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkElementImpl.java
index 749a03c5..c319a3f4 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkElementImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkElementImpl.java
@@ -83,6 +83,7 @@ public class NaryRelationLinkElementImpl extends MinimalEObjectImpl.Container im
*
* @generated
*/
+ @Override
public int getIndex() {
return index;
}
@@ -92,6 +93,7 @@ public class NaryRelationLinkElementImpl extends MinimalEObjectImpl.Container im
*
* @generated
*/
+ @Override
public void setIndex(int newIndex) {
int oldIndex = index;
index = newIndex;
@@ -104,6 +106,7 @@ public class NaryRelationLinkElementImpl extends MinimalEObjectImpl.Container im
*
* @generated
*/
+ @Override
public DefinedElement getParam() {
if (param != null && param.eIsProxy()) {
InternalEObject oldParam = (InternalEObject)param;
@@ -130,6 +133,7 @@ public class NaryRelationLinkElementImpl extends MinimalEObjectImpl.Container im
*
* @generated
*/
+ @Override
public void setParam(DefinedElement newParam) {
DefinedElement oldParam = param;
param = newParam;
@@ -215,7 +219,7 @@ public class NaryRelationLinkElementImpl extends MinimalEObjectImpl.Container im
public String toString() {
if (eIsProxy()) return super.toString();
- StringBuffer result = new StringBuffer(super.toString());
+ StringBuilder result = new StringBuilder(super.toString());
result.append(" (index: ");
result.append(index);
result.append(')');
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkImpl.java
index f387ee06..9f7628cf 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/NaryRelationLinkImpl.java
@@ -66,6 +66,7 @@ public class NaryRelationLinkImpl extends RelationLinkImpl implements NaryRelati
*
* @generated
*/
+ @Override
public EList getElements() {
if (elements == null) {
elements = new EObjectContainmentEList(NaryRelationLinkElement.class, this, PartialinterpretationPackage.NARY_RELATION_LINK__ELEMENTS);
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialComplexTypeInterpretationImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialComplexTypeInterpretationImpl.java
index 07ee282d..c00b4278 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialComplexTypeInterpretationImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialComplexTypeInterpretationImpl.java
@@ -79,6 +79,7 @@ public class PartialComplexTypeInterpretationImpl extends PartialTypeInterpratat
*
* @generated
*/
+ @Override
public EList getSupertypeInterpretation() {
if (supertypeInterpretation == null) {
supertypeInterpretation = new EObjectResolvingEList(PartialComplexTypeInterpretation.class, this, PartialinterpretationPackage.PARTIAL_COMPLEX_TYPE_INTERPRETATION__SUPERTYPE_INTERPRETATION);
@@ -91,6 +92,7 @@ public class PartialComplexTypeInterpretationImpl extends PartialTypeInterpratat
*
* @generated
*/
+ @Override
public TypeDeclaration getInterpretationOf() {
if (interpretationOf != null && interpretationOf.eIsProxy()) {
InternalEObject oldInterpretationOf = (InternalEObject)interpretationOf;
@@ -117,6 +119,7 @@ public class PartialComplexTypeInterpretationImpl extends PartialTypeInterpratat
*
* @generated
*/
+ @Override
public void setInterpretationOf(TypeDeclaration newInterpretationOf) {
TypeDeclaration oldInterpretationOf = interpretationOf;
interpretationOf = newInterpretationOf;
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialConstantInterpretationImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialConstantInterpretationImpl.java
index 81b2ce8d..6d51f0db 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialConstantInterpretationImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialConstantInterpretationImpl.java
@@ -63,6 +63,7 @@ public class PartialConstantInterpretationImpl extends MinimalEObjectImpl.Contai
*
* @generated
*/
+ @Override
public ConstantDeclaration getInterpretationOf() {
if (interpretationOf != null && interpretationOf.eIsProxy()) {
InternalEObject oldInterpretationOf = (InternalEObject)interpretationOf;
@@ -89,6 +90,7 @@ public class PartialConstantInterpretationImpl extends MinimalEObjectImpl.Contai
*
* @generated
*/
+ @Override
public void setInterpretationOf(ConstantDeclaration newInterpretationOf) {
ConstantDeclaration oldInterpretationOf = interpretationOf;
interpretationOf = newInterpretationOf;
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialFunctionInterpretationImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialFunctionInterpretationImpl.java
index 2d361e8e..855c4abc 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialFunctionInterpretationImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialFunctionInterpretationImpl.java
@@ -63,6 +63,7 @@ public class PartialFunctionInterpretationImpl extends MinimalEObjectImpl.Contai
*
* @generated
*/
+ @Override
public FunctionDeclaration getInterpretationOf() {
if (interpretationOf != null && interpretationOf.eIsProxy()) {
InternalEObject oldInterpretationOf = (InternalEObject)interpretationOf;
@@ -89,6 +90,7 @@ public class PartialFunctionInterpretationImpl extends MinimalEObjectImpl.Contai
*
* @generated
*/
+ @Override
public void setInterpretationOf(FunctionDeclaration newInterpretationOf) {
FunctionDeclaration oldInterpretationOf = interpretationOf;
interpretationOf = newInterpretationOf;
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialInterpretationImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialInterpretationImpl.java
index bce3e2e0..9afdd8d2 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialInterpretationImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialInterpretationImpl.java
@@ -47,6 +47,7 @@ import org.eclipse.emf.ecore.util.InternalEList;
* {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialInterpretationImpl#getScopes Scopes }
* {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialInterpretationImpl#getMinNewElements Min New Elements }
* {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialInterpretationImpl#getMaxNewElements Max New Elements }
+ * {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialInterpretationImpl#getMinNewElementsHeuristic Min New Elements Heuristic }
*
*
* @generated
@@ -182,6 +183,26 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*/
protected int maxNewElements = MAX_NEW_ELEMENTS_EDEFAULT;
+ /**
+ * The default value of the '{@link #getMinNewElementsHeuristic() Min New Elements Heuristic }' attribute.
+ *
+ *
+ * @see #getMinNewElementsHeuristic()
+ * @generated
+ * @ordered
+ */
+ protected static final int MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT = 0;
+
+ /**
+ * The cached value of the '{@link #getMinNewElementsHeuristic() Min New Elements Heuristic }' attribute.
+ *
+ *
+ * @see #getMinNewElementsHeuristic()
+ * @generated
+ * @ordered
+ */
+ protected int minNewElementsHeuristic = MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT;
+
/**
*
*
@@ -206,6 +227,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public LogicProblem getProblem() {
if (problem != null && problem.eIsProxy()) {
InternalEObject oldProblem = (InternalEObject)problem;
@@ -232,6 +254,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public void setProblem(LogicProblem newProblem) {
LogicProblem oldProblem = problem;
problem = newProblem;
@@ -244,6 +267,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public EList getPartialconstantinterpretation() {
if (partialconstantinterpretation == null) {
partialconstantinterpretation = new EObjectContainmentEList(PartialConstantInterpretation.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__PARTIALCONSTANTINTERPRETATION);
@@ -256,6 +280,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public EList getPartialrelationinterpretation() {
if (partialrelationinterpretation == null) {
partialrelationinterpretation = new EObjectContainmentEList(PartialRelationInterpretation.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__PARTIALRELATIONINTERPRETATION);
@@ -268,6 +293,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public EList getPartialfunctioninterpretation() {
if (partialfunctioninterpretation == null) {
partialfunctioninterpretation = new EObjectContainmentEList(PartialFunctionInterpretation.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__PARTIALFUNCTIONINTERPRETATION);
@@ -280,6 +306,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public EList getNewElements() {
if (newElements == null) {
newElements = new EObjectContainmentEList(DefinedElement.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__NEW_ELEMENTS);
@@ -292,6 +319,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public EList getPartialtypeinterpratation() {
if (partialtypeinterpratation == null) {
partialtypeinterpratation = new EObjectContainmentEList(PartialTypeInterpratation.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__PARTIALTYPEINTERPRATATION);
@@ -304,6 +332,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public EList getOpenWorldElements() {
if (openWorldElements == null) {
openWorldElements = new EObjectContainmentEList(DefinedElement.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__OPEN_WORLD_ELEMENTS);
@@ -316,6 +345,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public LogicProblem getProblemConainer() {
return problemConainer;
}
@@ -340,6 +370,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public void setProblemConainer(LogicProblem newProblemConainer) {
if (newProblemConainer != problemConainer) {
NotificationChain msgs = null;
@@ -359,6 +390,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public EList getScopes() {
if (scopes == null) {
scopes = new EObjectContainmentEList(Scope.class, this, PartialinterpretationPackage.PARTIAL_INTERPRETATION__SCOPES);
@@ -371,6 +403,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public int getMinNewElements() {
return minNewElements;
}
@@ -380,6 +413,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public void setMinNewElements(int newMinNewElements) {
int oldMinNewElements = minNewElements;
minNewElements = newMinNewElements;
@@ -392,6 +426,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public int getMaxNewElements() {
return maxNewElements;
}
@@ -401,6 +436,7 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
*
* @generated
*/
+ @Override
public void setMaxNewElements(int newMaxNewElements) {
int oldMaxNewElements = maxNewElements;
maxNewElements = newMaxNewElements;
@@ -408,6 +444,29 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
eNotify(new ENotificationImpl(this, Notification.SET, PartialinterpretationPackage.PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS, oldMaxNewElements, maxNewElements));
}
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public int getMinNewElementsHeuristic() {
+ return minNewElementsHeuristic;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void setMinNewElementsHeuristic(int newMinNewElementsHeuristic) {
+ int oldMinNewElementsHeuristic = minNewElementsHeuristic;
+ minNewElementsHeuristic = newMinNewElementsHeuristic;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, PartialinterpretationPackage.PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC, oldMinNewElementsHeuristic, minNewElementsHeuristic));
+ }
+
/**
*
*
@@ -467,6 +526,8 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
return getMinNewElements();
case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS:
return getMaxNewElements();
+ case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC:
+ return getMinNewElementsHeuristic();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -520,6 +581,9 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS:
setMaxNewElements((Integer)newValue);
return;
+ case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC:
+ setMinNewElementsHeuristic((Integer)newValue);
+ return;
}
super.eSet(featureID, newValue);
}
@@ -565,6 +629,9 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS:
setMaxNewElements(MAX_NEW_ELEMENTS_EDEFAULT);
return;
+ case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC:
+ setMinNewElementsHeuristic(MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT);
+ return;
}
super.eUnset(featureID);
}
@@ -599,6 +666,8 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
return minNewElements != MIN_NEW_ELEMENTS_EDEFAULT;
case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS:
return maxNewElements != MAX_NEW_ELEMENTS_EDEFAULT;
+ case PartialinterpretationPackage.PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC:
+ return minNewElementsHeuristic != MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT;
}
return super.eIsSet(featureID);
}
@@ -612,11 +681,13 @@ public class PartialInterpretationImpl extends MinimalEObjectImpl.Container impl
public String toString() {
if (eIsProxy()) return super.toString();
- StringBuffer result = new StringBuffer(super.toString());
+ StringBuilder result = new StringBuilder(super.toString());
result.append(" (minNewElements: ");
result.append(minNewElements);
result.append(", maxNewElements: ");
result.append(maxNewElements);
+ result.append(", minNewElementsHeuristic: ");
+ result.append(minNewElementsHeuristic);
result.append(')');
return result.toString();
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialRelationInterpretationImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialRelationInterpretationImpl.java
index 71aef9af..7ad06504 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialRelationInterpretationImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialRelationInterpretationImpl.java
@@ -106,6 +106,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai
*
* @generated
*/
+ @Override
public RelationDeclaration getInterpretationOf() {
if (interpretationOf != null && interpretationOf.eIsProxy()) {
InternalEObject oldInterpretationOf = (InternalEObject)interpretationOf;
@@ -132,6 +133,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai
*
* @generated
*/
+ @Override
public void setInterpretationOf(RelationDeclaration newInterpretationOf) {
RelationDeclaration oldInterpretationOf = interpretationOf;
interpretationOf = newInterpretationOf;
@@ -144,6 +146,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai
*
* @generated
*/
+ @Override
public EList getRelationlinks() {
if (relationlinks == null) {
relationlinks = new EObjectContainmentEList(RelationLink.class, this, PartialinterpretationPackage.PARTIAL_RELATION_INTERPRETATION__RELATIONLINKS);
@@ -156,6 +159,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai
*
* @generated
*/
+ @Override
public TypeReference getParam1() {
if (param1 != null && param1.eIsProxy()) {
InternalEObject oldParam1 = (InternalEObject)param1;
@@ -182,6 +186,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai
*
* @generated
*/
+ @Override
public void setParam1(TypeReference newParam1) {
TypeReference oldParam1 = param1;
param1 = newParam1;
@@ -194,6 +199,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai
*
* @generated
*/
+ @Override
public TypeReference getParam2() {
if (param2 != null && param2.eIsProxy()) {
InternalEObject oldParam2 = (InternalEObject)param2;
@@ -220,6 +226,7 @@ public class PartialRelationInterpretationImpl extends MinimalEObjectImpl.Contai
*
* @generated
*/
+ @Override
public void setParam2(TypeReference newParam2) {
TypeReference oldParam2 = param2;
param2 = newParam2;
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialTypeInterpratationImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialTypeInterpratationImpl.java
index da9b1472..51eabd2c 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialTypeInterpratationImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialTypeInterpratationImpl.java
@@ -76,6 +76,7 @@ public abstract class PartialTypeInterpratationImpl extends MinimalEObjectImpl.C
*
* @generated
*/
+ @Override
public EList getElements() {
if (elements == null) {
elements = new EObjectResolvingEList(DefinedElement.class, this, PartialinterpretationPackage.PARTIAL_TYPE_INTERPRATATION__ELEMENTS);
@@ -88,6 +89,7 @@ public abstract class PartialTypeInterpratationImpl extends MinimalEObjectImpl.C
*
* @generated
*/
+ @Override
public EList getScopes() {
if (scopes == null) {
scopes = new EObjectWithInverseResolvingEList(Scope.class, this, PartialinterpretationPackage.PARTIAL_TYPE_INTERPRATATION__SCOPES, PartialinterpretationPackage.SCOPE__TARGET_TYPE_INTERPRETATION);
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationFactoryImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationFactoryImpl.java
index af1db8a1..06ca4e37 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationFactoryImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationFactoryImpl.java
@@ -84,6 +84,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public PartialInterpretation createPartialInterpretation() {
PartialInterpretationImpl partialInterpretation = new PartialInterpretationImpl();
return partialInterpretation;
@@ -94,6 +95,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public PartialConstantInterpretation createPartialConstantInterpretation() {
PartialConstantInterpretationImpl partialConstantInterpretation = new PartialConstantInterpretationImpl();
return partialConstantInterpretation;
@@ -104,6 +106,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public PartialRelationInterpretation createPartialRelationInterpretation() {
PartialRelationInterpretationImpl partialRelationInterpretation = new PartialRelationInterpretationImpl();
return partialRelationInterpretation;
@@ -114,6 +117,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public PartialFunctionInterpretation createPartialFunctionInterpretation() {
PartialFunctionInterpretationImpl partialFunctionInterpretation = new PartialFunctionInterpretationImpl();
return partialFunctionInterpretation;
@@ -124,6 +128,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public UnaryElementRelationLink createUnaryElementRelationLink() {
UnaryElementRelationLinkImpl unaryElementRelationLink = new UnaryElementRelationLinkImpl();
return unaryElementRelationLink;
@@ -134,6 +139,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public BinaryElementRelationLink createBinaryElementRelationLink() {
BinaryElementRelationLinkImpl binaryElementRelationLink = new BinaryElementRelationLinkImpl();
return binaryElementRelationLink;
@@ -144,6 +150,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public NaryRelationLink createNaryRelationLink() {
NaryRelationLinkImpl naryRelationLink = new NaryRelationLinkImpl();
return naryRelationLink;
@@ -154,6 +161,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public NaryRelationLinkElement createNaryRelationLinkElement() {
NaryRelationLinkElementImpl naryRelationLinkElement = new NaryRelationLinkElementImpl();
return naryRelationLinkElement;
@@ -164,6 +172,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public BooleanElement createBooleanElement() {
BooleanElementImpl booleanElement = new BooleanElementImpl();
return booleanElement;
@@ -174,6 +183,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public IntegerElement createIntegerElement() {
IntegerElementImpl integerElement = new IntegerElementImpl();
return integerElement;
@@ -184,6 +194,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public RealElement createRealElement() {
RealElementImpl realElement = new RealElementImpl();
return realElement;
@@ -194,6 +205,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public StringElement createStringElement() {
StringElementImpl stringElement = new StringElementImpl();
return stringElement;
@@ -204,6 +216,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public Scope createScope() {
ScopeImpl scope = new ScopeImpl();
return scope;
@@ -214,6 +227,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public PartialBooleanInterpretation createPartialBooleanInterpretation() {
PartialBooleanInterpretationImpl partialBooleanInterpretation = new PartialBooleanInterpretationImpl();
return partialBooleanInterpretation;
@@ -224,6 +238,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public PartialIntegerInterpretation createPartialIntegerInterpretation() {
PartialIntegerInterpretationImpl partialIntegerInterpretation = new PartialIntegerInterpretationImpl();
return partialIntegerInterpretation;
@@ -234,6 +249,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public PartialRealInterpretation createPartialRealInterpretation() {
PartialRealInterpretationImpl partialRealInterpretation = new PartialRealInterpretationImpl();
return partialRealInterpretation;
@@ -244,6 +260,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public PartialStringInterpretation createPartialStringInterpretation() {
PartialStringInterpretationImpl partialStringInterpretation = new PartialStringInterpretationImpl();
return partialStringInterpretation;
@@ -254,6 +271,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public PartialComplexTypeInterpretation createPartialComplexTypeInterpretation() {
PartialComplexTypeInterpretationImpl partialComplexTypeInterpretation = new PartialComplexTypeInterpretationImpl();
return partialComplexTypeInterpretation;
@@ -264,6 +282,7 @@ public class PartialinterpretationFactoryImpl extends EFactoryImpl implements Pa
*
* @generated
*/
+ @Override
public PartialinterpretationPackage getPartialinterpretationPackage() {
return (PartialinterpretationPackage)getEPackage();
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationPackageImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationPackageImpl.java
index a21dc306..1ea3a11d 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationPackageImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PartialinterpretationPackageImpl.java
@@ -227,7 +227,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
/**
* Creates, registers, and initializes the Package for this model, and for any others upon which it depends.
- *
+ *
* This method is used to initialize {@link PartialinterpretationPackage#eINSTANCE} when that field is accessed.
* Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
*
@@ -241,7 +241,8 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
if (isInited) return (PartialinterpretationPackage)EPackage.Registry.INSTANCE.getEPackage(PartialinterpretationPackage.eNS_URI);
// Obtain or create and register package
- PartialinterpretationPackageImpl thePartialinterpretationPackage = (PartialinterpretationPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof PartialinterpretationPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new PartialinterpretationPackageImpl());
+ Object registeredPartialinterpretationPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
+ PartialinterpretationPackageImpl thePartialinterpretationPackage = registeredPartialinterpretationPackage instanceof PartialinterpretationPackageImpl ? (PartialinterpretationPackageImpl)registeredPartialinterpretationPackage : new PartialinterpretationPackageImpl();
isInited = true;
@@ -258,7 +259,6 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
// Mark meta-data to indicate it can't be changed
thePartialinterpretationPackage.freeze();
-
// Update the registry and return the package
EPackage.Registry.INSTANCE.put(PartialinterpretationPackage.eNS_URI, thePartialinterpretationPackage);
return thePartialinterpretationPackage;
@@ -269,6 +269,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getPartialInterpretation() {
return partialInterpretationEClass;
}
@@ -278,6 +279,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialInterpretation_Problem() {
return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(0);
}
@@ -287,6 +289,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialInterpretation_Partialconstantinterpretation() {
return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(1);
}
@@ -296,6 +299,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialInterpretation_Partialrelationinterpretation() {
return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(2);
}
@@ -305,6 +309,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialInterpretation_Partialfunctioninterpretation() {
return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(3);
}
@@ -314,6 +319,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialInterpretation_NewElements() {
return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(4);
}
@@ -323,6 +329,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialInterpretation_Partialtypeinterpratation() {
return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(5);
}
@@ -332,6 +339,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialInterpretation_OpenWorldElements() {
return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(6);
}
@@ -341,6 +349,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialInterpretation_ProblemConainer() {
return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(7);
}
@@ -350,6 +359,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialInterpretation_Scopes() {
return (EReference)partialInterpretationEClass.getEStructuralFeatures().get(8);
}
@@ -359,6 +369,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EAttribute getPartialInterpretation_MinNewElements() {
return (EAttribute)partialInterpretationEClass.getEStructuralFeatures().get(9);
}
@@ -368,6 +379,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EAttribute getPartialInterpretation_MaxNewElements() {
return (EAttribute)partialInterpretationEClass.getEStructuralFeatures().get(10);
}
@@ -377,6 +389,17 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
+ public EAttribute getPartialInterpretation_MinNewElementsHeuristic() {
+ return (EAttribute)partialInterpretationEClass.getEStructuralFeatures().get(11);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
public EClass getPartialConstantInterpretation() {
return partialConstantInterpretationEClass;
}
@@ -386,6 +409,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialConstantInterpretation_InterpretationOf() {
return (EReference)partialConstantInterpretationEClass.getEStructuralFeatures().get(0);
}
@@ -395,6 +419,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getPartialRelationInterpretation() {
return partialRelationInterpretationEClass;
}
@@ -404,6 +429,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialRelationInterpretation_InterpretationOf() {
return (EReference)partialRelationInterpretationEClass.getEStructuralFeatures().get(0);
}
@@ -413,6 +439,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialRelationInterpretation_Relationlinks() {
return (EReference)partialRelationInterpretationEClass.getEStructuralFeatures().get(1);
}
@@ -422,6 +449,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialRelationInterpretation_Param1() {
return (EReference)partialRelationInterpretationEClass.getEStructuralFeatures().get(2);
}
@@ -431,6 +459,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialRelationInterpretation_Param2() {
return (EReference)partialRelationInterpretationEClass.getEStructuralFeatures().get(3);
}
@@ -440,6 +469,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getPartialFunctionInterpretation() {
return partialFunctionInterpretationEClass;
}
@@ -449,6 +479,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialFunctionInterpretation_InterpretationOf() {
return (EReference)partialFunctionInterpretationEClass.getEStructuralFeatures().get(0);
}
@@ -458,6 +489,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getPartialTypeInterpratation() {
return partialTypeInterpratationEClass;
}
@@ -467,6 +499,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialTypeInterpratation_Elements() {
return (EReference)partialTypeInterpratationEClass.getEStructuralFeatures().get(0);
}
@@ -476,6 +509,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialTypeInterpratation_Scopes() {
return (EReference)partialTypeInterpratationEClass.getEStructuralFeatures().get(1);
}
@@ -485,6 +519,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getRelationLink() {
return relationLinkEClass;
}
@@ -494,6 +529,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getUnaryElementRelationLink() {
return unaryElementRelationLinkEClass;
}
@@ -503,6 +539,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getUnaryElementRelationLink_Param1() {
return (EReference)unaryElementRelationLinkEClass.getEStructuralFeatures().get(0);
}
@@ -512,6 +549,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getBinaryElementRelationLink() {
return binaryElementRelationLinkEClass;
}
@@ -521,6 +559,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getBinaryElementRelationLink_Param1() {
return (EReference)binaryElementRelationLinkEClass.getEStructuralFeatures().get(0);
}
@@ -530,6 +569,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getBinaryElementRelationLink_Param2() {
return (EReference)binaryElementRelationLinkEClass.getEStructuralFeatures().get(1);
}
@@ -539,6 +579,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getNaryRelationLink() {
return naryRelationLinkEClass;
}
@@ -548,6 +589,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getNaryRelationLink_Elements() {
return (EReference)naryRelationLinkEClass.getEStructuralFeatures().get(0);
}
@@ -557,6 +599,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getNaryRelationLinkElement() {
return naryRelationLinkElementEClass;
}
@@ -566,6 +609,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EAttribute getNaryRelationLinkElement_Index() {
return (EAttribute)naryRelationLinkElementEClass.getEStructuralFeatures().get(0);
}
@@ -575,6 +619,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getNaryRelationLinkElement_Param() {
return (EReference)naryRelationLinkElementEClass.getEStructuralFeatures().get(1);
}
@@ -584,6 +629,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getPrimitiveElement() {
return primitiveElementEClass;
}
@@ -593,6 +639,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EAttribute getPrimitiveElement_ValueSet() {
return (EAttribute)primitiveElementEClass.getEStructuralFeatures().get(0);
}
@@ -602,6 +649,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getBooleanElement() {
return booleanElementEClass;
}
@@ -611,6 +659,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EAttribute getBooleanElement_Value() {
return (EAttribute)booleanElementEClass.getEStructuralFeatures().get(0);
}
@@ -620,6 +669,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getIntegerElement() {
return integerElementEClass;
}
@@ -629,6 +679,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EAttribute getIntegerElement_Value() {
return (EAttribute)integerElementEClass.getEStructuralFeatures().get(0);
}
@@ -638,6 +689,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getRealElement() {
return realElementEClass;
}
@@ -647,6 +699,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EAttribute getRealElement_Value() {
return (EAttribute)realElementEClass.getEStructuralFeatures().get(0);
}
@@ -656,6 +709,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getStringElement() {
return stringElementEClass;
}
@@ -665,6 +719,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EAttribute getStringElement_Value() {
return (EAttribute)stringElementEClass.getEStructuralFeatures().get(0);
}
@@ -674,6 +729,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getScope() {
return scopeEClass;
}
@@ -683,6 +739,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EAttribute getScope_MinNewElements() {
return (EAttribute)scopeEClass.getEStructuralFeatures().get(0);
}
@@ -692,6 +749,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EAttribute getScope_MaxNewElements() {
return (EAttribute)scopeEClass.getEStructuralFeatures().get(1);
}
@@ -701,6 +759,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getScope_TargetTypeInterpretation() {
return (EReference)scopeEClass.getEStructuralFeatures().get(2);
}
@@ -710,6 +769,17 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
+ public EAttribute getScope_MinNewElementsHeuristic() {
+ return (EAttribute)scopeEClass.getEStructuralFeatures().get(3);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
public EClass getPartialPrimitiveInterpretation() {
return partialPrimitiveInterpretationEClass;
}
@@ -719,6 +789,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getPartialBooleanInterpretation() {
return partialBooleanInterpretationEClass;
}
@@ -728,6 +799,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getPartialIntegerInterpretation() {
return partialIntegerInterpretationEClass;
}
@@ -737,6 +809,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getPartialRealInterpretation() {
return partialRealInterpretationEClass;
}
@@ -746,6 +819,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getPartialStringInterpretation() {
return partialStringInterpretationEClass;
}
@@ -755,6 +829,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EClass getPartialComplexTypeInterpretation() {
return partialComplexTypeInterpretationEClass;
}
@@ -764,6 +839,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialComplexTypeInterpretation_SupertypeInterpretation() {
return (EReference)partialComplexTypeInterpretationEClass.getEStructuralFeatures().get(0);
}
@@ -773,6 +849,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public EReference getPartialComplexTypeInterpretation_InterpretationOf() {
return (EReference)partialComplexTypeInterpretationEClass.getEStructuralFeatures().get(1);
}
@@ -782,6 +859,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
*
* @generated
*/
+ @Override
public PartialinterpretationFactory getPartialinterpretationFactory() {
return (PartialinterpretationFactory)getEFactoryInstance();
}
@@ -817,6 +895,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
createEReference(partialInterpretationEClass, PARTIAL_INTERPRETATION__SCOPES);
createEAttribute(partialInterpretationEClass, PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS);
createEAttribute(partialInterpretationEClass, PARTIAL_INTERPRETATION__MAX_NEW_ELEMENTS);
+ createEAttribute(partialInterpretationEClass, PARTIAL_INTERPRETATION__MIN_NEW_ELEMENTS_HEURISTIC);
partialConstantInterpretationEClass = createEClass(PARTIAL_CONSTANT_INTERPRETATION);
createEReference(partialConstantInterpretationEClass, PARTIAL_CONSTANT_INTERPRETATION__INTERPRETATION_OF);
@@ -869,6 +948,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
createEAttribute(scopeEClass, SCOPE__MIN_NEW_ELEMENTS);
createEAttribute(scopeEClass, SCOPE__MAX_NEW_ELEMENTS);
createEReference(scopeEClass, SCOPE__TARGET_TYPE_INTERPRETATION);
+ createEAttribute(scopeEClass, SCOPE__MIN_NEW_ELEMENTS_HEURISTIC);
partialPrimitiveInterpretationEClass = createEClass(PARTIAL_PRIMITIVE_INTERPRETATION);
@@ -945,6 +1025,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
initEReference(getPartialInterpretation_Scopes(), this.getScope(), null, "scopes", null, 0, -1, PartialInterpretation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getPartialInterpretation_MinNewElements(), ecorePackage.getEInt(), "minNewElements", "0", 1, 1, PartialInterpretation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getPartialInterpretation_MaxNewElements(), ecorePackage.getEInt(), "maxNewElements", "-1", 1, 1, PartialInterpretation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getPartialInterpretation_MinNewElementsHeuristic(), ecorePackage.getEInt(), "minNewElementsHeuristic", "0", 1, 1, PartialInterpretation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(partialConstantInterpretationEClass, PartialConstantInterpretation.class, "PartialConstantInterpretation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getPartialConstantInterpretation_InterpretationOf(), theLogiclanguagePackage.getConstantDeclaration(), null, "interpretationOf", null, 1, 1, PartialConstantInterpretation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
@@ -997,6 +1078,7 @@ public class PartialinterpretationPackageImpl extends EPackageImpl implements Pa
initEAttribute(getScope_MinNewElements(), ecorePackage.getEInt(), "minNewElements", "0", 1, 1, Scope.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getScope_MaxNewElements(), ecorePackage.getEInt(), "maxNewElements", "-1", 1, 1, Scope.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getScope_TargetTypeInterpretation(), this.getPartialTypeInterpratation(), this.getPartialTypeInterpratation_Scopes(), "targetTypeInterpretation", null, 1, 1, Scope.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getScope_MinNewElementsHeuristic(), ecorePackage.getEInt(), "minNewElementsHeuristic", "0", 1, 1, Scope.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(partialPrimitiveInterpretationEClass, PartialPrimitiveInterpretation.class, "PartialPrimitiveInterpretation", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PrimitiveElementImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PrimitiveElementImpl.java
index 29a1e1be..a8ef81b0 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PrimitiveElementImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/PrimitiveElementImpl.java
@@ -71,6 +71,7 @@ public abstract class PrimitiveElementImpl extends DefinedElementImpl implements
*
* @generated
*/
+ @Override
public boolean isValueSet() {
return valueSet;
}
@@ -80,6 +81,7 @@ public abstract class PrimitiveElementImpl extends DefinedElementImpl implements
*
* @generated
*/
+ @Override
public void setValueSet(boolean newValueSet) {
boolean oldValueSet = valueSet;
valueSet = newValueSet;
@@ -154,7 +156,7 @@ public abstract class PrimitiveElementImpl extends DefinedElementImpl implements
public String toString() {
if (eIsProxy()) return super.toString();
- StringBuffer result = new StringBuffer(super.toString());
+ StringBuilder result = new StringBuilder(super.toString());
result.append(" (valueSet: ");
result.append(valueSet);
result.append(')');
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/RealElementImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/RealElementImpl.java
index 0361a3e9..67cff5a2 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/RealElementImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/RealElementImpl.java
@@ -71,6 +71,7 @@ public class RealElementImpl extends PrimitiveElementImpl implements RealElement
*
* @generated
*/
+ @Override
public BigDecimal getValue() {
return value;
}
@@ -80,6 +81,7 @@ public class RealElementImpl extends PrimitiveElementImpl implements RealElement
*
* @generated
*/
+ @Override
public void setValue(BigDecimal newValue) {
BigDecimal oldValue = value;
value = newValue;
@@ -154,7 +156,7 @@ public class RealElementImpl extends PrimitiveElementImpl implements RealElement
public String toString() {
if (eIsProxy()) return super.toString();
- StringBuffer result = new StringBuffer(super.toString());
+ StringBuilder result = new StringBuilder(super.toString());
result.append(" (value: ");
result.append(value);
result.append(')');
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/ScopeImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/ScopeImpl.java
index d8ade871..a1b6de35 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/ScopeImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/ScopeImpl.java
@@ -26,6 +26,7 @@ import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
*
{@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.ScopeImpl#getMinNewElements Min New Elements }
* {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.ScopeImpl#getMaxNewElements Max New Elements }
* {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.ScopeImpl#getTargetTypeInterpretation Target Type Interpretation }
+ * {@link hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.ScopeImpl#getMinNewElementsHeuristic Min New Elements Heuristic }
*
*
* @generated
@@ -81,6 +82,26 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
*/
protected PartialTypeInterpratation targetTypeInterpretation;
+ /**
+ * The default value of the '{@link #getMinNewElementsHeuristic() Min New Elements Heuristic }' attribute.
+ *
+ *
+ * @see #getMinNewElementsHeuristic()
+ * @generated
+ * @ordered
+ */
+ protected static final int MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT = 0;
+
+ /**
+ * The cached value of the '{@link #getMinNewElementsHeuristic() Min New Elements Heuristic }' attribute.
+ *
+ *
+ * @see #getMinNewElementsHeuristic()
+ * @generated
+ * @ordered
+ */
+ protected int minNewElementsHeuristic = MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT;
+
/**
*
*
@@ -105,6 +126,7 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
*
* @generated
*/
+ @Override
public int getMinNewElements() {
return minNewElements;
}
@@ -114,6 +136,7 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
*
* @generated
*/
+ @Override
public void setMinNewElements(int newMinNewElements) {
int oldMinNewElements = minNewElements;
minNewElements = newMinNewElements;
@@ -126,6 +149,7 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
*
* @generated
*/
+ @Override
public int getMaxNewElements() {
return maxNewElements;
}
@@ -135,6 +159,7 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
*
* @generated
*/
+ @Override
public void setMaxNewElements(int newMaxNewElements) {
int oldMaxNewElements = maxNewElements;
maxNewElements = newMaxNewElements;
@@ -147,6 +172,7 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
*
* @generated
*/
+ @Override
public PartialTypeInterpratation getTargetTypeInterpretation() {
if (targetTypeInterpretation != null && targetTypeInterpretation.eIsProxy()) {
InternalEObject oldTargetTypeInterpretation = (InternalEObject)targetTypeInterpretation;
@@ -188,6 +214,7 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
*
* @generated
*/
+ @Override
public void setTargetTypeInterpretation(PartialTypeInterpratation newTargetTypeInterpretation) {
if (newTargetTypeInterpretation != targetTypeInterpretation) {
NotificationChain msgs = null;
@@ -202,6 +229,29 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
eNotify(new ENotificationImpl(this, Notification.SET, PartialinterpretationPackage.SCOPE__TARGET_TYPE_INTERPRETATION, newTargetTypeInterpretation, newTargetTypeInterpretation));
}
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public int getMinNewElementsHeuristic() {
+ return minNewElementsHeuristic;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void setMinNewElementsHeuristic(int newMinNewElementsHeuristic) {
+ int oldMinNewElementsHeuristic = minNewElementsHeuristic;
+ minNewElementsHeuristic = newMinNewElementsHeuristic;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, PartialinterpretationPackage.SCOPE__MIN_NEW_ELEMENTS_HEURISTIC, oldMinNewElementsHeuristic, minNewElementsHeuristic));
+ }
+
/**
*
*
@@ -247,6 +297,8 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
case PartialinterpretationPackage.SCOPE__TARGET_TYPE_INTERPRETATION:
if (resolve) return getTargetTypeInterpretation();
return basicGetTargetTypeInterpretation();
+ case PartialinterpretationPackage.SCOPE__MIN_NEW_ELEMENTS_HEURISTIC:
+ return getMinNewElementsHeuristic();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -268,6 +320,9 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
case PartialinterpretationPackage.SCOPE__TARGET_TYPE_INTERPRETATION:
setTargetTypeInterpretation((PartialTypeInterpratation)newValue);
return;
+ case PartialinterpretationPackage.SCOPE__MIN_NEW_ELEMENTS_HEURISTIC:
+ setMinNewElementsHeuristic((Integer)newValue);
+ return;
}
super.eSet(featureID, newValue);
}
@@ -289,6 +344,9 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
case PartialinterpretationPackage.SCOPE__TARGET_TYPE_INTERPRETATION:
setTargetTypeInterpretation((PartialTypeInterpratation)null);
return;
+ case PartialinterpretationPackage.SCOPE__MIN_NEW_ELEMENTS_HEURISTIC:
+ setMinNewElementsHeuristic(MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT);
+ return;
}
super.eUnset(featureID);
}
@@ -307,6 +365,8 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
return maxNewElements != MAX_NEW_ELEMENTS_EDEFAULT;
case PartialinterpretationPackage.SCOPE__TARGET_TYPE_INTERPRETATION:
return targetTypeInterpretation != null;
+ case PartialinterpretationPackage.SCOPE__MIN_NEW_ELEMENTS_HEURISTIC:
+ return minNewElementsHeuristic != MIN_NEW_ELEMENTS_HEURISTIC_EDEFAULT;
}
return super.eIsSet(featureID);
}
@@ -320,11 +380,13 @@ public class ScopeImpl extends MinimalEObjectImpl.Container implements Scope {
public String toString() {
if (eIsProxy()) return super.toString();
- StringBuffer result = new StringBuffer(super.toString());
+ StringBuilder result = new StringBuilder(super.toString());
result.append(" (minNewElements: ");
result.append(minNewElements);
result.append(", maxNewElements: ");
result.append(maxNewElements);
+ result.append(", minNewElementsHeuristic: ");
+ result.append(minNewElementsHeuristic);
result.append(')');
return result.toString();
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/StringElementImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/StringElementImpl.java
index f207401d..0242c9b2 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/StringElementImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/StringElementImpl.java
@@ -69,6 +69,7 @@ public class StringElementImpl extends PrimitiveElementImpl implements StringEle
*
* @generated
*/
+ @Override
public String getValue() {
return value;
}
@@ -78,6 +79,7 @@ public class StringElementImpl extends PrimitiveElementImpl implements StringEle
*
* @generated
*/
+ @Override
public void setValue(String newValue) {
String oldValue = value;
value = newValue;
@@ -152,7 +154,7 @@ public class StringElementImpl extends PrimitiveElementImpl implements StringEle
public String toString() {
if (eIsProxy()) return super.toString();
- StringBuffer result = new StringBuffer(super.toString());
+ StringBuilder result = new StringBuilder(super.toString());
result.append(" (value: ");
result.append(value);
result.append(')');
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/UnaryElementRelationLinkImpl.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/UnaryElementRelationLinkImpl.java
index 2cb56323..e76a89b7 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/UnaryElementRelationLinkImpl.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/ecore-gen/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/partialinterpretation/impl/UnaryElementRelationLinkImpl.java
@@ -62,6 +62,7 @@ public class UnaryElementRelationLinkImpl extends RelationLinkImpl implements Un
*
* @generated
*/
+ @Override
public DefinedElement getParam1() {
if (param1 != null && param1.eIsProxy()) {
InternalEObject oldParam1 = (InternalEObject)param1;
@@ -88,6 +89,7 @@ public class UnaryElementRelationLinkImpl extends RelationLinkImpl implements Un
*
* @generated
*/
+ @Override
public void setParam1(DefinedElement newParam1) {
DefinedElement oldParam1 = param1;
param1 = newParam1;
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.ecore b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.ecore
index acf82a3f..47d54258 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.ecore
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.ecore
@@ -27,6 +27,9 @@
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt" defaultValueLiteral="0"/>
+
+
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.genmodel b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.genmodel
index 2ac0a4f3..daeaf594 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.genmodel
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/model/PartialInterpretation.genmodel
@@ -18,7 +18,10 @@
-
+
+
+
+
@@ -33,9 +36,8 @@
-
-
+
@@ -50,6 +52,7 @@
+
@@ -70,11 +73,16 @@
+
+
+
+
+
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend
index c7c1ad77..e4bdb086 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/Descriptor.xtend
@@ -60,6 +60,10 @@ import org.eclipse.xtend2.lib.StringConcatenationClient
return this.dataHash.hashCode
}
+ override equals(Object other) {
+ other.class == LocalNodeDescriptor && (other as AbstractNodeDescriptor).hashCode == hashCode
+ }
+
override protected prettyPrint() {
'''(«dataHash»)[«IF id !== null»id = "«id»"«IF types === null || !types.empty», «ENDIF»«ENDIF»«IF types === null»TYPES = null«ELSE»«FOR type : types SEPARATOR ", "»«type»«ENDFOR»«ENDIF»]'''
}
@@ -143,6 +147,10 @@ import org.eclipse.xtend2.lib.StringConcatenationClient
return this.dataHash.hashCode
}
+ override equals(Object other) {
+ other.class == FurtherNodeDescriptor && (other as AbstractNodeDescriptor).hashCode == hashCode
+ }
+
override prettyPrint() {
'''
(«dataHash»)[
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend
index efc89803..c6e03f75 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/NeighbourhoodOptions.xtend
@@ -7,12 +7,12 @@ import org.eclipse.xtend.lib.annotations.Data
@Data
class NeighbourhoodOptions {
- public static val FixPointRage = -1
+ public static val FixPointRange = -1
public static val GraphWidthRange = -2
public static val FullParallels = Integer.MAX_VALUE
public static val MaxNumbers = Integer.MAX_VALUE
- public static val DEFAULT = new NeighbourhoodOptions(GraphWidthRange, FullParallels, MaxNumbers, null, null)
+ public static val DEFAULT = new NeighbourhoodOptions(FixPointRange, FullParallels, MaxNumbers, null, null)
val int range
val int parallels
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend
index d474877d..ddf7d712 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2Hash.xtend
@@ -5,7 +5,7 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
class PartialInterpretation2Hash extends PartialInterpretation2NeighbourhoodRepresentation{
- protected new() {
+ new() {
super(false, true)
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2NeighbourhoodRepresentation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2NeighbourhoodRepresentation.xtend
index a0382e8e..3048167e 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2NeighbourhoodRepresentation.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretationlanguage/neighbourhood/PartialInterpretation2NeighbourhoodRepresentation.xtend
@@ -25,7 +25,7 @@ abstract class PartialInterpretation2NeighbourhoodRepresentation nodeRepresentations = null
- var Map extends AbstractNodeDescriptor, Integer> modelRepresentation = null
+class NeighbourhoodBasedHashStateCoderFactory extends AbstractNeighbourhoodBasedStateCoderFactory {
+ new() {
+ }
new(NeighbourhoodOptions options) {
super(options)
}
+ override protected doCreateStateCoder(NeighbourhoodOptions options) {
+ new NeighbourhoodBasedPartialInterpretationStateCoder(new PartialInterpretation2Hash, options)
+ }
+}
+
+class NeighbourhoodBasedPartialInterpretationStateCoder extends AbstractNeighbourhoodBasedPartialInterpretationStateCoder {
+ val PartialInterpretation2NeighbourhoodRepresentation calculator
+ var Map nodeRepresentations = null
+ var ModelRep modelRepresentation = null
+
+ new(PartialInterpretation2NeighbourhoodRepresentation calculator, NeighbourhoodOptions options) {
+ super(options)
+ this.calculator = calculator
+ }
+
override protected isRefreshNeeded() {
nodeRepresentations === null || modelRepresentation === null
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend
index 1abde0a8..aa02cd30 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasoner.xtend
@@ -12,12 +12,15 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage
import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicresultFactory
import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethodProvider
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.PartialInterpretationInitialiser
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialinterpretationPackage
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.AbstractNeighbourhoodBasedStateCoderFactory
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.IdentifierBasedStateCoderFactory
+import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.NeighbourhoodBasedHashStateCoderFactory
import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.PairwiseNeighbourhoodBasedStateCoderFactory
+import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.BasicScopeGlobalConstraint
import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.BestFirstStrategyForModelGeneration
import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.DiversityChecker
import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse.InconsistentScopeGlobalConstraint
@@ -39,7 +42,6 @@ import org.eclipse.viatra.dse.api.DesignSpaceExplorer
import org.eclipse.viatra.dse.api.DesignSpaceExplorer.DseLoggingLevel
import org.eclipse.viatra.dse.solutionstore.SolutionStore
import org.eclipse.viatra.dse.statecode.IStateCoderFactory
-import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.statecoder.NeighbourhoodBasedStateCoderFactory
class ViatraReasoner extends LogicReasoner {
val PartialInterpretationInitialiser initialiser = new PartialInterpretationInitialiser()
@@ -71,6 +73,11 @@ class ViatraReasoner extends LogicReasoner {
workspace.writeModel(emptySolution, "init.partialmodel")
}
emptySolution.problemConainer = problem
+ var BasicScopeGlobalConstraint basicScopeGlobalConstraint = null
+ if (viatraConfig.scopePropagatorStrategy == ScopePropagatorStrategy.None) {
+ basicScopeGlobalConstraint = new BasicScopeGlobalConstraint(emptySolution)
+ emptySolution.scopes.clear
+ }
val method = modelGenerationMethodProvider.createModelGenerationMethod(
problem,
@@ -79,11 +86,12 @@ class ViatraReasoner extends LogicReasoner {
viatraConfig.nameNewElements,
viatraConfig.typeInferenceMethod,
viatraConfig.scopePropagatorStrategy,
+ viatraConfig.hints,
viatraConfig.documentationLevel
)
dse.addObjective(new ModelGenerationCompositeObjective(
- new ScopeObjective,
+ basicScopeGlobalConstraint ?: new ScopeObjective,
method.unfinishedMultiplicities.map[new UnfinishedMultiplicityObjective(it)],
wf2ObjectiveConverter.createCompletenessObjective(method.unfinishedWF)
))
@@ -132,6 +140,9 @@ class ViatraReasoner extends LogicReasoner {
dse.addGlobalConstraint(wf2ObjectiveConverter.createInvalidationGlobalConstraint(method.invalidWF))
dse.addGlobalConstraint(new SurelyViolatedObjectiveGlobalConstraint(solutionSaver))
dse.addGlobalConstraint(new InconsistentScopeGlobalConstraint)
+ if (basicScopeGlobalConstraint !== null) {
+ dse.addGlobalConstraint(basicScopeGlobalConstraint)
+ }
for (additionalConstraint : viatraConfig.searchSpaceConstraints.additionalGlobalConstraints) {
dse.addGlobalConstraint(additionalConstraint.apply(method))
}
@@ -140,7 +151,7 @@ class ViatraReasoner extends LogicReasoner {
val IStateCoderFactory statecoder = switch (viatraConfig.stateCoderStrategy) {
case Neighbourhood:
- new NeighbourhoodBasedStateCoderFactory
+ new NeighbourhoodBasedHashStateCoderFactory
case PairwiseNeighbourhood:
new PairwiseNeighbourhoodBasedStateCoderFactory
default:
@@ -215,10 +226,18 @@ class ViatraReasoner extends LogicReasoner {
it.name = "Decisions"
it.value = method.statistics.decisionsTried
]
+ it.entries += createIntStatisticEntry => [
+ it.name = "Transformations"
+ it.value = method.statistics.transformationInvocations
+ ]
it.entries += createIntStatisticEntry => [
it.name = "ScopePropagations"
it.value = method.statistics.scopePropagatorInvocations
]
+ it.entries += createIntStatisticEntry => [
+ it.name = "ScopePropagationsSolverCalls"
+ it.value = method.statistics.scopePropagatorSolverInvocations
+ ]
if (diversityChecker.isActive) {
it.entries += createIntStatisticEntry => [
it.name = "SolutionDiversityCheckTime"
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend
index a5f42a5f..6f38d261 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/ViatraReasonerConfiguration.xtend
@@ -16,6 +16,7 @@ import java.util.LinkedList
import java.util.List
import java.util.Set
import org.eclipse.xtext.xbase.lib.Functions.Function1
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint
enum StateCoderStrategy {
Neighbourhood,
@@ -56,6 +57,8 @@ class ViatraReasonerConfiguration extends LogicSolverConfiguration {
public var ScopePropagatorStrategy scopePropagatorStrategy = new ScopePropagatorStrategy.Polyhedral(
PolyhedralScopePropagatorConstraints.Relational, PolyhedralScopePropagatorSolver.Clp)
+
+ public var List hints = newArrayList
public var List costObjectives = newArrayList
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BasicScopeGlobalConstraint.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BasicScopeGlobalConstraint.xtend
new file mode 100644
index 00000000..67f447ed
--- /dev/null
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BasicScopeGlobalConstraint.xtend
@@ -0,0 +1,103 @@
+package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse
+
+import com.google.common.collect.ImmutableList
+import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
+import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation
+import java.util.Comparator
+import java.util.List
+import org.eclipse.viatra.dse.base.ThreadContext
+import org.eclipse.viatra.dse.objectives.Comparators
+import org.eclipse.viatra.dse.objectives.IGlobalConstraint
+import org.eclipse.viatra.dse.objectives.IObjective
+import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
+
+class BasicScopeGlobalConstraint implements IGlobalConstraint, IObjective {
+ val PartialInterpretation p
+ val List assertions
+
+ new(PartialInterpretation p) {
+ this.p = p
+ assertions = ImmutableList.copyOf(p.scopes.map [
+ val currentSize = targetTypeInterpretation.elements.size
+ val minElements = minNewElements + currentSize
+ val maxElements = if (maxNewElements < 0) {
+ -1
+ } else {
+ maxNewElements + currentSize
+ }
+ new ScopeAssertion(minElements, maxElements, targetTypeInterpretation)
+ ])
+ }
+
+ override init(ThreadContext context) {
+ if (context.model != p) {
+ throw new IllegalArgumentException(
+ "Partial model must be passed to the constructor of BasicScopeGlobalConstraint")
+ }
+ }
+
+ override checkGlobalConstraint(ThreadContext context) {
+ assertions.forall[upperBoundSatisfied]
+ }
+
+ override getFitness(ThreadContext context) {
+ var double fitness = p.minNewElements
+ for (assertion : assertions) {
+ if (!assertion.lowerBoundSatisfied) {
+ fitness += 1
+ }
+ }
+ fitness
+ }
+
+ override satisifiesHardObjective(Double fitness) {
+ fitness <= 0.01
+ }
+
+ override BasicScopeGlobalConstraint createNew() {
+ this
+ }
+
+ override getName() {
+ class.name
+ }
+
+ override getComparator() {
+ Comparators.LOWER_IS_BETTER
+ }
+
+ override getLevel() {
+ 2
+ }
+
+ override isHardObjective() {
+ true
+ }
+
+ override setComparator(Comparator comparator) {
+ throw new UnsupportedOperationException
+ }
+
+ override setLevel(int level) {
+ throw new UnsupportedOperationException
+ }
+
+ @FinalFieldsConstructor
+ private static class ScopeAssertion {
+ val int lowerBound
+ val int upperBound
+ val PartialTypeInterpratation typeDefinitions
+
+ private def getCount() {
+ typeDefinitions.elements.size
+ }
+
+ private def isLowerBoundSatisfied() {
+ count >= lowerBound
+ }
+
+ private def isUpperBoundSatisfied() {
+ upperBound < 0 || count <= upperBound
+ }
+ }
+}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java
index 5af7fc69..081e48fa 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/BestFirstStrategyForModelGeneration.java
@@ -255,7 +255,7 @@ public class BestFirstStrategyForModelGeneration implements IStrategy {
activationIds = new ArrayList(context.getUntraversedActivationIds());
Collections.shuffle(activationIds);
} catch (NullPointerException e) {
- logger.warn("Unexpected state code: " + context.getDesignSpaceManager().getCurrentState());
+// logger.warn("Unexpected state code: " + context.getDesignSpaceManager().getCurrentState());
numberOfStatecoderFail++;
activationIds = Collections.emptyList();
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend
index 9a33753c..2976bebe 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ModelGenerationCompositeObjective.xtend
@@ -59,7 +59,7 @@ class ModelGenerationCompositeObjective implements IThreeValuedObjective {
}
sum += multiplicity
sum += unfinishedWFsFitness // *0.5
- // println('''Sum=«sum»|Scope=«scopeFitnes»|Multiplicity=«multiplicity»|WFs=«unfinishedWFsFitness»''')
+// println('''Sum=«sum»|Scope=«scopeFitnes»|Multiplicity=«multiplicity»|WFs=«unfinishedWFsFitness»''')
return sum
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ScopeObjective.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ScopeObjective.xtend
index 69efe0d7..e7967b00 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ScopeObjective.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ScopeObjective.xtend
@@ -23,9 +23,9 @@ class ScopeObjective implements IObjective{
override getFitness(ThreadContext context) {
val interpretation = context.model as PartialInterpretation
- var res = interpretation.minNewElements.doubleValue
+ var res = interpretation.minNewElementsHeuristic.doubleValue
for(scope : interpretation.scopes) {
- res += scope.minNewElements*2
+ res += scope.minNewElementsHeuristic*2
}
return res
}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/UnfinishedWFObjective.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/UnfinishedWFObjective.xtend
index bf34aeeb..1b61ffa5 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/UnfinishedWFObjective.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/UnfinishedWFObjective.xtend
@@ -14,41 +14,51 @@ import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher
class UnfinishedWFObjective implements IObjective {
Collection extends IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>> unfinishedWFs
val List> matchers
-
- new(Collection extends IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>> unfinishedWFs) {
+
+ new(
+ Collection extends IQuerySpecification extends ViatraQueryMatcher extends IPatternMatch>>> unfinishedWFs) {
this.unfinishedWFs = unfinishedWFs
matchers = new ArrayList(unfinishedWFs.size)
}
+
override getName() '''unfinishedWFs'''
+
override createNew() {
return new UnfinishedWFObjective(unfinishedWFs)
}
+
override init(ThreadContext context) {
- val engine = context.queryEngine//ViatraQueryEngine.on(new EMFScope(context.model))
- for(unfinishedWF : unfinishedWFs) {
+ val engine = context.queryEngine // ViatraQueryEngine.on(new EMFScope(context.model))
+ for (unfinishedWF : unfinishedWFs) {
matchers += unfinishedWF.getMatcher(engine)
}
}
-
+
override getComparator() { Comparators.LOWER_IS_BETTER }
+
override getFitness(ThreadContext context) {
var sumOfMatches = 0
- for(matcher : matchers) {
+ for (matcher : matchers) {
val number = matcher.countMatches
- //println('''«matcher.patternName» = «number»''')
- sumOfMatches+=number
+// if (number > 0) {
+// println('''«matcher.patternName» = «number»''')
+// }
+ sumOfMatches += number
}
return sumOfMatches.doubleValue
}
-
+
override getLevel() { 2 }
+
override isHardObjective() { true }
- override satisifiesHardObjective(Double fitness) { return fitness <=0.01 }
-
+
+ override satisifiesHardObjective(Double fitness) { return fitness <= 0.01 }
+
override setComparator(Comparator comparator) {
throw new UnsupportedOperationException()
}
+
override setLevel(int level) {
throw new UnsupportedOperationException()
}
-}
\ No newline at end of file
+}
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ViatraReasonerSolutionSaver.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ViatraReasonerSolutionSaver.xtend
index 6bffeb59..74500cc2 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ViatraReasonerSolutionSaver.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/ViatraReasonerSolutionSaver.xtend
@@ -42,7 +42,7 @@ class ViatraReasonerSolutionSaver implements ISolutionSaver {
private def saveBestSolutionOnly(ThreadContext context, Object id, SolutionTrajectory solutionTrajectory) {
val fitness = context.lastFitness
- if (!fitness.satisifiesHardObjectives) {
+ if (!shouldSaveSolution(fitness, context)) {
return false
}
val dominatedTrajectories = newArrayList
@@ -83,7 +83,7 @@ class ViatraReasonerSolutionSaver implements ISolutionSaver {
private def saveAnyDiverseSolution(ThreadContext context, Object id, SolutionTrajectory solutionTrajectory) {
val fitness = context.lastFitness
- if (!fitness.satisifiesHardObjectives) {
+ if (!shouldSaveSolution(fitness, context)) {
return false
}
if (!diversityChecker.newSolution(context, id, emptyList)) {
@@ -92,7 +92,12 @@ class ViatraReasonerSolutionSaver implements ISolutionSaver {
basicSaveSolution(context, id, solutionTrajectory, fitness)
}
- private def basicSaveSolution(ThreadContext context, Object id, SolutionTrajectory solutionTrajectory, Fitness fitness) {
+ private def shouldSaveSolution(Fitness fitness, ThreadContext context) {
+ return fitness.satisifiesHardObjectives
+ }
+
+ private def basicSaveSolution(ThreadContext context, Object id, SolutionTrajectory solutionTrajectory,
+ Fitness fitness) {
var boolean solutionSaved = false
var dseSolution = solutionsCollection.get(id)
if (dseSolution === null) {
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/META-INF/MANIFEST.MF b/Tests/hu.bme.mit.inf.dslreasoner.run/META-INF/MANIFEST.MF
index cc274c7c..fe223d4a 100644
--- a/Tests/hu.bme.mit.inf.dslreasoner.run/META-INF/MANIFEST.MF
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/META-INF/MANIFEST.MF
@@ -28,8 +28,10 @@ Require-Bundle: hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlan
hu.bme.mit.inf.dslreasoner.visualisation;bundle-version="1.0.0",
hu.bme.mit.inf.dslreasoner.domains.alloyexamples;bundle-version="1.0.0",
org.eclipse.collections;bundle-version="9.2.0",
- org.eclipse.viatra.query.patternlanguage.emf;bundle-version="2.2.0",
- org.eclipse.viatra.query.runtime.rete;bundle-version="2.2.0",
- org.objectweb.asm;bundle-version="7.0.0"
+ org.eclipse.viatra.query.patternlanguage.emf;bundle-version="2.0.0",
+ org.eclipse.viatra.query.runtime.rete;bundle-version="2.0.0",
+ org.objectweb.asm;bundle-version="7.0.0",
+ com.google.gson;bundle-version="2.8.2",
+ hu.bme.mit.inf.dslreasoner.domains.satellite;bundle-version="0.1.0"
Import-Package: org.apache.log4j
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/FAM_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/FAM_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
new file mode 100644
index 00000000..26df3c74
--- /dev/null
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/FAM_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
@@ -0,0 +1,13 @@
+{
+ "inputPath": "initialModels",
+ "outputPath": "outputModels",
+ "timeout": 1200,
+ "saveModels": true,
+ "warmupIterations": 0,
+ "iterations": 1,
+ "domain": "FAM",
+ "scope": "none",
+ "sizes": [500],
+ "solver": "ViatraSolver",
+ "scopePropagator": "basic"
+}
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
new file mode 100644
index 00000000..5f8a01b1
--- /dev/null
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/Yakindu_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
@@ -0,0 +1,16 @@
+{
+ "inputPath": "initialModels",
+ "outputPath": "outputModels",
+ "timeout": 1200,
+ "saveModels": false,
+ "warmupIterations": 0,
+ "iterations": 5,
+ "domain": "Yakindu",
+ "scope": "quantiles",
+ "sizes": [100],
+ "solver": "ViatraSolver",
+ "scopePropagator": "polyhedral",
+ "propagatedConstraints": "hints",
+ "polyhedronSolver": "Clp",
+ "scopeHeuristic": "basic"
+}
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
new file mode 100644
index 00000000..42073422
--- /dev/null
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/ecore_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
@@ -0,0 +1,15 @@
+{
+ "inputPath": "initialModels",
+ "outputPath": "outputModels",
+ "timeout": 1200,
+ "saveModels": true,
+ "warmupIterations": 0,
+ "iterations": 5,
+ "domain": "ecore",
+ "scope": "quantiles",
+ "sizes": [100],
+ "solver": "ViatraSolver",
+ "scopePropagator": "polyhedral",
+ "propagatedConstraints": "relations",
+ "polyhedronSolver": "Clp"
+}
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/fs_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/fs_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
new file mode 100644
index 00000000..d7955ddd
--- /dev/null
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/fs_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
@@ -0,0 +1,15 @@
+{
+ "inputPath": "initialModels",
+ "outputPath": "outputModels",
+ "timeout": 1200,
+ "saveModels": true,
+ "warmupIterations": 1,
+ "iterations": 1,
+ "domain": "fs",
+ "scope": "useful",
+ "sizes": [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],
+ "solver": "ViatraSolver",
+ "scopePropagator": "polyhedral",
+ "propagatedConstraints": "relations",
+ "polyhedronSolver": "Clp"
+}
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
new file mode 100644
index 00000000..474962e7
--- /dev/null
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/configs/satellite_useful_ViatraSolver_polyhedral_typeHierarchy_Clp.json
@@ -0,0 +1,17 @@
+{
+ "inputPath": "initialModels",
+ "outputPath": "outputModels",
+ "timeout": 1200,
+ "saveModels": true,
+ "saveTemporaryFiles": true,
+ "warmupIterations": 0,
+ "iterations": 1,
+ "domain": "satellite",
+ "scope": "quantiles",
+ "sizes": [50],
+ "solver": "ViatraSolver",
+ "scopePropagator": "polyhedral",
+ "propagatedConstraints": "hints",
+ "polyhedronSolver": "Clp",
+ "scopeHeuristic": "polyhedral"
+}
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/initialModels/satellite.xmi b/Tests/hu.bme.mit.inf.dslreasoner.run/initialModels/satellite.xmi
new file mode 100644
index 00000000..77f6ecfd
--- /dev/null
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/initialModels/satellite.xmi
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/CountMatches.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/CountMatches.xtend
deleted file mode 100644
index 02caf9dd..00000000
--- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/CountMatches.xtend
+++ /dev/null
@@ -1,176 +0,0 @@
-package hu.bme.mit.inf.dslreasoner.run
-
-import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage
-import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.mutated.Mutated
-import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace
-import java.io.File
-import java.util.ArrayList
-import java.util.Collection
-import java.util.Comparator
-import java.util.HashMap
-import java.util.List
-import java.util.Map
-import java.util.TreeSet
-import org.eclipse.emf.ecore.EObject
-import org.eclipse.emf.ecore.resource.Resource
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
-import org.eclipse.viatra.query.runtime.api.IPatternMatch
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
-import org.eclipse.viatra.query.runtime.emf.EMFScope
-
-class QueryComparator implements Comparator>{
-
- override compare(IQuerySpecification> arg0, IQuerySpecification> arg1) {
- arg0.fullyQualifiedName.compareTo(arg1.fullyQualifiedName)
- }
-}
-
-class CountMatches {
- var static List> wfPatterns;
- var static Map,IQuerySpecification>> query2Reference
-
- def static void main(String[] args) {
- YakindummPackage.eINSTANCE.eClass
- Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("*",new XMIResourceFactoryImpl)
-
- wfPatterns = Mutated.instance.specifications.toList;
- //wfPatterns = wfPatterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toList
- wfPatterns.sort(new QueryComparator)
-
- val groupName2Representant = new HashMap
- query2Reference = new HashMap
- for(wfPattern : wfPatterns) {
- val groupName = wfPattern.groupName
- if(groupName2Representant.containsKey(groupName)) {
- val representant = groupName2Representant.get(groupName)
- query2Reference.put(wfPattern,representant)
- } else {
- groupName2Representant.put(groupName,wfPattern)
- }
- }
-
-
- println('''modelpath;run;model;«
- FOR wfPattern:wfPatterns SEPARATOR ";"»#(«
- wfPattern.fullyQualifiedName.split("\\.").last»);hash(«
- wfPattern.fullyQualifiedName.split("\\.").last»)«ENDFOR»;«
- FOR mutant : wfPatterns.filter[query2Reference.keySet.contains(it)] SEPARATOR ';'»diff(«
- mutant.fullyQualifiedName.split("\\.").last»)«ENDFOR»'''
- )
- countMatches('''D:/FASE18Meas/RemoHF''')
- }
-
- def private static simpleName(IQuerySpecification> wfPattern) {
- wfPattern.fullyQualifiedName.split("\\.").last
- }
- def private static groupName(IQuerySpecification> wfPattern) {
- wfPattern.simpleName.split('_').head
- }
-
- def static void countMatches(String path) {
- val file = new File(path)
- if(file.isDirectory) {
- for(subFileName : file.list) {
- (path + "/" + subFileName).countMatches
- }
- } else if(file.isFile) {
- if(path.endsWith("xmi")) {
- countMatches(file,path)
- }
- }
- }
-
- def static void countMatches(File file, String path) {
-
-
- val pathSegments = path.split("/")
- val groupName = pathSegments.get(pathSegments.size-2).split("\\.").last.split("_").get(0)
- print(groupName +";")
- val nameExtension = pathSegments.get(pathSegments.size-1).split("\\.").get(0).split("_")
- try{
- val runNumber = nameExtension.get(1)
- val modelNumber = nameExtension.get(2)
- print('''«runNumber»;«modelNumber»''')
- } catch(Exception e) {
- print('''«file.name»;0''')
- }
-
- val parent = file.parent
- val workspace = new FileSystemWorkspace(parent,"")
- val model = workspace.readModel(EObject,file.name)
-
- val engine = ViatraQueryEngine.on(new EMFScope(model))
- val objectCode = model.eResource.calculateObjectCode
-
- val pattern2Hash = new HashMap
- for(pattern : wfPatterns) {
- val matcher = pattern.getMatcher(engine)
- val matches = matcher.allMatches
- val hash = matches.getMatchSetDescriptor(objectCode)
- pattern2Hash.put(pattern,hash)
- print(''';«matcher.countMatches»;«hash»''')
- }
- var mutantsKilled = 0
- for(mutant : wfPatterns.filter[query2Reference.keySet.contains(it)]) {
- val equals = pattern2Hash.get(mutant) == pattern2Hash.get(query2Reference.get(mutant))
- print(''';''')
- if(equals) {
- print('0')
- } else {
- print('1')
- mutantsKilled++
- }
- }
- //print(''';«mutantsKilled»''')
- println()
- }
-
- def static Map calculateObjectCode(Resource resource) {
- val res = new HashMap
- val iterator = resource.allContents
- var index = 1
- while(iterator.hasNext) {
- res.put(iterator.next,index++)
- }
- return res
- }
-
- def static getMatchSetDescriptor(Collection extends IPatternMatch> matchSet, Map objectCode) {
- val set = new TreeSet(new ArrayComparator)
- for(match: matchSet) {
- val size = match.parameterNames.size
- val idArray = new ArrayList(size)
- for(i:0..> {
-
- override compare(List arg0, List arg1) {
- if(arg0.size === arg1.size) {
- for(i : 0.. nameToType
+ val Map> nameToRelation
+
+ protected new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
+ nameToType = ImmutableMap.copyOf(ecore2Logic.allClassesInScope(trace).toMap[name].mapValues [ eClass |
+ ecore2Logic.TypeofEClass(trace, eClass)
+ ])
+ nameToRelation = ImmutableMap.copyOf(ecore2Logic.allReferencesInScope(trace).groupBy[EContainingClass.name].
+ mapValues [ references |
+ ImmutableMap.copyOf(references.toMap[name].mapValues [ reference |
+ ecore2Logic.relationOfReference(trace, reference)
+ ])
+ ])
+ }
+
+ protected def getType(String name) {
+ nameToType.get(name)
+ }
+
+ protected def relation(String typeName, String relationName) {
+ nameToRelation.get(typeName).get(relationName)
+ }
+
+ protected static def int countMatches(ViatraQueryMatcher matcher, PartialInterpretation p) {
+ val match = matcher.newEmptyMatch
+ match.set(0, p.problem)
+ match.set(1, p)
+ matcher.countMatches(match)
+ }
+
+ protected static def int getCount(ViatraQueryMatcher matcher, PartialInterpretation p) {
+ val match = matcher.newEmptyMatch
+ match.set(0, p.problem)
+ match.set(1, p)
+ val realMatch = matcher.getOneArbitraryMatch(match)
+ if (realMatch.present) {
+ realMatch.get.get(2) as Integer
+ } else {
+ 0
+ }
+ }
+}
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend
index 34f3c267..54724226 100644
--- a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MetamodelLoader.xtend
@@ -4,18 +4,23 @@ import functionalarchitecture.FunctionalarchitecturePackage
import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Ecore
import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.FileSystem
import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FilesystemPackage
+import hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.SatelliteQueriesAll
import hu.bme.mit.inf.dslreasoner.domains.transima.fam.FamPatterns
import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage
+import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic
+import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor
import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns
import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor
import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.ModelGenerationMethod
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeConstraintHint
import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ModelGenerationMethodBasedGlobalConstraint
import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace
import java.util.Collection
import java.util.HashMap
import java.util.LinkedHashMap
import java.util.List
+import java.util.Map
import java.util.Set
import org.eclipse.emf.ecore.EAttribute
import org.eclipse.emf.ecore.EClass
@@ -24,60 +29,83 @@ import org.eclipse.emf.ecore.EEnumLiteral
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.EReference
import org.eclipse.emf.ecore.EcorePackage
+import org.eclipse.xtend.lib.annotations.Data
import org.eclipse.xtext.xbase.lib.Functions.Function1
-import hu.bme.mit.inf.dslreasoner.domains.transima.fam.Type
-import hu.bme.mit.inf.dslreasoner.domains.transima.fam.Model
+import satellite.SatellitePackage
+
+@Data
+class TypeQuantiles {
+ double low
+ double high
+}
abstract class MetamodelLoader {
protected val ReasonerWorkspace workspace
+
new(ReasonerWorkspace workspace) {
this.workspace = workspace
- }
+ }
+
def EcoreMetamodelDescriptor loadMetamodel()
+
def Set getRelevantTypes(EcoreMetamodelDescriptor descriptor)
+
def Set getRelevantReferences(EcoreMetamodelDescriptor descriptor)
+
def ViatraQuerySetDescriptor loadQueries(EcoreMetamodelDescriptor metamodel)
+
def List loadPartialModel()
-
- def List> additionalConstraints()
-
- def filterByNames(Iterable collection, Function1 nameExtractor, Collection requiredNames) {
+
+ def List> additionalConstraints()
+
+ def Map getTypeQuantiles() {
+ emptyMap
+ }
+
+ def List getHints(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
+ emptyList
+ }
+
+ def filterByNames(Iterable collection, Function1 nameExtractor,
+ Collection requiredNames) {
val res = collection.filter[requiredNames.contains(nameExtractor.apply(it))]
if(res.size != requiredNames.size) throw new IllegalArgumentException
return res.toSet
}
}
-class FAMLoader extends MetamodelLoader{
-
+class FAMLoader extends MetamodelLoader {
+
new(ReasonerWorkspace workspace) {
super(workspace)
}
-
+
override loadMetamodel() {
val package = FunctionalarchitecturePackage.eINSTANCE
val List classes = package.EClassifiers.filter(EClass).toList
val List enums = package.EClassifiers.filter(EEnum).toList
val List literals = enums.map[ELiterals].flatten.toList
- val List references = classes.map[EReferences].flatten.toList
+ val List references = classes.map[EReferences].flatten.filter[name != "type" && name != "model"].
+ toList
val List attributes = classes.map[EAttributes].flatten.toList
- return new EcoreMetamodelDescriptor(classes,#{},false,enums,literals,references,attributes)
+ return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes)
}
-
- override getRelevantTypes(EcoreMetamodelDescriptor descriptor) {
- return descriptor.classes.filterByNames([it.name],#["FunctionalElement"])
+
+ override getRelevantTypes(EcoreMetamodelDescriptor descriptor) {
+ return descriptor.classes.filterByNames([it.name], #["FunctionalElement"])
}
+
override getRelevantReferences(EcoreMetamodelDescriptor descriptor) {
- return descriptor.references.filterByNames([it.name],#["subElements"])
+ return descriptor.references.filterByNames([it.name], #["subElements"])
}
-
+
override loadQueries(EcoreMetamodelDescriptor metamodel) {
val i = FamPatterns.instance
val patterns = i.specifications.toList
- val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name== "Constraint"]].toSet
+ val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet
val derivedFeatures = new LinkedHashMap
- derivedFeatures.put(Type.instance,metamodel.attributes.filter[it.name == "type"].head)
- derivedFeatures.put(Model.instance,metamodel.references.filter[it.name == "model"].head)
+// derivedFeatures.put(Type.instance,metamodel.attributes.filter[it.name == "type"].head)
+// derivedFeatures.put(Model.instance,metamodel.references.filter[it.name == "model"].head)
val res = new ViatraQuerySetDescriptor(
patterns,
wfPatterns,
@@ -85,65 +113,67 @@ class FAMLoader extends MetamodelLoader{
)
return res
}
+
override loadPartialModel() {
- this.workspace.readModel(EObject,"FAM.xmi").eResource.allContents.toList
+ this.workspace.readModel(EObject, "FAM.xmi").eResource.allContents.toList
}
-
+
override additionalConstraints() { #[] }
}
-class YakinduLoader extends MetamodelLoader{
-
+class YakinduLoader extends MetamodelLoader {
+
var useSynchronization = true;
- var useComplexStates = false;
- public static val patternsWithSynchronization = #[
- "synchHasNoOutgoing", "synchHasNoIncoming", "SynchronizedIncomingInSameRegion", "notSynchronizingStates",
- "hasMultipleOutgoingTrainsition", "hasMultipleIncomingTrainsition", "SynchronizedRegionsAreNotSiblings",
- "SynchronizedRegionDoesNotHaveMultipleRegions", "synchThree", "twoSynch","noSynch2","synch","noSynch4","noSynch3","noSynch"]
- public static val patternsWithComplexStates =#["outgoingFromExit","outgoingFromFinal","choiceHasNoOutgoing","choiceHasNoIncoming"]
+ var useComplexStates = false;
+ public static val patternsWithSynchronization = #["synchHasNoOutgoing", "synchHasNoIncoming",
+ "SynchronizedIncomingInSameRegion", "SynchronizedIncomingInSameRegionHelper1",
+ "SynchronizedIncomingInSameRegionHelper2", "notSynchronizingStates", "hasMultipleOutgoingTrainsition",
+ "hasMultipleIncomingTrainsition", "SynchronizedRegionsAreNotSiblings",
+ "SynchronizedRegionsAreNotSiblingsHelper1", "SynchronizedRegionsAreNotSiblingsHelper2",
+ "SynchronizedRegionDoesNotHaveMultipleRegions", "synchThree", "twoSynch", "noSynch2", "synch", "noSynch4",
+ "noSynch3", "noSynch"]
+ public static val patternsWithComplexStates = #["outgoingFromExit", "outgoingFromFinal", "choiceHasNoOutgoing",
+ "choiceHasNoIncoming"]
+
new(ReasonerWorkspace workspace) {
super(workspace)
YakindummPackage.eINSTANCE.eClass
}
-
+
def setUseSynchronization(boolean useSynchronization) {
this.useSynchronization = useSynchronization
}
+
def setUseComplexStates(boolean useComplexStates) {
this.useComplexStates = useComplexStates
}
-
+
override loadMetamodel() {
val useSynchInThisLoad = this.useSynchronization
val useComplexStates = this.useComplexStates
-
+
val package = YakindummPackage.eINSTANCE
- val List classes = package.EClassifiers.filter(EClass)
- .filter[useSynchInThisLoad || (it.name != "Synchronization")]
- .filter[useComplexStates || (it.name != "Choice" && it.name != "Exit" && it.name != "FinalState")]
- .toList
+ val List classes = package.EClassifiers.filter(EClass).filter [
+ useSynchInThisLoad || (it.name != "Synchronization")
+ ].filter[useComplexStates || (it.name != "Choice" && it.name != "Exit" && it.name != "FinalState")].toList
val List enums = package.EClassifiers.filter(EEnum).toList
val List literals = enums.map[ELiterals].flatten.toList
val List references = classes.map[EReferences].flatten.toList
val List attributes = classes.map[EAttributes].flatten.toList
- return new EcoreMetamodelDescriptor(classes,#{},false,enums,literals,references,attributes)
+ return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes)
}
+
override loadQueries(EcoreMetamodelDescriptor metamodel) {
val useSynchInThisLoad = this.useSynchronization
-
+
val i = Patterns.instance
- val patterns = i.specifications
- .filter[spec |
- useSynchInThisLoad ||
- !patternsWithSynchronization.exists[spec.fullyQualifiedName.endsWith(it)]
- ]
- .filter[spec |
- useComplexStates ||
- !patternsWithComplexStates.exists[spec.fullyQualifiedName.endsWith(it)]
- ]
- .toList
- val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name== "Constraint"]].toSet
+ val patterns = i.specifications.filter [ spec |
+ useSynchInThisLoad || !patternsWithSynchronization.exists[spec.fullyQualifiedName.endsWith(it)]
+ ].filter [ spec |
+ useComplexStates || !patternsWithComplexStates.exists[spec.fullyQualifiedName.endsWith(it)]
+ ].toList
+ val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet
val derivedFeatures = new LinkedHashMap
val res = new ViatraQuerySetDescriptor(
patterns,
@@ -152,53 +182,71 @@ class YakinduLoader extends MetamodelLoader{
)
return res
}
+
override getRelevantTypes(EcoreMetamodelDescriptor descriptor) {
- descriptor.classes.filterByNames([it.name],#["Vertex","Transition","Synchronization"])
+ descriptor.classes.filterByNames([it.name], #["Vertex", "Transition", "Synchronization"])
}
-
+
override getRelevantReferences(EcoreMetamodelDescriptor descriptor) {
- descriptor.references.filterByNames([it.name],#["source","target"])
+ descriptor.references.filterByNames([it.name], #["source", "target"])
}
-
+
override loadPartialModel() {
- this.workspace.readModel(EObject,"Yakindu.xmi").eResource.allContents.toList
+ this.workspace.readModel(EObject, "Yakindu.xmi").eResource.allContents.toList
}
-
- override additionalConstraints() { //#[]
- #[[method | new SGraphInconsistencyDetector(method)]]
+
+ override additionalConstraints() { // #[]
+ #[[method|new SGraphInconsistencyDetector(method)]]
+ }
+
+ override getTypeQuantiles() {
+ #{
+ "Choice" -> new TypeQuantiles(0.118279569892473, 0.154020979020979),
+ "Entry" -> new TypeQuantiles(0.0283018867924528, 0.0620167525773196),
+ "Exit" -> new TypeQuantiles(0, 0),
+ "FinalState" -> new TypeQuantiles(0, 0),
+ "Region" -> new TypeQuantiles(0.0294117647058824, 0.0633258678611422),
+ "State" -> new TypeQuantiles(0.132023636740618, 0.175925925925926),
+// "Statechart" -> new TypeQuantiles(0.00961538461538462, 0.010752688172043),
+ "Transition" -> new TypeQuantiles(0.581632653061224, 0.645161290322581)
+ }
+ }
+
+ override getHints(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
+ #[new SGraphHint(ecore2Logic, trace)]
}
}
-class FileSystemLoader extends MetamodelLoader{
-
+class FileSystemLoader extends MetamodelLoader {
+
new(ReasonerWorkspace workspace) {
super(workspace)
}
-
+
override loadMetamodel() {
val package = FilesystemPackage.eINSTANCE
val List classes = package.EClassifiers.filter(EClass).toList
val List enums = package.EClassifiers.filter(EEnum).toList
val List literals = enums.map[ELiterals].flatten.toList
- val List references = classes.map[EReferences].flatten.toList
+ val List references = classes.map[EReferences].flatten.filter[name != "live"].toList
val List attributes = classes.map[EAttributes].flatten.toList
- return new EcoreMetamodelDescriptor(classes,#{},false,enums,literals,references,attributes)
+ return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes)
}
-
+
override getRelevantTypes(EcoreMetamodelDescriptor descriptor) {
return null
}
-
+
override getRelevantReferences(EcoreMetamodelDescriptor descriptor) {
null
}
-
+
override loadQueries(EcoreMetamodelDescriptor metamodel) {
val patternGroup = FileSystem.instance
val patterns = patternGroup.specifications.toList
val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet
val derivedFeatures = new HashMap
- derivedFeatures.put(patternGroup.live,metamodel.references.filter[it.name == "live"].head)
+// derivedFeatures.put(patternGroup.live,metamodel.references.filter[it.name == "live"].head)
return new ViatraQuerySetDescriptor(
patterns,
wfPatterns,
@@ -206,41 +254,46 @@ class FileSystemLoader extends MetamodelLoader{
)
}
-
+
override loadPartialModel() {
- this.workspace.readModel(EObject,"fs.xmi").eResource.allContents.toList
+ this.workspace.readModel(EObject, "fs.xmi").eResource.allContents.toList
}
-
+
override additionalConstraints() {
- #[[method | new FileSystemInconsistencyDetector(method)]]
+ #[[method|new FileSystemInconsistencyDetector(method)]]
}
-
+
}
class EcoreLoader extends MetamodelLoader {
-
+
new(ReasonerWorkspace workspace) {
super(workspace)
}
-
+
override loadMetamodel() {
val package = EcorePackage.eINSTANCE
- val List classes = package.EClassifiers.filter(EClass).filter[it.name!="EFactory"].toList
+ val List classes = package.EClassifiers.filter(EClass).filter [
+ it.name != "EFactory" && it.name != "EObject" && it.name != "EResource"
+ ].toList
val List enums = package.EClassifiers.filter(EEnum).toList
val List literals = enums.map[ELiterals].flatten.toList
- val List references = classes.map[EReferences].flatten.filter[it.name!="eFactoryInstance"].filter[!it.derived].toList
- val List attributes = #[] //classes.map[EAttributes].flatten.toList
- return new EcoreMetamodelDescriptor(classes,#{},false,enums,literals,references,attributes)
+ val List references = classes.map[EReferences].flatten.filter [
+ it.name != "eFactoryInstance" && it.name != "contents" && it.name != "references" &&
+ it.name != "eGenericType" && it.name != "eGenericSuperTypes"
+ ].filter[!it.derived].toList
+ val List attributes = #[] // classes.map[EAttributes].flatten.toList
+ return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes)
}
-
+
override getRelevantTypes(EcoreMetamodelDescriptor descriptor) {
return null
}
-
+
override getRelevantReferences(EcoreMetamodelDescriptor descriptor) {
null
}
-
+
override loadQueries(EcoreMetamodelDescriptor metamodel) {
val patternGroup = Ecore.instance
val patterns = patternGroup.specifications.toList
@@ -253,13 +306,92 @@ class EcoreLoader extends MetamodelLoader {
)
}
-
+
override loadPartialModel() {
- this.workspace.readModel(EObject,"ecore.xmi").eResource.allContents.toList
+ this.workspace.readModel(EObject, "ecore.xmi").eResource.allContents.toList
}
-
+
override additionalConstraints() {
#[]
}
+
+ override getTypeQuantiles() {
+ #{
+ "EAnnotation" -> new TypeQuantiles(0, 0),
+ "EAttribute" -> new TypeQuantiles(0.14, 0.300943396226415),
+ "EClass" -> new TypeQuantiles(0.224014336917563, 0.372881355932203),
+ "EDataType" -> new TypeQuantiles(0, 0),
+ "EEnum" -> new TypeQuantiles(0, 0.0275208638045255),
+ "EEnumLiteral" -> new TypeQuantiles(0, 0.105204907665065),
+ "EGenericType" -> new TypeQuantiles(0, 0),
+ "EOperation" -> new TypeQuantiles(0, 0),
+ "EPackage" -> new TypeQuantiles(0.0119047619047619, 0.0192307692307692),
+ "EParameter" -> new TypeQuantiles(0, 0),
+ "EReference" -> new TypeQuantiles(0.217599234815878, 0.406779661016949),
+ "EStringToStringMapEntry" -> new TypeQuantiles(0, 0),
+ "ETypeParameter" -> new TypeQuantiles(0, 0)
+ }
+ }
+
+}
+
+class SatelliteLoader extends MetamodelLoader {
+
+ new(ReasonerWorkspace workspace) {
+ super(workspace)
+ }
+
+ override loadMetamodel() {
+ val package = SatellitePackage.eINSTANCE
+ val List classes = package.EClassifiers.filter(EClass).toList
+ val List enums = package.EClassifiers.filter(EEnum).toList
+ val List literals = enums.map[ELiterals].flatten.toList
+ val List references = classes.map[EReferences].flatten.toList
+ val List attributes = classes.map[EAttributes].flatten.toList
+ return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes)
+ }
+
+ override getRelevantTypes(EcoreMetamodelDescriptor descriptor) {
+ null
+ }
+
+ override getRelevantReferences(EcoreMetamodelDescriptor descriptor) {
+ null
+ }
+
+ override loadQueries(EcoreMetamodelDescriptor metamodel) {
+ val i = SatelliteQueriesAll.instance
+ val patterns = i.specifications.toList
+ val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet
+ val derivedFeatures = new LinkedHashMap
+ val res = new ViatraQuerySetDescriptor(
+ patterns,
+ wfPatterns,
+ derivedFeatures
+ )
+ return res
+ }
+
+ override loadPartialModel() {
+ this.workspace.readModel(EObject, "satellite.xmi").eResource.allContents.toList
+ }
+
+ override additionalConstraints() { #[] }
+
+ override getHints(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
+ #[new SatelliteHint(ecore2Logic, trace)]
+ }
+
+ override getTypeQuantiles() {
+ #{
+ "CubeSat3U" -> new TypeQuantiles(0.1, 0.25),
+ "CubeSat6U" -> new TypeQuantiles(0, 0.25),
+ "SmallSat" -> new TypeQuantiles(0, 0.15),
+ "UHFCommSubsystem" -> new TypeQuantiles(0.08, 0.25),
+ "XCommSubsystem" -> new TypeQuantiles(0.08, 0.25),
+ "KaCommSubsystem" -> new TypeQuantiles(0, 0.1),
+ "InterferometryPayload" -> new TypeQuantiles(0.15, 0.25)
+ }
+ }
-}
\ No newline at end of file
+}
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphHint.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphHint.xtend
new file mode 100644
index 00000000..97ce4ee6
--- /dev/null
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SGraphHint.xtend
@@ -0,0 +1,46 @@
+package hu.bme.mit.inf.dslreasoner.run
+
+import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic
+import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator
+
+class SGraphHint extends Ecore2LogicTraceBasedHint {
+ new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
+ super(ecore2Logic, trace)
+ }
+
+ override getAdditionalPatterns(extension PatternGenerator patternGenerator) {
+ ""
+ }
+
+ override createConstraintUpdater(LinearTypeExpressionBuilderFactory it) {
+ val newEntriesWithoutRegionCount = createBuilder.add(1, "Entry".type).add(-1, "Region".type).build
+ val newStatesWithoutRegionCount = createBuilder.add(1, "State".type).add(-1, "Region".type).build
+ val newTransitionWithoutNeedsOutgoingCount = createBuilder.add(1, "Transition".type).add(-1, "Entry".type).
+ add(-1, "Choice".type).build
+ val newTransitionWithoutNeedsIncomingCount = createBuilder.add(1, "Transition".type).add(-1, "Choice".type).
+ build
+
+ val regionsWithoutEntryMatcher = createMatcher(
+ "unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_noEntryInRegion")
+ val regionsWithoutStateMatcher = createMatcher(
+ "unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_noStateInRegion")
+ val entryHasNoOutgoingMatcher = createMatcher(
+ "unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_noOutgoingTransitionFromEntry")
+ val choiceHasNoOutgoingMatcher = createMatcher(
+ "unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_choiceHasNoOutgoing")
+ val choiceHasNoIncomingMatcher = createMatcher(
+ "unfinishedBy_pattern_hu_bme_mit_inf_dslreasoner_partialsnapshot_mavo_yakindu_choiceHasNoIncoming")
+ val transitionWithoutTargetMatcher = createMatcher("unfinishedLowerMultiplicity_target_reference_Transition")
+
+ return [ p |
+ newEntriesWithoutRegionCount.assertEqualsTo(regionsWithoutEntryMatcher.countMatches(p))
+ newStatesWithoutRegionCount.tightenLowerBound(regionsWithoutStateMatcher.countMatches(p))
+ newTransitionWithoutNeedsOutgoingCount.tightenLowerBound(
+ entryHasNoOutgoingMatcher.countMatches(p) + choiceHasNoOutgoingMatcher.countMatches(p))
+ newTransitionWithoutNeedsIncomingCount.tightenLowerBound(
+ choiceHasNoIncomingMatcher.countMatches(p) - transitionWithoutTargetMatcher.getCount(p))
+ ]
+ }
+}
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend
new file mode 100644
index 00000000..e95c0c64
--- /dev/null
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/SatelliteHint.xtend
@@ -0,0 +1,86 @@
+package hu.bme.mit.inf.dslreasoner.run
+
+import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic
+import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.LinearTypeExpressionBuilderFactory
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternGenerator
+
+class SatelliteHint extends Ecore2LogicTraceBasedHint {
+ static val INTERFEROMETY_PAYLOAD = "hint_interferometryPayload"
+ static val REMAINING_CONTENTS_KA_COMM_SUBSYSTEM = "hint_kaCommSubsystem"
+ static val HINT_SPACECRAFT_UHF_POSSIBLE_LINK = "hint_spacecraftWithUhfPossibleLink"
+ static val HINT_SPACECRAFT_UHF_ONLY_NO_LINK = "hint_spacecraftUhfOnlyNoLink"
+
+ new(Ecore2Logic ecore2Logic, Ecore2Logic_Trace trace) {
+ super(ecore2Logic, trace)
+ }
+
+ override getAdditionalPatterns(PatternGenerator it) '''
+ pattern «INTERFEROMETY_PAYLOAD»(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement) {
+ find interpretation(problem, interpretation);
+ find mustExist(problem, interpretation, object);
+ «typeIndexer.referInstanceOf("InterferometryPayload".type, Modality.MUST, "object")»
+ }
+
+ private pattern «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»_helper(problem:LogicProblem, interpretation:PartialInterpretation, object:DefinedElement, remainingContents:java Integer) {
+ find remainingContents_commSubsystem_reference_CommunicatingElement_helper(problem, interpretation, object, remainingContents);
+ «typeIndexer.referInstanceOf("SmallSat".type, Modality.MUST, "object")»
+ }
+
+ pattern «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»(problem:LogicProblem, interpretation:PartialInterpretation, remainingContents:java Integer) {
+ find interpretation(problem, interpretation);
+ remainingContents == sum find «REMAINING_CONTENTS_KA_COMM_SUBSYSTEM»_helper(problem, interpretation, _, #_);
+ }
+
+ private pattern hint_spacecraftNotUhfOnly(problem:LogicProblem, interpretation:PartialInterpretation, spacecraft:DefinedElement) {
+ find interpretation(problem, interpretation);
+ find mustExist(problem, interpretation, spacecraft);
+ «typeIndexer.referInstanceOf("Spacecraft".type, Modality.MUST, "spacecraft")»
+ «relationDeclarationIndexer.referRelation("CommunicatingElement".relation("commSubsystem"), "spacecraft", "comm", Modality.MAY)»
+ neg «typeIndexer.referInstanceOf("UHFCommSubsystem".type, Modality.MUST, "comm")»
+ }
+
+ private pattern hint_spacecraftWithUhf(problem:LogicProblem, interpretation:PartialInterpretation, spacecraft:DefinedElement) {
+ find interpretation(problem, interpretation);
+ find mustExist(problem, interpretation, spacecraft);
+ «typeIndexer.referInstanceOf("Spacecraft".type, Modality.MUST, "spacecraft")»
+ «relationDeclarationIndexer.referRelation("CommunicatingElement".relation("commSubsystem"), "spacecraft", "comm", Modality.MUST)»
+ «typeIndexer.referInstanceOf("UHFCommSubsystem".type, Modality.MUST, "comm")»
+ }
+
+ pattern «HINT_SPACECRAFT_UHF_POSSIBLE_LINK»(problem:LogicProblem, interpretation:PartialInterpretation) {
+ find hint_spacecraftWithUhf(problem, interpretation, spacecraft);
+ find hint_spacecraftNotUhfOnly(problem, interpretation, spacecraft);
+ }
+
+ pattern «HINT_SPACECRAFT_UHF_ONLY_NO_LINK»(problem:LogicProblem, interpretation:PartialInterpretation) {
+ find interpretation(problem, interpretation);
+ find mustExist(problem, interpretation, spacecraft);
+ «typeIndexer.referInstanceOf("Spacecraft".type, Modality.MUST, "spacecraft")»
+ neg find hint_spacecraftNotUhfOnly(problem, interpretation, spacecraft);
+ find currentInRelation_pattern_hu_bme_mit_inf_dslreasoner_domains_satellite_queries_noLinkToGroundStation(problem, interpretation, spacecraft);
+ }
+ '''
+
+ override createConstraintUpdater(LinearTypeExpressionBuilderFactory it) {
+ val interferometryPayloadCount = createBuilder.add(1, "InterferometryPayload".type).build
+ val kaCommSubsystemWithoutSmallSatCount = createBuilder.add(1, "KaCommSubsystem".type).add(-2, "SmallSat".type).
+ build
+ val uhfCommSubsystemCount = createBuilder.add(1, "UHFCommSubsystem".type).build
+
+ val interferometryPayloadMatcher = createMatcher(INTERFEROMETY_PAYLOAD)
+ val kaCommSubsystemRemainingContentsMatcher = createMatcher(REMAINING_CONTENTS_KA_COMM_SUBSYSTEM)
+ val uhfPossibleLinkMatcher = createMatcher(HINT_SPACECRAFT_UHF_POSSIBLE_LINK)
+ val uhfNoLinkMatcher = createMatcher(HINT_SPACECRAFT_UHF_ONLY_NO_LINK)
+
+ return [ p |
+ interferometryPayloadCount.tightenLowerBound(2 - interferometryPayloadMatcher.countMatches(p))
+ kaCommSubsystemWithoutSmallSatCount.tightenUpperBound(kaCommSubsystemRemainingContentsMatcher.getCount(p))
+ if (uhfPossibleLinkMatcher.countMatches(p) == 0 && uhfNoLinkMatcher.countMatches(p) >= 1) {
+ uhfCommSubsystemCount.tightenLowerBound(1)
+ }
+ ]
+ }
+
+}
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend
new file mode 100644
index 00000000..e2d6e6ca
--- /dev/null
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend
@@ -0,0 +1,35 @@
+package hu.bme.mit.inf.dslreasoner.run
+
+import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage
+import java.io.File
+import org.eclipse.emf.common.util.URI
+import org.eclipse.emf.ecore.EPackage
+import org.eclipse.emf.ecore.EcorePackage
+import org.eclipse.emf.ecore.resource.Resource
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
+
+class TypeDistributionCalculator {
+ public static def void main(String[] args) {
+ Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl)
+ EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE)
+ EPackage.Registry.INSTANCE.put(YakindummPackage.eNS_URI, YakindummPackage.eINSTANCE)
+
+ println("model,className,count")
+ val directory = new File(args.get(0))
+ for (file : directory.listFiles) {
+ val modelName = file.name
+ val resourceSet = new ResourceSetImpl
+ val resource = resourceSet.getResource(URI.createFileURI(file.absolutePath), true)
+ val objectsByTypeName = resource.allContents.filter [ obj |
+ val featureName = obj.eContainingFeature?.name
+ // Filter out "derived containment" references in Ecore.
+ // See https://stackoverflow.com/a/46340165
+ featureName != "eGenericType" && featureName != "eGenericSuperTypes"
+ ].groupBy[eClass.name]
+ for (pair : objectsByTypeName.entrySet) {
+ println('''«modelName»,«pair.key»,«pair.value.size»''')
+ }
+ }
+ }
+}
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend
new file mode 100644
index 00000000..5abff962
--- /dev/null
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScript.xtend
@@ -0,0 +1,70 @@
+package hu.bme.mit.inf.dslreasoner.run.script
+
+import java.util.List
+import org.eclipse.xtend.lib.annotations.Accessors
+
+@Accessors
+class MeasurementScript {
+ String inputPath
+ String outputPath
+ int timeout
+ boolean saveModels
+ boolean saveTemporaryFiles
+ int warmupIterations
+ int iterations
+ Domain domain
+ Scope scope
+ List sizes
+ Solver solver
+ ScopePropagator scopePropagator
+ ScopeConstraints propagatedConstraints
+ PolyhedronSolver polyhedronSolver
+ ScopeHeuristic scopeHeuristic
+
+ def toCsvHeader() {
+ '''«domain»,«scope»,«solver»,«scopePropagator ?: "NULL"»,«propagatedConstraints ?: "NULL"»,«polyhedronSolver ?: "NULL"»'''
+ }
+}
+
+enum Domain {
+ fs,
+ ecore,
+ Yakindu,
+ FAM,
+ satellite
+}
+
+enum Scope {
+ none,
+ quantiles
+}
+
+enum Solver {
+ ViatraSolver,
+ AlloySolver
+}
+
+enum ScopePropagator {
+ none,
+ basic,
+ polyhedral
+}
+
+enum ScopeConstraints {
+ none,
+ typeHierarchy,
+ relations,
+ hints
+}
+
+enum PolyhedronSolver {
+ Z3Integer,
+ Z3Real,
+ Cbc,
+ Clp
+}
+
+enum ScopeHeuristic {
+ basic,
+ polyhedral
+}
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend
new file mode 100644
index 00000000..48e750cb
--- /dev/null
+++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/script/MeasurementScriptRunner.xtend
@@ -0,0 +1,351 @@
+package hu.bme.mit.inf.dslreasoner.run.script
+
+import com.google.gson.Gson
+import hu.bme.mit.inf.dslreasoner.ecore2logic.EClassMapper
+import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic
+import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration
+import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
+import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel
+import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes
+import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement
+import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.IntLiteral
+import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RealLiteral
+import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.StringLiteral
+import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
+import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition
+import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem
+import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.IntStatisticEntry
+import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicresultFactory
+import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult
+import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.RealStatisticEntry
+import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.Statistics
+import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.StringStatisticEntry
+import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore
+import hu.bme.mit.inf.dslreasoner.run.EcoreLoader
+import hu.bme.mit.inf.dslreasoner.run.FAMLoader
+import hu.bme.mit.inf.dslreasoner.run.FileSystemLoader
+import hu.bme.mit.inf.dslreasoner.run.MetamodelLoader
+import hu.bme.mit.inf.dslreasoner.run.SatelliteLoader
+import hu.bme.mit.inf.dslreasoner.run.YakinduLoader
+import hu.bme.mit.inf.dslreasoner.util.CollectionsUtil
+import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic
+import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorConstraints
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.PolyhedralScopePropagatorSolver
+import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.cardinality.ScopePropagatorStrategy
+import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic
+import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partial2logicannotations.PartialModelRelation2Assertion
+import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasoner
+import hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.ViatraReasonerConfiguration
+import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace
+import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace
+import java.io.FileReader
+import java.util.HashMap
+import java.util.HashSet
+import java.util.Map
+import java.util.Set
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.emf.ecore.resource.Resource
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
+import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup
+import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineOptions
+import org.eclipse.viatra.query.runtime.rete.matcher.ReteBackendFactory
+import org.eclipse.xtend.lib.annotations.Data
+
+class MeasurementScriptRunner {
+ static val MODEL_SIZE_GAP = 0
+ static val SCOPE_PROPAGATOR_TIMEOUT = 10
+ static val USEC_TO_MSEC = 1000000
+
+ static extension val LogicresultFactory = LogicresultFactory.eINSTANCE
+
+ val MeasurementScript script
+ val ReasonerWorkspace inputWorkspace
+ val ReasonerWorkspace outputWorkspace
+ val MetamodelLoader metamodelLoader
+
+ new(MeasurementScript script) {
+ this.script = script
+ inputWorkspace = new FileSystemWorkspace(script.inputPath + "/", "")
+ outputWorkspace = new FileSystemWorkspace(script.outputPath +
+ "/", '''«script.domain»_«script.solver»_«script.scope»_«script.scopePropagator ?: "na"»_«script.propagatedConstraints ?: "na"»_«script.polyhedronSolver ?: "na"»_''')
+ metamodelLoader = switch (script.domain) {
+ case fs: new FileSystemLoader(inputWorkspace)
+ case ecore: new EcoreLoader(inputWorkspace)
+ case Yakindu: new YakinduLoader(inputWorkspace) => [useSynchronization = false; useComplexStates = true]
+ case FAM: new FAMLoader(inputWorkspace)
+ case satellite: new SatelliteLoader(inputWorkspace)
+ default: throw new IllegalArgumentException("Unsupported domain: " + script.domain)
+ }
+ }
+
+ def run() {
+ if (script.sizes.empty) {
+ return
+ }
+ val start = System.currentTimeMillis
+ val warmupSize = script.sizes.head
+ for (var int i = 0; i < script.warmupIterations; i++) {
+ System.err.println('''Warmup «i + 1»/«script.warmupIterations»...''')
+ runExperiment(warmupSize)
+ }
+ val warmupEnd = System.currentTimeMillis
+ System.err.println('''Warmup completed in «(warmupEnd - start) / 1000» seconds''')
+ for (size : script.sizes) {
+ var int failures = 0
+ for (var int i = 0; i < script.iterations; i++) {
+ System.err.println("Running GC...")
+ runGc()
+ System.err.println('''Iteration «i + 1»/«script.iterations» of size «size»...''')
+ val startTime = System.currentTimeMillis
+ val result = runExperiment(size)
+ val headerPrefix = '''«script.toCsvHeader»,«size»,«i + 1»,«result.resultName»'''
+ println('''«headerPrefix»,startTime,«startTime»''')
+ println('''«headerPrefix»,logic2SolverTransformationTime,«result.statistics.transformationTime»''')
+ println('''«headerPrefix»,solverTime,«result.statistics.solverTime»''')
+ for (statistic : result.statistics.entries) {
+ val valueString = switch (statistic) {
+ IntStatisticEntry: statistic.value.toString
+ RealStatisticEntry: statistic.value.toString
+ StringStatisticEntry: statistic.value.toString
+ default: statistic.toString
+ }
+ println('''«headerPrefix»,«statistic.name»,«valueString»''')
+ }
+ if (script.saveModels && result.model !== null) {
+ outputWorkspace.writeModel(result.model, '''«size»_«i + 1».xmi''')
+ }
+ if (result.resultName === "InsuficientResourcesResultImpl") {
+ failures++
+ }
+ System.out.flush
+ }
+ if (failures == script.iterations) {
+ System.err.println("All measurements failed")
+ return
+ }
+ }
+ val end = System.currentTimeMillis
+ System.err.println('''Measurement completed in «(end - start) / 1000» seconds''')
+ }
+
+ private static def void runGc() {
+ System.gc
+ Thread.sleep(100)
+ System.gc
+ Thread.sleep(100)
+ System.gc
+ Thread.sleep(800)
+ }
+
+ private def runExperiment(int modelSize) {
+ if (script.solver != Solver.ViatraSolver) {
+ throw new IllegalArgumentException("Only VIATRA-Generator is supported")
+ }
+ val config = new ViatraReasonerConfiguration
+ config.solutionScope.numberOfRequiredSolutions = 1
+ config.scopePropagatorStrategy = switch (script.scopePropagator) {
+ case none:
+ ScopePropagatorStrategy.None
+ case basic:
+ switch (script.propagatedConstraints) {
+ case none:
+ ScopePropagatorStrategy.Basic
+ case typeHierarchy:
+ ScopePropagatorStrategy.BasicTypeHierarchy
+ case relations,
+ case hints:
+ throw new IllegalArgumentException(
+ "Basic scope propagator does not support relational and hint constraints")
+ default:
+ throw new IllegalArgumentException("Unknown scope constraints: " + script.propagatedConstraints)
+ }
+ case polyhedral: {
+ val constraints = switch (script.propagatedConstraints) {
+ case none:
+ throw new IllegalArgumentException(
+ "Polyhedral scope propagator needs at least type hierarchy constraints")
+ case typeHierarchy:
+ PolyhedralScopePropagatorConstraints.TypeHierarchy
+ case relations,
+ case hints:
+ PolyhedralScopePropagatorConstraints.Relational
+ default:
+ throw new IllegalArgumentException("Unknown scope constraints: " + script.propagatedConstraints)
+ }
+ val polyhedronSolver = switch (script.polyhedronSolver) {
+ case Z3Integer: PolyhedralScopePropagatorSolver.Z3Integer
+ case Z3Real: PolyhedralScopePropagatorSolver.Z3Real
+ case Cbc: PolyhedralScopePropagatorSolver.Cbc
+ case Clp: PolyhedralScopePropagatorSolver.Clp
+ default: throw new IllegalArgumentException("Unknown polyhedron solver: " + script.polyhedronSolver)
+ }
+ val updateHeuristic = script.scopeHeuristic != ScopeHeuristic.basic
+ new ScopePropagatorStrategy.Polyhedral(constraints, polyhedronSolver, updateHeuristic,
+ SCOPE_PROPAGATOR_TIMEOUT)
+ }
+ default:
+ throw new IllegalArgumentException("Unknown scope propagator: " + script.scopePropagator)
+ }
+ config.runtimeLimit = script.timeout
+ config.documentationLevel = if(script.saveTemporaryFiles) DocumentationLevel.NORMAL else DocumentationLevel.NONE
+ config.debugConfiguration.partialInterpretatioVisualiser = null
+ config.searchSpaceConstraints.additionalGlobalConstraints += metamodelLoader.additionalConstraints
+
+ val modelLoadingStart = System.nanoTime
+ val metamodelDescriptor = metamodelLoader.loadMetamodel
+ val partialModelDescriptor = metamodelLoader.loadPartialModel
+ val queryDescriptor = metamodelLoader.loadQueries(metamodelDescriptor)
+ val modelLoadingTime = System.nanoTime - modelLoadingStart
+
+ val domain2LogicTransformationStart = System.nanoTime
+ val Ecore2Logic ecore2Logic = new Ecore2Logic
+ val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic)
+ val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic
+ var modelGeneration = ecore2Logic.transformMetamodel(metamodelDescriptor, new Ecore2LogicConfiguration())
+ var problem = modelGeneration.output
+ problem = instanceModel2Logic.transform(
+ modelGeneration,
+ partialModelDescriptor
+ ).output
+ problem = viatra2Logic.transformQueries(
+ queryDescriptor,
+ modelGeneration,
+ new Viatra2LogicConfiguration
+ ).output
+ initializeScope(config, modelSize, problem, ecore2Logic, modelGeneration.trace)
+ if (script.propagatedConstraints == ScopeConstraints.hints) {
+ config.hints = metamodelLoader.getHints(ecore2Logic, modelGeneration.trace)
+ }
+ val domain2LogicTransformationTime = System.nanoTime - domain2LogicTransformationStart
+
+ if (config.documentationLevel != DocumentationLevel.NONE) {
+ outputWorkspace.writeModel(problem, "initial.logicproblem")
+ }
+
+ val solver = new ViatraReasoner
+ val result = solver.solve(problem, config, outputWorkspace)
+ val statistics = result.statistics
+ statistics.entries += createIntStatisticEntry => [
+ name = "modelLoadingTime"
+ value = (modelLoadingTime / USEC_TO_MSEC) as int
+ ]
+ statistics.entries += createIntStatisticEntry => [
+ name = "domain2LogicTransformationTime"
+ value = (domain2LogicTransformationTime / USEC_TO_MSEC) as int
+ ]
+ var EObject modelResult = null
+ if (result instanceof ModelResult) {
+ val intepretations = solver.getInterpretations(result)
+ if (intepretations.size != 1) {
+ throw new IllegalStateException("Expected 1 interpretation, got " + intepretations.size)
+ }
+ var resultTransformationStart = System.nanoTime
+ val logic2Ecore = new Logic2Ecore(ecore2Logic)
+ modelResult = logic2Ecore.transformInterpretation(intepretations.head, modelGeneration.trace)
+ val resultTransformationTime = System.nanoTime - resultTransformationStart
+ statistics.entries += createIntStatisticEntry => [
+ name = "ecore2LogicTransformationTime"
+ value = (resultTransformationTime / USEC_TO_MSEC) as int
+ ]
+ }
+
+ new ExperimentResult(result.class.simpleName, statistics, modelResult)
+ }
+
+ private def initializeScope(ViatraReasonerConfiguration config, int modelSize, LogicProblem problem,
+ EClassMapper eClassMapper, Ecore2Logic_Trace trace) {
+ val knownElements = initializeKnownElements(problem, config.typeScopes)
+ if (modelSize < 0) {
+ config.typeScopes.minNewElements = 0
+ config.typeScopes.maxNewElements = TypeScopes.Unlimited
+ } else {
+ val numberOfKnownElements = knownElements.values.flatten.toSet.size
+ val newElementCount = modelSize - numberOfKnownElements
+ config.typeScopes.minNewElements = newElementCount
+ config.typeScopes.maxNewElements = newElementCount + MODEL_SIZE_GAP
+ }
+ switch (script.scope) {
+ case none:
+ return
+ case quantiles: {
+ val quantiles = metamodelLoader.typeQuantiles
+ for (eClassInScope : eClassMapper.allClassesInScope(trace)) {
+ val quantile = quantiles.get(eClassInScope.name)
+ if (quantile !== null) {
+ val type = eClassMapper.TypeofEClass(trace, eClassInScope)
+ val knownInstances = knownElements.get(type)
+ val currentCount = if(knownInstances === null) 0 else knownInstances.size
+ val lowCount = Math.floor(modelSize * quantile.low) as int
+ val highCount = Math.ceil((modelSize + MODEL_SIZE_GAP) * quantile.high) as int
+ config.typeScopes.minNewElementsByType.put(type, lowCount - currentCount)
+ config.typeScopes.maxNewElementsByType.put(type, highCount - currentCount)
+ }
+ }
+ }
+ default:
+ throw new IllegalArgumentException("Unknown scope: " + script.scope)
+ }
+ }
+
+ /*
+ * Copied from hu.bme.mit.inf.dslreasoner.application.execution.ScopeLoader.initialiseknownElements(LogicProblem, TypeScopes)
+ */
+ private static def initializeKnownElements(LogicProblem p, TypeScopes s) {
+ val Map> res = new HashMap
+
+ // 1. fill map with every types
+ for (t : p.types) {
+ res.put(t, new HashSet)
+ }
+
+ // 2. fill map with every objects
+ for (definedType : p.types.filter(TypeDefinition)) {
+ val supertypes = CollectionsUtil.transitiveClosureStar(definedType)[supertypes]
+ for (supertype : supertypes) {
+ for (element : definedType.elements) {
+ res.get(supertype).add(element)
+ }
+ }
+ }
+ val partialModelContents = p.annotations.filter(PartialModelRelation2Assertion).map[target].toList.map [
+ eAllContents.toIterable
+ ].flatten.toList
+ s.knownIntegers += partialModelContents.filter(IntLiteral).map[it.value]
+ s.knownReals += partialModelContents.filter(RealLiteral).map[it.value]
+ s.knownStrings += partialModelContents.filter(StringLiteral).map[it.value]
+
+ res
+ }
+
+ public static def void main(String[] args) {
+ if (args.length != 1) {
+ System.err.println("Missing measurement script name.")
+ System.exit(-1)
+ }
+ EMFPatternLanguageStandaloneSetup.doSetup
+ ViatraQueryEngineOptions.setSystemDefaultBackends(ReteBackendFactory.INSTANCE, ReteBackendFactory.INSTANCE,
+ ReteBackendFactory.INSTANCE)
+ Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl)
+ val config = readConfig(args.get(0))
+ val runnner = new MeasurementScriptRunner(config)
+ runnner.run()
+ }
+
+ static def readConfig(String scriptPath) {
+ val gson = new Gson
+ val reader = new FileReader(scriptPath)
+ try {
+ gson.fromJson(reader, MeasurementScript)
+ } finally {
+ reader.close
+ }
+ }
+
+ @Data
+ private static class ExperimentResult {
+ String resultName
+ Statistics statistics
+ EObject model
+ }
+}
--
cgit v1.2.3-70-g09d2