diff options
author | 2018-02-24 19:03:35 -0500 | |
---|---|---|
committer | 2018-02-24 19:03:35 -0500 | |
commit | d7e2de55047e357ca6a4db4709885ca59946a484 (patch) | |
tree | 227768e3e5c2b5805a108ec77ee408fe1e582e50 /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra | |
parent | Project workspace folder structure generation patch (diff) | |
download | VIATRA-Generator-d7e2de55047e357ca6a4db4709885ca59946a484.tar.gz VIATRA-Generator-d7e2de55047e357ca6a4db4709885ca59946a484.tar.zst VIATRA-Generator-d7e2de55047e357ca6a4db4709885ca59946a484.zip |
Translated PQueryies are added to annotation.
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra')
3 files changed, 33 insertions, 19 deletions
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 656f806b..ff8ab437 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 | |||
@@ -1,5 +1,6 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra |
2 | 2 | ||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | ||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | 4 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem |
4 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternProvider | 5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns.PatternProvider |
5 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules.GoalConstraintProvider | 6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.rules.GoalConstraintProvider |
@@ -14,6 +15,8 @@ import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher | |||
14 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | 15 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery |
15 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRule | 16 | import org.eclipse.viatra.transformation.runtime.emf.rules.batch.BatchTransformationRule |
16 | import org.eclipse.xtend.lib.annotations.Data | 17 | import org.eclipse.xtend.lib.annotations.Data |
18 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery | ||
19 | import java.util.Set | ||
17 | 20 | ||
18 | class ModelGenerationStatistics { | 21 | class ModelGenerationStatistics { |
19 | public var long transformationExecutionTime = 0 | 22 | public var long transformationExecutionTime = 0 |
@@ -47,13 +50,23 @@ class ModelGenerationMethodProvider { | |||
47 | public def ModelGenerationMethod createModelGenerationMethod( | 50 | public def ModelGenerationMethod createModelGenerationMethod( |
48 | LogicProblem logicProblem, | 51 | LogicProblem logicProblem, |
49 | PartialInterpretation emptySolution, | 52 | PartialInterpretation emptySolution, |
50 | Iterable<PQuery> existingQueries, | ||
51 | ReasonerWorkspace workspace, | 53 | ReasonerWorkspace workspace, |
52 | boolean nameNewElements, | 54 | boolean nameNewElements, |
53 | TypeInferenceMethod typeInferenceMethod | 55 | TypeInferenceMethod typeInferenceMethod, |
56 | DocumentationLevel debugLevel | ||
54 | ) { | 57 | ) { |
55 | val statistics = new ModelGenerationStatistics | 58 | val statistics = new ModelGenerationStatistics |
56 | val queries = patternProvider.generateQueries(logicProblem,emptySolution,statistics,existingQueries,workspace,typeInferenceMethod) | 59 | val writeFiles = (debugLevel === DocumentationLevel.NORMAL || debugLevel === DocumentationLevel.FULL) |
60 | |||
61 | val Set<PQuery> existingQueries = logicProblem | ||
62 | .relations | ||
63 | .map[annotations] | ||
64 | .flatten | ||
65 | .filter(TransfomedViatraQuery) | ||
66 | .map[it.patternPQuery as PQuery] | ||
67 | .toSet | ||
68 | |||
69 | val queries = patternProvider.generateQueries(logicProblem,emptySolution,statistics,existingQueries,workspace,typeInferenceMethod,writeFiles) | ||
57 | 70 | ||
58 | val //LinkedHashMap<Pair<Relation, ? extends Type>, BatchTransformationRule<GenericPatternMatch, ViatraQueryMatcher<GenericPatternMatch>>> | 71 | val //LinkedHashMap<Pair<Relation, ? extends Type>, BatchTransformationRule<GenericPatternMatch, ViatraQueryMatcher<GenericPatternMatch>>> |
59 | objectRefinementRules = refinementRuleProvider.createObjectRefinementRules(queries,nameNewElements,statistics) | 72 | objectRefinementRules = refinementRuleProvider.createObjectRefinementRules(queries,nameNewElements,statistics) |
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 cc8860b4..0e13a5e1 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 | |||
@@ -20,6 +20,7 @@ import org.eclipse.xtend.lib.annotations.Data | |||
20 | 20 | ||
21 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 21 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
22 | import java.util.Collection | 22 | import java.util.Collection |
23 | import java.util.Set | ||
23 | 24 | ||
24 | @Data class GeneratedPatterns { | 25 | @Data class GeneratedPatterns { |
25 | public Map<Relation, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> invalidWFQueries | 26 | public Map<Relation, IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> invalidWFQueries |
@@ -39,10 +40,11 @@ class PatternProvider { | |||
39 | LogicProblem problem, | 40 | LogicProblem problem, |
40 | PartialInterpretation emptySolution, | 41 | PartialInterpretation emptySolution, |
41 | ModelGenerationStatistics statistics, | 42 | ModelGenerationStatistics statistics, |
42 | Iterable<PQuery> existingQueries, | 43 | Set<PQuery> existingQueries, |
43 | ReasonerWorkspace workspace, | 44 | ReasonerWorkspace workspace, |
44 | TypeInferenceMethod typeInferenceMethod | 45 | TypeInferenceMethod typeInferenceMethod, |
45 | ) { | 46 | boolean writeToFile) |
47 | { | ||
46 | val fqn2Query = existingQueries.toMap[it.fullyQualifiedName] | 48 | val fqn2Query = existingQueries.toMap[it.fullyQualifiedName] |
47 | val PatternGenerator patternGenerator = new PatternGenerator(typeInferenceMethod) | 49 | val PatternGenerator patternGenerator = new PatternGenerator(typeInferenceMethod) |
48 | val typeAnalysisResult = if(patternGenerator.requiresTypeAnalysis) { | 50 | val typeAnalysisResult = if(patternGenerator.requiresTypeAnalysis) { |
@@ -55,19 +57,15 @@ class PatternProvider { | |||
55 | null | 57 | null |
56 | } | 58 | } |
57 | val baseIndexerFile = patternGenerator.transformBaseProperties(problem,emptySolution,fqn2Query,typeAnalysisResult) | 59 | val baseIndexerFile = patternGenerator.transformBaseProperties(problem,emptySolution,fqn2Query,typeAnalysisResult) |
58 | writeQueries(baseIndexerFile,"GeneratedQueries",workspace) | 60 | if(writeToFile) { |
61 | workspace.writeText('''generated3valued.vql_deactivated''',baseIndexerFile) | ||
62 | } | ||
59 | val ParseUtil parseUtil = new ParseUtil | 63 | val ParseUtil parseUtil = new ParseUtil |
60 | val generatedQueries = parseUtil.parse(baseIndexerFile) | 64 | val generatedQueries = parseUtil.parse(baseIndexerFile) |
61 | val runtimeQueries = calclulateRuntimeQueries(patternGenerator,problem,emptySolution,typeAnalysisResult,generatedQueries); | 65 | val runtimeQueries = calclulateRuntimeQueries(patternGenerator,problem,emptySolution,typeAnalysisResult,generatedQueries); |
62 | return runtimeQueries | 66 | return runtimeQueries |
63 | } | 67 | } |
64 | 68 | ||
65 | private def writeQueries(CharSequence content, String name,ReasonerWorkspace workspace) { | ||
66 | if(workspace!=null) { | ||
67 | workspace.writeText('''«name».vql_deactivated''',content) | ||
68 | } | ||
69 | } | ||
70 | |||
71 | private def GeneratedPatterns calclulateRuntimeQueries( | 69 | private def GeneratedPatterns calclulateRuntimeQueries( |
72 | PatternGenerator patternGenerator, | 70 | PatternGenerator patternGenerator, |
73 | LogicProblem problem, | 71 | LogicProblem problem, |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend index 1e86f826..794e706b 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend | |||
@@ -3,10 +3,13 @@ package hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.patterns | |||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDefinition | 3 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDefinition |
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | 4 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem |
5 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery | 5 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery |
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | ||
6 | import java.util.Map | 7 | import java.util.Map |
7 | import org.eclipse.emf.ecore.EAttribute | 8 | import org.eclipse.emf.ecore.EAttribute |
9 | import org.eclipse.emf.ecore.EEnumLiteral | ||
8 | import org.eclipse.emf.ecore.EReference | 10 | import org.eclipse.emf.ecore.EReference |
9 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey | 11 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey |
12 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey | ||
10 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey | 13 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey |
11 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint | 14 | import org.eclipse.viatra.query.runtime.matchers.psystem.PConstraint |
12 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable | 15 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable |
@@ -21,8 +24,6 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeCo | |||
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | 24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery |
22 | 25 | ||
23 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 26 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
24 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey | ||
25 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | ||
26 | 27 | ||
27 | class RelationDefinitionIndexer { | 28 | class RelationDefinitionIndexer { |
28 | val PatternGenerator base; | 29 | val PatternGenerator base; |
@@ -193,13 +194,15 @@ class RelationDefinitionIndexer { | |||
193 | 194 | ||
194 | var String targetString; | 195 | var String targetString; |
195 | var String additionalDefinition; | 196 | var String additionalDefinition; |
196 | if(target instanceof Enum<?>) { | 197 | if(target instanceof EEnumLiteral) { |
197 | targetString = '''const_«target.name»_«target.declaringClass.simpleName»''' | 198 | targetString = '''const_«target.name»_«target.EEnum.name»''' |
198 | additionalDefinition = '''DefinedElement.name(«targetString»,"«target.name» «target.declaringClass.simpleName»"); LogicProblem.elements(problem,«targetString»);''' | 199 | additionalDefinition = '''DefinedElement.name(«targetString»,"«target.name» «target.EEnum.name»"); LogicProblem.elements(problem,«targetString»);''' |
199 | } else if(target instanceof Integer) { | 200 | } else if(target instanceof Integer) { |
200 | targetString = target.toString | 201 | targetString = target.toString |
201 | additionalDefinition = '''''' | 202 | additionalDefinition = '''''' |
202 | } else throw new UnsupportedOperationException('''Unknown constant type: «target.class»''') | 203 | } else { |
204 | throw new UnsupportedOperationException('''Unknown constant type: «target.class»''') | ||
205 | } | ||
203 | 206 | ||
204 | val source = c.variablesTuple | 207 | val source = c.variablesTuple |
205 | var String sourceName | 208 | var String sourceName |