diff options
author | 20001LastOrder <boqi.chen@mail.mcgill.ca> | 2019-08-08 16:45:45 -0400 |
---|---|---|
committer | 20001LastOrder <boqi.chen@mail.mcgill.ca> | 2019-08-08 16:45:45 -0400 |
commit | c33f0b9c4e112ee573d1b26d205a253cc0e487f8 (patch) | |
tree | 1ec2c4ab56b5bc0d0d56fa111bab0520c05604b4 /Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io | |
parent | Further development of realistic solver, create generation config for ecore m... (diff) | |
download | VIATRA-Generator-c33f0b9c4e112ee573d1b26d205a253cc0e487f8.tar.gz VIATRA-Generator-c33f0b9c4e112ee573d1b26d205a253cc0e487f8.tar.zst VIATRA-Generator-c33f0b9c4e112ee573d1b26d205a253cc0e487f8.zip |
Configurations for generation and new domain for generation ecore model
Diffstat (limited to 'Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io')
2 files changed, 54 insertions, 14 deletions
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/GraphReader.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/GraphReader.xtend index 491501b0..858113e9 100644 --- a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/GraphReader.xtend +++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/GraphReader.xtend | |||
@@ -20,6 +20,8 @@ import org.eclipse.emf.ecore.resource.Resource | |||
20 | import org.eclipse.emf.ecore.resource.ResourceSet | 20 | import org.eclipse.emf.ecore.resource.ResourceSet |
21 | import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl | 21 | import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl |
22 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | 22 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl |
23 | import org.eclipse.emf.ecore.EGenericType | ||
24 | import org.eclipse.emf.ecore.EStructuralFeature | ||
23 | 25 | ||
24 | class GraphReader{ | 26 | class GraphReader{ |
25 | val ResourceSet resSet = new ResourceSetImpl(); | 27 | val ResourceSet resSet = new ResourceSetImpl(); |
@@ -53,9 +55,11 @@ class GraphReader{ | |||
53 | metrics.add(new TypedOutDegree()); | 55 | metrics.add(new TypedOutDegree()); |
54 | metrics.add(new NodeTypeMetric()); | 56 | metrics.add(new NodeTypeMetric()); |
55 | metrics.add(new EdgeTypeMetric()); | 57 | metrics.add(new EdgeTypeMetric()); |
56 | 58 | var count = 1 | |
57 | //check all files in the directory with suffix | 59 | //check all files in the directory with suffix |
58 | for(String name : dir.list.filter[it| it.endsWith(suffix)]){ | 60 | for(String name : dir.list.filter[it| it.endsWith(suffix)]){ |
61 | println(name) | ||
62 | println(count) | ||
59 | val file = new File(name); | 63 | val file = new File(name); |
60 | val roots = readModel(EObject, path, file.name); | 64 | val roots = readModel(EObject, path, file.name); |
61 | //add a list of metrics | 65 | //add a list of metrics |
@@ -63,7 +67,8 @@ class GraphReader{ | |||
63 | for(root : roots){ | 67 | for(root : roots){ |
64 | g.init(root, metrics, name.replaceFirst(suffix, ""), referenceTypes); | 68 | g.init(root, metrics, name.replaceFirst(suffix, ""), referenceTypes); |
65 | } | 69 | } |
66 | 70 | ||
71 | count ++; | ||
67 | graphs.add(g); | 72 | graphs.add(g); |
68 | } | 73 | } |
69 | 74 | ||
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/RepMetricsReader.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/RepMetricsReader.xtend index 6af0b6c7..06e88efc 100644 --- a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/RepMetricsReader.xtend +++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/RepMetricsReader.xtend | |||
@@ -4,34 +4,62 @@ import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app.Domain | |||
4 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MetricSampleGroup | 4 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MetricSampleGroup |
5 | import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl.YakindummPackageImpl | 5 | import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl.YakindummPackageImpl |
6 | import java.util.HashMap | 6 | import java.util.HashMap |
7 | import org.eclipse.emf.ecore.EReference | ||
8 | import org.eclipse.emf.ecore.impl.EcorePackageImpl | ||
7 | 9 | ||
8 | /** | 10 | /** |
9 | * Read the sample of the distribution of a metric provided the csv file of the metric | 11 | * Read the sample of the distribution of a metric provided the csv file of the metric |
10 | */ | 12 | */ |
11 | class RepMetricsReader { | 13 | class RepMetricsReader { |
14 | static var Domain domain; | ||
12 | static def read(Domain d){ | 15 | static def read(Domain d){ |
13 | var reader = new GraphReader(YakindummPackageImpl.eINSTANCE, '.xmi'); | 16 | var GraphReader reader; |
17 | if(d == Domain.Yakindumm){ | ||
18 | reader = new GraphReader(YakindummPackageImpl.eINSTANCE, '.xmi'); | ||
19 | }else if (d == Domain.Ecore){ | ||
20 | reader = new GraphReader(EcorePackageImpl.eINSTANCE, '.ecore'); | ||
21 | }else if (d == Domain.Github){ | ||
22 | // Initialize the reader with github package | ||
23 | } | ||
14 | 24 | ||
25 | domain = d; | ||
15 | 26 | ||
16 | var domainRepPath = DataName.REP_PATH + d.name + '/'; | 27 | var domainRepPath = DataName.REP_PATH + d.name + '/'; |
17 | var rep = new MetricSampleGroup() | 28 | var rep = new MetricSampleGroup() |
18 | var out_d = readMetrics(reader, domainRepPath + DataName.OUT_D_REP); | 29 | var out_d = readMetrics(reader, domainRepPath + DataName.OUT_D_REP); |
19 | rep.mpcSamples = readMetrics(reader, domainRepPath + DataName.MPC_REP).mpcSamples; | 30 | var mpc = readMetrics(reader, domainRepPath + DataName.MPC_REP); |
31 | rep.mpcSamples = mpc.mpcSamples; | ||
20 | rep.outDegreeSamples = out_d.outDegreeSamples; | 32 | rep.outDegreeSamples = out_d.outDegreeSamples; |
21 | rep.naSamples = readMetrics(reader, domainRepPath + DataName.NA_REP).naSamples; | 33 | rep.naSamples = readMetrics(reader, domainRepPath + DataName.NA_REP).naSamples; |
22 | rep.typedOutDegreeSamples = out_d.typedOutDegreeSamples; | 34 | rep.typedOutDegreeSamples = out_d.typedOutDegreeSamples; |
23 | rep.edgeTypeSamples = out_d.edgeTypeSamples; | 35 | rep.edgeTypeSamples = mpc.edgeTypeSamples; |
24 | 36 | ||
25 | //TODO: Parameterize the prior node distribution | 37 | //TODO: Parameterize the prior node distribution |
26 | var nodeTypeSamples = new HashMap<String, Double>(); | 38 | var nodeTypeSamples = new HashMap<String, Double>(); |
27 | nodeTypeSamples.put('Entry', 0.04257802080554814); | 39 | if(d == Domain.Yakindumm){ |
28 | nodeTypeSamples.put('Choice', 0.1267671379034409); | 40 | nodeTypeSamples.put('Entry', 0.04257802080554814); |
29 | nodeTypeSamples.put('State', 0.1596092291277674); | 41 | nodeTypeSamples.put('Choice', 0.1267671379034409); |
30 | nodeTypeSamples.put('Transition', 0.6138636969858629); | 42 | nodeTypeSamples.put('State', 0.1596092291277674); |
31 | nodeTypeSamples.put('Statechart', 0.010136036276340358); | 43 | nodeTypeSamples.put('Transition', 0.6138636969858629); |
32 | nodeTypeSamples.put('Region', 0.04467858095492131); | 44 | nodeTypeSamples.put('Statechart', 0.010136036276340358); |
33 | nodeTypeSamples.put('Exit', 0.0018338223526273673); | 45 | nodeTypeSamples.put('Region', 0.04467858095492131); |
34 | nodeTypeSamples.put('FinalState', 0.0005334755934915977); | 46 | nodeTypeSamples.put('Exit', 0.0018338223526273673); |
47 | nodeTypeSamples.put('FinalState', 0.0005334755934915977); | ||
48 | }else if(d ==Domain.Ecore){ | ||
49 | nodeTypeSamples.put('EAttribute', 0.23539778449144008); | ||
50 | nodeTypeSamples.put('EClass', 0.33081570996978854); | ||
51 | nodeTypeSamples.put('EReference', 0.30996978851963747); | ||
52 | nodeTypeSamples.put('EPackage', 0.012789526686807653); | ||
53 | nodeTypeSamples.put('EAnnotation', 0.002517623363544813); | ||
54 | nodeTypeSamples.put('EEnumLiteral', 0.07275931520644502); | ||
55 | nodeTypeSamples.put('EEnum', 0.013645518630412891); | ||
56 | nodeTypeSamples.put('EDataType', 0.004028197381671702); | ||
57 | nodeTypeSamples.put('EParameter', 0.005941591137965764); | ||
58 | nodeTypeSamples.put('EGenericType', 0.002014098690835851); | ||
59 | nodeTypeSamples.put('EOperation', 0.009415911379657605); | ||
60 | nodeTypeSamples.put('ETypeParameter', 0.0007049345417925478); | ||
61 | } | ||
62 | |||
35 | 63 | ||
36 | 64 | ||
37 | rep.nodeTypeSamples = nodeTypeSamples; | 65 | rep.nodeTypeSamples = nodeTypeSamples; |
@@ -42,7 +70,14 @@ class RepMetricsReader { | |||
42 | * Read representative model | 70 | * Read representative model |
43 | */ | 71 | */ |
44 | private static def readMetrics(GraphReader r, String path){ | 72 | private static def readMetrics(GraphReader r, String path){ |
45 | var model = r.readModels(path).head; | 73 | val model = r.readModels(path).head; |
74 | if(domain == Domain.Ecore){ | ||
75 | var refsToRemove = EcorePackageImpl.eINSTANCE.eAllContents.filter(EReference).filter[ | ||
76 | it.name.equals('eGenericType') || it.name.equals('eGenericSuperTypes') || it.name.equals('eFactoryInstance') || | ||
77 | it.name.equals('eGenericExceptions') || it.name.equals('references') || it.name.equals('contents'); | ||
78 | ]; | ||
79 | refsToRemove.forEach[model.removeReference(it)]; | ||
80 | } | ||
46 | return model.evaluateAllMetricsToSamples(); | 81 | return model.evaluateAllMetricsToSamples(); |
47 | } | 82 | } |
48 | 83 | ||