aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/GeneralTest.xtend
diff options
context:
space:
mode:
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.xtend117
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 @@
1package ca.mcgill.ecse.dslreasoner.vampire.icse 1package ca.mcgill.ecse.dslreasoner.vampire.icse
2 2
3import ca.mcgill.ecse.dslreasoner.vampire.reasoner.VampireSolver
4import ca.mcgill.ecse.dslreasoner.vampire.reasoner.VampireSolverConfiguration
5import ca.mcgill.ecse.dslreasoner.vampireLanguage.VampireLanguageFactory
6import functionalarchitecture.Function
7import functionalarchitecture.FunctionalInterface
8import functionalarchitecture.FunctionalOutput
9import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic 3import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic
10import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration 4import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic_Trace
11import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor 5import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor
12import hu.bme.mit.inf.dslreasoner.logic.model.builder.LogicReasoner
13import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type 6import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
14import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.LogicResult
15import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore
16import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic
17import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor 7import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor
18import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic
19import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace
20import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace 8import hu.bme.mit.inf.dslreasoner.workspace.ReasonerWorkspace
21import java.util.HashMap 9import java.util.HashMap
22import java.util.List 10import java.util.List
11import java.util.Map
23import org.eclipse.emf.ecore.EAttribute 12import org.eclipse.emf.ecore.EAttribute
24import org.eclipse.emf.ecore.EClass 13import org.eclipse.emf.ecore.EClass
25import org.eclipse.emf.ecore.EEnum 14import org.eclipse.emf.ecore.EEnum
@@ -30,100 +19,18 @@ import org.eclipse.emf.ecore.EReference
30import org.eclipse.emf.ecore.resource.Resource 19import org.eclipse.emf.ecore.resource.Resource
31import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl 20import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
32import org.eclipse.viatra.query.runtime.api.IQueryGroup 21import org.eclipse.viatra.query.runtime.api.IQueryGroup
33import hu.bme.mit.inf.dslreasoner.logic.model.builder.DocumentationLevel
34 22
35class GeneralTest { 23class 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) {