aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic
diff options
context:
space:
mode:
authorLibravatar Aren Babikian <aren.babikian@mail.mcgill.ca>2021-01-24 01:49:37 +0100
committerLibravatar Aren Babikian <aren.babikian@mail.mcgill.ca>2021-01-24 01:49:37 +0100
commit181d6443766d7b2212218b57183dce6af038c199 (patch)
tree5b19edfeb41bde2b8e4de48ddea679ade8158848 /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic
parentSorry, I forgot something last commit (diff)
downloadVIATRA-Generator-181d6443766d7b2212218b57183dce6af038c199.tar.gz
VIATRA-Generator-181d6443766d7b2212218b57183dce6af038c199.tar.zst
VIATRA-Generator-181d6443766d7b2212218b57183dce6af038c199.zip
Fix bug for ignored-attributes + better logic problem creation
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic')
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend99
-rw-r--r--Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend38
2 files changed, 109 insertions, 28 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend
index f74c2ab4..1e2bbe6d 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/InstanceModel2PartialInterpretation.xtend
@@ -25,6 +25,8 @@ import org.eclipse.emf.ecore.EObject
25import org.eclipse.emf.ecore.resource.Resource 25import org.eclipse.emf.ecore.resource.Resource
26 26
27import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* 27import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.*
28import org.eclipse.emf.ecore.EClass
29import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
28 30
29class InstanceModel2PartialInterpretation { 31class InstanceModel2PartialInterpretation {
30 val extension LogiclanguageFactory factory = LogiclanguageFactory.eINSTANCE 32 val extension LogiclanguageFactory factory = LogiclanguageFactory.eINSTANCE
@@ -123,26 +125,31 @@ class InstanceModel2PartialInterpretation {
123 // Transforming the attributes 125 // Transforming the attributes
124 for(attribute : source.eClass.EAllAttributes.filter[attributesUsed.contains(it) && !it.derived]) { 126 for(attribute : source.eClass.EAllAttributes.filter[attributesUsed.contains(it) && !it.derived]) {
125 val isIgnored = checkIfIgnored(source, attribute, ignoredAttribs) 127 val isIgnored = checkIfIgnored(source, attribute, ignoredAttribs)
126 if (!isIgnored) { 128 val type = ecore2Logic.relationOfAttribute(ecore2LogicTrace, attribute)
127 val type = ecore2Logic.relationOfAttribute(ecore2LogicTrace,attribute) 129 val interpretation = type.lookup(partialInterpretationTrace.relation2Interpretation)
128 val interpretation = type.lookup(partialInterpretationTrace.relation2Interpretation) 130 val sourceElement = source.lookup(object2DefinedElement)
129 val sourceElement = source.lookup(object2DefinedElement) 131 if (attribute.isMany) {
130 if(attribute.isMany) { 132 val listOfTargets = source.eGet(attribute) as List<? extends EObject>
131 val listOfTargets = source.eGet(attribute) as List<? extends EObject> 133 for (target : listOfTargets) {
132 for(target : listOfTargets) { 134 var DefinedElement value = null
133 val value = translateValue(target,ecore2LogicTrace,partialInterpretationTrace) 135 if (!isIgnored) value = translateValue(target, ecore2LogicTrace, partialInterpretationTrace)
134 if(value !== null) { 136 else value = createUnknownElement(partialInterpretation, target)
135 translateLink(interpretation,sourceElement,value) 137 if (value !== null) {
136 } 138 translateLink(interpretation, sourceElement, value)
137 } 139 }
138 } else { 140 }
139 val target = source.eGet(attribute) 141 } else {
140 if(target !== null) { 142 val target = source.eGet(attribute)
141 val value = translateValue(target,ecore2LogicTrace,partialInterpretationTrace) 143 if (target !== null) {
142 if(value !== null) { 144 if (!isIgnored) {
143 translateLink(interpretation,sourceElement,value) 145 val value = translateValue(target, ecore2LogicTrace, partialInterpretationTrace)
146 if (value !== null) {
147 translateLink(interpretation, sourceElement, value)
144 } 148 }
145 } 149 }
150 else translateLink(interpretation, sourceElement, createUnknownElement(partialInterpretation, target))
151// else value = null
152
146 } 153 }
147 } 154 }
148 } 155 }
@@ -190,11 +197,18 @@ class InstanceModel2PartialInterpretation {
190 ) { 197 ) {
191 val classInIgnored = ignoredAttribs.get(object.eClass.name) 198 val classInIgnored = ignoredAttribs.get(object.eClass.name)
192 val mayIgnored = ( 199 val mayIgnored = (
200 classInIgnored !== null && classInIgnored.containsKey("*")
201 ||
193 classInIgnored !== null && classInIgnored.containsKey(attribute.name)) 202 classInIgnored !== null && classInIgnored.containsKey(attribute.name))
194 203
195 var isIgnored = false 204 var isIgnored = false
196 if (mayIgnored) { 205 if (mayIgnored) {
197 val specificIgnoredValue = classInIgnored.get(attribute.name) 206 var String specificIgnoredValue = null
207 if (classInIgnored.containsKey("*"))
208 specificIgnoredValue = classInIgnored.get("*")
209 else
210 specificIgnoredValue = classInIgnored.get(attribute.name)
211
198 if (specificIgnoredValue.equals("*")) 212 if (specificIgnoredValue.equals("*"))
199 isIgnored = true 213 isIgnored = true
200 else { 214 else {
@@ -208,10 +222,10 @@ class InstanceModel2PartialInterpretation {
208 } 222 }
209 // DEBUG 223 // DEBUG
210 if (isIgnored) { 224 if (isIgnored) {
211 println("IGNORED") 225// println("IGNORED")
212 println(object) 226// println(object)
213 println(attribute) 227// println(attribute)
214 println(object.eGet(attribute)) 228// println(object.eGet(attribute))
215 } 229 }
216 // END DEBUG 230 // END DEBUG
217 return isIgnored 231 return isIgnored
@@ -276,4 +290,45 @@ class InstanceModel2PartialInterpretation {
276 dispatch protected def translateValue(String value, Ecore2Logic_Trace ecore2LogicTrace, Problem2PartialInterpretationTrace partialInterpretationTrace) { 290 dispatch protected def translateValue(String value, Ecore2Logic_Trace ecore2LogicTrace, Problem2PartialInterpretationTrace partialInterpretationTrace) {
277 value.lookup(partialInterpretationTrace.primitiveValues.stringMap) 291 value.lookup(partialInterpretationTrace.primitiveValues.stringMap)
278 } 292 }
293
294 dispatch protected def createUnknownElement(PartialInterpretation p, Enumerator value) {
295 throw new UnsupportedOperationException("Currently we do not support ignored Enums")
296 //TODO Unsure about this
297 }
298
299 dispatch protected def createUnknownElement(PartialInterpretation p, Boolean value) {
300 val e = createBooleanElement => [valueSet = false]
301 p.newElements += e
302 return e
303 }
304
305 dispatch protected def createUnknownElement(PartialInterpretation p, Integer value) {
306 val e = createIntegerElement => [valueSet = false]
307 p.newElements += e
308 return e
309 }
310
311 dispatch protected def createUnknownElement(PartialInterpretation p, Short value) {
312 val e = createIntegerElement => [valueSet = false]
313 p.newElements += e
314 return e
315 }
316
317 dispatch protected def createUnknownElement(PartialInterpretation p, Double value) {
318 val e = createRealElement => [it.valueSet = false]
319 p.newElements += e
320 return e
321 }
322
323 dispatch protected def createUnknownElement(PartialInterpretation p, Float value) {
324 val e = createRealElement => [valueSet = false]
325 p.newElements += e
326 return e
327 }
328
329 dispatch protected def createUnknownElement(PartialInterpretation p, String value) {
330 val e = createStringElement => [valueSet = false]
331 p.newElements += e
332 return e
333 }
279} \ No newline at end of file 334} \ No newline at end of file
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend
index f15f5787..a2d2f625 100644
--- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend
+++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage/src/hu/bme/mit/inf/dslreasoner/viatrasolver/partialinterpretation2logic/PartialInterpretation2Logic.xtend
@@ -162,12 +162,22 @@ class PartialInterpretation2Logic {
162 162
163 def private createLink(RelationLink link, SymbolicDeclaration relationDeclaration) { 163 def private createLink(RelationLink link, SymbolicDeclaration relationDeclaration) {
164 if(link instanceof BinaryElementRelationLink) { 164 if(link instanceof BinaryElementRelationLink) {
165 if((link.param1 !== null) && (link.param2 !== null)) { 165 if ((link.param1 !== null) && (link.param2 !== null)) {
166 return createSymbolicValue=>[ 166 if (typeof(PrimitiveElement).isAssignableFrom(link.param2.class) &&
167 it.symbolicReference=relationDeclaration 167 !(link.param2 as PrimitiveElement).valueSet) {
168 it.parameterSubstitutions += createValueInLink(link.param1) 168 return createSymbolicValue => [
169 it.parameterSubstitutions += createValueInLink(link.param2) 169 it.symbolicReference = relationDeclaration
170 ] 170 it.parameterSubstitutions += createValueInLink(link.param1)
171 it.parameterSubstitutions += createUnkownValueInLink(link.param2)
172 ]
173 } else {
174 return createSymbolicValue => [
175 it.symbolicReference = relationDeclaration
176 it.parameterSubstitutions += createValueInLink(link.param1)
177 it.parameterSubstitutions += createValueInLink(link.param2)
178 ]
179 }
180
171 } else { 181 } else {
172 throw new IllegalArgumentException 182 throw new IllegalArgumentException
173 } 183 }
@@ -189,4 +199,20 @@ class PartialInterpretation2Logic {
189 def private dispatch createValueInLink(DefinedElement element) { 199 def private dispatch createValueInLink(DefinedElement element) {
190 return createSymbolicValue => [it.symbolicReference = element] 200 return createSymbolicValue => [it.symbolicReference = element]
191 } 201 }
202
203 def private dispatch createUnkownValueInLink(BooleanElement element) {
204 Exists[addVar(createBoolTypeReference)]
205 }
206 def private dispatch createUnkownValueInLink(IntegerElement element) {
207 Exists[addVar(createIntTypeReference)]
208 }
209 def private dispatch createUnkownValueInLink(RealElement element) {
210 Exists[addVar(createRealTypeReference)]
211 }
212 def private dispatch createUnkownValueInLink(StringElement element) {
213 throw new UnsupportedOperationException("Currently cannot create an unknown String")
214 }
215 def private dispatch createUnkownValueInLink(DefinedElement element) {
216 Exists[addVar(createComplexTypeReference => [it.referred = element.definedInType.get(0)])]
217 }
192} \ No newline at end of file 218} \ No newline at end of file