diff options
Diffstat (limited to 'Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse')
7 files changed, 40 insertions, 19 deletions
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/Main.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/Main.xtend index 2add9f0e..dfde6593 100644 --- a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/Main.xtend +++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/Main.xtend | |||
@@ -18,9 +18,9 @@ import org.eclipse.emf.ecore.EReference | |||
18 | class Main { | 18 | class Main { |
19 | var static Domain d = Domain.Yakindumm; | 19 | var static Domain d = Domain.Yakindumm; |
20 | val static String suffix = '.xmi' | 20 | val static String suffix = '.xmi' |
21 | val static String OUTPUT_FOLDER = "Inputs/yakindumm/human/humanInput100/"; | 21 | val static String OUTPUT_FOLDER = "Inputs/measurement2/yakindu/Alloy/"; |
22 | val static String INPUT_FOLDER = "outputs/Human/"; | 22 | val static String INPUT_FOLDER = "outputs/measurement2/yakindu/Alloy/"; |
23 | val static int NUM_RUNS = 100; | 23 | val static int NUM_RUNS = 1; |
24 | 24 | ||
25 | static class RWInformation{ | 25 | static class RWInformation{ |
26 | public var String inputFolder; | 26 | public var String inputFolder; |
@@ -37,7 +37,6 @@ class Main { | |||
37 | def static void main(String[] args){ | 37 | def static void main(String[] args){ |
38 | //init model | 38 | //init model |
39 | var EPackage metamodel; | 39 | var EPackage metamodel; |
40 | |||
41 | //init viatra engine for the violation checker | 40 | //init viatra engine for the violation checker |
42 | ReteEngine.getClass(); | 41 | ReteEngine.getClass(); |
43 | 42 | ||
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/PartialInterpretationMetricDistance.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/PartialInterpretationMetricDistance.xtend index 4c9246d1..697b2639 100644 --- a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/PartialInterpretationMetricDistance.xtend +++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/PartialInterpretationMetricDistance.xtend | |||
@@ -162,9 +162,11 @@ class PartialInterpretationMetricDistance { | |||
162 | def double[] calculateFeature(int step, int violations){ | 162 | def double[] calculateFeature(int step, int violations){ |
163 | var features = newDoubleArrayOfSize(2); | 163 | var features = newDoubleArrayOfSize(2); |
164 | //constant term | 164 | //constant term |
165 | features.set(0, 1); | 165 | features.set(0, 1); //a |
166 | features.set(0, Math.sqrt(step) + 30) | 166 | features.set(0, Math.sqrt(step) + 30) // b |
167 | features.set(1, 1.0 / (step + 30) ); | 167 | features.set(1, 1.0 / (step + 30) );// c |
168 | |||
169 | |||
168 | // features.set(2, violations); | 170 | // features.set(2, violations); |
169 | // features.set(3, Math.pow(violations, 2)); | 171 | // features.set(3, Math.pow(violations, 2)); |
170 | 172 | ||
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend index af05a1cd..31788bb2 100644 --- a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend +++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend | |||
@@ -186,5 +186,9 @@ class GraphStatistic { | |||
186 | return outgoingEdges; | 186 | return outgoingEdges; |
187 | } | 187 | } |
188 | 188 | ||
189 | def HashMap<String, Multimap<EObject, EObject>> incomingEdges(){ | ||
190 | return incomingEdges; | ||
191 | } | ||
192 | |||
189 | } | 193 | } |
190 | 194 | ||
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 858113e9..053e0da3 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 | |||
@@ -22,6 +22,7 @@ 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 | 23 | import org.eclipse.emf.ecore.EGenericType |
24 | import org.eclipse.emf.ecore.EStructuralFeature | 24 | import org.eclipse.emf.ecore.EStructuralFeature |
25 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.TypedClusteringCoefficientMetric | ||
25 | 26 | ||
26 | class GraphReader{ | 27 | class GraphReader{ |
27 | val ResourceSet resSet = new ResourceSetImpl(); | 28 | val ResourceSet resSet = new ResourceSetImpl(); |
@@ -58,8 +59,6 @@ class GraphReader{ | |||
58 | var count = 1 | 59 | var count = 1 |
59 | //check all files in the directory with suffix | 60 | //check all files in the directory with suffix |
60 | for(String name : dir.list.filter[it| it.endsWith(suffix)]){ | 61 | for(String name : dir.list.filter[it| it.endsWith(suffix)]){ |
61 | println(name) | ||
62 | println(count) | ||
63 | val file = new File(name); | 62 | val file = new File(name); |
64 | val roots = readModel(EObject, path, file.name); | 63 | val roots = readModel(EObject, path, file.name); |
65 | //add a list of metrics | 64 | //add a list of metrics |
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 06e88efc..2e7be586 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 | |||
@@ -2,6 +2,7 @@ package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io | |||
2 | 2 | ||
3 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app.Domain | 3 | 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 github.impl.GithubPackageImpl | ||
5 | import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl.YakindummPackageImpl | 6 | import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl.YakindummPackageImpl |
6 | import java.util.HashMap | 7 | import java.util.HashMap |
7 | import org.eclipse.emf.ecore.EReference | 8 | import org.eclipse.emf.ecore.EReference |
@@ -19,7 +20,7 @@ class RepMetricsReader { | |||
19 | }else if (d == Domain.Ecore){ | 20 | }else if (d == Domain.Ecore){ |
20 | reader = new GraphReader(EcorePackageImpl.eINSTANCE, '.ecore'); | 21 | reader = new GraphReader(EcorePackageImpl.eINSTANCE, '.ecore'); |
21 | }else if (d == Domain.Github){ | 22 | }else if (d == Domain.Github){ |
22 | // Initialize the reader with github package | 23 | reader = new GraphReader(GithubPackageImpl.eINSTANCE, '.githubmodel') |
23 | } | 24 | } |
24 | 25 | ||
25 | domain = d; | 26 | domain = d; |
@@ -58,6 +59,13 @@ class RepMetricsReader { | |||
58 | nodeTypeSamples.put('EGenericType', 0.002014098690835851); | 59 | nodeTypeSamples.put('EGenericType', 0.002014098690835851); |
59 | nodeTypeSamples.put('EOperation', 0.009415911379657605); | 60 | nodeTypeSamples.put('EOperation', 0.009415911379657605); |
60 | nodeTypeSamples.put('ETypeParameter', 0.0007049345417925478); | 61 | nodeTypeSamples.put('ETypeParameter', 0.0007049345417925478); |
62 | }else if (d == Domain.Github){ | ||
63 | nodeTypeSamples.put('Project', 0.012636538873420432); | ||
64 | nodeTypeSamples.put('Commit', 0.5525808524309276); | ||
65 | nodeTypeSamples.put('User', 0.05847076461769116); | ||
66 | nodeTypeSamples.put('Issue', 0.12743628185907047); | ||
67 | nodeTypeSamples.put('PullRequest', 0.07560505461554937); | ||
68 | nodeTypeSamples.put('IssueEvent', 0.17327050760334123); | ||
61 | } | 69 | } |
62 | 70 | ||
63 | 71 | ||
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedClusteringCoefficientMetric.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedClusteringCoefficientMetric.xtend index 93f5ccd4..0b6d61c6 100644 --- a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedClusteringCoefficientMetric.xtend +++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedClusteringCoefficientMetric.xtend | |||
@@ -4,6 +4,7 @@ import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.GraphStatis | |||
4 | import java.text.DecimalFormat | 4 | import java.text.DecimalFormat |
5 | import java.util.ArrayList | 5 | import java.util.ArrayList |
6 | import java.util.HashMap | 6 | import java.util.HashMap |
7 | import java.util.HashSet | ||
7 | import org.eclipse.emf.ecore.EObject | 8 | import org.eclipse.emf.ecore.EObject |
8 | 9 | ||
9 | class TypedClusteringCoefficientMetric extends Metric { | 10 | class TypedClusteringCoefficientMetric extends Metric { |
@@ -18,7 +19,9 @@ class TypedClusteringCoefficientMetric extends Metric { | |||
18 | //calculate the metric distribution | 19 | //calculate the metric distribution |
19 | g.allNodes.forEach[n| | 20 | g.allNodes.forEach[n| |
20 | var coef = calculateTCC1(n, g); | 21 | var coef = calculateTCC1(n, g); |
21 | 22 | if(coef > 0){ | |
23 | println(n); | ||
24 | } | ||
22 | //format number to String | 25 | //format number to String |
23 | val value = formatter.format(coef); | 26 | val value = formatter.format(coef); |
24 | if(!map.containsKey(value)){ | 27 | if(!map.containsKey(value)){ |
@@ -61,15 +64,20 @@ class TypedClusteringCoefficientMetric extends Metric { | |||
61 | var triangles = 0; | 64 | var triangles = 0; |
62 | 65 | ||
63 | for(type1 : g.allTypes){ | 66 | for(type1 : g.allTypes){ |
64 | val type1EdgeTargetNodes = g.outgoingEdges.get(type1).values; | 67 | val typed1RelatedOfN = new HashSet<EObject>(g.outgoingEdges.get(type1).get(n)); |
68 | val type1EdgeSourceNodesOfN = new HashSet<EObject>(g.incomingEdges.get(type1).get(n)); | ||
69 | |||
70 | typed1RelatedOfN.addAll(type1EdgeSourceNodesOfN); | ||
71 | |||
72 | |||
65 | 73 | ||
66 | // number of wedges | 74 | // number of wedges |
67 | val d = type1EdgeTargetNodes.size | 75 | val d = typed1RelatedOfN.size |
68 | wedges += d * (d-1) | 76 | wedges += d * (d-1) // we will also count each closed triangle twice |
69 | 77 | ||
70 | // pairs of neighbors | 78 | // pairs of neighbors |
71 | for (n1: type1EdgeTargetNodes) { | 79 | for (n1: typed1RelatedOfN) { |
72 | for (n2: type1EdgeTargetNodes) { | 80 | for (n2: typed1RelatedOfN) { |
73 | for(type2 : g.allTypes){ | 81 | for(type2 : g.allTypes){ |
74 | if ((type1 != type2) && | 82 | if ((type1 != type2) && |
75 | (g.outgoingEdges.get(type2).containsEntry(n1, n2) || | 83 | (g.outgoingEdges.get(type2).containsEntry(n1, n2) || |
@@ -81,10 +89,11 @@ class TypedClusteringCoefficientMetric extends Metric { | |||
81 | } | 89 | } |
82 | } | 90 | } |
83 | } | 91 | } |
92 | |||
84 | if (wedges == 0.0) { | 93 | if (wedges == 0.0) { |
85 | return 0.0 | 94 | return 0.0 |
86 | } else { | 95 | } else { |
87 | return triangles/wedges | 96 | return (triangles as double)/wedges |
88 | } | 97 | } |
89 | } | 98 | } |
90 | } \ No newline at end of file | 99 | } \ No newline at end of file |
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/validation/ViolationCheck.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/validation/ViolationCheck.xtend index 3c98bb1c..4db5f940 100644 --- a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/validation/ViolationCheck.xtend +++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/validation/ViolationCheck.xtend | |||
@@ -2,7 +2,7 @@ package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.validation | |||
2 | 2 | ||
3 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app.Domain | 3 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app.Domain |
4 | import com.google.common.reflect.ClassPath | 4 | import com.google.common.reflect.ClassPath |
5 | import ecore.Ecore_pattern | 5 | import ecore.Ecore |
6 | import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns | 6 | import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns |
7 | import java.util.ArrayList | 7 | import java.util.ArrayList |
8 | import org.eclipse.emf.ecore.EObject | 8 | import org.eclipse.emf.ecore.EObject |
@@ -23,7 +23,7 @@ class ViolationCheck { | |||
23 | } | 23 | } |
24 | 24 | ||
25 | var constriants = loadConstraints(packageName); | 25 | var constriants = loadConstraints(packageName); |
26 | var collections = new ConstraintCollection(constriants, Ecore_pattern.instance); | 26 | var collections = new ConstraintCollection(constriants, Ecore.instance); |
27 | collections.addModel(root); | 27 | collections.addModel(root); |
28 | var results = collections.calculateViolations(); | 28 | var results = collections.calculateViolations(); |
29 | if(results.size > 0){ | 29 | if(results.size > 0){ |