diff options
author | 2017-06-10 19:05:05 +0200 | |
---|---|---|
committer | 2017-06-10 19:05:05 +0200 | |
commit | 60f01f46ba232ed6416054f0a6115cb2a9b70b4e (patch) | |
tree | 5edf8aeb07abc51f3fec63bbd15c926e1de09552 /Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/consistencychecker/TypeConsistencyChecker.xtend | |
parent | Initial commit, migrating from SVN (diff) | |
download | VIATRA-Generator-60f01f46ba232ed6416054f0a6115cb2a9b70b4e.tar.gz VIATRA-Generator-60f01f46ba232ed6416054f0a6115cb2a9b70b4e.tar.zst VIATRA-Generator-60f01f46ba232ed6416054f0a6115cb2a9b70b4e.zip |
Migrating Additional projects
Diffstat (limited to 'Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/consistencychecker/TypeConsistencyChecker.xtend')
-rw-r--r-- | Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/consistencychecker/TypeConsistencyChecker.xtend | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/consistencychecker/TypeConsistencyChecker.xtend b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/consistencychecker/TypeConsistencyChecker.xtend new file mode 100644 index 00000000..abb05e83 --- /dev/null +++ b/Framework/hu.bme.mit.inf.dslreasoner.logic.model/src/hu/bme/mit/inf/dslreasoner/logic/model/builder/consistencychecker/TypeConsistencyChecker.xtend | |||
@@ -0,0 +1,75 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.logic.model.builder.consistencychecker | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner | ||
4 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicSolverConfiguration | ||
6 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | ||
7 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasonerException | ||
8 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult | ||
9 | import org.eclipse.viatra.query.runtime.emf.EMFScope | ||
10 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | ||
11 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicproblemPackage | ||
12 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicresultFactory | ||
13 | import hu.bme.mit.inf.dslreasoner.logic.model.patterns.TypeSystemIsInconsistentMatcher | ||
14 | import hu.bme.mit.inf.dslreasoner.logic.model.patterns.ElementNotDefinedInSupertypeMatcher | ||
15 | import hu.bme.mit.inf.dslreasoner.logic.model.patterns.ElementWithNoPossibleDynamicTypeMatcher | ||
16 | import hu.bme.mit.inf.dslreasoner.logic.model.patterns.PossibleDynamicTypeMatcher | ||
17 | |||
18 | class TypeConsistencyChecker extends LogicReasoner{ | ||
19 | val extension LogicresultFactory factory = LogicresultFactory.eINSTANCE | ||
20 | |||
21 | new() { | ||
22 | LogicproblemPackage.eINSTANCE.class | ||
23 | } | ||
24 | |||
25 | override solve(LogicProblem problem, LogicSolverConfiguration configuration, ReasonerWorkspace workspace) throws LogicReasonerException { | ||
26 | val statistics = createStatistics => [ | ||
27 | it.transformationTime = 0 | ||
28 | it.solverMemory = -1 | ||
29 | ] | ||
30 | |||
31 | val start = System.currentTimeMillis | ||
32 | |||
33 | val queryEngine = ViatraQueryEngine.on(new EMFScope(problem)) | ||
34 | |||
35 | val typeSystemInconsistencyMatcher = TypeSystemIsInconsistentMatcher.on(queryEngine) | ||
36 | val elementNotDefinedInSupertype = ElementNotDefinedInSupertypeMatcher.on(queryEngine) | ||
37 | val elementWithNoPossibleDynamicType = ElementWithNoPossibleDynamicTypeMatcher.on(queryEngine) | ||
38 | val possibleDynamicType = PossibleDynamicTypeMatcher.on(queryEngine) | ||
39 | |||
40 | val hasErrorPatternMatch = typeSystemInconsistencyMatcher.hasMatch(problem) | ||
41 | |||
42 | statistics.solverTime = (System.currentTimeMillis - start) as int | ||
43 | |||
44 | val possibleDynamicTypeStatisticEntry = problem.elements.map[e| | ||
45 | '''«e.name»: [«possibleDynamicType.getAllValuesOfdynamic(problem,e).map[it.name].join(", ")»]''' | ||
46 | ].join("\n") | ||
47 | |||
48 | if(hasErrorPatternMatch) { | ||
49 | return createInconsistencyResult =>[ | ||
50 | it.problem = problem | ||
51 | it.statistics = statistics | ||
52 | it.statistics.entries += createStringStatisticEntry => [ | ||
53 | it.name = "possibleDynamicType" | ||
54 | it.value = possibleDynamicTypeStatisticEntry | ||
55 | ] | ||
56 | it.statistics.entries += createStringStatisticEntry => [ | ||
57 | it.name = "elementNotDefinedInSupertype" | ||
58 | it.value=elementNotDefinedInSupertype.allValuesOfelement.map[it.name].join(", ") | ||
59 | ] | ||
60 | |||
61 | it.statistics.entries += createStringStatisticEntry => [ | ||
62 | it.name = "elementWithNoPossibleDynamicType" | ||
63 | it.value=elementWithNoPossibleDynamicType.allValuesOfelement.map[it.name].join(", ") | ||
64 | ] | ||
65 | ] | ||
66 | } else { | ||
67 | return createUndecidableResult => | ||
68 | [it.problem = problem it.statistics = statistics] | ||
69 | } | ||
70 | } | ||
71 | |||
72 | override getInterpretation(ModelResult modelResult) { | ||
73 | throw new UnsupportedOperationException('''This solver is unable to create interpretations!''') | ||
74 | } | ||
75 | } \ No newline at end of file | ||