diff options
Diffstat (limited to 'Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/GeneralTest.xtend')
-rw-r--r-- | Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/GeneralTest.xtend | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/GeneralTest.xtend b/Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/GeneralTest.xtend index 2c53d181..8a60f486 100644 --- a/Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/GeneralTest.xtend +++ b/Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/GeneralTest.xtend | |||
@@ -26,56 +26,74 @@ import org.eclipse.emf.ecore.EReference | |||
26 | import org.eclipse.emf.ecore.resource.Resource | 26 | import org.eclipse.emf.ecore.resource.Resource |
27 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | 27 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl |
28 | import org.eclipse.viatra.query.runtime.api.IQueryGroup | 28 | import org.eclipse.viatra.query.runtime.api.IQueryGroup |
29 | import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloySolver | ||
30 | import hu.bme.mit.inf.dlsreasoner.alloy.reasoner.AlloySolverConfiguration | ||
31 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | ||
29 | 32 | ||
30 | class GeneralTest { | 33 | class GeneralTest { |
31 | def static String createAndSolveProblem(EcoreMetamodelDescriptor metamodel, List<EObject> partialModel, ViatraQuerySetDescriptor queries, FileSystemWorkspace workspace) { | 34 | def static String createAndSolveProblem(EcoreMetamodelDescriptor metamodel, List<EObject> partialModel, |
35 | ViatraQuerySetDescriptor queries, FileSystemWorkspace workspace) { | ||
32 | val Ecore2Logic ecore2Logic = new Ecore2Logic | 36 | val Ecore2Logic ecore2Logic = new Ecore2Logic |
33 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) | 37 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) |
34 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) | 38 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) |
35 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic | 39 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic |
36 | 40 | ||
37 | val modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel,new Ecore2LogicConfiguration()) | 41 | val modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, new Ecore2LogicConfiguration()) |
38 | var problem = instanceModel2Logic.transform(modelGenerationProblem,partialModel).output | 42 | var problem = instanceModel2Logic.transform(modelGenerationProblem, partialModel).output |
39 | problem = viatra2Logic.transformQueries(queries,modelGenerationProblem,new Viatra2LogicConfiguration).output | 43 | problem = viatra2Logic.transformQueries(queries, modelGenerationProblem, new Viatra2LogicConfiguration).output |
40 | 44 | ||
41 | workspace.writeModel(problem, "Fam.logicproblem") | 45 | workspace.writeModel(problem, "Fam.logicproblem") |
42 | 46 | ||
43 | println("Problem created") | 47 | println("Problem created") |
44 | 48 | ||
45 | var LogicResult solution | 49 | var LogicResult solution |
46 | var LogicReasoner reasoner | 50 | var LogicReasoner reasoner |
51 | |||
47 | //* | 52 | //* |
48 | reasoner = new VampireSolver | 53 | reasoner = new VampireSolver |
49 | val vampireConfig = new VampireSolverConfiguration => [ | 54 | val vampireConfig = new VampireSolverConfiguration => [ |
50 | //add configuration things, in config file first | 55 | // add configuration things, in config file first |
51 | it.writeToFile = true | 56 | it.documentationLevel = DocumentationLevel::FULL |
57 | it.typeScopes.minNewElements = 5 | ||
52 | ] | 58 | ] |
59 | solution = reasoner.solve(problem, vampireConfig, workspace) | ||
53 | 60 | ||
54 | solution = reasoner.solve(problem, vampireConfig, workspace) | 61 | /*/ |
55 | 62 | ||
63 | reasoner = new AlloySolver | ||
64 | val alloyConfig = new AlloySolverConfiguration => [ | ||
65 | it.typeScopes.maxNewElements = 7 | ||
66 | it.typeScopes.minNewElements = 3 | ||
67 | it.solutionScope.numberOfRequiredSolution = 1 | ||
68 | it.typeScopes.maxNewIntegers = 0 | ||
69 | it.documentationLevel = DocumentationLevel::NORMAL | ||
70 | ] | ||
71 | solution = reasoner.solve(problem, alloyConfig, workspace) | ||
72 | //*/ | ||
73 | |||
56 | println("Problem solved") | 74 | println("Problem solved") |
57 | } | 75 | } |
58 | 76 | ||
59 | def static loadMetamodel(EPackage pckg) { | 77 | def static loadMetamodel(EPackage pckg) { |
60 | val List<EClass> classes = pckg.getEClassifiers.filter(EClass).toList | 78 | val List<EClass> classes = pckg.getEClassifiers.filter(EClass).toList |
61 | val List<EEnum> enums = pckg.getEClassifiers.filter(EEnum).toList | 79 | val List<EEnum> enums = pckg.getEClassifiers.filter(EEnum).toList |
62 | val List<EEnumLiteral> literals = enums.map[getELiterals].flatten.toList | 80 | val List<EEnumLiteral> literals = enums.map[getELiterals].flatten.toList |
63 | val List<EReference> references = classes.map[getEReferences].flatten.toList | 81 | val List<EReference> references = classes.map[getEReferences].flatten.toList |
64 | val List<EAttribute> attributes = classes.map[getEAttributes].flatten.toList | 82 | val List<EAttribute> attributes = classes.map[getEAttributes].flatten.toList |
65 | return new EcoreMetamodelDescriptor(classes,#{},false,enums,literals,references,attributes) | 83 | return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes) |
66 | } | 84 | } |
67 | 85 | ||
68 | def static loadPartialModel(ReasonerWorkspace inputs, String path) { | 86 | def static loadPartialModel(ReasonerWorkspace inputs, String path) { |
69 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()); | 87 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()); |
70 | inputs.readModel(EObject,path).eResource.contents | 88 | inputs.readModel(EObject, path).eResource.contents |
71 | // inputs.readModel(EObject,"FamInstance.xmi").eResource.allContents.toList | 89 | // inputs.readModel(EObject,"FamInstance.xmi").eResource.allContents.toList |
72 | } | 90 | } |
73 | 91 | ||
74 | def static loadQueries(EcoreMetamodelDescriptor metamodel, IQueryGroup i) { | 92 | def static loadQueries(EcoreMetamodelDescriptor metamodel, IQueryGroup i) { |
75 | val patterns = i.specifications.toList | 93 | val patterns = i.specifications.toList |
76 | val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name== "Constraint"]].toSet | 94 | val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet |
77 | val derivedFeatures = emptyMap | 95 | val derivedFeatures = emptyMap |
78 | //NO DERIVED FEATURES | 96 | // NO DERIVED FEATURES |
79 | // val derivedFeatures = new LinkedHashMap | 97 | // val derivedFeatures = new LinkedHashMap |
80 | // derivedFeatures.put(i.type,metamodel.attributes.filter[it.name == "type"].head) | 98 | // derivedFeatures.put(i.type,metamodel.attributes.filter[it.name == "type"].head) |
81 | // derivedFeatures.put(i.model,metamodel.references.filter[it.name == "model"].head) | 99 | // derivedFeatures.put(i.model,metamodel.references.filter[it.name == "model"].head) |
@@ -86,4 +104,4 @@ class GeneralTest { | |||
86 | ) | 104 | ) |
87 | return res | 105 | return res |
88 | } | 106 | } |
89 | } \ No newline at end of file | 107 | } |