diff options
author | LilianaBohus <boli96@gmailcom> | 2018-05-22 16:19:31 +0200 |
---|---|---|
committer | LilianaBohus <boli96@gmailcom> | 2018-05-22 16:19:31 +0200 |
commit | 876ea3d3dd2d86c6361ad9959d49b8b02501ffe7 (patch) | |
tree | 71e1726eeeba6e1042eed6f4b92814f4a0a15f78 /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse | |
parent | Initial implementation of cardinality calculator (diff) | |
download | VIATRA-Generator-876ea3d3dd2d86c6361ad9959d49b8b02501ffe7.tar.gz VIATRA-Generator-876ea3d3dd2d86c6361ad9959d49b8b02501ffe7.tar.zst VIATRA-Generator-876ea3d3dd2d86c6361ad9959d49b8b02501ffe7.zip |
Abstract supertype cardinality countcardinality-counter
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/CardinalityCalculator.java | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/CardinalityCalculator.java b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/CardinalityCalculator.java index 3dd2157e..55ace527 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/CardinalityCalculator.java +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner/src/hu/bme/mit/inf/dslreasoner/viatrasolver/reasoner/dse/CardinalityCalculator.java | |||
@@ -1,25 +1,50 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse; | 1 | package hu.bme.mit.inf.dslreasoner.viatrasolver.reasoner.dse; |
2 | 2 | ||
3 | import java.util.Map; | ||
4 | |||
3 | import org.eclipse.emf.common.util.EList; | 5 | import org.eclipse.emf.common.util.EList; |
6 | import org.eclipse.emf.ecore.EObject; | ||
7 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; | ||
4 | 8 | ||
5 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes; | 9 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.TypeScopes; |
10 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Iff; | ||
6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; | 11 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type; |
12 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.Annotation; | ||
13 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.AssertionAnnotation; | ||
7 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; | 14 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem; |
15 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.RelationAnnotation; | ||
16 | import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.impl.RelationAnnotationImpl; | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; | 17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation; |
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation; | 18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialTypeInterpratation; |
10 | 19 | ||
11 | public class CardinalityCalculator { | 20 | public class CardinalityCalculator { |
21 | |||
12 | public boolean isViolated(PartialInterpretation partialInterpretation, TypeScopes typeScopes) { | 22 | public boolean isViolated(PartialInterpretation partialInterpretation, TypeScopes typeScopes) { |
13 | // LogicProblem problem = partialInterpretation.getProblem(); | 23 | |
14 | // EList<Type> types = problem.getTypes(); | 24 | LogicProblem problem = partialInterpretation.getProblem(); |
15 | // for (Type type : types) { | 25 | EList<Type> types = problem.getTypes(); |
16 | // type.isIsAbstract() | 26 | |
17 | // } | 27 | Map<Type, Integer> minNewElementsByType = typeScopes.minNewElementsByType; |
18 | // problem.getAnnotations(). | 28 | Map<Type, Integer> maxNewElementsByType = typeScopes.maxNewElementsByType; |
19 | // EList<PartialTypeInterpratation> partialtypeinterpratation = partialInterpretation.getPartialtypeinterpratation(); | 29 | |
20 | // | 30 | for (Type type : types) { |
21 | // | 31 | if (type.isIsAbstract()) { |
22 | // typeScopes.minNewElementsByType | 32 | int sumOfSubtypeMinimumScopes = 0; |
33 | int sumOfSubtypeMaximumScopes = 0; | ||
34 | EList<Type> subtypesOfAbstract = type.getSubtypes(); | ||
35 | for (Type subtype : subtypesOfAbstract) { | ||
36 | sumOfSubtypeMinimumScopes += minNewElementsByType.get(subtype); | ||
37 | sumOfSubtypeMaximumScopes += maxNewElementsByType.get(subtype); | ||
38 | } | ||
39 | Integer maxNewElementsOfAbstract = maxNewElementsByType.get(type); | ||
40 | Integer minNewElementsOfAbstract = minNewElementsByType.get(type); | ||
41 | if (sumOfSubtypeMinimumScopes > maxNewElementsOfAbstract | ||
42 | || sumOfSubtypeMaximumScopes < minNewElementsOfAbstract) { | ||
43 | return true; | ||
44 | } | ||
45 | } | ||
46 | } | ||
23 | return false; | 47 | return false; |
24 | } | 48 | } |
49 | |||
25 | } | 50 | } |