diff options
author | 2018-02-28 18:13:31 -0500 | |
---|---|---|
committer | 2018-02-28 18:13:31 -0500 | |
commit | c05d5d65970b7d55f296bf7d3ec7bc3c134a7efc (patch) | |
tree | c748edd0a274bc5de3d7a1d3390a15a1a47a6d9a /Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme | |
parent | removed maven + added refresh() to filesystem (diff) | |
download | VIATRA-Generator-c05d5d65970b7d55f296bf7d3ec7bc3c134a7efc.tar.gz VIATRA-Generator-c05d5d65970b7d55f296bf7d3ec7bc3c134a7efc.tar.zst VIATRA-Generator-c05d5d65970b7d55f296bf7d3ec7bc3c134a7efc.zip |
fixed default model number overriding custom value + added visualisation
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme')
2 files changed, 53 insertions, 15 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend index 44d9fab0..33f59413 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/GenerationTaskExecutor.xtend | |||
@@ -14,6 +14,9 @@ import hu.bme.mit.inf.dslreasoner.logic2ecore.Logic2Ecore | |||
14 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic | 14 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2Logic |
15 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration | 15 | import hu.bme.mit.inf.dslreasoner.viatra2logic.Viatra2LogicConfiguration |
16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic | 16 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2Logic |
17 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation | ||
18 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | ||
19 | import hu.bme.mit.inf.dslreasoner.visualisation.pi2graphviz.GraphvizVisualisation; | ||
17 | import hu.bme.mit.inf.dslreasoner.workspace.ProjectWorkspace | 20 | import hu.bme.mit.inf.dslreasoner.workspace.ProjectWorkspace |
18 | import java.util.Optional | 21 | import java.util.Optional |
19 | import org.eclipse.emf.common.util.URI | 22 | import org.eclipse.emf.common.util.URI |
@@ -51,6 +54,19 @@ class GenerationTaskExecutor { | |||
51 | val memoryLimit = scriptExecutor.getMemoryLimit(configSpecification) | 54 | val memoryLimit = scriptExecutor.getMemoryLimit(configSpecification) |
52 | // 2. create console | 55 | // 2. create console |
53 | 56 | ||
57 | val reasonerWorkspace = if(debugFolder!== null) { | ||
58 | new ProjectWorkspace(debugFolder.path,"") | ||
59 | } else { | ||
60 | new NullWorkspace | ||
61 | } | ||
62 | reasonerWorkspace.initAndClear | ||
63 | val outputWorkspace = if(outputFolder !== null) { | ||
64 | new ProjectWorkspace(outputFolder.path,"") | ||
65 | } else { | ||
66 | new NullWorkspace | ||
67 | } | ||
68 | outputWorkspace.initAndClear | ||
69 | |||
54 | val console = new ScriptConsole(true,true, | 70 | val console = new ScriptConsole(true,true, |
55 | if(messageFile!==null) URI.createURI(messageFile.path) else null, | 71 | if(messageFile!==null) URI.createURI(messageFile.path) else null, |
56 | if(debugFolder!==null) URI.createURI('''«debugFolder.path»/errors.txt''') else null, | 72 | if(debugFolder!==null) URI.createURI('''«debugFolder.path»/errors.txt''') else null, |
@@ -96,27 +112,22 @@ class GenerationTaskExecutor { | |||
96 | new Viatra2LogicConfiguration | 112 | new Viatra2LogicConfiguration |
97 | ).output | 113 | ).output |
98 | } | 114 | } |
115 | if(documentationLevel.atLeastNormal) { | ||
116 | reasonerWorkspace.writeModel(problem,"generation.logicproblem") | ||
117 | } | ||
99 | 118 | ||
100 | // 5. create a solver and a configuration | 119 | // 5. create a solver and a configuration |
101 | // 5.1 initialize | 120 | // 5.1 initialize |
102 | val solver = solverLoader.loadSolver(task.solver,configurationMap) | 121 | val solver = solverLoader.loadSolver(task.solver,configurationMap) |
103 | val solverConfig = solverLoader.loadSolverConfig(task.solver,configurationMap,console) | 122 | val solverConfig = solverLoader.loadSolverConfig(task.solver,configurationMap,console) |
104 | val reasonerWorkspace = if(debugFolder!== null) { | 123 | |
105 | new ProjectWorkspace(debugFolder.path,"") | ||
106 | } else { | ||
107 | new NullWorkspace | ||
108 | } | ||
109 | reasonerWorkspace.initAndClear | ||
110 | if(documentationLevel.atLeastNormal) { | ||
111 | reasonerWorkspace.writeModel(problem,"generation.logicproblem") | ||
112 | } | ||
113 | 124 | ||
114 | // 5.2 set values that defined directly | 125 | // 5.2 set values that defined directly |
115 | solverConfig.solutionScope = new SolutionScope => [ | 126 | solverConfig.solutionScope = new SolutionScope => [ |
116 | it.numberOfRequiredSolution = if(task.numberSpecified) { | 127 | it.numberOfRequiredSolution = if(task.numberSpecified) { |
117 | 1 | ||
118 | } else { | ||
119 | task.number | 128 | task.number |
129 | } else { | ||
130 | 1 | ||
120 | } | 131 | } |
121 | ] | 132 | ] |
122 | solverConfig.typeScopes = scopeLoader.loadScope( | 133 | solverConfig.typeScopes = scopeLoader.loadScope( |
@@ -146,6 +157,7 @@ class GenerationTaskExecutor { | |||
146 | reasonerWorkspace | 157 | reasonerWorkspace |
147 | } | 158 | } |
148 | 159 | ||
160 | |||
149 | // 7. Solver call | 161 | // 7. Solver call |
150 | 162 | ||
151 | val solution = solver.solve(problem,solverConfig,reasonerWorkspaceForRun) | 163 | val solution = solver.solve(problem,solverConfig,reasonerWorkspaceForRun) |
@@ -156,6 +168,33 @@ class GenerationTaskExecutor { | |||
156 | if(solution instanceof ModelResult) { | 168 | if(solution instanceof ModelResult) { |
157 | // | 169 | // |
158 | val interpretations = solver.getInterpretations(solution) | 170 | val interpretations = solver.getInterpretations(solution) |
171 | val outputWorkspaceForRun = if(runs > 1) { | ||
172 | outputWorkspace.subWorkspace('''run«run»''',"") => [initAndClear] | ||
173 | } else { | ||
174 | outputWorkspace | ||
175 | } | ||
176 | |||
177 | for(interpretationIndex : 0..<interpretations.size) { | ||
178 | val interpretation = interpretations.get(interpretationIndex) | ||
179 | val model = logic2Ecore.transformInterpretation(interpretation,modelGeneration.trace) | ||
180 | outputWorkspaceForRun.writeModel(model,'''model«IF runs>1»_«run»«ENDIF»_«interpretationIndex».xmi''') | ||
181 | |||
182 | val representation = solution.representation.get(interpretationIndex) | ||
183 | if(representation instanceof PartialInterpretation) { | ||
184 | val vis1 = new PartialInterpretation2Gml | ||
185 | val gml = vis1.transform(representation) | ||
186 | outputWorkspaceForRun.writeText('''model«IF runs>1»_«run»«ENDIF»_«interpretationIndex».gml''',gml) | ||
187 | if(representation.newElements.size + representation.problem.elements.size < 150) { | ||
188 | val vis2 = new GraphvizVisualisation | ||
189 | val dot = vis2.visualiseConcretization(representation) | ||
190 | dot.writeToFile(outputWorkspaceForRun,'''model«IF runs>1»_«run»«ENDIF»_«interpretationIndex»''') | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | |||
195 | for(representation : solution.representation) { | ||
196 | |||
197 | } | ||
159 | } | 198 | } |
160 | 199 | ||
161 | } | 200 | } |
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ModelLoader.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ModelLoader.xtend index ca674280..350901ea 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ModelLoader.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/execution/ModelLoader.xtend | |||
@@ -1,10 +1,9 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.execution | 1 | package hu.bme.mit.inf.dslreasoner.application.execution |
2 | 2 | ||
3 | import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl | ||
4 | import org.eclipse.emf.common.util.URI | ||
5 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.PartialModelSpecification | 3 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.PartialModelSpecification |
6 | import org.eclipse.emf.ecore.EObject | ||
7 | import java.util.List | 4 | import java.util.List |
5 | import org.eclipse.emf.common.util.URI | ||
6 | import org.eclipse.emf.ecore.EObject | ||
8 | 7 | ||
9 | class ModelLoader { | 8 | class ModelLoader { |
10 | 9 | ||
@@ -20,7 +19,7 @@ class ModelLoader { | |||
20 | return null | 19 | return null |
21 | } | 20 | } |
22 | 21 | ||
23 | val resourceSet = new ResourceSetImpl | 22 | val resourceSet = specification.eResource.resourceSet |
24 | val resource = resourceSet.getResource(uri, true) | 23 | val resource = resourceSet.getResource(uri, true) |
25 | if (resource === null) { | 24 | if (resource === null) { |
26 | } else { | 25 | } else { |