diff options
Diffstat (limited to 'Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icseTests/FAMTest.xtend')
-rw-r--r-- | Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icseTests/FAMTest.xtend | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icseTests/FAMTest.xtend b/Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icseTests/FAMTest.xtend new file mode 100644 index 00000000..a8b4dcfb --- /dev/null +++ b/Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icseTests/FAMTest.xtend | |||
@@ -0,0 +1,103 @@ | |||
1 | package ca.mcgill.ecse.dslreasoner.vampire.test | ||
2 | |||
3 | import ca.mcgill.ecse.dslreasoner.vampire.reasoner.VampireSolver | ||
4 | import ca.mcgill.ecse.dslreasoner.vampire.reasoner.VampireSolverConfiguration | ||
5 | import functionalarchitecture.FunctionalarchitecturePackage | ||
6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
7 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration | ||
8 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor | ||
9 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner | ||
10 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult | ||
11 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore | ||
12 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic | ||
13 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic | ||
14 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace | ||
15 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | ||
16 | import java.util.List | ||
17 | import org.eclipse.emf.ecore.EAttribute | ||
18 | import org.eclipse.emf.ecore.EClass | ||
19 | import org.eclipse.emf.ecore.EEnum | ||
20 | import org.eclipse.emf.ecore.EEnumLiteral | ||
21 | import org.eclipse.emf.ecore.EObject | ||
22 | import org.eclipse.emf.ecore.EReference | ||
23 | import org.eclipse.emf.ecore.resource.Resource | ||
24 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
25 | |||
26 | class DslTest { | ||
27 | def static void main(String[] args) { | ||
28 | val inputs = new FileSystemWorkspace('''initialModels/''', "") | ||
29 | val workspace = new FileSystemWorkspace('''outputDslModels/''', "") | ||
30 | workspace.initAndClear | ||
31 | |||
32 | println("Input and output workspaces are created") | ||
33 | |||
34 | val metamodel = loadMetamodel() | ||
35 | val partialModel = loadPartialModel(inputs) | ||
36 | // val queries = loadQueries(metamodel) | ||
37 | |||
38 | println("DSL loaded") | ||
39 | |||
40 | val Ecore2Logic ecore2Logic = new Ecore2Logic | ||
41 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) | ||
42 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) | ||
43 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic | ||
44 | |||
45 | val modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel,new Ecore2LogicConfiguration()) | ||
46 | // val modelExtensionProblem = instanceModel2Logic.transform(modelGenerationProblem,partialModel) | ||
47 | // val validModelExtensionProblem = viatra2Logic.transformQueries(queries,modelGenerationProblem,new Viatra2LogicConfiguration) | ||
48 | |||
49 | val logicProblem = modelGenerationProblem.output | ||
50 | // val logicProblem = modelExtensionProblem.output | ||
51 | // val logicProblem = validModelExtensionProblem.output | ||
52 | |||
53 | |||
54 | println("Problem created") | ||
55 | |||
56 | var LogicResult solution | ||
57 | var LogicReasoner reasoner | ||
58 | //* | ||
59 | reasoner = new VampireSolver | ||
60 | val vampireConfig = new VampireSolverConfiguration => [ | ||
61 | //add configuration things, in config file first | ||
62 | it.writeToFile = false | ||
63 | ] | ||
64 | |||
65 | solution = reasoner.solve(logicProblem, vampireConfig, workspace) | ||
66 | |||
67 | println("Problem solved") | ||
68 | |||
69 | |||
70 | } | ||
71 | |||
72 | def private static loadMetamodel() { | ||
73 | //FAM | ||
74 | val pckg = FunctionalarchitecturePackage.eINSTANCE | ||
75 | val List<EClass> classes = pckg.EClassifiers.filter(EClass).toList | ||
76 | val List<EEnum> enums = pckg.EClassifiers.filter(EEnum).toList | ||
77 | val List<EEnumLiteral> literals = enums.map[getELiterals].flatten.toList | ||
78 | val List<EReference> references = classes.map[getEReferences].flatten.toList | ||
79 | val List<EAttribute> attributes = classes.map[getEAttributes].flatten.toList | ||
80 | return new EcoreMetamodelDescriptor(classes,#{},false,enums,literals,references,attributes) | ||
81 | } | ||
82 | |||
83 | def private static loadPartialModel(ReasonerWorkspace inputs) { | ||
84 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()); | ||
85 | inputs.readModel(EObject,"FunctionalArchitectureModel.xmi").eResource.allContents.toList | ||
86 | // inputs.readModel(EObject,"FAM.xmi").eResource.allContents.toList | ||
87 | } | ||
88 | |||
89 | // def private static loadQueries(EcoreMetamodelDescriptor metamodel) { | ||
90 | // val i = hu.bme.mit.inf.dslreasoner.domains.transima.fam.patterns.Pattern.instance | ||
91 | // val patterns = i.specifications.toList | ||
92 | // val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name== "Constraint"]].toSet | ||
93 | // val derivedFeatures = new LinkedHashMap | ||
94 | // derivedFeatures.put(i.type,metamodel.attributes.filter[it.name == "type"].head) | ||
95 | // derivedFeatures.put(i.model,metamodel.references.filter[it.name == "model"].head) | ||
96 | // val res = new ViatraQuerySetDescriptor( | ||
97 | // patterns, | ||
98 | // wfPatterns, | ||
99 | // derivedFeatures | ||
100 | // ) | ||
101 | // return res | ||
102 | // } | ||
103 | } | ||