diff options
author | 2017-09-27 21:10:32 +0200 | |
---|---|---|
committer | 2017-09-27 21:10:32 +0200 | |
commit | 5a286dab2c1d23e16aad6e96e3ad93d0e15cb931 (patch) | |
tree | 6e881a862bd6cdda182774f55d4a32ddfbdbe886 /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src | |
parent | If a query is not supported query exception. (diff) | |
download | VIATRA-Generator-5a286dab2c1d23e16aad6e96e3ad93d0e15cb931.tar.gz VIATRA-Generator-5a286dab2c1d23e16aad6e96e3ad93d0e15cb931.tar.zst VIATRA-Generator-5a286dab2c1d23e16aad6e96e3ad93d0e15cb931.zip |
PS with outgoing references to excluded objects are supported now
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src')
2 files changed, 23 insertions, 10 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend index 1bda1f49..d9c1b8f6 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend | |||
@@ -82,8 +82,10 @@ class InstanceModel2PartialInterpretation { | |||
82 | if(reference.isMany) { | 82 | if(reference.isMany) { |
83 | val listOfTargets = source.eGet(reference) as List<? extends EObject> | 83 | val listOfTargets = source.eGet(reference) as List<? extends EObject> |
84 | for(target : listOfTargets) { | 84 | for(target : listOfTargets) { |
85 | val targetElement = target.lookup(object2DefinedElement) | 85 | if(target !== null && object2DefinedElement.containsKey(target)) { |
86 | translateLink(interpretation,sourceElement,targetElement) | 86 | val targetElement = target.lookup(object2DefinedElement) |
87 | translateLink(interpretation,sourceElement,targetElement) | ||
88 | } | ||
87 | } | 89 | } |
88 | } else { | 90 | } else { |
89 | val target = source.eGet(reference) as EObject | 91 | val target = source.eGet(reference) as EObject |
@@ -95,7 +97,7 @@ class InstanceModel2PartialInterpretation { | |||
95 | } | 97 | } |
96 | 98 | ||
97 | // Transforming the attributes | 99 | // Transforming the attributes |
98 | for(attribute : source.eClass.EAllAttributes.filter[referencesUsed.contains(it)]) { | 100 | for(attribute : source.eClass.EAllAttributes.filter[attributesUsed.contains(it)]) { |
99 | val type = ecore2Logic.relationOfAttribute(ecore2LogicTrace,attribute) | 101 | val type = ecore2Logic.relationOfAttribute(ecore2LogicTrace,attribute) |
100 | val interpretation = type.lookup(partialInterpretationTrace.relation2Interpretation) | 102 | val interpretation = type.lookup(partialInterpretationTrace.relation2Interpretation) |
101 | val sourceElement = source.lookup(object2DefinedElement) | 103 | val sourceElement = source.lookup(object2DefinedElement) |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend index c5fe1d74..09a7fa60 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend | |||
@@ -20,8 +20,12 @@ import java.util.Set | |||
20 | import org.eclipse.xtend.lib.annotations.Data | 20 | import org.eclipse.xtend.lib.annotations.Data |
21 | 21 | ||
22 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 22 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
23 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.DefinedElement | ||
24 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.SymbolicValue | ||
23 | 25 | ||
24 | @Data class PartialInterpretation2Logic_Trace { | 26 | @Data class PartialInterpretation2Logic_Trace { |
27 | Map<DefinedElement,DefinedElement> new2Old = new HashMap | ||
28 | |||
25 | Map<TypeDeclaration, TypeDefinition> definedPart = new HashMap | 29 | Map<TypeDeclaration, TypeDefinition> definedPart = new HashMap |
26 | Map<TypeDeclaration, TypeDeclaration> undefinedPart = new HashMap | 30 | Map<TypeDeclaration, TypeDeclaration> undefinedPart = new HashMap |
27 | Set<Type> originalTypes = new HashSet | 31 | Set<Type> originalTypes = new HashSet |
@@ -38,7 +42,7 @@ class PartialInterpretation2Logic { | |||
38 | if(! i.newElements.empty) { | 42 | if(! i.newElements.empty) { |
39 | 43 | ||
40 | // Elements adding | 44 | // Elements adding |
41 | addExistingElementToProblem(p,i) | 45 | addExistingElementToProblem(p,i,trace) |
42 | 46 | ||
43 | // Types | 47 | // Types |
44 | for(partialTypeDeclaration : i.partialtypeinterpratation) { | 48 | for(partialTypeDeclaration : i.partialtypeinterpratation) { |
@@ -48,12 +52,13 @@ class PartialInterpretation2Logic { | |||
48 | 52 | ||
49 | // Relations | 53 | // Relations |
50 | for(partialRelationInterpretation : i.partialrelationinterpretation) { | 54 | for(partialRelationInterpretation : i.partialrelationinterpretation) { |
55 | //println(partialRelationInterpretation.interpretationOf.name) | ||
51 | relationLinksToAssertion(p,partialRelationInterpretation,trace) | 56 | relationLinksToAssertion(p,partialRelationInterpretation,trace) |
52 | } | 57 | } |
53 | } | 58 | } |
54 | } | 59 | } |
55 | 60 | ||
56 | private def addExistingElementToProblem(LogicProblem p, PartialInterpretation i) { | 61 | private def addExistingElementToProblem(LogicProblem p, PartialInterpretation i,PartialInterpretation2Logic_Trace trace) { |
57 | val newElements = new ArrayList(i.newElements) | 62 | val newElements = new ArrayList(i.newElements) |
58 | var newElementIndex = 1 | 63 | var newElementIndex = 1 |
59 | for(newElement : newElements) { | 64 | for(newElement : newElements) { |
@@ -136,6 +141,8 @@ class PartialInterpretation2Logic { | |||
136 | links.map[link|createLink(link,relation)].And | 141 | links.map[link|createLink(link,relation)].And |
137 | } | 142 | } |
138 | val assertion = Assertion('''PartialInterpretation «r.interpretationOf.name»''',term) | 143 | val assertion = Assertion('''PartialInterpretation «r.interpretationOf.name»''',term) |
144 | //val error= assertion.eAllContents.toIterable.filter(SymbolicValue).filter[it.symbolicReference === null] | ||
145 | //error.forEach[println("error")] | ||
139 | p.add(assertion) | 146 | p.add(assertion) |
140 | } | 147 | } |
141 | 148 | ||
@@ -143,11 +150,15 @@ class PartialInterpretation2Logic { | |||
143 | 150 | ||
144 | def private createLink(RelationLink link, SymbolicDeclaration relationDeclaration) { | 151 | def private createLink(RelationLink link, SymbolicDeclaration relationDeclaration) { |
145 | if(link instanceof BinaryElementRelationLink) { | 152 | if(link instanceof BinaryElementRelationLink) { |
146 | return createSymbolicValue=>[ | 153 | if((link.param1 !== null) && (link.param2 !== null)) { |
147 | it.symbolicReference=relationDeclaration | 154 | return createSymbolicValue=>[ |
148 | it.parameterSubstitutions += createSymbolicValue => [link.param1] | 155 | it.symbolicReference=relationDeclaration |
149 | it.parameterSubstitutions += createSymbolicValue => [link.param2] | 156 | it.parameterSubstitutions += createSymbolicValue => [it.symbolicReference = link.param1] |
150 | ] | 157 | it.parameterSubstitutions += createSymbolicValue => [it.symbolicReference = link.param2] |
158 | ] | ||
159 | } else { | ||
160 | throw new IllegalArgumentException | ||
161 | } | ||
151 | } else throw new UnsupportedOperationException | 162 | } else throw new UnsupportedOperationException |
152 | } | 163 | } |
153 | } \ No newline at end of file | 164 | } \ No newline at end of file |