diff options
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run')
-rw-r--r-- | Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend | 81 |
1 files changed, 2 insertions, 79 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend index 859a4455..bd77634f 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src/run/GenerateFromConfig.xtend | |||
@@ -48,8 +48,8 @@ import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | |||
48 | import org.eclipse.viatra.query.runtime.api.IQueryGroup | 48 | import org.eclipse.viatra.query.runtime.api.IQueryGroup |
49 | 49 | ||
50 | class GenerateFromConfig { | 50 | class GenerateFromConfig { |
51 | static val SIZE_LB = 1 | 51 | static val SIZE_LB = 20 |
52 | static val SIZE_UB = 1 | 52 | static val SIZE_UB = 20 |
53 | static val SIZE_MUL = 1 | 53 | static val SIZE_MUL = 1 |
54 | static val SIZE_INC = 5 | 54 | static val SIZE_INC = 5 |
55 | 55 | ||
@@ -181,83 +181,6 @@ class GenerateFromConfig { | |||
181 | if(GLOBAL_WRT) global_writer.close | 181 | if(GLOBAL_WRT) global_writer.close |
182 | } | 182 | } |
183 | 183 | ||
184 | def static Map<Type, Integer> getTypeMap(Map<Class, Integer> classMap, EcoreMetamodelDescriptor metamodel, | ||
185 | Ecore2Logic e2l, Ecore2Logic_Trace trace) { | ||
186 | val typeMap = new HashMap<Type, Integer> | ||
187 | val listMap = metamodel.classes.toMap[s|s.name] | ||
188 | |||
189 | for (Class elem : classMap.keySet) { | ||
190 | typeMap.put(e2l.TypeofEClass( | ||
191 | trace, | ||
192 | listMap.get(elem.simpleName) | ||
193 | ), classMap.get(elem)) | ||
194 | } | ||
195 | return typeMap | ||
196 | } | ||
197 | |||
198 | def static loadMetamodel(EPackage pckg) { | ||
199 | val List<EClass> classes = pckg.getEClassifiers.filter(EClass).toList | ||
200 | val List<EEnum> enums = pckg.getEClassifiers.filter(EEnum).toList | ||
201 | val List<EEnumLiteral> literals = enums.map[getELiterals].flatten.toList | ||
202 | val List<EReference> references = classes.map[getEReferences].flatten.toList | ||
203 | val List<EAttribute> attributes = classes.map[getEAttributes].flatten.toList | ||
204 | return new EcoreMetamodelDescriptor(classes, #{}, false, enums, literals, references, attributes) | ||
205 | } | ||
206 | |||
207 | def static loadPartialModel(ReasonerWorkspace inputs, String path) { | ||
208 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()) | ||
209 | inputs.readModel(EObject, path).eResource.contents | ||
210 | // inputs.readModel(EObject,"FamInstance.xmi").eResource.allContents.toList | ||
211 | } | ||
212 | |||
213 | def static loadQueries(EcoreMetamodelDescriptor metamodel, IQueryGroup i) { | ||
214 | val patterns = i.specifications.toList | ||
215 | val wfPatterns = patterns.filter[it.allAnnotations.exists[it.name == "Constraint"]].toSet | ||
216 | val derivedFeatures = emptyMap | ||
217 | // NO DERIVED FEATURES | ||
218 | // val derivedFeatures = new LinkedHashMap | ||
219 | // derivedFeatures.put(i.type,metamodel.attributes.filter[it.name == "type"].head) | ||
220 | // derivedFeatures.put(i.model,metamodel.references.filter[it.name == "model"].head) | ||
221 | val res = new ViatraQuerySetDescriptor( | ||
222 | patterns, | ||
223 | wfPatterns, | ||
224 | derivedFeatures | ||
225 | ) | ||
226 | return res | ||
227 | } | ||
228 | |||
229 | def static writeInterpretation(LogicResult solution, Logic2Ecore logic2Ecore, ReasonerWorkspace workspace, | ||
230 | String id, ViatraReasoner reasoner, TracedOutput<LogicProblem, Ecore2Logic_Trace> mgProb) { | ||
231 | val interpretations = reasoner.getInterpretations(solution as ModelResult) | ||
232 | for (interpIndex : 0 ..< interpretations.size) { | ||
233 | // val extension b = new LogicStructureBuilder | ||
234 | // val extension a = new LogicProblemBuilder | ||
235 | val interpretation = interpretations.get(interpIndex) | ||
236 | val model = logic2Ecore.transformInterpretation(interpretation, mgProb.trace) | ||
237 | // println(model) | ||
238 | workspace.writeModel(model, '''sol-«id»_«interpIndex».xmi''') | ||
239 | } | ||
240 | } | ||
241 | |||
242 | def static writeRepresentation(LogicResult solution, ReasonerWorkspace workspace, String id) { | ||
243 | val representations = solution.representation | ||
244 | for (representationIndex : 0 ..< representations.size) { | ||
245 | val representation = representations.get(representationIndex) | ||
246 | if (representation instanceof PartialInterpretation) { | ||
247 | val gml = (new PartialInterpretation2Gml).transform(representation) | ||
248 | workspace.writeText('''sol-«id»_«representationIndex».gml''', gml) | ||
249 | |||
250 | val png = (new GraphvizVisualiser).visualiseConcretization(representation) | ||
251 | // println(png) | ||
252 | png.writeToFile(workspace, '''sol-«id»_«representationIndex».png''') | ||
253 | |||
254 | // workspace.writeModel(representation, '''solution«representationIndex».partialintrpretation''') | ||
255 | } else { | ||
256 | workspace.writeText('''sol-«representationIndex».txt''', representation.toString) | ||
257 | } | ||
258 | } | ||
259 | } | ||
260 | |||
261 | def static writeStats(LogicResult solution, long time, ViatraReasonerConfiguration config) { | 184 | def static writeStats(LogicResult solution, long time, ViatraReasonerConfiguration config) { |
262 | val stats = solution.statistics | 185 | val stats = solution.statistics |
263 | println(" Statistics:") | 186 | println(" Statistics:") |