diff options
Diffstat (limited to 'Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/FAMTest.xtend')
-rw-r--r-- | Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/FAMTest.xtend | 68 |
1 files changed, 43 insertions, 25 deletions
diff --git a/Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/FAMTest.xtend b/Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/FAMTest.xtend index 4efbc821..1045189c 100644 --- a/Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/FAMTest.xtend +++ b/Tests/ca.mcgill.ecse.dslreasoner.vampire.test/src/ca/mcgill/ecse/dslreasoner/vampire/icse/FAMTest.xtend | |||
@@ -2,7 +2,6 @@ package ca.mcgill.ecse.dslreasoner.vampire.icse | |||
2 | 2 | ||
3 | import ca.mcgill.ecse.dslreasoner.vampire.reasoner.VampireSolver | 3 | import ca.mcgill.ecse.dslreasoner.vampire.reasoner.VampireSolver |
4 | import ca.mcgill.ecse.dslreasoner.vampire.reasoner.VampireSolverConfiguration | 4 | import ca.mcgill.ecse.dslreasoner.vampire.reasoner.VampireSolverConfiguration |
5 | import ca.mcgill.ecse.dslreasoner.vampire.reasoner.builder.VampireModelInterpretation | ||
6 | import functionalarchitecture.Function | 5 | import functionalarchitecture.Function |
7 | import functionalarchitecture.FunctionalArchitectureModel | 6 | import functionalarchitecture.FunctionalArchitectureModel |
8 | import functionalarchitecture.FunctionalInterface | 7 | import functionalarchitecture.FunctionalInterface |
@@ -16,18 +15,22 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logicresult.ModelResult | |||
16 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore | 15 | import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore |
17 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic | 16 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic |
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic | 17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic |
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2PartialInterpretation | ||
19 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | ||
21 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualiser | ||
19 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace | 22 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace |
20 | import java.util.HashMap | 23 | import java.util.HashMap |
21 | import java.util.List | ||
22 | import org.eclipse.emf.ecore.resource.Resource | 24 | import org.eclipse.emf.ecore.resource.Resource |
23 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | 25 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl |
24 | 26 | ||
25 | class FAMTest { | 27 | class FAMTest { |
26 | def static void main(String[] args) { | 28 | def static void main(String[] args) { |
27 | val Ecore2Logic ecore2Logic = new Ecore2Logic | 29 | val Ecore2Logic ecore2Logic = new Ecore2Logic |
28 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) | 30 | val Logic2Ecore logic2Ecore = new Logic2Ecore(ecore2Logic) |
29 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) | 31 | val Viatra2Logic viatra2Logic = new Viatra2Logic(ecore2Logic) |
30 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic | 32 | val InstanceModel2Logic instanceModel2Logic = new InstanceModel2Logic |
33 | val InstanceModel2PartialInterpretation im2pi = new InstanceModel2PartialInterpretation | ||
31 | 34 | ||
32 | // Workspace setup | 35 | // Workspace setup |
33 | val inputs = new FileSystemWorkspace('''initialModels/''', "") | 36 | val inputs = new FileSystemWorkspace('''initialModels/''', "") |
@@ -56,8 +59,8 @@ class FAMTest { | |||
56 | workspace.writeModel(problem, "Fam.logicproblem") | 59 | workspace.writeModel(problem, "Fam.logicproblem") |
57 | 60 | ||
58 | println("Problem created") | 61 | println("Problem created") |
59 | 62 | ||
60 | //Start Time | 63 | // Start Time |
61 | var startTime = System.currentTimeMillis | 64 | var startTime = System.currentTimeMillis |
62 | 65 | ||
63 | var VampireSolver reasoner | 66 | var VampireSolver reasoner |
@@ -71,16 +74,16 @@ class FAMTest { | |||
71 | // classMapMin.put(Function, 1) | 74 | // classMapMin.put(Function, 1) |
72 | // classMapMin.put(FunctionalInterface, 2) | 75 | // classMapMin.put(FunctionalInterface, 2) |
73 | classMapMin.put(FunctionalOutput, 3) | 76 | classMapMin.put(FunctionalOutput, 3) |
74 | 77 | ||
75 | val typeMapMin = GeneralTest.getTypeMap(classMapMin, metamodel, ecore2Logic, modelGenerationProblem.trace) | 78 | val typeMapMin = GeneralTest.getTypeMap(classMapMin, metamodel, ecore2Logic, modelGenerationProblem.trace) |
76 | 79 | ||
77 | // Maximum Scope | 80 | // Maximum Scope |
78 | val classMapMax = new HashMap<Class, Integer> | 81 | val classMapMax = new HashMap<Class, Integer> |
79 | classMapMax.put(FunctionalArchitectureModel, 3) | 82 | classMapMax.put(FunctionalArchitectureModel, 3) |
80 | classMapMax.put(Function, 5) | 83 | classMapMax.put(Function, 5) |
81 | classMapMax.put(FunctionalInterface, 3) | 84 | classMapMax.put(FunctionalInterface, 3) |
82 | classMapMax.put(FunctionalOutput, 4) | 85 | classMapMax.put(FunctionalOutput, 4) |
83 | 86 | ||
84 | val typeMapMax = GeneralTest.getTypeMap(classMapMax, metamodel, ecore2Logic, modelGenerationProblem.trace) | 87 | val typeMapMax = GeneralTest.getTypeMap(classMapMax, metamodel, ecore2Logic, modelGenerationProblem.trace) |
85 | 88 | ||
86 | // Define Config File | 89 | // Define Config File |
@@ -88,27 +91,43 @@ class FAMTest { | |||
88 | // add configuration things, in config file first | 91 | // add configuration things, in config file first |
89 | it.documentationLevel = DocumentationLevel::FULL | 92 | it.documentationLevel = DocumentationLevel::FULL |
90 | 93 | ||
91 | it.typeScopes.minNewElements = 24 | 94 | it.typeScopes.minNewElements = 4//24 |
92 | it.typeScopes.maxNewElements = 25 | 95 | it.typeScopes.maxNewElements = 5//25 |
93 | if(typeMapMin.size != 0) it.typeScopes.minNewElementsByType = typeMapMin | 96 | // if(typeMapMin.size != 0) it.typeScopes.minNewElementsByType = typeMapMin |
94 | if(typeMapMin.size != 0) it.typeScopes.maxNewElementsByType = typeMapMax | 97 | // if(typeMapMin.size != 0) it.typeScopes.maxNewElementsByType = typeMapMax |
95 | it.contCycleLevel = 5 | 98 | it.contCycleLevel = 5 |
96 | it.uniquenessDuplicates = false | 99 | it.uniquenessDuplicates = false |
97 | ] | 100 | ] |
98 | 101 | ||
99 | var LogicResult solution = reasoner.solve(problem, vampireConfig, workspace) | 102 | var LogicResult solution = reasoner.solve(problem, vampireConfig, workspace) |
100 | |||
101 | //visualisation, see | ||
102 | var interpretations = reasoner.getInterpretations(solution as ModelResult) | ||
103 | interpretations.get(0) as VampireModelInterpretation | ||
104 | println(ecore2Logic.allAttributesInScope(modelGenerationProblem.trace)) | ||
105 | |||
106 | // for(interpretation : interpretations) { | ||
107 | // val model = logic2Ecore.transformInterpretation(interpretation,modelGenerationProblem.trace) | ||
108 | // //look here: hu.bme.mit.inf.dslreasoner.application.execution.GenerationTaskExecutor | ||
109 | // } | ||
110 | //transform interpretation to ecore, and it is easy from there | ||
111 | 103 | ||
104 | // visualisation, see | ||
105 | var interpretations = reasoner.getInterpretations(solution as ModelResult) | ||
106 | // interpretations.get(0) as VampireModelInterpretation | ||
107 | // println(ecore2Logic.IsAttributeValue(modelGenerationProblem.trace, ) | ||
108 | // Literal(modelGenerationProblem.trace, ecore2Logic.allLiteralsInScope(modelGenerationProblem.trace).get(0) ) | ||
109 | // ) | ||
110 | // println((ecore2Logic.allAttributesInScope(modelGenerationProblem.trace)).get(0).EAttributeType) | ||
111 | for (interpretation : interpretations) { | ||
112 | val model = logic2Ecore.transformInterpretation(interpretation, modelGenerationProblem.trace) | ||
113 | workspace.writeModel(model, "model.xmi") | ||
114 | |||
115 | val representation = im2pi.transform(modelGenerationProblem, model.eAllContents.toList, false)//solution.representation.get(0) // TODO: fix for multiple represenations | ||
116 | if (representation instanceof PartialInterpretation) { | ||
117 | val vis1 = new PartialInterpretation2Gml | ||
118 | val gml = vis1.transform(representation) | ||
119 | workspace.writeText("model.gml", gml) | ||
120 | |||
121 | val vis2 = new GraphvizVisualiser | ||
122 | val dot = vis2.visualiseConcretization(representation) | ||
123 | dot.writeToFile(workspace, "model.png") | ||
124 | } else { | ||
125 | println("ERROR") | ||
126 | } | ||
127 | // look here: hu.bme.mit.inf.dslreasoner.application.execution.GenerationTaskExecutor | ||
128 | } | ||
129 | |||
130 | // transform interpretation to ecore, and it is easy from there | ||
112 | /*/ | 131 | /*/ |
113 | * | 132 | * |
114 | * reasoner = new AlloySolver | 133 | * reasoner = new AlloySolver |
@@ -121,8 +140,7 @@ class FAMTest { | |||
121 | * ] | 140 | * ] |
122 | * solution = reasoner.solve(problem, alloyConfig, workspace) | 141 | * solution = reasoner.solve(problem, alloyConfig, workspace) |
123 | //*/ | 142 | //*/ |
124 | // ///////////////////////////////////////////////////// | 143 | // ///////////////////////////////////////////////////// |
125 | |||
126 | var totalTimeMin = (System.currentTimeMillis - startTime) / 60000 | 144 | var totalTimeMin = (System.currentTimeMillis - startTime) / 60000 |
127 | var totalTimeSec = ((System.currentTimeMillis - startTime) / 1000) % 60 | 145 | var totalTimeSec = ((System.currentTimeMillis - startTime) / 1000) % 60 |
128 | 146 | ||