diff options
author | ArenBabikian <aren.babikian@mail.mcgill.ca> | 2019-05-19 04:57:59 -0400 |
---|---|---|
committer | ArenBabikian <aren.babikian@mail.mcgill.ca> | 2019-05-19 04:57:59 -0400 |
commit | 250722c453223a238192fda8db9e692ea776afc7 (patch) | |
tree | d3ba95ae84e0119cb222cf9d3540f6a944cc7321 /Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner | |
parent | add inital metrics project (diff) | |
download | VIATRA-Generator-250722c453223a238192fda8db9e692ea776afc7.tar.gz VIATRA-Generator-250722c453223a238192fda8db9e692ea776afc7.tar.zst VIATRA-Generator-250722c453223a238192fda8db9e692ea776afc7.zip |
REALMET: first impl of n'hood visualis. minor bug with adding outgng 0s.
Diffstat (limited to 'Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner')
-rw-r--r-- | Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/examples/CSERposterSample.xtend | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/examples/CSERposterSample.xtend b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/examples/CSERposterSample.xtend new file mode 100644 index 00000000..8dd16090 --- /dev/null +++ b/Metrics/ca.mcgill.ecse.dslreasoner.realistic.metrics/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/examples/CSERposterSample.xtend | |||
@@ -0,0 +1,76 @@ | |||
1 | package ca.mcgill.ecse.dslreasoner.realistic.metrics.examples | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2Logic | ||
5 | import hu.bme.mit.inf.dslreasoner.ecore2logic.Ecore2LogicConfiguration | ||
6 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor | ||
7 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretation2logic.InstanceModel2PartialInterpretation | ||
8 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.PartialInterpretation2ImmutableTypeLattice | ||
9 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.visualisation.PartialInterpretation2Gml | ||
10 | import hu.bme.mit.inf.dslreasoner.workspace.FileSystemWorkspace | ||
11 | import java.util.Collections | ||
12 | import org.eclipse.emf.ecore.EClass | ||
13 | import org.eclipse.emf.ecore.EEnum | ||
14 | import org.eclipse.emf.ecore.EObject | ||
15 | import org.eclipse.emf.ecore.resource.Resource | ||
16 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
17 | import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine | ||
18 | import java.io.PrintWriter | ||
19 | import linkedList.LinkedListPackage | ||
20 | import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.neighbourhood.Neighbourhood2Gml | ||
21 | |||
22 | class CSERposterSample { | ||
23 | static val partialInterpretation2Logic = new InstanceModel2PartialInterpretation | ||
24 | static val neighbourhoodComputer = new PartialInterpretation2ImmutableTypeLattice | ||
25 | static val Ecore2Logic ecore2Logic = new Ecore2Logic | ||
26 | static val partialVisualizer = new PartialInterpretation2Gml | ||
27 | static val neighbourhoodVisualizer = new Neighbourhood2Gml | ||
28 | static val depth = 1 | ||
29 | |||
30 | def static void main(String[] args) { | ||
31 | Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("*", new XMIResourceFactoryImpl) | ||
32 | YakindummPackage.eINSTANCE.eClass | ||
33 | LinkedListPackage.eINSTANCE.eClass | ||
34 | ReteEngine.getClass | ||
35 | |||
36 | val outputs = "outputs" | ||
37 | val instModName = "realisticModel" | ||
38 | val workspace = new FileSystemWorkspace('''resources''', "") | ||
39 | val model = workspace.readModel(EObject, instModName+".xmi") | ||
40 | |||
41 | val pckg = model.eClass.EPackage | ||
42 | val metamodel = new EcoreMetamodelDescriptor( | ||
43 | pckg.EClassifiers.filter(EClass).toList, | ||
44 | Collections::emptySet, | ||
45 | false, | ||
46 | pckg.EClassifiers.filter(EEnum).toList, | ||
47 | pckg.EClassifiers.filter(EEnum).map[ELiterals].flatten.toList, | ||
48 | pckg.EClassifiers.filter(EClass).map[EReferences].flatten.toList, | ||
49 | pckg.EClassifiers.filter(EClass).map[EAttributes].flatten.toList | ||
50 | ) | ||
51 | val metamodelTransformationOutput = ecore2Logic.transformMetamodel(metamodel, new Ecore2LogicConfiguration) | ||
52 | |||
53 | val partialModelOutput = partialInterpretation2Logic.transform(metamodelTransformationOutput, model.eResource, false) | ||
54 | |||
55 | val writer = new PrintWriter(outputs+"//"+instModName+"MODEL.gml") | ||
56 | |||
57 | writer.print(partialVisualizer.transform(partialModelOutput)) | ||
58 | |||
59 | writer.close | ||
60 | |||
61 | val hood = neighbourhoodComputer.createRepresentation(partialModelOutput, depth, Integer.MAX_VALUE, Integer.MAX_VALUE) | ||
62 | |||
63 | val w2 = new PrintWriter(outputs+"/"+instModName+"NEIGHBOURHOOD.gml") | ||
64 | |||
65 | w2.print(neighbourhoodVisualizer.transform(hood, partialModelOutput)) | ||
66 | |||
67 | w2.close | ||
68 | |||
69 | println("visualization done") | ||
70 | |||
71 | // partialModelOutput.openWorldElements | ||
72 | //RESULTS | ||
73 | // print(hood) | ||
74 | |||
75 | } | ||
76 | } | ||