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 | 117 |
1 files changed, 12 insertions, 105 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 949abe87..89375801 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 | |||
@@ -1,25 +1,14 @@ | |||
1 | package ca.mcgill.ecse.dslreasoner.vampire.icse | 1 | package ca.mcgill.ecse.dslreasoner.vampire.icse |
2 | 2 | ||
3 | import ca.mcgill.ecse.dslreasoner.vampire.reasoner.VampireSolver | ||
4 | import ca.mcgill.ecse.dslreasoner.vampire.reasoner.VampireSolverConfiguration | ||
5 | import ca.mcgill.ecse.dslreasoner.vampireLanguage.VampireLanguageFactory | ||
6 | import functionalarchitecture.Function | ||
7 | import functionalarchitecture.FunctionalInterface | ||
8 | import functionalarchitecture.FunctionalOutput | ||
9 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | 3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic |
10 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration | 4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace |
11 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor | 5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor |
12 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner | ||
13 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type | 6 | import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type |
14 | import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult | ||
15 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore | ||
16 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic | ||
17 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor | 7 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor |
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic | ||
19 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace | ||
20 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace | 8 | import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace |
21 | import java.util.HashMap | 9 | import java.util.HashMap |
22 | import java.util.List | 10 | import java.util.List |
11 | import java.util.Map | ||
23 | import org.eclipse.emf.ecore.EAttribute | 12 | import org.eclipse.emf.ecore.EAttribute |
24 | import org.eclipse.emf.ecore.EClass | 13 | import org.eclipse.emf.ecore.EClass |
25 | import org.eclipse.emf.ecore.EEnum | 14 | import org.eclipse.emf.ecore.EEnum |
@@ -30,100 +19,18 @@ import org.eclipse.emf.ecore.EReference | |||
30 | import org.eclipse.emf.ecore.resource.Resource | 19 | import org.eclipse.emf.ecore.resource.Resource |
31 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | 20 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl |
32 | import org.eclipse.viatra.query.runtime.api.IQueryGroup | 21 | import org.eclipse.viatra.query.runtime.api.IQueryGroup |
33 | import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel | ||
34 | 22 | ||
35 | class GeneralTest { | 23 | class GeneralTest { |
36 | def static String createAndSolveProblem(EcoreMetamodelDescriptor metamodel, List<EObject> partialModel, | 24 | def static Map<Type, Integer> getTypeMap(Map<Class, Integer> classMap, EcoreMetamodelDescriptor metamodel, Ecore2Logic e2l, Ecore2Logic_Trace trace) { |
37 | ViatraQuerySetDescriptor queries, FileSystemWorkspace workspace) { | 25 | val typeMap = new HashMap<Type, Integer> |
38 | val extension VampireLanguageFactory factory = VampireLanguageFactory.eINSTANCE | 26 | val listMap = metamodel.classes.toMap[s|s.name] |
39 | val Ecore2Logic ecore2Logic = new Ecore2Logic | ||
40 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) | ||
41 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) | ||
42 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic | ||
43 | |||
44 | val modelGenerationProblem = ecore2Logic.transformMetamodel(metamodel, new Ecore2LogicConfiguration()) | ||
45 | var problem = modelGenerationProblem.output | ||
46 | // problem = instanceModel2Logic.transform(modelGenerationProblem, partialModel).output | ||
47 | // problem = viatra2Logic.transformQueries(queries, modelGenerationProblem, new Viatra2LogicConfiguration).output | ||
48 | workspace.writeModel(problem, "Fam.logicproblem") | ||
49 | |||
50 | println("Problem created") | ||
51 | |||
52 | var startTime = System.currentTimeMillis | ||
53 | |||
54 | var LogicResult solution | ||
55 | var LogicReasoner reasoner | ||
56 | |||
57 | // * | ||
58 | reasoner = new VampireSolver | ||
59 | |||
60 | // Setting up scope | ||
61 | val typeMapMin = new HashMap<Type, Integer> | ||
62 | val typeMapMax = new HashMap<Type, Integer> | ||
63 | val list2MapMin = metamodel.classes.toMap[s|s.name] | ||
64 | val list2MapMax = metamodel.classes.toMap[s|s.name] | ||
65 | |||
66 | // Minimum Scope | ||
67 | typeMapMin.put(ecore2Logic.TypeofEClass(modelGenerationProblem.trace, | ||
68 | list2MapMin.get(Function.simpleName) | ||
69 | ), 1) | ||
70 | typeMapMin.put(ecore2Logic.TypeofEClass(modelGenerationProblem.trace, | ||
71 | list2MapMin.get(FunctionalInterface.simpleName) | ||
72 | ), 2) | ||
73 | typeMapMin.put(ecore2Logic.TypeofEClass(modelGenerationProblem.trace, | ||
74 | list2MapMin.get(FunctionalOutput.simpleName) | ||
75 | ), 3) | ||
76 | |||
77 | // Maximum Scope | ||
78 | typeMapMax.put(ecore2Logic.TypeofEClass( | ||
79 | modelGenerationProblem.trace, | ||
80 | list2MapMax.get(Function.simpleName) | ||
81 | ), 5) | ||
82 | typeMapMax.put(ecore2Logic.TypeofEClass( | ||
83 | modelGenerationProblem.trace, | ||
84 | list2MapMax.get(FunctionalInterface.simpleName) | ||
85 | ), 2) | ||
86 | typeMapMax.put(ecore2Logic.TypeofEClass( | ||
87 | modelGenerationProblem.trace, | ||
88 | list2MapMax.get(FunctionalOutput.simpleName) | ||
89 | ), 4) | ||
90 | |||
91 | // Configuration | ||
92 | val vampireConfig = new VampireSolverConfiguration => [ | ||
93 | // add configuration things, in config file first | ||
94 | it.documentationLevel = DocumentationLevel::FULL | ||
95 | it.typeScopes.minNewElements = 4 | ||
96 | it.typeScopes.maxNewElements = 25 | ||
97 | it.typeScopes.minNewElementsByType = typeMapMin | ||
98 | it.typeScopes.maxNewElementsByType = typeMapMax | ||
99 | it.contCycleLevel = 5 | ||
100 | it.uniquenessDuplicates = false | ||
101 | ] | ||
102 | solution = reasoner.solve(problem, vampireConfig, workspace) | ||
103 | |||
104 | /*/ | ||
105 | * | ||
106 | * reasoner = new AlloySolver | ||
107 | * val alloyConfig = new AlloySolverConfiguration => [ | ||
108 | * it.typeScopes.maxNewElements = 7 | ||
109 | * it.typeScopes.minNewElements = 3 | ||
110 | * it.solutionScope.numberOfRequiredSolution = 1 | ||
111 | * it.typeScopes.maxNewIntegers = 0 | ||
112 | * it.documentationLevel = DocumentationLevel::NORMAL | ||
113 | * ] | ||
114 | * solution = reasoner.solve(problem, alloyConfig, workspace) | ||
115 | //*/ | ||
116 | |||
117 | |||
118 | var totalTimeMin = (System.currentTimeMillis - startTime)/60000 | ||
119 | var totalTimeSec = ((System.currentTimeMillis - startTime)/1000)% 60 | ||
120 | |||
121 | println("Problem solved") | ||
122 | println("Time was: " + totalTimeMin + ":" + totalTimeSec) | ||
123 | |||
124 | |||
125 | |||
126 | 27 | ||
28 | for (Class elem : classMap.keySet) { | ||
29 | typeMap.put(e2l.TypeofEClass( | ||
30 | trace, listMap.get(elem.simpleName) | ||
31 | ), classMap.get(elem)) | ||
32 | } | ||
33 | return typeMap | ||
127 | } | 34 | } |
128 | 35 | ||
129 | def static loadMetamodel(EPackage pckg) { | 36 | def static loadMetamodel(EPackage pckg) { |