aboutsummaryrefslogtreecommitdiffstats
path: root/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator
diff options
context:
space:
mode:
Diffstat (limited to 'Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator')
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.classpath12
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.gitignore6
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.project34
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.settings/org.eclipse.wst.validation.prefs10
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/Inputs/.gitignore4
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/META-INF/MANIFEST.MF30
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/build.properties4
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/ecore/LoopInInheritenceConstraint0.java79
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/ecore/NonSymmetricOppositeConstraint0.java80
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/ecore/OppositeDifferentClassConstraint0.java79
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/ChoiceHasNoIncomingConstraint0.java79
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/ChoiceHasNoOutgoingConstraint0.java79
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/IncomingToEntryConstraint0.java80
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/MultipleEntryInRegionConstraint0.java79
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/MultipleTransitionFromEntryConstraint0.java81
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/NoEntryInRegionConstraint0.java79
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/NoOutgoingTransitionFromEntryConstraint0.java79
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/NoStateInRegionConstraint0.java79
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/OutgoingFromExitConstraint0.java80
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/OutgoingFromFinalConstraint0.java80
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/.gitignore8
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/DirectSupertype.java692
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/Ecore.java97
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/LoopInInheritence.java548
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/NonSymmetricOpposite.java707
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/Opposite.java693
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/OppositeDifferentClass.java577
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/ecore.ecore1016
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/Domain.xtend7
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/Main.xtend96
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/PartialInterpretationMetric.xtend85
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/PartialInterpretationMetricDistance.xtend216
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/distance/CostDistance.xtend38
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/distance/EuclideanDistance.xtend72
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/distance/JSDistance.xtend88
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/distance/KSDistance.xtend102
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/EMFGraph.xtend124
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/Graph.xtend71
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend194
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/PartialInterpretationGraph.xtend134
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/CsvFileWriter.xtend52
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/GraphReader.xtend112
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/RepMetricsReader.xtend100
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/EdgeTypeMetric.xtend41
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/Metric.xtend8
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/MetricSampleGroup.xtend13
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/MultiplexParticipationCoefficientMetric.xtend80
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/NodeActivityMetric.xtend49
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/NodeTypeMetric.xtend42
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/OutDegreeMetric.xtend49
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedClusteringCoefficientMetric.xtend99
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedOutDegree.xtend60
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/predictor/LinearModel.xtend91
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/validation/ConstraintCollection.xtend80
-rw-r--r--Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/validation/ViolationCheck.xtend66
56 files changed, 7647 insertions, 0 deletions
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.classpath b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.classpath
new file mode 100644
index 00000000..c5fe8c25
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.classpath
@@ -0,0 +1,12 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<classpath>
3 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4 <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5 <classpathentry kind="src" path="src"/>
6 <classpathentry kind="src" path="xtend-gen"/>
7 <classpathentry kind="src" path="constraints"/>
8 <classpathentry kind="lib" path="C:/Users/chenp/eclipse-workspace/VIATRA-Generator/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/lib/commons-math3-3.6.1.jar"/>
9 <classpathentry kind="lib" path="C:/Users/chenp/eclipse-workspace/VIATRA-Generator/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/lib/commons-math3-3.6.1-javadoc.jar"/>
10 <classpathentry kind="lib" path="C:/Users/chenp/eclipse-workspace/VIATRA-Generator/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/lib/weka.jar"/>
11 <classpathentry kind="output" path="bin"/>
12</classpath>
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.gitignore b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.gitignore
new file mode 100644
index 00000000..317e68e2
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.gitignore
@@ -0,0 +1,6 @@
1/bin/
2bin/
3testInput/
4testOutput/
5xtend-gen/
6*.csv \ No newline at end of file
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.project b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.project
new file mode 100644
index 00000000..5154dea0
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.project
@@ -0,0 +1,34 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<projectDescription>
3 <name>ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator</name>
4 <comment></comment>
5 <projects>
6 </projects>
7 <buildSpec>
8 <buildCommand>
9 <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 <buildCommand>
14 <name>org.eclipse.jdt.core.javabuilder</name>
15 <arguments>
16 </arguments>
17 </buildCommand>
18 <buildCommand>
19 <name>org.eclipse.pde.ManifestBuilder</name>
20 <arguments>
21 </arguments>
22 </buildCommand>
23 <buildCommand>
24 <name>org.eclipse.pde.SchemaBuilder</name>
25 <arguments>
26 </arguments>
27 </buildCommand>
28 </buildSpec>
29 <natures>
30 <nature>org.eclipse.pde.PluginNature</nature>
31 <nature>org.eclipse.jdt.core.javanature</nature>
32 <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
33 </natures>
34</projectDescription>
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.settings/org.eclipse.jdt.core.prefs b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..0c68a61d
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
1eclipse.preferences.version=1
2org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4org.eclipse.jdt.core.compiler.compliance=1.8
5org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7org.eclipse.jdt.core.compiler.source=1.8
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.settings/org.eclipse.wst.validation.prefs b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.settings/org.eclipse.wst.validation.prefs
new file mode 100644
index 00000000..b0a80408
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,10 @@
1DELEGATES_PREFERENCE=delegateValidatorList
2USER_BUILD_PREFERENCE=enabledBuildValidatorList
3USER_MANUAL_PREFERENCE=enabledManualValidatorList
4USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.701.v201810290944
5eclipse.preferences.version=1
6override=true
7suspend=false
8vals/org.eclipse.wst.xml.core.xml/global=FF03
9vals/org.eclipse.wst.xsd.core.xsd/global=FF02162org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator
10vf.version=3
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/Inputs/.gitignore b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/Inputs/.gitignore
new file mode 100644
index 00000000..17126b28
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/Inputs/.gitignore
@@ -0,0 +1,4 @@
1# ignore everything in this folder except for this folder it self
2
3*
4!.gitignore \ No newline at end of file
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/META-INF/MANIFEST.MF b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..7c4f553d
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
1Manifest-Version: 1.0
2Bundle-ManifestVersion: 2
3Bundle-Name: Graph_metrics_calculation
4Bundle-SymbolicName: ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator
5Bundle-Version: 1.0.0.qualifier
6Automatic-Module-Name: graph_metrics_calculation
7Bundle-RequiredExecutionEnvironment: JavaSE-1.8
8Require-Bundle: com.google.guava,
9 org.eclipse.xtext.xbase.lib,
10 org.eclipse.xtend.lib,
11 org.eclipse.xtend.lib.macro,
12 org.eclipse.emf.ecore;bundle-version="2.17.0",
13 org.eclipse.emf.ecore.xmi;bundle-version="2.15.0",
14 hu.bme.mit.inf.dslreasoner.viatra2logic;bundle-version="1.0.0",
15 hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage;bundle-version="1.0.0",
16 org.eclipse.viatra.dse;bundle-version="0.21.2",
17 org.eclipse.viatra.query.runtime.rete;bundle-version="2.1.2",
18 org.eclipse.viatra.addon.validation.core;bundle-version="2.1.2",
19 org.eclipse.collections;bundle-version="9.2.0",
20 org.eclipse.viatra.query.runtime.localsearch;bundle-version="2.1.2",
21 org.apache.log4j;bundle-version="1.2.15",
22 hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph;bundle-version="1.0.0",
23 github-graph;bundle-version="0.1.0"
24Export-Package: ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app,
25 ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance,
26 ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph,
27 ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io,
28 ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics,
29 ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.predictor,
30 ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.validation
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/build.properties b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/build.properties
new file mode 100644
index 00000000..34d2e4d2
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/build.properties
@@ -0,0 +1,4 @@
1source.. = src/
2output.. = bin/
3bin.includes = META-INF/,\
4 .
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/ecore/LoopInInheritenceConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/ecore/LoopInInheritenceConstraint0.java
new file mode 100644
index 00000000..c31e59e7
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/ecore/LoopInInheritenceConstraint0.java
@@ -0,0 +1,79 @@
1/**
2Generated from platform:/resource/SocialNetwork_plugin/queries/queries/Ecore.vql
3*/
4package constraints.ecore;
5
6import java.util.Arrays;
7import java.util.HashMap;
8import java.util.HashSet;
9import java.util.List;
10import java.util.Map;
11import java.util.Set;
12
13import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
14import org.eclipse.viatra.addon.validation.core.api.Severity;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import ecore.LoopInInheritence;
20
21public class LoopInInheritenceConstraint0 implements IConstraintSpecification {
22
23 private LoopInInheritence querySpecification;
24
25 public LoopInInheritenceConstraint0() {
26 querySpecification = LoopInInheritence.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("a",signature.get("a"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "a"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 );
54 return propertyNames;
55 }
56
57 @Override
58 public Set<List<String>> getSymmetricPropertyNames() {
59 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
60 return symmetricPropertyNamesSet;
61 }
62
63 @Override
64 public Set<List<String>> getSymmetricKeyNames() {
65 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
66 return symmetricKeyNamesSet;
67 }
68
69 @Override
70 public Severity getSeverity() {
71 return Severity.ERROR;
72 }
73
74 @Override
75 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
76 return querySpecification;
77 }
78
79}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/ecore/NonSymmetricOppositeConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/ecore/NonSymmetricOppositeConstraint0.java
new file mode 100644
index 00000000..29b35552
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/ecore/NonSymmetricOppositeConstraint0.java
@@ -0,0 +1,80 @@
1/**
2Generated from platform:/resource/SocialNetwork_plugin/queries/queries/Ecore.vql
3*/
4package constraints.ecore;
5
6import java.util.Arrays;
7import java.util.HashMap;
8import java.util.HashSet;
9import java.util.List;
10import java.util.Map;
11import java.util.Set;
12
13import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
14import org.eclipse.viatra.addon.validation.core.api.Severity;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import ecore.NonSymmetricOpposite;
20
21public class NonSymmetricOppositeConstraint0 implements IConstraintSpecification {
22
23 private NonSymmetricOpposite querySpecification;
24
25 public NonSymmetricOppositeConstraint0() {
26 querySpecification = NonSymmetricOpposite.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("a",signature.get("a"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "a"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 "b"
54 );
55 return propertyNames;
56 }
57
58 @Override
59 public Set<List<String>> getSymmetricPropertyNames() {
60 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
61 return symmetricPropertyNamesSet;
62 }
63
64 @Override
65 public Set<List<String>> getSymmetricKeyNames() {
66 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
67 return symmetricKeyNamesSet;
68 }
69
70 @Override
71 public Severity getSeverity() {
72 return Severity.ERROR;
73 }
74
75 @Override
76 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
77 return querySpecification;
78 }
79
80}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/ecore/OppositeDifferentClassConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/ecore/OppositeDifferentClassConstraint0.java
new file mode 100644
index 00000000..9ef4e35e
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/ecore/OppositeDifferentClassConstraint0.java
@@ -0,0 +1,79 @@
1/**
2Generated from platform:/resource/SocialNetwork_plugin/queries/queries/Ecore.vql
3*/
4package constraints.ecore;
5
6import java.util.Arrays;
7import java.util.HashMap;
8import java.util.HashSet;
9import java.util.List;
10import java.util.Map;
11import java.util.Set;
12
13import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
14import org.eclipse.viatra.addon.validation.core.api.Severity;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import ecore.OppositeDifferentClass;
20
21public class OppositeDifferentClassConstraint0 implements IConstraintSpecification {
22
23 private OppositeDifferentClass querySpecification;
24
25 public OppositeDifferentClassConstraint0() {
26 querySpecification = OppositeDifferentClass.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("a",signature.get("a"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "a"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 );
54 return propertyNames;
55 }
56
57 @Override
58 public Set<List<String>> getSymmetricPropertyNames() {
59 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
60 return symmetricPropertyNamesSet;
61 }
62
63 @Override
64 public Set<List<String>> getSymmetricKeyNames() {
65 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
66 return symmetricKeyNamesSet;
67 }
68
69 @Override
70 public Severity getSeverity() {
71 return Severity.ERROR;
72 }
73
74 @Override
75 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
76 return querySpecification;
77 }
78
79}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/ChoiceHasNoIncomingConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/ChoiceHasNoIncomingConstraint0.java
new file mode 100644
index 00000000..dbc51a5e
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/ChoiceHasNoIncomingConstraint0.java
@@ -0,0 +1,79 @@
1/**
2Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
3*/
4package constraints.yakindumm;
5
6import java.util.HashMap;
7import java.util.HashSet;
8import java.util.List;
9import java.util.Map;
10import java.util.Set;
11import java.util.Arrays;
12
13import org.eclipse.viatra.addon.validation.core.api.Severity;
14import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.ChoiceHasNoIncoming;
20
21public class ChoiceHasNoIncomingConstraint0 implements IConstraintSpecification {
22
23 private ChoiceHasNoIncoming querySpecification;
24
25 public ChoiceHasNoIncomingConstraint0() {
26 querySpecification = ChoiceHasNoIncoming.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("c",signature.get("c"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "c"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 );
54 return propertyNames;
55 }
56
57 @Override
58 public Set<List<String>> getSymmetricPropertyNames() {
59 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
60 return symmetricPropertyNamesSet;
61 }
62
63 @Override
64 public Set<List<String>> getSymmetricKeyNames() {
65 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
66 return symmetricKeyNamesSet;
67 }
68
69 @Override
70 public Severity getSeverity() {
71 return Severity.ERROR;
72 }
73
74 @Override
75 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
76 return querySpecification;
77 }
78
79}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/ChoiceHasNoOutgoingConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/ChoiceHasNoOutgoingConstraint0.java
new file mode 100644
index 00000000..bdddd5b5
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/ChoiceHasNoOutgoingConstraint0.java
@@ -0,0 +1,79 @@
1/**
2Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
3*/
4package constraints.yakindumm;
5
6import java.util.HashMap;
7import java.util.HashSet;
8import java.util.List;
9import java.util.Map;
10import java.util.Set;
11import java.util.Arrays;
12
13import org.eclipse.viatra.addon.validation.core.api.Severity;
14import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.ChoiceHasNoOutgoing;
20
21public class ChoiceHasNoOutgoingConstraint0 implements IConstraintSpecification {
22
23 private ChoiceHasNoOutgoing querySpecification;
24
25 public ChoiceHasNoOutgoingConstraint0() {
26 querySpecification = ChoiceHasNoOutgoing.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("c",signature.get("c"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "c"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 );
54 return propertyNames;
55 }
56
57 @Override
58 public Set<List<String>> getSymmetricPropertyNames() {
59 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
60 return symmetricPropertyNamesSet;
61 }
62
63 @Override
64 public Set<List<String>> getSymmetricKeyNames() {
65 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
66 return symmetricKeyNamesSet;
67 }
68
69 @Override
70 public Severity getSeverity() {
71 return Severity.ERROR;
72 }
73
74 @Override
75 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
76 return querySpecification;
77 }
78
79}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/IncomingToEntryConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/IncomingToEntryConstraint0.java
new file mode 100644
index 00000000..b49d9474
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/IncomingToEntryConstraint0.java
@@ -0,0 +1,80 @@
1/**
2Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
3*/
4package constraints.yakindumm;
5
6import java.util.HashMap;
7import java.util.HashSet;
8import java.util.List;
9import java.util.Map;
10import java.util.Set;
11import java.util.Arrays;
12
13import org.eclipse.viatra.addon.validation.core.api.Severity;
14import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.IncomingToEntry;
20
21public class IncomingToEntryConstraint0 implements IConstraintSpecification {
22
23 private IncomingToEntry querySpecification;
24
25 public IncomingToEntryConstraint0() {
26 querySpecification = IncomingToEntry.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("e",signature.get("e"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "e"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 "t"
54 );
55 return propertyNames;
56 }
57
58 @Override
59 public Set<List<String>> getSymmetricPropertyNames() {
60 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
61 return symmetricPropertyNamesSet;
62 }
63
64 @Override
65 public Set<List<String>> getSymmetricKeyNames() {
66 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
67 return symmetricKeyNamesSet;
68 }
69
70 @Override
71 public Severity getSeverity() {
72 return Severity.ERROR;
73 }
74
75 @Override
76 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
77 return querySpecification;
78 }
79
80}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/MultipleEntryInRegionConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/MultipleEntryInRegionConstraint0.java
new file mode 100644
index 00000000..535e7eee
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/MultipleEntryInRegionConstraint0.java
@@ -0,0 +1,79 @@
1/**
2Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
3*/
4package constraints.yakindumm;
5
6import java.util.HashMap;
7import java.util.HashSet;
8import java.util.List;
9import java.util.Map;
10import java.util.Set;
11import java.util.Arrays;
12
13import org.eclipse.viatra.addon.validation.core.api.Severity;
14import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.MultipleEntryInRegion;
20
21public class MultipleEntryInRegionConstraint0 implements IConstraintSpecification {
22
23 private MultipleEntryInRegion querySpecification;
24
25 public MultipleEntryInRegionConstraint0() {
26 querySpecification = MultipleEntryInRegion.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("r",signature.get("r"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "r"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 );
54 return propertyNames;
55 }
56
57 @Override
58 public Set<List<String>> getSymmetricPropertyNames() {
59 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
60 return symmetricPropertyNamesSet;
61 }
62
63 @Override
64 public Set<List<String>> getSymmetricKeyNames() {
65 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
66 return symmetricKeyNamesSet;
67 }
68
69 @Override
70 public Severity getSeverity() {
71 return Severity.ERROR;
72 }
73
74 @Override
75 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
76 return querySpecification;
77 }
78
79}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/MultipleTransitionFromEntryConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/MultipleTransitionFromEntryConstraint0.java
new file mode 100644
index 00000000..a41b2fc1
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/MultipleTransitionFromEntryConstraint0.java
@@ -0,0 +1,81 @@
1/**
2Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
3*/
4package constraints.yakindumm;
5
6import java.util.HashMap;
7import java.util.HashSet;
8import java.util.List;
9import java.util.Map;
10import java.util.Set;
11import java.util.Arrays;
12
13import org.eclipse.viatra.addon.validation.core.api.Severity;
14import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.MultipleTransitionFromEntry;
20
21public class MultipleTransitionFromEntryConstraint0 implements IConstraintSpecification {
22
23 private MultipleTransitionFromEntry querySpecification;
24
25 public MultipleTransitionFromEntryConstraint0() {
26 querySpecification = MultipleTransitionFromEntry.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("e",signature.get("e"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "e"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 "t1",
54 "t2"
55 );
56 return propertyNames;
57 }
58
59 @Override
60 public Set<List<String>> getSymmetricPropertyNames() {
61 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
62 return symmetricPropertyNamesSet;
63 }
64
65 @Override
66 public Set<List<String>> getSymmetricKeyNames() {
67 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
68 return symmetricKeyNamesSet;
69 }
70
71 @Override
72 public Severity getSeverity() {
73 return Severity.ERROR;
74 }
75
76 @Override
77 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
78 return querySpecification;
79 }
80
81}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/NoEntryInRegionConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/NoEntryInRegionConstraint0.java
new file mode 100644
index 00000000..9eb7783f
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/NoEntryInRegionConstraint0.java
@@ -0,0 +1,79 @@
1/**
2Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
3*/
4package constraints.yakindumm;
5
6import java.util.HashMap;
7import java.util.HashSet;
8import java.util.List;
9import java.util.Map;
10import java.util.Set;
11import java.util.Arrays;
12
13import org.eclipse.viatra.addon.validation.core.api.Severity;
14import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.NoEntryInRegion;
20
21public class NoEntryInRegionConstraint0 implements IConstraintSpecification {
22
23 private NoEntryInRegion querySpecification;
24
25 public NoEntryInRegionConstraint0() {
26 querySpecification = NoEntryInRegion.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("r1",signature.get("r1"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "r1"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 );
54 return propertyNames;
55 }
56
57 @Override
58 public Set<List<String>> getSymmetricPropertyNames() {
59 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
60 return symmetricPropertyNamesSet;
61 }
62
63 @Override
64 public Set<List<String>> getSymmetricKeyNames() {
65 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
66 return symmetricKeyNamesSet;
67 }
68
69 @Override
70 public Severity getSeverity() {
71 return Severity.ERROR;
72 }
73
74 @Override
75 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
76 return querySpecification;
77 }
78
79}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/NoOutgoingTransitionFromEntryConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/NoOutgoingTransitionFromEntryConstraint0.java
new file mode 100644
index 00000000..35d54e8e
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/NoOutgoingTransitionFromEntryConstraint0.java
@@ -0,0 +1,79 @@
1/**
2Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
3*/
4package constraints.yakindumm;
5
6import java.util.HashMap;
7import java.util.HashSet;
8import java.util.List;
9import java.util.Map;
10import java.util.Set;
11import java.util.Arrays;
12
13import org.eclipse.viatra.addon.validation.core.api.Severity;
14import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.NoOutgoingTransitionFromEntry;
20
21public class NoOutgoingTransitionFromEntryConstraint0 implements IConstraintSpecification {
22
23 private NoOutgoingTransitionFromEntry querySpecification;
24
25 public NoOutgoingTransitionFromEntryConstraint0() {
26 querySpecification = NoOutgoingTransitionFromEntry.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("e",signature.get("e"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "e"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 );
54 return propertyNames;
55 }
56
57 @Override
58 public Set<List<String>> getSymmetricPropertyNames() {
59 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
60 return symmetricPropertyNamesSet;
61 }
62
63 @Override
64 public Set<List<String>> getSymmetricKeyNames() {
65 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
66 return symmetricKeyNamesSet;
67 }
68
69 @Override
70 public Severity getSeverity() {
71 return Severity.ERROR;
72 }
73
74 @Override
75 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
76 return querySpecification;
77 }
78
79}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/NoStateInRegionConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/NoStateInRegionConstraint0.java
new file mode 100644
index 00000000..49c0063f
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/NoStateInRegionConstraint0.java
@@ -0,0 +1,79 @@
1/**
2Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
3*/
4package constraints.yakindumm;
5
6import java.util.HashMap;
7import java.util.HashSet;
8import java.util.List;
9import java.util.Map;
10import java.util.Set;
11import java.util.Arrays;
12
13import org.eclipse.viatra.addon.validation.core.api.Severity;
14import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.NoStateInRegion;
20
21public class NoStateInRegionConstraint0 implements IConstraintSpecification {
22
23 private NoStateInRegion querySpecification;
24
25 public NoStateInRegionConstraint0() {
26 querySpecification = NoStateInRegion.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("region",signature.get("region"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "region"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 );
54 return propertyNames;
55 }
56
57 @Override
58 public Set<List<String>> getSymmetricPropertyNames() {
59 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
60 return symmetricPropertyNamesSet;
61 }
62
63 @Override
64 public Set<List<String>> getSymmetricKeyNames() {
65 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
66 return symmetricKeyNamesSet;
67 }
68
69 @Override
70 public Severity getSeverity() {
71 return Severity.ERROR;
72 }
73
74 @Override
75 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
76 return querySpecification;
77 }
78
79}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/OutgoingFromExitConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/OutgoingFromExitConstraint0.java
new file mode 100644
index 00000000..ddb907ff
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/OutgoingFromExitConstraint0.java
@@ -0,0 +1,80 @@
1/**
2Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
3*/
4package constraints.yakindumm;
5
6import java.util.HashMap;
7import java.util.HashSet;
8import java.util.List;
9import java.util.Map;
10import java.util.Set;
11import java.util.Arrays;
12
13import org.eclipse.viatra.addon.validation.core.api.Severity;
14import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.OutgoingFromExit;
20
21public class OutgoingFromExitConstraint0 implements IConstraintSpecification {
22
23 private OutgoingFromExit querySpecification;
24
25 public OutgoingFromExitConstraint0() {
26 querySpecification = OutgoingFromExit.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("e",signature.get("e"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "e"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 "t"
54 );
55 return propertyNames;
56 }
57
58 @Override
59 public Set<List<String>> getSymmetricPropertyNames() {
60 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
61 return symmetricPropertyNamesSet;
62 }
63
64 @Override
65 public Set<List<String>> getSymmetricKeyNames() {
66 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
67 return symmetricKeyNamesSet;
68 }
69
70 @Override
71 public Severity getSeverity() {
72 return Severity.ERROR;
73 }
74
75 @Override
76 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
77 return querySpecification;
78 }
79
80}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/OutgoingFromFinalConstraint0.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/OutgoingFromFinalConstraint0.java
new file mode 100644
index 00000000..3b2949fd
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/constraints/yakindumm/OutgoingFromFinalConstraint0.java
@@ -0,0 +1,80 @@
1/**
2Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql
3*/
4package constraints.yakindumm;
5
6import java.util.HashMap;
7import java.util.HashSet;
8import java.util.List;
9import java.util.Map;
10import java.util.Set;
11import java.util.Arrays;
12
13import org.eclipse.viatra.addon.validation.core.api.Severity;
14import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification;
15import org.eclipse.viatra.query.runtime.api.IPatternMatch;
16import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
17import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
18
19import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.OutgoingFromFinal;
20
21public class OutgoingFromFinalConstraint0 implements IConstraintSpecification {
22
23 private OutgoingFromFinal querySpecification;
24
25 public OutgoingFromFinalConstraint0() {
26 querySpecification = OutgoingFromFinal.instance();
27 }
28
29 @Override
30 public String getMessageFormat() {
31 return "error";
32 }
33
34
35 @Override
36 public Map<String,Object> getKeyObjects(IPatternMatch signature) {
37 Map<String,Object> map = new HashMap<>();
38 map.put("f",signature.get("f"));
39 return map;
40 }
41
42 @Override
43 public List<String> getKeyNames() {
44 List<String> keyNames = Arrays.asList(
45 "f"
46 );
47 return keyNames;
48 }
49
50 @Override
51 public List<String> getPropertyNames() {
52 List<String> propertyNames = Arrays.asList(
53 "t"
54 );
55 return propertyNames;
56 }
57
58 @Override
59 public Set<List<String>> getSymmetricPropertyNames() {
60 Set<List<String>> symmetricPropertyNamesSet = new HashSet<>();
61 return symmetricPropertyNamesSet;
62 }
63
64 @Override
65 public Set<List<String>> getSymmetricKeyNames() {
66 Set<List<String>> symmetricKeyNamesSet = new HashSet<>();
67 return symmetricKeyNamesSet;
68 }
69
70 @Override
71 public Severity getSeverity() {
72 return Severity.ERROR;
73 }
74
75 @Override
76 public IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> getQuerySpecification() {
77 return querySpecification;
78 }
79
80}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/.gitignore b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/.gitignore
new file mode 100644
index 00000000..c42ca056
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/.gitignore
@@ -0,0 +1,8 @@
1/.Ecore_pattern.java._trace
2/.MoreThenFiveSuperTypes.java._trace
3/.DirectSupertype.java._trace
4/.Ecore.java._trace
5/.LoopInInheritence.java._trace
6/.NonSymmetricOpposite.java._trace
7/.Opposite.java._trace
8/.OppositeDifferentClass.java._trace
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/DirectSupertype.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/DirectSupertype.java
new file mode 100644
index 00000000..a6ffad45
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/DirectSupertype.java
@@ -0,0 +1,692 @@
1/**
2 * Generated from platform:/resource/SocialNetwork_plugin/queries/ecore/Ecore.vql
3 */
4package ecore;
5
6import java.util.Arrays;
7import java.util.Collection;
8import java.util.LinkedHashSet;
9import java.util.List;
10import java.util.Objects;
11import java.util.Optional;
12import java.util.Set;
13import java.util.function.Consumer;
14import java.util.stream.Collectors;
15import java.util.stream.Stream;
16import org.apache.log4j.Logger;
17import org.eclipse.emf.ecore.EClass;
18import org.eclipse.viatra.query.runtime.api.IPatternMatch;
19import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
20import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
21import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
22import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
23import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
24import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
25import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
26import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
27import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
28import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
30import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
31import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
33import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
34import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
35import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
36import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
37import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
38import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
39
40/**
41 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
42 *
43 * <p>Original source:
44 * <code><pre>
45 * pattern directSupertype(a: EClass, b:EClass) {
46 * EClass.eSuperTypes(a,b);
47 * }
48 * </pre></code>
49 *
50 * @see Matcher
51 * @see Match
52 *
53 */
54@SuppressWarnings("all")
55public final class DirectSupertype extends BaseGeneratedEMFQuerySpecification<DirectSupertype.Matcher> {
56 /**
57 * Pattern-specific match representation of the ecore.directSupertype pattern,
58 * to be used in conjunction with {@link Matcher}.
59 *
60 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
61 * Each instance is a (possibly partial) substitution of pattern parameters,
62 * usable to represent a match of the pattern in the result of a query,
63 * or to specify the bound (fixed) input parameters when issuing a query.
64 *
65 * @see Matcher
66 *
67 */
68 public static abstract class Match extends BasePatternMatch {
69 private EClass fA;
70
71 private EClass fB;
72
73 private static List<String> parameterNames = makeImmutableList("a", "b");
74
75 private Match(final EClass pA, final EClass pB) {
76 this.fA = pA;
77 this.fB = pB;
78 }
79
80 @Override
81 public Object get(final String parameterName) {
82 if ("a".equals(parameterName)) return this.fA;
83 if ("b".equals(parameterName)) return this.fB;
84 return null;
85 }
86
87 public EClass getA() {
88 return this.fA;
89 }
90
91 public EClass getB() {
92 return this.fB;
93 }
94
95 @Override
96 public boolean set(final String parameterName, final Object newValue) {
97 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
98 if ("a".equals(parameterName) ) {
99 this.fA = (EClass) newValue;
100 return true;
101 }
102 if ("b".equals(parameterName) ) {
103 this.fB = (EClass) newValue;
104 return true;
105 }
106 return false;
107 }
108
109 public void setA(final EClass pA) {
110 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
111 this.fA = pA;
112 }
113
114 public void setB(final EClass pB) {
115 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
116 this.fB = pB;
117 }
118
119 @Override
120 public String patternName() {
121 return "ecore.directSupertype";
122 }
123
124 @Override
125 public List<String> parameterNames() {
126 return DirectSupertype.Match.parameterNames;
127 }
128
129 @Override
130 public Object[] toArray() {
131 return new Object[]{fA, fB};
132 }
133
134 @Override
135 public DirectSupertype.Match toImmutable() {
136 return isMutable() ? newMatch(fA, fB) : this;
137 }
138
139 @Override
140 public String prettyPrint() {
141 StringBuilder result = new StringBuilder();
142 result.append("\"a\"=" + prettyPrintValue(fA) + ", ");
143 result.append("\"b\"=" + prettyPrintValue(fB));
144 return result.toString();
145 }
146
147 @Override
148 public int hashCode() {
149 return Objects.hash(fA, fB);
150 }
151
152 @Override
153 public boolean equals(final Object obj) {
154 if (this == obj)
155 return true;
156 if (obj == null) {
157 return false;
158 }
159 if ((obj instanceof DirectSupertype.Match)) {
160 DirectSupertype.Match other = (DirectSupertype.Match) obj;
161 return Objects.equals(fA, other.fA) && Objects.equals(fB, other.fB);
162 } else {
163 // this should be infrequent
164 if (!(obj instanceof IPatternMatch)) {
165 return false;
166 }
167 IPatternMatch otherSig = (IPatternMatch) obj;
168 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
169 }
170 }
171
172 @Override
173 public DirectSupertype specification() {
174 return DirectSupertype.instance();
175 }
176
177 /**
178 * Returns an empty, mutable match.
179 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
180 *
181 * @return the empty match.
182 *
183 */
184 public static DirectSupertype.Match newEmptyMatch() {
185 return new Mutable(null, null);
186 }
187
188 /**
189 * Returns a mutable (partial) match.
190 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
191 *
192 * @param pA the fixed value of pattern parameter a, or null if not bound.
193 * @param pB the fixed value of pattern parameter b, or null if not bound.
194 * @return the new, mutable (partial) match object.
195 *
196 */
197 public static DirectSupertype.Match newMutableMatch(final EClass pA, final EClass pB) {
198 return new Mutable(pA, pB);
199 }
200
201 /**
202 * Returns a new (partial) match.
203 * This can be used e.g. to call the matcher with a partial match.
204 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
205 * @param pA the fixed value of pattern parameter a, or null if not bound.
206 * @param pB the fixed value of pattern parameter b, or null if not bound.
207 * @return the (partial) match object.
208 *
209 */
210 public static DirectSupertype.Match newMatch(final EClass pA, final EClass pB) {
211 return new Immutable(pA, pB);
212 }
213
214 private static final class Mutable extends DirectSupertype.Match {
215 Mutable(final EClass pA, final EClass pB) {
216 super(pA, pB);
217 }
218
219 @Override
220 public boolean isMutable() {
221 return true;
222 }
223 }
224
225 private static final class Immutable extends DirectSupertype.Match {
226 Immutable(final EClass pA, final EClass pB) {
227 super(pA, pB);
228 }
229
230 @Override
231 public boolean isMutable() {
232 return false;
233 }
234 }
235 }
236
237 /**
238 * Generated pattern matcher API of the ecore.directSupertype pattern,
239 * providing pattern-specific query methods.
240 *
241 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
242 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
243 *
244 * <p>Matches of the pattern will be represented as {@link Match}.
245 *
246 * <p>Original source:
247 * <code><pre>
248 * pattern directSupertype(a: EClass, b:EClass) {
249 * EClass.eSuperTypes(a,b);
250 * }
251 * </pre></code>
252 *
253 * @see Match
254 * @see DirectSupertype
255 *
256 */
257 public static class Matcher extends BaseMatcher<DirectSupertype.Match> {
258 /**
259 * Initializes the pattern matcher within an existing VIATRA Query engine.
260 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
261 *
262 * @param engine the existing VIATRA Query engine in which this matcher will be created.
263 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
264 *
265 */
266 public static DirectSupertype.Matcher on(final ViatraQueryEngine engine) {
267 // check if matcher already exists
268 Matcher matcher = engine.getExistingMatcher(querySpecification());
269 if (matcher == null) {
270 matcher = (Matcher)engine.getMatcher(querySpecification());
271 }
272 return matcher;
273 }
274
275 /**
276 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
277 * @return an initialized matcher
278 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
279 *
280 */
281 public static DirectSupertype.Matcher create() {
282 return new Matcher();
283 }
284
285 private static final int POSITION_A = 0;
286
287 private static final int POSITION_B = 1;
288
289 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(DirectSupertype.Matcher.class);
290
291 /**
292 * Initializes the pattern matcher within an existing VIATRA Query engine.
293 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
294 *
295 * @param engine the existing VIATRA Query engine in which this matcher will be created.
296 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
297 *
298 */
299 private Matcher() {
300 super(querySpecification());
301 }
302
303 /**
304 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
305 * @param pA the fixed value of pattern parameter a, or null if not bound.
306 * @param pB the fixed value of pattern parameter b, or null if not bound.
307 * @return matches represented as a Match object.
308 *
309 */
310 public Collection<DirectSupertype.Match> getAllMatches(final EClass pA, final EClass pB) {
311 return rawStreamAllMatches(new Object[]{pA, pB}).collect(Collectors.toSet());
312 }
313
314 /**
315 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
316 * </p>
317 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
318 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
319 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
320 * @param pA the fixed value of pattern parameter a, or null if not bound.
321 * @param pB the fixed value of pattern parameter b, or null if not bound.
322 * @return a stream of matches represented as a Match object.
323 *
324 */
325 public Stream<DirectSupertype.Match> streamAllMatches(final EClass pA, final EClass pB) {
326 return rawStreamAllMatches(new Object[]{pA, pB});
327 }
328
329 /**
330 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
331 * Neither determinism nor randomness of selection is guaranteed.
332 * @param pA the fixed value of pattern parameter a, or null if not bound.
333 * @param pB the fixed value of pattern parameter b, or null if not bound.
334 * @return a match represented as a Match object, or null if no match is found.
335 *
336 */
337 public Optional<DirectSupertype.Match> getOneArbitraryMatch(final EClass pA, final EClass pB) {
338 return rawGetOneArbitraryMatch(new Object[]{pA, pB});
339 }
340
341 /**
342 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
343 * under any possible substitution of the unspecified parameters (if any).
344 * @param pA the fixed value of pattern parameter a, or null if not bound.
345 * @param pB the fixed value of pattern parameter b, or null if not bound.
346 * @return true if the input is a valid (partial) match of the pattern.
347 *
348 */
349 public boolean hasMatch(final EClass pA, final EClass pB) {
350 return rawHasMatch(new Object[]{pA, pB});
351 }
352
353 /**
354 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
355 * @param pA the fixed value of pattern parameter a, or null if not bound.
356 * @param pB the fixed value of pattern parameter b, or null if not bound.
357 * @return the number of pattern matches found.
358 *
359 */
360 public int countMatches(final EClass pA, final EClass pB) {
361 return rawCountMatches(new Object[]{pA, pB});
362 }
363
364 /**
365 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
366 * Neither determinism nor randomness of selection is guaranteed.
367 * @param pA the fixed value of pattern parameter a, or null if not bound.
368 * @param pB the fixed value of pattern parameter b, or null if not bound.
369 * @param processor the action that will process the selected match.
370 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
371 *
372 */
373 public boolean forOneArbitraryMatch(final EClass pA, final EClass pB, final Consumer<? super DirectSupertype.Match> processor) {
374 return rawForOneArbitraryMatch(new Object[]{pA, pB}, processor);
375 }
376
377 /**
378 * Returns a new (partial) match.
379 * This can be used e.g. to call the matcher with a partial match.
380 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
381 * @param pA the fixed value of pattern parameter a, or null if not bound.
382 * @param pB the fixed value of pattern parameter b, or null if not bound.
383 * @return the (partial) match object.
384 *
385 */
386 public DirectSupertype.Match newMatch(final EClass pA, final EClass pB) {
387 return DirectSupertype.Match.newMatch(pA, pB);
388 }
389
390 /**
391 * Retrieve the set of values that occur in matches for a.
392 * @return the Set of all values or empty set if there are no matches
393 *
394 */
395 protected Stream<EClass> rawStreamAllValuesOfa(final Object[] parameters) {
396 return rawStreamAllValues(POSITION_A, parameters).map(EClass.class::cast);
397 }
398
399 /**
400 * Retrieve the set of values that occur in matches for a.
401 * @return the Set of all values or empty set if there are no matches
402 *
403 */
404 public Set<EClass> getAllValuesOfa() {
405 return rawStreamAllValuesOfa(emptyArray()).collect(Collectors.toSet());
406 }
407
408 /**
409 * Retrieve the set of values that occur in matches for a.
410 * @return the Set of all values or empty set if there are no matches
411 *
412 */
413 public Stream<EClass> streamAllValuesOfa() {
414 return rawStreamAllValuesOfa(emptyArray());
415 }
416
417 /**
418 * Retrieve the set of values that occur in matches for a.
419 * </p>
420 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
421 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
422 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
423 *
424 * @return the Stream of all values or empty set if there are no matches
425 *
426 */
427 public Stream<EClass> streamAllValuesOfa(final DirectSupertype.Match partialMatch) {
428 return rawStreamAllValuesOfa(partialMatch.toArray());
429 }
430
431 /**
432 * Retrieve the set of values that occur in matches for a.
433 * </p>
434 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
435 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
436 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
437 *
438 * @return the Stream of all values or empty set if there are no matches
439 *
440 */
441 public Stream<EClass> streamAllValuesOfa(final EClass pB) {
442 return rawStreamAllValuesOfa(new Object[]{null, pB});
443 }
444
445 /**
446 * Retrieve the set of values that occur in matches for a.
447 * @return the Set of all values or empty set if there are no matches
448 *
449 */
450 public Set<EClass> getAllValuesOfa(final DirectSupertype.Match partialMatch) {
451 return rawStreamAllValuesOfa(partialMatch.toArray()).collect(Collectors.toSet());
452 }
453
454 /**
455 * Retrieve the set of values that occur in matches for a.
456 * @return the Set of all values or empty set if there are no matches
457 *
458 */
459 public Set<EClass> getAllValuesOfa(final EClass pB) {
460 return rawStreamAllValuesOfa(new Object[]{null, pB}).collect(Collectors.toSet());
461 }
462
463 /**
464 * Retrieve the set of values that occur in matches for b.
465 * @return the Set of all values or empty set if there are no matches
466 *
467 */
468 protected Stream<EClass> rawStreamAllValuesOfb(final Object[] parameters) {
469 return rawStreamAllValues(POSITION_B, parameters).map(EClass.class::cast);
470 }
471
472 /**
473 * Retrieve the set of values that occur in matches for b.
474 * @return the Set of all values or empty set if there are no matches
475 *
476 */
477 public Set<EClass> getAllValuesOfb() {
478 return rawStreamAllValuesOfb(emptyArray()).collect(Collectors.toSet());
479 }
480
481 /**
482 * Retrieve the set of values that occur in matches for b.
483 * @return the Set of all values or empty set if there are no matches
484 *
485 */
486 public Stream<EClass> streamAllValuesOfb() {
487 return rawStreamAllValuesOfb(emptyArray());
488 }
489
490 /**
491 * Retrieve the set of values that occur in matches for b.
492 * </p>
493 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
494 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
495 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
496 *
497 * @return the Stream of all values or empty set if there are no matches
498 *
499 */
500 public Stream<EClass> streamAllValuesOfb(final DirectSupertype.Match partialMatch) {
501 return rawStreamAllValuesOfb(partialMatch.toArray());
502 }
503
504 /**
505 * Retrieve the set of values that occur in matches for b.
506 * </p>
507 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
508 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
509 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
510 *
511 * @return the Stream of all values or empty set if there are no matches
512 *
513 */
514 public Stream<EClass> streamAllValuesOfb(final EClass pA) {
515 return rawStreamAllValuesOfb(new Object[]{pA, null});
516 }
517
518 /**
519 * Retrieve the set of values that occur in matches for b.
520 * @return the Set of all values or empty set if there are no matches
521 *
522 */
523 public Set<EClass> getAllValuesOfb(final DirectSupertype.Match partialMatch) {
524 return rawStreamAllValuesOfb(partialMatch.toArray()).collect(Collectors.toSet());
525 }
526
527 /**
528 * Retrieve the set of values that occur in matches for b.
529 * @return the Set of all values or empty set if there are no matches
530 *
531 */
532 public Set<EClass> getAllValuesOfb(final EClass pA) {
533 return rawStreamAllValuesOfb(new Object[]{pA, null}).collect(Collectors.toSet());
534 }
535
536 @Override
537 protected DirectSupertype.Match tupleToMatch(final Tuple t) {
538 try {
539 return DirectSupertype.Match.newMatch((EClass) t.get(POSITION_A), (EClass) t.get(POSITION_B));
540 } catch(ClassCastException e) {
541 LOGGER.error("Element(s) in tuple not properly typed!",e);
542 return null;
543 }
544 }
545
546 @Override
547 protected DirectSupertype.Match arrayToMatch(final Object[] match) {
548 try {
549 return DirectSupertype.Match.newMatch((EClass) match[POSITION_A], (EClass) match[POSITION_B]);
550 } catch(ClassCastException e) {
551 LOGGER.error("Element(s) in array not properly typed!",e);
552 return null;
553 }
554 }
555
556 @Override
557 protected DirectSupertype.Match arrayToMatchMutable(final Object[] match) {
558 try {
559 return DirectSupertype.Match.newMutableMatch((EClass) match[POSITION_A], (EClass) match[POSITION_B]);
560 } catch(ClassCastException e) {
561 LOGGER.error("Element(s) in array not properly typed!",e);
562 return null;
563 }
564 }
565
566 /**
567 * @return the singleton instance of the query specification of this pattern
568 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
569 *
570 */
571 public static IQuerySpecification<DirectSupertype.Matcher> querySpecification() {
572 return DirectSupertype.instance();
573 }
574 }
575
576 private DirectSupertype() {
577 super(GeneratedPQuery.INSTANCE);
578 }
579
580 /**
581 * @return the singleton instance of the query specification
582 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
583 *
584 */
585 public static DirectSupertype instance() {
586 try{
587 return LazyHolder.INSTANCE;
588 } catch (ExceptionInInitializerError err) {
589 throw processInitializerError(err);
590 }
591 }
592
593 @Override
594 protected DirectSupertype.Matcher instantiate(final ViatraQueryEngine engine) {
595 return DirectSupertype.Matcher.on(engine);
596 }
597
598 @Override
599 public DirectSupertype.Matcher instantiate() {
600 return DirectSupertype.Matcher.create();
601 }
602
603 @Override
604 public DirectSupertype.Match newEmptyMatch() {
605 return DirectSupertype.Match.newEmptyMatch();
606 }
607
608 @Override
609 public DirectSupertype.Match newMatch(final Object... parameters) {
610 return DirectSupertype.Match.newMatch((org.eclipse.emf.ecore.EClass) parameters[0], (org.eclipse.emf.ecore.EClass) parameters[1]);
611 }
612
613 /**
614 * Inner class allowing the singleton instance of {@link JvmGenericType: ecore.DirectSupertype (visibility: PUBLIC, simpleName: DirectSupertype, identifier: ecore.DirectSupertype, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ecore) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
615 * <b>not</b> at the class load time of the outer class,
616 * but rather at the first call to {@link JvmGenericType: ecore.DirectSupertype (visibility: PUBLIC, simpleName: DirectSupertype, identifier: ecore.DirectSupertype, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ecore) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
617 *
618 * <p> This workaround is required e.g. to support recursion.
619 *
620 */
621 private static class LazyHolder {
622 private static final DirectSupertype INSTANCE = new DirectSupertype();
623
624 /**
625 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
626 * This initialization order is required to support indirect recursion.
627 *
628 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
629 *
630 */
631 private static final Object STATIC_INITIALIZER = ensureInitialized();
632
633 public static Object ensureInitialized() {
634 INSTANCE.ensureInitializedInternal();
635 return null;
636 }
637 }
638
639 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
640 private static final DirectSupertype.GeneratedPQuery INSTANCE = new GeneratedPQuery();
641
642 private final PParameter parameter_a = new PParameter("a", "org.eclipse.emf.ecore.EClass", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EClass")), PParameterDirection.INOUT);
643
644 private final PParameter parameter_b = new PParameter("b", "org.eclipse.emf.ecore.EClass", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EClass")), PParameterDirection.INOUT);
645
646 private final List<PParameter> parameters = Arrays.asList(parameter_a, parameter_b);
647
648 private GeneratedPQuery() {
649 super(PVisibility.PUBLIC);
650 }
651
652 @Override
653 public String getFullyQualifiedName() {
654 return "ecore.directSupertype";
655 }
656
657 @Override
658 public List<String> getParameterNames() {
659 return Arrays.asList("a","b");
660 }
661
662 @Override
663 public List<PParameter> getParameters() {
664 return parameters;
665 }
666
667 @Override
668 public Set<PBody> doGetContainedBodies() {
669 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
670 Set<PBody> bodies = new LinkedHashSet<>();
671 {
672 PBody body = new PBody(this);
673 PVariable var_a = body.getOrCreateVariableByName("a");
674 PVariable var_b = body.getOrCreateVariableByName("b");
675 new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass")));
676 new TypeConstraint(body, Tuples.flatTupleOf(var_b), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass")));
677 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
678 new ExportedParameter(body, var_a, parameter_a),
679 new ExportedParameter(body, var_b, parameter_b)
680 ));
681 // EClass.eSuperTypes(a,b)
682 new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass")));
683 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
684 new TypeConstraint(body, Tuples.flatTupleOf(var_a, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass", "eSuperTypes")));
685 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass")));
686 new Equality(body, var__virtual_0_, var_b);
687 bodies.add(body);
688 }
689 return bodies;
690 }
691 }
692}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/Ecore.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/Ecore.java
new file mode 100644
index 00000000..bca43a17
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/Ecore.java
@@ -0,0 +1,97 @@
1/**
2 * Generated from platform:/resource/SocialNetwork_plugin/queries/ecore/Ecore.vql
3 */
4package ecore;
5
6import ecore.DirectSupertype;
7import ecore.LoopInInheritence;
8import ecore.NonSymmetricOpposite;
9import ecore.Opposite;
10import ecore.OppositeDifferentClass;
11import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
12import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
13
14/**
15 * A pattern group formed of all public patterns defined in Ecore.vql.
16 *
17 * <p>Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare
18 * a VIATRA Query engine for matching all patterns originally defined in file Ecore.vql,
19 * in order to achieve better performance than one-by-one on-demand matcher initialization.
20 *
21 * <p> From package ecore, the group contains the definition of the following patterns: <ul>
22 * <li>directSupertype</li>
23 * <li>loopInInheritence</li>
24 * <li>opposite</li>
25 * <li>oppositeDifferentClass</li>
26 * <li>nonSymmetricOpposite</li>
27 * </ul>
28 *
29 * @see IQueryGroup
30 *
31 */
32@SuppressWarnings("all")
33public final class Ecore extends BaseGeneratedPatternGroup {
34 /**
35 * Access the pattern group.
36 *
37 * @return the singleton instance of the group
38 * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications
39 *
40 */
41 public static Ecore instance() {
42 if (INSTANCE == null) {
43 INSTANCE = new Ecore();
44 }
45 return INSTANCE;
46 }
47
48 private static Ecore INSTANCE;
49
50 private Ecore() {
51 querySpecifications.add(DirectSupertype.instance());
52 querySpecifications.add(LoopInInheritence.instance());
53 querySpecifications.add(Opposite.instance());
54 querySpecifications.add(OppositeDifferentClass.instance());
55 querySpecifications.add(NonSymmetricOpposite.instance());
56 }
57
58 public DirectSupertype getDirectSupertype() {
59 return DirectSupertype.instance();
60 }
61
62 public DirectSupertype.Matcher getDirectSupertype(final ViatraQueryEngine engine) {
63 return DirectSupertype.Matcher.on(engine);
64 }
65
66 public LoopInInheritence getLoopInInheritence() {
67 return LoopInInheritence.instance();
68 }
69
70 public LoopInInheritence.Matcher getLoopInInheritence(final ViatraQueryEngine engine) {
71 return LoopInInheritence.Matcher.on(engine);
72 }
73
74 public Opposite getOpposite() {
75 return Opposite.instance();
76 }
77
78 public Opposite.Matcher getOpposite(final ViatraQueryEngine engine) {
79 return Opposite.Matcher.on(engine);
80 }
81
82 public OppositeDifferentClass getOppositeDifferentClass() {
83 return OppositeDifferentClass.instance();
84 }
85
86 public OppositeDifferentClass.Matcher getOppositeDifferentClass(final ViatraQueryEngine engine) {
87 return OppositeDifferentClass.Matcher.on(engine);
88 }
89
90 public NonSymmetricOpposite getNonSymmetricOpposite() {
91 return NonSymmetricOpposite.instance();
92 }
93
94 public NonSymmetricOpposite.Matcher getNonSymmetricOpposite(final ViatraQueryEngine engine) {
95 return NonSymmetricOpposite.Matcher.on(engine);
96 }
97}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/LoopInInheritence.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/LoopInInheritence.java
new file mode 100644
index 00000000..fb14941f
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/LoopInInheritence.java
@@ -0,0 +1,548 @@
1/**
2 * Generated from platform:/resource/SocialNetwork_plugin/queries/ecore/Ecore.vql
3 */
4package ecore;
5
6import ecore.DirectSupertype;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Objects;
12import java.util.Optional;
13import java.util.Set;
14import java.util.function.Consumer;
15import java.util.stream.Collectors;
16import java.util.stream.Stream;
17import org.apache.log4j.Logger;
18import org.eclipse.emf.ecore.EClass;
19import org.eclipse.viatra.query.runtime.api.IPatternMatch;
20import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
21import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
22import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
24import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
25import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
26import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
27import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
28import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
30import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
31import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
35import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
38import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
39import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
40import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
41
42/**
43 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
44 *
45 * <p>Original source:
46 * <code><pre>
47 * {@literal @}Constraint(key={a}, severity="error", message="error")
48 * pattern loopInInheritence(a: EClass) {
49 * find directSupertype+(a,a);
50 * }
51 * </pre></code>
52 *
53 * @see Matcher
54 * @see Match
55 *
56 */
57@SuppressWarnings("all")
58public final class LoopInInheritence extends BaseGeneratedEMFQuerySpecification<LoopInInheritence.Matcher> {
59 /**
60 * Pattern-specific match representation of the ecore.loopInInheritence pattern,
61 * to be used in conjunction with {@link Matcher}.
62 *
63 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
64 * Each instance is a (possibly partial) substitution of pattern parameters,
65 * usable to represent a match of the pattern in the result of a query,
66 * or to specify the bound (fixed) input parameters when issuing a query.
67 *
68 * @see Matcher
69 *
70 */
71 public static abstract class Match extends BasePatternMatch {
72 private EClass fA;
73
74 private static List<String> parameterNames = makeImmutableList("a");
75
76 private Match(final EClass pA) {
77 this.fA = pA;
78 }
79
80 @Override
81 public Object get(final String parameterName) {
82 if ("a".equals(parameterName)) return this.fA;
83 return null;
84 }
85
86 public EClass getA() {
87 return this.fA;
88 }
89
90 @Override
91 public boolean set(final String parameterName, final Object newValue) {
92 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
93 if ("a".equals(parameterName) ) {
94 this.fA = (EClass) newValue;
95 return true;
96 }
97 return false;
98 }
99
100 public void setA(final EClass pA) {
101 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
102 this.fA = pA;
103 }
104
105 @Override
106 public String patternName() {
107 return "ecore.loopInInheritence";
108 }
109
110 @Override
111 public List<String> parameterNames() {
112 return LoopInInheritence.Match.parameterNames;
113 }
114
115 @Override
116 public Object[] toArray() {
117 return new Object[]{fA};
118 }
119
120 @Override
121 public LoopInInheritence.Match toImmutable() {
122 return isMutable() ? newMatch(fA) : this;
123 }
124
125 @Override
126 public String prettyPrint() {
127 StringBuilder result = new StringBuilder();
128 result.append("\"a\"=" + prettyPrintValue(fA));
129 return result.toString();
130 }
131
132 @Override
133 public int hashCode() {
134 return Objects.hash(fA);
135 }
136
137 @Override
138 public boolean equals(final Object obj) {
139 if (this == obj)
140 return true;
141 if (obj == null) {
142 return false;
143 }
144 if ((obj instanceof LoopInInheritence.Match)) {
145 LoopInInheritence.Match other = (LoopInInheritence.Match) obj;
146 return Objects.equals(fA, other.fA);
147 } else {
148 // this should be infrequent
149 if (!(obj instanceof IPatternMatch)) {
150 return false;
151 }
152 IPatternMatch otherSig = (IPatternMatch) obj;
153 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
154 }
155 }
156
157 @Override
158 public LoopInInheritence specification() {
159 return LoopInInheritence.instance();
160 }
161
162 /**
163 * Returns an empty, mutable match.
164 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
165 *
166 * @return the empty match.
167 *
168 */
169 public static LoopInInheritence.Match newEmptyMatch() {
170 return new Mutable(null);
171 }
172
173 /**
174 * Returns a mutable (partial) match.
175 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
176 *
177 * @param pA the fixed value of pattern parameter a, or null if not bound.
178 * @return the new, mutable (partial) match object.
179 *
180 */
181 public static LoopInInheritence.Match newMutableMatch(final EClass pA) {
182 return new Mutable(pA);
183 }
184
185 /**
186 * Returns a new (partial) match.
187 * This can be used e.g. to call the matcher with a partial match.
188 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
189 * @param pA the fixed value of pattern parameter a, or null if not bound.
190 * @return the (partial) match object.
191 *
192 */
193 public static LoopInInheritence.Match newMatch(final EClass pA) {
194 return new Immutable(pA);
195 }
196
197 private static final class Mutable extends LoopInInheritence.Match {
198 Mutable(final EClass pA) {
199 super(pA);
200 }
201
202 @Override
203 public boolean isMutable() {
204 return true;
205 }
206 }
207
208 private static final class Immutable extends LoopInInheritence.Match {
209 Immutable(final EClass pA) {
210 super(pA);
211 }
212
213 @Override
214 public boolean isMutable() {
215 return false;
216 }
217 }
218 }
219
220 /**
221 * Generated pattern matcher API of the ecore.loopInInheritence pattern,
222 * providing pattern-specific query methods.
223 *
224 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
225 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
226 *
227 * <p>Matches of the pattern will be represented as {@link Match}.
228 *
229 * <p>Original source:
230 * <code><pre>
231 * {@literal @}Constraint(key={a}, severity="error", message="error")
232 * pattern loopInInheritence(a: EClass) {
233 * find directSupertype+(a,a);
234 * }
235 * </pre></code>
236 *
237 * @see Match
238 * @see LoopInInheritence
239 *
240 */
241 public static class Matcher extends BaseMatcher<LoopInInheritence.Match> {
242 /**
243 * Initializes the pattern matcher within an existing VIATRA Query engine.
244 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
245 *
246 * @param engine the existing VIATRA Query engine in which this matcher will be created.
247 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
248 *
249 */
250 public static LoopInInheritence.Matcher on(final ViatraQueryEngine engine) {
251 // check if matcher already exists
252 Matcher matcher = engine.getExistingMatcher(querySpecification());
253 if (matcher == null) {
254 matcher = (Matcher)engine.getMatcher(querySpecification());
255 }
256 return matcher;
257 }
258
259 /**
260 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
261 * @return an initialized matcher
262 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
263 *
264 */
265 public static LoopInInheritence.Matcher create() {
266 return new Matcher();
267 }
268
269 private static final int POSITION_A = 0;
270
271 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(LoopInInheritence.Matcher.class);
272
273 /**
274 * Initializes the pattern matcher within an existing VIATRA Query engine.
275 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
276 *
277 * @param engine the existing VIATRA Query engine in which this matcher will be created.
278 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
279 *
280 */
281 private Matcher() {
282 super(querySpecification());
283 }
284
285 /**
286 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
287 * @param pA the fixed value of pattern parameter a, or null if not bound.
288 * @return matches represented as a Match object.
289 *
290 */
291 public Collection<LoopInInheritence.Match> getAllMatches(final EClass pA) {
292 return rawStreamAllMatches(new Object[]{pA}).collect(Collectors.toSet());
293 }
294
295 /**
296 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
297 * </p>
298 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
299 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
300 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
301 * @param pA the fixed value of pattern parameter a, or null if not bound.
302 * @return a stream of matches represented as a Match object.
303 *
304 */
305 public Stream<LoopInInheritence.Match> streamAllMatches(final EClass pA) {
306 return rawStreamAllMatches(new Object[]{pA});
307 }
308
309 /**
310 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
311 * Neither determinism nor randomness of selection is guaranteed.
312 * @param pA the fixed value of pattern parameter a, or null if not bound.
313 * @return a match represented as a Match object, or null if no match is found.
314 *
315 */
316 public Optional<LoopInInheritence.Match> getOneArbitraryMatch(final EClass pA) {
317 return rawGetOneArbitraryMatch(new Object[]{pA});
318 }
319
320 /**
321 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
322 * under any possible substitution of the unspecified parameters (if any).
323 * @param pA the fixed value of pattern parameter a, or null if not bound.
324 * @return true if the input is a valid (partial) match of the pattern.
325 *
326 */
327 public boolean hasMatch(final EClass pA) {
328 return rawHasMatch(new Object[]{pA});
329 }
330
331 /**
332 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
333 * @param pA the fixed value of pattern parameter a, or null if not bound.
334 * @return the number of pattern matches found.
335 *
336 */
337 public int countMatches(final EClass pA) {
338 return rawCountMatches(new Object[]{pA});
339 }
340
341 /**
342 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
343 * Neither determinism nor randomness of selection is guaranteed.
344 * @param pA the fixed value of pattern parameter a, or null if not bound.
345 * @param processor the action that will process the selected match.
346 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
347 *
348 */
349 public boolean forOneArbitraryMatch(final EClass pA, final Consumer<? super LoopInInheritence.Match> processor) {
350 return rawForOneArbitraryMatch(new Object[]{pA}, processor);
351 }
352
353 /**
354 * Returns a new (partial) match.
355 * This can be used e.g. to call the matcher with a partial match.
356 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
357 * @param pA the fixed value of pattern parameter a, or null if not bound.
358 * @return the (partial) match object.
359 *
360 */
361 public LoopInInheritence.Match newMatch(final EClass pA) {
362 return LoopInInheritence.Match.newMatch(pA);
363 }
364
365 /**
366 * Retrieve the set of values that occur in matches for a.
367 * @return the Set of all values or empty set if there are no matches
368 *
369 */
370 protected Stream<EClass> rawStreamAllValuesOfa(final Object[] parameters) {
371 return rawStreamAllValues(POSITION_A, parameters).map(EClass.class::cast);
372 }
373
374 /**
375 * Retrieve the set of values that occur in matches for a.
376 * @return the Set of all values or empty set if there are no matches
377 *
378 */
379 public Set<EClass> getAllValuesOfa() {
380 return rawStreamAllValuesOfa(emptyArray()).collect(Collectors.toSet());
381 }
382
383 /**
384 * Retrieve the set of values that occur in matches for a.
385 * @return the Set of all values or empty set if there are no matches
386 *
387 */
388 public Stream<EClass> streamAllValuesOfa() {
389 return rawStreamAllValuesOfa(emptyArray());
390 }
391
392 @Override
393 protected LoopInInheritence.Match tupleToMatch(final Tuple t) {
394 try {
395 return LoopInInheritence.Match.newMatch((EClass) t.get(POSITION_A));
396 } catch(ClassCastException e) {
397 LOGGER.error("Element(s) in tuple not properly typed!",e);
398 return null;
399 }
400 }
401
402 @Override
403 protected LoopInInheritence.Match arrayToMatch(final Object[] match) {
404 try {
405 return LoopInInheritence.Match.newMatch((EClass) match[POSITION_A]);
406 } catch(ClassCastException e) {
407 LOGGER.error("Element(s) in array not properly typed!",e);
408 return null;
409 }
410 }
411
412 @Override
413 protected LoopInInheritence.Match arrayToMatchMutable(final Object[] match) {
414 try {
415 return LoopInInheritence.Match.newMutableMatch((EClass) match[POSITION_A]);
416 } catch(ClassCastException e) {
417 LOGGER.error("Element(s) in array not properly typed!",e);
418 return null;
419 }
420 }
421
422 /**
423 * @return the singleton instance of the query specification of this pattern
424 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
425 *
426 */
427 public static IQuerySpecification<LoopInInheritence.Matcher> querySpecification() {
428 return LoopInInheritence.instance();
429 }
430 }
431
432 private LoopInInheritence() {
433 super(GeneratedPQuery.INSTANCE);
434 }
435
436 /**
437 * @return the singleton instance of the query specification
438 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
439 *
440 */
441 public static LoopInInheritence instance() {
442 try{
443 return LazyHolder.INSTANCE;
444 } catch (ExceptionInInitializerError err) {
445 throw processInitializerError(err);
446 }
447 }
448
449 @Override
450 protected LoopInInheritence.Matcher instantiate(final ViatraQueryEngine engine) {
451 return LoopInInheritence.Matcher.on(engine);
452 }
453
454 @Override
455 public LoopInInheritence.Matcher instantiate() {
456 return LoopInInheritence.Matcher.create();
457 }
458
459 @Override
460 public LoopInInheritence.Match newEmptyMatch() {
461 return LoopInInheritence.Match.newEmptyMatch();
462 }
463
464 @Override
465 public LoopInInheritence.Match newMatch(final Object... parameters) {
466 return LoopInInheritence.Match.newMatch((org.eclipse.emf.ecore.EClass) parameters[0]);
467 }
468
469 /**
470 * Inner class allowing the singleton instance of {@link JvmGenericType: ecore.LoopInInheritence (visibility: PUBLIC, simpleName: LoopInInheritence, identifier: ecore.LoopInInheritence, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ecore) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
471 * <b>not</b> at the class load time of the outer class,
472 * but rather at the first call to {@link JvmGenericType: ecore.LoopInInheritence (visibility: PUBLIC, simpleName: LoopInInheritence, identifier: ecore.LoopInInheritence, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ecore) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
473 *
474 * <p> This workaround is required e.g. to support recursion.
475 *
476 */
477 private static class LazyHolder {
478 private static final LoopInInheritence INSTANCE = new LoopInInheritence();
479
480 /**
481 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
482 * This initialization order is required to support indirect recursion.
483 *
484 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
485 *
486 */
487 private static final Object STATIC_INITIALIZER = ensureInitialized();
488
489 public static Object ensureInitialized() {
490 INSTANCE.ensureInitializedInternal();
491 return null;
492 }
493 }
494
495 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
496 private static final LoopInInheritence.GeneratedPQuery INSTANCE = new GeneratedPQuery();
497
498 private final PParameter parameter_a = new PParameter("a", "org.eclipse.emf.ecore.EClass", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EClass")), PParameterDirection.INOUT);
499
500 private final List<PParameter> parameters = Arrays.asList(parameter_a);
501
502 private GeneratedPQuery() {
503 super(PVisibility.PUBLIC);
504 }
505
506 @Override
507 public String getFullyQualifiedName() {
508 return "ecore.loopInInheritence";
509 }
510
511 @Override
512 public List<String> getParameterNames() {
513 return Arrays.asList("a");
514 }
515
516 @Override
517 public List<PParameter> getParameters() {
518 return parameters;
519 }
520
521 @Override
522 public Set<PBody> doGetContainedBodies() {
523 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
524 Set<PBody> bodies = new LinkedHashSet<>();
525 {
526 PBody body = new PBody(this);
527 PVariable var_a = body.getOrCreateVariableByName("a");
528 new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass")));
529 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
530 new ExportedParameter(body, var_a, parameter_a)
531 ));
532 // find directSupertype+(a,a)
533 new BinaryTransitiveClosure(body, Tuples.flatTupleOf(var_a, var_a), DirectSupertype.instance().getInternalQueryRepresentation());
534 bodies.add(body);
535 }
536 {
537 PAnnotation annotation = new PAnnotation("Constraint");
538 annotation.addAttribute("key", Arrays.asList(new Object[] {
539 new ParameterReference("a")
540 }));
541 annotation.addAttribute("severity", "error");
542 annotation.addAttribute("message", "error");
543 addAnnotation(annotation);
544 }
545 return bodies;
546 }
547 }
548}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/NonSymmetricOpposite.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/NonSymmetricOpposite.java
new file mode 100644
index 00000000..d230e3f4
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/NonSymmetricOpposite.java
@@ -0,0 +1,707 @@
1/**
2 * Generated from platform:/resource/SocialNetwork_plugin/queries/ecore/Ecore.vql
3 */
4package ecore;
5
6import ecore.Opposite;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Objects;
12import java.util.Optional;
13import java.util.Set;
14import java.util.function.Consumer;
15import java.util.stream.Collectors;
16import java.util.stream.Stream;
17import org.apache.log4j.Logger;
18import org.eclipse.emf.ecore.EClass;
19import org.eclipse.emf.ecore.EReference;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
31import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
32import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
38import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
40import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
41import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
42import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
43
44/**
45 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
46 *
47 * <p>Original source:
48 * <code><pre>
49 * {@literal @}Constraint(key={a}, severity="error", message="error")
50 * pattern nonSymmetricOpposite(a:EReference, b:EReference) {
51 * find opposite(a,b);
52 * neg find opposite(b,a);
53 * }
54 * </pre></code>
55 *
56 * @see Matcher
57 * @see Match
58 *
59 */
60@SuppressWarnings("all")
61public final class NonSymmetricOpposite extends BaseGeneratedEMFQuerySpecification<NonSymmetricOpposite.Matcher> {
62 /**
63 * Pattern-specific match representation of the ecore.nonSymmetricOpposite pattern,
64 * to be used in conjunction with {@link Matcher}.
65 *
66 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
67 * Each instance is a (possibly partial) substitution of pattern parameters,
68 * usable to represent a match of the pattern in the result of a query,
69 * or to specify the bound (fixed) input parameters when issuing a query.
70 *
71 * @see Matcher
72 *
73 */
74 public static abstract class Match extends BasePatternMatch {
75 private EReference fA;
76
77 private EReference fB;
78
79 private static List<String> parameterNames = makeImmutableList("a", "b");
80
81 private Match(final EReference pA, final EReference pB) {
82 this.fA = pA;
83 this.fB = pB;
84 }
85
86 @Override
87 public Object get(final String parameterName) {
88 if ("a".equals(parameterName)) return this.fA;
89 if ("b".equals(parameterName)) return this.fB;
90 return null;
91 }
92
93 public EReference getA() {
94 return this.fA;
95 }
96
97 public EReference getB() {
98 return this.fB;
99 }
100
101 @Override
102 public boolean set(final String parameterName, final Object newValue) {
103 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
104 if ("a".equals(parameterName) ) {
105 this.fA = (EReference) newValue;
106 return true;
107 }
108 if ("b".equals(parameterName) ) {
109 this.fB = (EReference) newValue;
110 return true;
111 }
112 return false;
113 }
114
115 public void setA(final EReference pA) {
116 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
117 this.fA = pA;
118 }
119
120 public void setB(final EReference pB) {
121 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
122 this.fB = pB;
123 }
124
125 @Override
126 public String patternName() {
127 return "ecore.nonSymmetricOpposite";
128 }
129
130 @Override
131 public List<String> parameterNames() {
132 return NonSymmetricOpposite.Match.parameterNames;
133 }
134
135 @Override
136 public Object[] toArray() {
137 return new Object[]{fA, fB};
138 }
139
140 @Override
141 public NonSymmetricOpposite.Match toImmutable() {
142 return isMutable() ? newMatch(fA, fB) : this;
143 }
144
145 @Override
146 public String prettyPrint() {
147 StringBuilder result = new StringBuilder();
148 result.append("\"a\"=" + prettyPrintValue(fA) + ", ");
149 result.append("\"b\"=" + prettyPrintValue(fB));
150 return result.toString();
151 }
152
153 @Override
154 public int hashCode() {
155 return Objects.hash(fA, fB);
156 }
157
158 @Override
159 public boolean equals(final Object obj) {
160 if (this == obj)
161 return true;
162 if (obj == null) {
163 return false;
164 }
165 if ((obj instanceof NonSymmetricOpposite.Match)) {
166 NonSymmetricOpposite.Match other = (NonSymmetricOpposite.Match) obj;
167 return Objects.equals(fA, other.fA) && Objects.equals(fB, other.fB);
168 } else {
169 // this should be infrequent
170 if (!(obj instanceof IPatternMatch)) {
171 return false;
172 }
173 IPatternMatch otherSig = (IPatternMatch) obj;
174 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
175 }
176 }
177
178 @Override
179 public NonSymmetricOpposite specification() {
180 return NonSymmetricOpposite.instance();
181 }
182
183 /**
184 * Returns an empty, mutable match.
185 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
186 *
187 * @return the empty match.
188 *
189 */
190 public static NonSymmetricOpposite.Match newEmptyMatch() {
191 return new Mutable(null, null);
192 }
193
194 /**
195 * Returns a mutable (partial) match.
196 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
197 *
198 * @param pA the fixed value of pattern parameter a, or null if not bound.
199 * @param pB the fixed value of pattern parameter b, or null if not bound.
200 * @return the new, mutable (partial) match object.
201 *
202 */
203 public static NonSymmetricOpposite.Match newMutableMatch(final EReference pA, final EReference pB) {
204 return new Mutable(pA, pB);
205 }
206
207 /**
208 * Returns a new (partial) match.
209 * This can be used e.g. to call the matcher with a partial match.
210 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
211 * @param pA the fixed value of pattern parameter a, or null if not bound.
212 * @param pB the fixed value of pattern parameter b, or null if not bound.
213 * @return the (partial) match object.
214 *
215 */
216 public static NonSymmetricOpposite.Match newMatch(final EReference pA, final EReference pB) {
217 return new Immutable(pA, pB);
218 }
219
220 private static final class Mutable extends NonSymmetricOpposite.Match {
221 Mutable(final EReference pA, final EReference pB) {
222 super(pA, pB);
223 }
224
225 @Override
226 public boolean isMutable() {
227 return true;
228 }
229 }
230
231 private static final class Immutable extends NonSymmetricOpposite.Match {
232 Immutable(final EReference pA, final EReference pB) {
233 super(pA, pB);
234 }
235
236 @Override
237 public boolean isMutable() {
238 return false;
239 }
240 }
241 }
242
243 /**
244 * Generated pattern matcher API of the ecore.nonSymmetricOpposite pattern,
245 * providing pattern-specific query methods.
246 *
247 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
248 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
249 *
250 * <p>Matches of the pattern will be represented as {@link Match}.
251 *
252 * <p>Original source:
253 * <code><pre>
254 * {@literal @}Constraint(key={a}, severity="error", message="error")
255 * pattern nonSymmetricOpposite(a:EReference, b:EReference) {
256 * find opposite(a,b);
257 * neg find opposite(b,a);
258 * }
259 * </pre></code>
260 *
261 * @see Match
262 * @see NonSymmetricOpposite
263 *
264 */
265 public static class Matcher extends BaseMatcher<NonSymmetricOpposite.Match> {
266 /**
267 * Initializes the pattern matcher within an existing VIATRA Query engine.
268 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
269 *
270 * @param engine the existing VIATRA Query engine in which this matcher will be created.
271 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
272 *
273 */
274 public static NonSymmetricOpposite.Matcher on(final ViatraQueryEngine engine) {
275 // check if matcher already exists
276 Matcher matcher = engine.getExistingMatcher(querySpecification());
277 if (matcher == null) {
278 matcher = (Matcher)engine.getMatcher(querySpecification());
279 }
280 return matcher;
281 }
282
283 /**
284 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
285 * @return an initialized matcher
286 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
287 *
288 */
289 public static NonSymmetricOpposite.Matcher create() {
290 return new Matcher();
291 }
292
293 private static final int POSITION_A = 0;
294
295 private static final int POSITION_B = 1;
296
297 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NonSymmetricOpposite.Matcher.class);
298
299 /**
300 * Initializes the pattern matcher within an existing VIATRA Query engine.
301 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
302 *
303 * @param engine the existing VIATRA Query engine in which this matcher will be created.
304 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
305 *
306 */
307 private Matcher() {
308 super(querySpecification());
309 }
310
311 /**
312 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
313 * @param pA the fixed value of pattern parameter a, or null if not bound.
314 * @param pB the fixed value of pattern parameter b, or null if not bound.
315 * @return matches represented as a Match object.
316 *
317 */
318 public Collection<NonSymmetricOpposite.Match> getAllMatches(final EReference pA, final EReference pB) {
319 return rawStreamAllMatches(new Object[]{pA, pB}).collect(Collectors.toSet());
320 }
321
322 /**
323 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
324 * </p>
325 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
326 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
327 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
328 * @param pA the fixed value of pattern parameter a, or null if not bound.
329 * @param pB the fixed value of pattern parameter b, or null if not bound.
330 * @return a stream of matches represented as a Match object.
331 *
332 */
333 public Stream<NonSymmetricOpposite.Match> streamAllMatches(final EReference pA, final EReference pB) {
334 return rawStreamAllMatches(new Object[]{pA, pB});
335 }
336
337 /**
338 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
339 * Neither determinism nor randomness of selection is guaranteed.
340 * @param pA the fixed value of pattern parameter a, or null if not bound.
341 * @param pB the fixed value of pattern parameter b, or null if not bound.
342 * @return a match represented as a Match object, or null if no match is found.
343 *
344 */
345 public Optional<NonSymmetricOpposite.Match> getOneArbitraryMatch(final EReference pA, final EReference pB) {
346 return rawGetOneArbitraryMatch(new Object[]{pA, pB});
347 }
348
349 /**
350 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
351 * under any possible substitution of the unspecified parameters (if any).
352 * @param pA the fixed value of pattern parameter a, or null if not bound.
353 * @param pB the fixed value of pattern parameter b, or null if not bound.
354 * @return true if the input is a valid (partial) match of the pattern.
355 *
356 */
357 public boolean hasMatch(final EReference pA, final EReference pB) {
358 return rawHasMatch(new Object[]{pA, pB});
359 }
360
361 /**
362 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
363 * @param pA the fixed value of pattern parameter a, or null if not bound.
364 * @param pB the fixed value of pattern parameter b, or null if not bound.
365 * @return the number of pattern matches found.
366 *
367 */
368 public int countMatches(final EReference pA, final EReference pB) {
369 return rawCountMatches(new Object[]{pA, pB});
370 }
371
372 /**
373 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
374 * Neither determinism nor randomness of selection is guaranteed.
375 * @param pA the fixed value of pattern parameter a, or null if not bound.
376 * @param pB the fixed value of pattern parameter b, or null if not bound.
377 * @param processor the action that will process the selected match.
378 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
379 *
380 */
381 public boolean forOneArbitraryMatch(final EReference pA, final EReference pB, final Consumer<? super NonSymmetricOpposite.Match> processor) {
382 return rawForOneArbitraryMatch(new Object[]{pA, pB}, processor);
383 }
384
385 /**
386 * Returns a new (partial) match.
387 * This can be used e.g. to call the matcher with a partial match.
388 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
389 * @param pA the fixed value of pattern parameter a, or null if not bound.
390 * @param pB the fixed value of pattern parameter b, or null if not bound.
391 * @return the (partial) match object.
392 *
393 */
394 public NonSymmetricOpposite.Match newMatch(final EReference pA, final EReference pB) {
395 return NonSymmetricOpposite.Match.newMatch(pA, pB);
396 }
397
398 /**
399 * Retrieve the set of values that occur in matches for a.
400 * @return the Set of all values or empty set if there are no matches
401 *
402 */
403 protected Stream<EReference> rawStreamAllValuesOfa(final Object[] parameters) {
404 return rawStreamAllValues(POSITION_A, parameters).map(EReference.class::cast);
405 }
406
407 /**
408 * Retrieve the set of values that occur in matches for a.
409 * @return the Set of all values or empty set if there are no matches
410 *
411 */
412 public Set<EReference> getAllValuesOfa() {
413 return rawStreamAllValuesOfa(emptyArray()).collect(Collectors.toSet());
414 }
415
416 /**
417 * Retrieve the set of values that occur in matches for a.
418 * @return the Set of all values or empty set if there are no matches
419 *
420 */
421 public Stream<EReference> streamAllValuesOfa() {
422 return rawStreamAllValuesOfa(emptyArray());
423 }
424
425 /**
426 * Retrieve the set of values that occur in matches for a.
427 * </p>
428 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
429 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
430 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
431 *
432 * @return the Stream of all values or empty set if there are no matches
433 *
434 */
435 public Stream<EReference> streamAllValuesOfa(final NonSymmetricOpposite.Match partialMatch) {
436 return rawStreamAllValuesOfa(partialMatch.toArray());
437 }
438
439 /**
440 * Retrieve the set of values that occur in matches for a.
441 * </p>
442 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
443 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
444 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
445 *
446 * @return the Stream of all values or empty set if there are no matches
447 *
448 */
449 public Stream<EReference> streamAllValuesOfa(final EReference pB) {
450 return rawStreamAllValuesOfa(new Object[]{null, pB});
451 }
452
453 /**
454 * Retrieve the set of values that occur in matches for a.
455 * @return the Set of all values or empty set if there are no matches
456 *
457 */
458 public Set<EReference> getAllValuesOfa(final NonSymmetricOpposite.Match partialMatch) {
459 return rawStreamAllValuesOfa(partialMatch.toArray()).collect(Collectors.toSet());
460 }
461
462 /**
463 * Retrieve the set of values that occur in matches for a.
464 * @return the Set of all values or empty set if there are no matches
465 *
466 */
467 public Set<EReference> getAllValuesOfa(final EReference pB) {
468 return rawStreamAllValuesOfa(new Object[]{null, pB}).collect(Collectors.toSet());
469 }
470
471 /**
472 * Retrieve the set of values that occur in matches for b.
473 * @return the Set of all values or empty set if there are no matches
474 *
475 */
476 protected Stream<EReference> rawStreamAllValuesOfb(final Object[] parameters) {
477 return rawStreamAllValues(POSITION_B, parameters).map(EReference.class::cast);
478 }
479
480 /**
481 * Retrieve the set of values that occur in matches for b.
482 * @return the Set of all values or empty set if there are no matches
483 *
484 */
485 public Set<EReference> getAllValuesOfb() {
486 return rawStreamAllValuesOfb(emptyArray()).collect(Collectors.toSet());
487 }
488
489 /**
490 * Retrieve the set of values that occur in matches for b.
491 * @return the Set of all values or empty set if there are no matches
492 *
493 */
494 public Stream<EReference> streamAllValuesOfb() {
495 return rawStreamAllValuesOfb(emptyArray());
496 }
497
498 /**
499 * Retrieve the set of values that occur in matches for b.
500 * </p>
501 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
502 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
503 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
504 *
505 * @return the Stream of all values or empty set if there are no matches
506 *
507 */
508 public Stream<EReference> streamAllValuesOfb(final NonSymmetricOpposite.Match partialMatch) {
509 return rawStreamAllValuesOfb(partialMatch.toArray());
510 }
511
512 /**
513 * Retrieve the set of values that occur in matches for b.
514 * </p>
515 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
516 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
517 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
518 *
519 * @return the Stream of all values or empty set if there are no matches
520 *
521 */
522 public Stream<EReference> streamAllValuesOfb(final EReference pA) {
523 return rawStreamAllValuesOfb(new Object[]{pA, null});
524 }
525
526 /**
527 * Retrieve the set of values that occur in matches for b.
528 * @return the Set of all values or empty set if there are no matches
529 *
530 */
531 public Set<EReference> getAllValuesOfb(final NonSymmetricOpposite.Match partialMatch) {
532 return rawStreamAllValuesOfb(partialMatch.toArray()).collect(Collectors.toSet());
533 }
534
535 /**
536 * Retrieve the set of values that occur in matches for b.
537 * @return the Set of all values or empty set if there are no matches
538 *
539 */
540 public Set<EReference> getAllValuesOfb(final EReference pA) {
541 return rawStreamAllValuesOfb(new Object[]{pA, null}).collect(Collectors.toSet());
542 }
543
544 @Override
545 protected NonSymmetricOpposite.Match tupleToMatch(final Tuple t) {
546 try {
547 return NonSymmetricOpposite.Match.newMatch((EReference) t.get(POSITION_A), (EReference) t.get(POSITION_B));
548 } catch(ClassCastException e) {
549 LOGGER.error("Element(s) in tuple not properly typed!",e);
550 return null;
551 }
552 }
553
554 @Override
555 protected NonSymmetricOpposite.Match arrayToMatch(final Object[] match) {
556 try {
557 return NonSymmetricOpposite.Match.newMatch((EReference) match[POSITION_A], (EReference) match[POSITION_B]);
558 } catch(ClassCastException e) {
559 LOGGER.error("Element(s) in array not properly typed!",e);
560 return null;
561 }
562 }
563
564 @Override
565 protected NonSymmetricOpposite.Match arrayToMatchMutable(final Object[] match) {
566 try {
567 return NonSymmetricOpposite.Match.newMutableMatch((EReference) match[POSITION_A], (EReference) match[POSITION_B]);
568 } catch(ClassCastException e) {
569 LOGGER.error("Element(s) in array not properly typed!",e);
570 return null;
571 }
572 }
573
574 /**
575 * @return the singleton instance of the query specification of this pattern
576 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
577 *
578 */
579 public static IQuerySpecification<NonSymmetricOpposite.Matcher> querySpecification() {
580 return NonSymmetricOpposite.instance();
581 }
582 }
583
584 private NonSymmetricOpposite() {
585 super(GeneratedPQuery.INSTANCE);
586 }
587
588 /**
589 * @return the singleton instance of the query specification
590 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
591 *
592 */
593 public static NonSymmetricOpposite instance() {
594 try{
595 return LazyHolder.INSTANCE;
596 } catch (ExceptionInInitializerError err) {
597 throw processInitializerError(err);
598 }
599 }
600
601 @Override
602 protected NonSymmetricOpposite.Matcher instantiate(final ViatraQueryEngine engine) {
603 return NonSymmetricOpposite.Matcher.on(engine);
604 }
605
606 @Override
607 public NonSymmetricOpposite.Matcher instantiate() {
608 return NonSymmetricOpposite.Matcher.create();
609 }
610
611 @Override
612 public NonSymmetricOpposite.Match newEmptyMatch() {
613 return NonSymmetricOpposite.Match.newEmptyMatch();
614 }
615
616 @Override
617 public NonSymmetricOpposite.Match newMatch(final Object... parameters) {
618 return NonSymmetricOpposite.Match.newMatch((org.eclipse.emf.ecore.EReference) parameters[0], (org.eclipse.emf.ecore.EReference) parameters[1]);
619 }
620
621 /**
622 * Inner class allowing the singleton instance of {@link JvmGenericType: ecore.NonSymmetricOpposite (visibility: PUBLIC, simpleName: NonSymmetricOpposite, identifier: ecore.NonSymmetricOpposite, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ecore) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
623 * <b>not</b> at the class load time of the outer class,
624 * but rather at the first call to {@link JvmGenericType: ecore.NonSymmetricOpposite (visibility: PUBLIC, simpleName: NonSymmetricOpposite, identifier: ecore.NonSymmetricOpposite, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ecore) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
625 *
626 * <p> This workaround is required e.g. to support recursion.
627 *
628 */
629 private static class LazyHolder {
630 private static final NonSymmetricOpposite INSTANCE = new NonSymmetricOpposite();
631
632 /**
633 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
634 * This initialization order is required to support indirect recursion.
635 *
636 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
637 *
638 */
639 private static final Object STATIC_INITIALIZER = ensureInitialized();
640
641 public static Object ensureInitialized() {
642 INSTANCE.ensureInitializedInternal();
643 return null;
644 }
645 }
646
647 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
648 private static final NonSymmetricOpposite.GeneratedPQuery INSTANCE = new GeneratedPQuery();
649
650 private final PParameter parameter_a = new PParameter("a", "org.eclipse.emf.ecore.EReference", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EReference")), PParameterDirection.INOUT);
651
652 private final PParameter parameter_b = new PParameter("b", "org.eclipse.emf.ecore.EReference", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EReference")), PParameterDirection.INOUT);
653
654 private final List<PParameter> parameters = Arrays.asList(parameter_a, parameter_b);
655
656 private GeneratedPQuery() {
657 super(PVisibility.PUBLIC);
658 }
659
660 @Override
661 public String getFullyQualifiedName() {
662 return "ecore.nonSymmetricOpposite";
663 }
664
665 @Override
666 public List<String> getParameterNames() {
667 return Arrays.asList("a","b");
668 }
669
670 @Override
671 public List<PParameter> getParameters() {
672 return parameters;
673 }
674
675 @Override
676 public Set<PBody> doGetContainedBodies() {
677 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
678 Set<PBody> bodies = new LinkedHashSet<>();
679 {
680 PBody body = new PBody(this);
681 PVariable var_a = body.getOrCreateVariableByName("a");
682 PVariable var_b = body.getOrCreateVariableByName("b");
683 new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference")));
684 new TypeConstraint(body, Tuples.flatTupleOf(var_b), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference")));
685 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
686 new ExportedParameter(body, var_a, parameter_a),
687 new ExportedParameter(body, var_b, parameter_b)
688 ));
689 // find opposite(a,b)
690 new PositivePatternCall(body, Tuples.flatTupleOf(var_a, var_b), Opposite.instance().getInternalQueryRepresentation());
691 // neg find opposite(b,a)
692 new NegativePatternCall(body, Tuples.flatTupleOf(var_b, var_a), Opposite.instance().getInternalQueryRepresentation());
693 bodies.add(body);
694 }
695 {
696 PAnnotation annotation = new PAnnotation("Constraint");
697 annotation.addAttribute("key", Arrays.asList(new Object[] {
698 new ParameterReference("a")
699 }));
700 annotation.addAttribute("severity", "error");
701 annotation.addAttribute("message", "error");
702 addAnnotation(annotation);
703 }
704 return bodies;
705 }
706 }
707}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/Opposite.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/Opposite.java
new file mode 100644
index 00000000..d826f072
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/Opposite.java
@@ -0,0 +1,693 @@
1/**
2 * Generated from platform:/resource/SocialNetwork_plugin/queries/ecore/Ecore.vql
3 */
4package ecore;
5
6import java.util.Arrays;
7import java.util.Collection;
8import java.util.LinkedHashSet;
9import java.util.List;
10import java.util.Objects;
11import java.util.Optional;
12import java.util.Set;
13import java.util.function.Consumer;
14import java.util.stream.Collectors;
15import java.util.stream.Stream;
16import org.apache.log4j.Logger;
17import org.eclipse.emf.ecore.EClass;
18import org.eclipse.emf.ecore.EReference;
19import org.eclipse.viatra.query.runtime.api.IPatternMatch;
20import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
21import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
22import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
24import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
25import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
26import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
27import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
28import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
31import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
34import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
35import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
37import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
38import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
39import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
40
41/**
42 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
43 *
44 * <p>Original source:
45 * <code><pre>
46 * pattern opposite(a:EReference, b: EReference) {
47 * EReference.eOpposite(a,b);
48 * }
49 * </pre></code>
50 *
51 * @see Matcher
52 * @see Match
53 *
54 */
55@SuppressWarnings("all")
56public final class Opposite extends BaseGeneratedEMFQuerySpecification<Opposite.Matcher> {
57 /**
58 * Pattern-specific match representation of the ecore.opposite pattern,
59 * to be used in conjunction with {@link Matcher}.
60 *
61 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
62 * Each instance is a (possibly partial) substitution of pattern parameters,
63 * usable to represent a match of the pattern in the result of a query,
64 * or to specify the bound (fixed) input parameters when issuing a query.
65 *
66 * @see Matcher
67 *
68 */
69 public static abstract class Match extends BasePatternMatch {
70 private EReference fA;
71
72 private EReference fB;
73
74 private static List<String> parameterNames = makeImmutableList("a", "b");
75
76 private Match(final EReference pA, final EReference pB) {
77 this.fA = pA;
78 this.fB = pB;
79 }
80
81 @Override
82 public Object get(final String parameterName) {
83 if ("a".equals(parameterName)) return this.fA;
84 if ("b".equals(parameterName)) return this.fB;
85 return null;
86 }
87
88 public EReference getA() {
89 return this.fA;
90 }
91
92 public EReference getB() {
93 return this.fB;
94 }
95
96 @Override
97 public boolean set(final String parameterName, final Object newValue) {
98 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
99 if ("a".equals(parameterName) ) {
100 this.fA = (EReference) newValue;
101 return true;
102 }
103 if ("b".equals(parameterName) ) {
104 this.fB = (EReference) newValue;
105 return true;
106 }
107 return false;
108 }
109
110 public void setA(final EReference pA) {
111 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
112 this.fA = pA;
113 }
114
115 public void setB(final EReference pB) {
116 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
117 this.fB = pB;
118 }
119
120 @Override
121 public String patternName() {
122 return "ecore.opposite";
123 }
124
125 @Override
126 public List<String> parameterNames() {
127 return Opposite.Match.parameterNames;
128 }
129
130 @Override
131 public Object[] toArray() {
132 return new Object[]{fA, fB};
133 }
134
135 @Override
136 public Opposite.Match toImmutable() {
137 return isMutable() ? newMatch(fA, fB) : this;
138 }
139
140 @Override
141 public String prettyPrint() {
142 StringBuilder result = new StringBuilder();
143 result.append("\"a\"=" + prettyPrintValue(fA) + ", ");
144 result.append("\"b\"=" + prettyPrintValue(fB));
145 return result.toString();
146 }
147
148 @Override
149 public int hashCode() {
150 return Objects.hash(fA, fB);
151 }
152
153 @Override
154 public boolean equals(final Object obj) {
155 if (this == obj)
156 return true;
157 if (obj == null) {
158 return false;
159 }
160 if ((obj instanceof Opposite.Match)) {
161 Opposite.Match other = (Opposite.Match) obj;
162 return Objects.equals(fA, other.fA) && Objects.equals(fB, other.fB);
163 } else {
164 // this should be infrequent
165 if (!(obj instanceof IPatternMatch)) {
166 return false;
167 }
168 IPatternMatch otherSig = (IPatternMatch) obj;
169 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
170 }
171 }
172
173 @Override
174 public Opposite specification() {
175 return Opposite.instance();
176 }
177
178 /**
179 * Returns an empty, mutable match.
180 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
181 *
182 * @return the empty match.
183 *
184 */
185 public static Opposite.Match newEmptyMatch() {
186 return new Mutable(null, null);
187 }
188
189 /**
190 * Returns a mutable (partial) match.
191 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
192 *
193 * @param pA the fixed value of pattern parameter a, or null if not bound.
194 * @param pB the fixed value of pattern parameter b, or null if not bound.
195 * @return the new, mutable (partial) match object.
196 *
197 */
198 public static Opposite.Match newMutableMatch(final EReference pA, final EReference pB) {
199 return new Mutable(pA, pB);
200 }
201
202 /**
203 * Returns a new (partial) match.
204 * This can be used e.g. to call the matcher with a partial match.
205 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
206 * @param pA the fixed value of pattern parameter a, or null if not bound.
207 * @param pB the fixed value of pattern parameter b, or null if not bound.
208 * @return the (partial) match object.
209 *
210 */
211 public static Opposite.Match newMatch(final EReference pA, final EReference pB) {
212 return new Immutable(pA, pB);
213 }
214
215 private static final class Mutable extends Opposite.Match {
216 Mutable(final EReference pA, final EReference pB) {
217 super(pA, pB);
218 }
219
220 @Override
221 public boolean isMutable() {
222 return true;
223 }
224 }
225
226 private static final class Immutable extends Opposite.Match {
227 Immutable(final EReference pA, final EReference pB) {
228 super(pA, pB);
229 }
230
231 @Override
232 public boolean isMutable() {
233 return false;
234 }
235 }
236 }
237
238 /**
239 * Generated pattern matcher API of the ecore.opposite pattern,
240 * providing pattern-specific query methods.
241 *
242 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
243 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
244 *
245 * <p>Matches of the pattern will be represented as {@link Match}.
246 *
247 * <p>Original source:
248 * <code><pre>
249 * pattern opposite(a:EReference, b: EReference) {
250 * EReference.eOpposite(a,b);
251 * }
252 * </pre></code>
253 *
254 * @see Match
255 * @see Opposite
256 *
257 */
258 public static class Matcher extends BaseMatcher<Opposite.Match> {
259 /**
260 * Initializes the pattern matcher within an existing VIATRA Query engine.
261 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
262 *
263 * @param engine the existing VIATRA Query engine in which this matcher will be created.
264 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
265 *
266 */
267 public static Opposite.Matcher on(final ViatraQueryEngine engine) {
268 // check if matcher already exists
269 Matcher matcher = engine.getExistingMatcher(querySpecification());
270 if (matcher == null) {
271 matcher = (Matcher)engine.getMatcher(querySpecification());
272 }
273 return matcher;
274 }
275
276 /**
277 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
278 * @return an initialized matcher
279 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
280 *
281 */
282 public static Opposite.Matcher create() {
283 return new Matcher();
284 }
285
286 private static final int POSITION_A = 0;
287
288 private static final int POSITION_B = 1;
289
290 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Opposite.Matcher.class);
291
292 /**
293 * Initializes the pattern matcher within an existing VIATRA Query engine.
294 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
295 *
296 * @param engine the existing VIATRA Query engine in which this matcher will be created.
297 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
298 *
299 */
300 private Matcher() {
301 super(querySpecification());
302 }
303
304 /**
305 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
306 * @param pA the fixed value of pattern parameter a, or null if not bound.
307 * @param pB the fixed value of pattern parameter b, or null if not bound.
308 * @return matches represented as a Match object.
309 *
310 */
311 public Collection<Opposite.Match> getAllMatches(final EReference pA, final EReference pB) {
312 return rawStreamAllMatches(new Object[]{pA, pB}).collect(Collectors.toSet());
313 }
314
315 /**
316 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
317 * </p>
318 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
319 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
320 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
321 * @param pA the fixed value of pattern parameter a, or null if not bound.
322 * @param pB the fixed value of pattern parameter b, or null if not bound.
323 * @return a stream of matches represented as a Match object.
324 *
325 */
326 public Stream<Opposite.Match> streamAllMatches(final EReference pA, final EReference pB) {
327 return rawStreamAllMatches(new Object[]{pA, pB});
328 }
329
330 /**
331 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
332 * Neither determinism nor randomness of selection is guaranteed.
333 * @param pA the fixed value of pattern parameter a, or null if not bound.
334 * @param pB the fixed value of pattern parameter b, or null if not bound.
335 * @return a match represented as a Match object, or null if no match is found.
336 *
337 */
338 public Optional<Opposite.Match> getOneArbitraryMatch(final EReference pA, final EReference pB) {
339 return rawGetOneArbitraryMatch(new Object[]{pA, pB});
340 }
341
342 /**
343 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
344 * under any possible substitution of the unspecified parameters (if any).
345 * @param pA the fixed value of pattern parameter a, or null if not bound.
346 * @param pB the fixed value of pattern parameter b, or null if not bound.
347 * @return true if the input is a valid (partial) match of the pattern.
348 *
349 */
350 public boolean hasMatch(final EReference pA, final EReference pB) {
351 return rawHasMatch(new Object[]{pA, pB});
352 }
353
354 /**
355 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
356 * @param pA the fixed value of pattern parameter a, or null if not bound.
357 * @param pB the fixed value of pattern parameter b, or null if not bound.
358 * @return the number of pattern matches found.
359 *
360 */
361 public int countMatches(final EReference pA, final EReference pB) {
362 return rawCountMatches(new Object[]{pA, pB});
363 }
364
365 /**
366 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
367 * Neither determinism nor randomness of selection is guaranteed.
368 * @param pA the fixed value of pattern parameter a, or null if not bound.
369 * @param pB the fixed value of pattern parameter b, or null if not bound.
370 * @param processor the action that will process the selected match.
371 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
372 *
373 */
374 public boolean forOneArbitraryMatch(final EReference pA, final EReference pB, final Consumer<? super Opposite.Match> processor) {
375 return rawForOneArbitraryMatch(new Object[]{pA, pB}, processor);
376 }
377
378 /**
379 * Returns a new (partial) match.
380 * This can be used e.g. to call the matcher with a partial match.
381 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
382 * @param pA the fixed value of pattern parameter a, or null if not bound.
383 * @param pB the fixed value of pattern parameter b, or null if not bound.
384 * @return the (partial) match object.
385 *
386 */
387 public Opposite.Match newMatch(final EReference pA, final EReference pB) {
388 return Opposite.Match.newMatch(pA, pB);
389 }
390
391 /**
392 * Retrieve the set of values that occur in matches for a.
393 * @return the Set of all values or empty set if there are no matches
394 *
395 */
396 protected Stream<EReference> rawStreamAllValuesOfa(final Object[] parameters) {
397 return rawStreamAllValues(POSITION_A, parameters).map(EReference.class::cast);
398 }
399
400 /**
401 * Retrieve the set of values that occur in matches for a.
402 * @return the Set of all values or empty set if there are no matches
403 *
404 */
405 public Set<EReference> getAllValuesOfa() {
406 return rawStreamAllValuesOfa(emptyArray()).collect(Collectors.toSet());
407 }
408
409 /**
410 * Retrieve the set of values that occur in matches for a.
411 * @return the Set of all values or empty set if there are no matches
412 *
413 */
414 public Stream<EReference> streamAllValuesOfa() {
415 return rawStreamAllValuesOfa(emptyArray());
416 }
417
418 /**
419 * Retrieve the set of values that occur in matches for a.
420 * </p>
421 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
422 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
423 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
424 *
425 * @return the Stream of all values or empty set if there are no matches
426 *
427 */
428 public Stream<EReference> streamAllValuesOfa(final Opposite.Match partialMatch) {
429 return rawStreamAllValuesOfa(partialMatch.toArray());
430 }
431
432 /**
433 * Retrieve the set of values that occur in matches for a.
434 * </p>
435 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
436 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
437 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
438 *
439 * @return the Stream of all values or empty set if there are no matches
440 *
441 */
442 public Stream<EReference> streamAllValuesOfa(final EReference pB) {
443 return rawStreamAllValuesOfa(new Object[]{null, pB});
444 }
445
446 /**
447 * Retrieve the set of values that occur in matches for a.
448 * @return the Set of all values or empty set if there are no matches
449 *
450 */
451 public Set<EReference> getAllValuesOfa(final Opposite.Match partialMatch) {
452 return rawStreamAllValuesOfa(partialMatch.toArray()).collect(Collectors.toSet());
453 }
454
455 /**
456 * Retrieve the set of values that occur in matches for a.
457 * @return the Set of all values or empty set if there are no matches
458 *
459 */
460 public Set<EReference> getAllValuesOfa(final EReference pB) {
461 return rawStreamAllValuesOfa(new Object[]{null, pB}).collect(Collectors.toSet());
462 }
463
464 /**
465 * Retrieve the set of values that occur in matches for b.
466 * @return the Set of all values or empty set if there are no matches
467 *
468 */
469 protected Stream<EReference> rawStreamAllValuesOfb(final Object[] parameters) {
470 return rawStreamAllValues(POSITION_B, parameters).map(EReference.class::cast);
471 }
472
473 /**
474 * Retrieve the set of values that occur in matches for b.
475 * @return the Set of all values or empty set if there are no matches
476 *
477 */
478 public Set<EReference> getAllValuesOfb() {
479 return rawStreamAllValuesOfb(emptyArray()).collect(Collectors.toSet());
480 }
481
482 /**
483 * Retrieve the set of values that occur in matches for b.
484 * @return the Set of all values or empty set if there are no matches
485 *
486 */
487 public Stream<EReference> streamAllValuesOfb() {
488 return rawStreamAllValuesOfb(emptyArray());
489 }
490
491 /**
492 * Retrieve the set of values that occur in matches for b.
493 * </p>
494 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
495 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
496 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
497 *
498 * @return the Stream of all values or empty set if there are no matches
499 *
500 */
501 public Stream<EReference> streamAllValuesOfb(final Opposite.Match partialMatch) {
502 return rawStreamAllValuesOfb(partialMatch.toArray());
503 }
504
505 /**
506 * Retrieve the set of values that occur in matches for b.
507 * </p>
508 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
509 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
510 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
511 *
512 * @return the Stream of all values or empty set if there are no matches
513 *
514 */
515 public Stream<EReference> streamAllValuesOfb(final EReference pA) {
516 return rawStreamAllValuesOfb(new Object[]{pA, null});
517 }
518
519 /**
520 * Retrieve the set of values that occur in matches for b.
521 * @return the Set of all values or empty set if there are no matches
522 *
523 */
524 public Set<EReference> getAllValuesOfb(final Opposite.Match partialMatch) {
525 return rawStreamAllValuesOfb(partialMatch.toArray()).collect(Collectors.toSet());
526 }
527
528 /**
529 * Retrieve the set of values that occur in matches for b.
530 * @return the Set of all values or empty set if there are no matches
531 *
532 */
533 public Set<EReference> getAllValuesOfb(final EReference pA) {
534 return rawStreamAllValuesOfb(new Object[]{pA, null}).collect(Collectors.toSet());
535 }
536
537 @Override
538 protected Opposite.Match tupleToMatch(final Tuple t) {
539 try {
540 return Opposite.Match.newMatch((EReference) t.get(POSITION_A), (EReference) t.get(POSITION_B));
541 } catch(ClassCastException e) {
542 LOGGER.error("Element(s) in tuple not properly typed!",e);
543 return null;
544 }
545 }
546
547 @Override
548 protected Opposite.Match arrayToMatch(final Object[] match) {
549 try {
550 return Opposite.Match.newMatch((EReference) match[POSITION_A], (EReference) match[POSITION_B]);
551 } catch(ClassCastException e) {
552 LOGGER.error("Element(s) in array not properly typed!",e);
553 return null;
554 }
555 }
556
557 @Override
558 protected Opposite.Match arrayToMatchMutable(final Object[] match) {
559 try {
560 return Opposite.Match.newMutableMatch((EReference) match[POSITION_A], (EReference) match[POSITION_B]);
561 } catch(ClassCastException e) {
562 LOGGER.error("Element(s) in array not properly typed!",e);
563 return null;
564 }
565 }
566
567 /**
568 * @return the singleton instance of the query specification of this pattern
569 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
570 *
571 */
572 public static IQuerySpecification<Opposite.Matcher> querySpecification() {
573 return Opposite.instance();
574 }
575 }
576
577 private Opposite() {
578 super(GeneratedPQuery.INSTANCE);
579 }
580
581 /**
582 * @return the singleton instance of the query specification
583 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
584 *
585 */
586 public static Opposite instance() {
587 try{
588 return LazyHolder.INSTANCE;
589 } catch (ExceptionInInitializerError err) {
590 throw processInitializerError(err);
591 }
592 }
593
594 @Override
595 protected Opposite.Matcher instantiate(final ViatraQueryEngine engine) {
596 return Opposite.Matcher.on(engine);
597 }
598
599 @Override
600 public Opposite.Matcher instantiate() {
601 return Opposite.Matcher.create();
602 }
603
604 @Override
605 public Opposite.Match newEmptyMatch() {
606 return Opposite.Match.newEmptyMatch();
607 }
608
609 @Override
610 public Opposite.Match newMatch(final Object... parameters) {
611 return Opposite.Match.newMatch((org.eclipse.emf.ecore.EReference) parameters[0], (org.eclipse.emf.ecore.EReference) parameters[1]);
612 }
613
614 /**
615 * Inner class allowing the singleton instance of {@link JvmGenericType: ecore.Opposite (visibility: PUBLIC, simpleName: Opposite, identifier: ecore.Opposite, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ecore) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
616 * <b>not</b> at the class load time of the outer class,
617 * but rather at the first call to {@link JvmGenericType: ecore.Opposite (visibility: PUBLIC, simpleName: Opposite, identifier: ecore.Opposite, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ecore) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
618 *
619 * <p> This workaround is required e.g. to support recursion.
620 *
621 */
622 private static class LazyHolder {
623 private static final Opposite INSTANCE = new Opposite();
624
625 /**
626 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
627 * This initialization order is required to support indirect recursion.
628 *
629 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
630 *
631 */
632 private static final Object STATIC_INITIALIZER = ensureInitialized();
633
634 public static Object ensureInitialized() {
635 INSTANCE.ensureInitializedInternal();
636 return null;
637 }
638 }
639
640 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
641 private static final Opposite.GeneratedPQuery INSTANCE = new GeneratedPQuery();
642
643 private final PParameter parameter_a = new PParameter("a", "org.eclipse.emf.ecore.EReference", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EReference")), PParameterDirection.INOUT);
644
645 private final PParameter parameter_b = new PParameter("b", "org.eclipse.emf.ecore.EReference", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EReference")), PParameterDirection.INOUT);
646
647 private final List<PParameter> parameters = Arrays.asList(parameter_a, parameter_b);
648
649 private GeneratedPQuery() {
650 super(PVisibility.PUBLIC);
651 }
652
653 @Override
654 public String getFullyQualifiedName() {
655 return "ecore.opposite";
656 }
657
658 @Override
659 public List<String> getParameterNames() {
660 return Arrays.asList("a","b");
661 }
662
663 @Override
664 public List<PParameter> getParameters() {
665 return parameters;
666 }
667
668 @Override
669 public Set<PBody> doGetContainedBodies() {
670 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
671 Set<PBody> bodies = new LinkedHashSet<>();
672 {
673 PBody body = new PBody(this);
674 PVariable var_a = body.getOrCreateVariableByName("a");
675 PVariable var_b = body.getOrCreateVariableByName("b");
676 new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference")));
677 new TypeConstraint(body, Tuples.flatTupleOf(var_b), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference")));
678 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
679 new ExportedParameter(body, var_a, parameter_a),
680 new ExportedParameter(body, var_b, parameter_b)
681 ));
682 // EReference.eOpposite(a,b)
683 new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference")));
684 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
685 new TypeConstraint(body, Tuples.flatTupleOf(var_a, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference", "eOpposite")));
686 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference")));
687 new Equality(body, var__virtual_0_, var_b);
688 bodies.add(body);
689 }
690 return bodies;
691 }
692 }
693}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/OppositeDifferentClass.java b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/OppositeDifferentClass.java
new file mode 100644
index 00000000..3a0df648
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/constraints/ecore/OppositeDifferentClass.java
@@ -0,0 +1,577 @@
1/**
2 * Generated from platform:/resource/SocialNetwork_plugin/queries/ecore/Ecore.vql
3 */
4package ecore;
5
6import java.util.Arrays;
7import java.util.Collection;
8import java.util.LinkedHashSet;
9import java.util.List;
10import java.util.Objects;
11import java.util.Optional;
12import java.util.Set;
13import java.util.function.Consumer;
14import java.util.stream.Collectors;
15import java.util.stream.Stream;
16import org.apache.log4j.Logger;
17import org.eclipse.emf.ecore.EClass;
18import org.eclipse.emf.ecore.EReference;
19import org.eclipse.viatra.query.runtime.api.IPatternMatch;
20import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
21import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
22import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
24import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
25import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
26import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
27import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
28import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
31import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
32import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
34import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
37import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
38import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
40import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
41import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
42import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
43
44/**
45 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
46 *
47 * <p>Original source:
48 * <code><pre>
49 * {@literal @}Constraint(key={a}, severity="error", message="error")
50 * pattern oppositeDifferentClass(a:EReference) {
51 * EReference.eOpposite(a,b);
52 * EReference.eContainingClass(a,aContaining);
53 * EReference.eType(b,bTarget);
54 * aContaining != bTarget;
55 * }
56 * </pre></code>
57 *
58 * @see Matcher
59 * @see Match
60 *
61 */
62@SuppressWarnings("all")
63public final class OppositeDifferentClass extends BaseGeneratedEMFQuerySpecification<OppositeDifferentClass.Matcher> {
64 /**
65 * Pattern-specific match representation of the ecore.oppositeDifferentClass pattern,
66 * to be used in conjunction with {@link Matcher}.
67 *
68 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
69 * Each instance is a (possibly partial) substitution of pattern parameters,
70 * usable to represent a match of the pattern in the result of a query,
71 * or to specify the bound (fixed) input parameters when issuing a query.
72 *
73 * @see Matcher
74 *
75 */
76 public static abstract class Match extends BasePatternMatch {
77 private EReference fA;
78
79 private static List<String> parameterNames = makeImmutableList("a");
80
81 private Match(final EReference pA) {
82 this.fA = pA;
83 }
84
85 @Override
86 public Object get(final String parameterName) {
87 if ("a".equals(parameterName)) return this.fA;
88 return null;
89 }
90
91 public EReference getA() {
92 return this.fA;
93 }
94
95 @Override
96 public boolean set(final String parameterName, final Object newValue) {
97 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
98 if ("a".equals(parameterName) ) {
99 this.fA = (EReference) newValue;
100 return true;
101 }
102 return false;
103 }
104
105 public void setA(final EReference pA) {
106 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
107 this.fA = pA;
108 }
109
110 @Override
111 public String patternName() {
112 return "ecore.oppositeDifferentClass";
113 }
114
115 @Override
116 public List<String> parameterNames() {
117 return OppositeDifferentClass.Match.parameterNames;
118 }
119
120 @Override
121 public Object[] toArray() {
122 return new Object[]{fA};
123 }
124
125 @Override
126 public OppositeDifferentClass.Match toImmutable() {
127 return isMutable() ? newMatch(fA) : this;
128 }
129
130 @Override
131 public String prettyPrint() {
132 StringBuilder result = new StringBuilder();
133 result.append("\"a\"=" + prettyPrintValue(fA));
134 return result.toString();
135 }
136
137 @Override
138 public int hashCode() {
139 return Objects.hash(fA);
140 }
141
142 @Override
143 public boolean equals(final Object obj) {
144 if (this == obj)
145 return true;
146 if (obj == null) {
147 return false;
148 }
149 if ((obj instanceof OppositeDifferentClass.Match)) {
150 OppositeDifferentClass.Match other = (OppositeDifferentClass.Match) obj;
151 return Objects.equals(fA, other.fA);
152 } else {
153 // this should be infrequent
154 if (!(obj instanceof IPatternMatch)) {
155 return false;
156 }
157 IPatternMatch otherSig = (IPatternMatch) obj;
158 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
159 }
160 }
161
162 @Override
163 public OppositeDifferentClass specification() {
164 return OppositeDifferentClass.instance();
165 }
166
167 /**
168 * Returns an empty, mutable match.
169 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
170 *
171 * @return the empty match.
172 *
173 */
174 public static OppositeDifferentClass.Match newEmptyMatch() {
175 return new Mutable(null);
176 }
177
178 /**
179 * Returns a mutable (partial) match.
180 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
181 *
182 * @param pA the fixed value of pattern parameter a, or null if not bound.
183 * @return the new, mutable (partial) match object.
184 *
185 */
186 public static OppositeDifferentClass.Match newMutableMatch(final EReference pA) {
187 return new Mutable(pA);
188 }
189
190 /**
191 * Returns a new (partial) match.
192 * This can be used e.g. to call the matcher with a partial match.
193 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
194 * @param pA the fixed value of pattern parameter a, or null if not bound.
195 * @return the (partial) match object.
196 *
197 */
198 public static OppositeDifferentClass.Match newMatch(final EReference pA) {
199 return new Immutable(pA);
200 }
201
202 private static final class Mutable extends OppositeDifferentClass.Match {
203 Mutable(final EReference pA) {
204 super(pA);
205 }
206
207 @Override
208 public boolean isMutable() {
209 return true;
210 }
211 }
212
213 private static final class Immutable extends OppositeDifferentClass.Match {
214 Immutable(final EReference pA) {
215 super(pA);
216 }
217
218 @Override
219 public boolean isMutable() {
220 return false;
221 }
222 }
223 }
224
225 /**
226 * Generated pattern matcher API of the ecore.oppositeDifferentClass pattern,
227 * providing pattern-specific query methods.
228 *
229 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
230 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
231 *
232 * <p>Matches of the pattern will be represented as {@link Match}.
233 *
234 * <p>Original source:
235 * <code><pre>
236 * {@literal @}Constraint(key={a}, severity="error", message="error")
237 * pattern oppositeDifferentClass(a:EReference) {
238 * EReference.eOpposite(a,b);
239 * EReference.eContainingClass(a,aContaining);
240 * EReference.eType(b,bTarget);
241 * aContaining != bTarget;
242 * }
243 * </pre></code>
244 *
245 * @see Match
246 * @see OppositeDifferentClass
247 *
248 */
249 public static class Matcher extends BaseMatcher<OppositeDifferentClass.Match> {
250 /**
251 * Initializes the pattern matcher within an existing VIATRA Query engine.
252 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
253 *
254 * @param engine the existing VIATRA Query engine in which this matcher will be created.
255 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
256 *
257 */
258 public static OppositeDifferentClass.Matcher on(final ViatraQueryEngine engine) {
259 // check if matcher already exists
260 Matcher matcher = engine.getExistingMatcher(querySpecification());
261 if (matcher == null) {
262 matcher = (Matcher)engine.getMatcher(querySpecification());
263 }
264 return matcher;
265 }
266
267 /**
268 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
269 * @return an initialized matcher
270 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
271 *
272 */
273 public static OppositeDifferentClass.Matcher create() {
274 return new Matcher();
275 }
276
277 private static final int POSITION_A = 0;
278
279 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(OppositeDifferentClass.Matcher.class);
280
281 /**
282 * Initializes the pattern matcher within an existing VIATRA Query engine.
283 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
284 *
285 * @param engine the existing VIATRA Query engine in which this matcher will be created.
286 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
287 *
288 */
289 private Matcher() {
290 super(querySpecification());
291 }
292
293 /**
294 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
295 * @param pA the fixed value of pattern parameter a, or null if not bound.
296 * @return matches represented as a Match object.
297 *
298 */
299 public Collection<OppositeDifferentClass.Match> getAllMatches(final EReference pA) {
300 return rawStreamAllMatches(new Object[]{pA}).collect(Collectors.toSet());
301 }
302
303 /**
304 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
305 * </p>
306 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
307 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
308 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
309 * @param pA the fixed value of pattern parameter a, or null if not bound.
310 * @return a stream of matches represented as a Match object.
311 *
312 */
313 public Stream<OppositeDifferentClass.Match> streamAllMatches(final EReference pA) {
314 return rawStreamAllMatches(new Object[]{pA});
315 }
316
317 /**
318 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
319 * Neither determinism nor randomness of selection is guaranteed.
320 * @param pA the fixed value of pattern parameter a, or null if not bound.
321 * @return a match represented as a Match object, or null if no match is found.
322 *
323 */
324 public Optional<OppositeDifferentClass.Match> getOneArbitraryMatch(final EReference pA) {
325 return rawGetOneArbitraryMatch(new Object[]{pA});
326 }
327
328 /**
329 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
330 * under any possible substitution of the unspecified parameters (if any).
331 * @param pA the fixed value of pattern parameter a, or null if not bound.
332 * @return true if the input is a valid (partial) match of the pattern.
333 *
334 */
335 public boolean hasMatch(final EReference pA) {
336 return rawHasMatch(new Object[]{pA});
337 }
338
339 /**
340 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
341 * @param pA the fixed value of pattern parameter a, or null if not bound.
342 * @return the number of pattern matches found.
343 *
344 */
345 public int countMatches(final EReference pA) {
346 return rawCountMatches(new Object[]{pA});
347 }
348
349 /**
350 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
351 * Neither determinism nor randomness of selection is guaranteed.
352 * @param pA the fixed value of pattern parameter a, or null if not bound.
353 * @param processor the action that will process the selected match.
354 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
355 *
356 */
357 public boolean forOneArbitraryMatch(final EReference pA, final Consumer<? super OppositeDifferentClass.Match> processor) {
358 return rawForOneArbitraryMatch(new Object[]{pA}, processor);
359 }
360
361 /**
362 * Returns a new (partial) match.
363 * This can be used e.g. to call the matcher with a partial match.
364 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
365 * @param pA the fixed value of pattern parameter a, or null if not bound.
366 * @return the (partial) match object.
367 *
368 */
369 public OppositeDifferentClass.Match newMatch(final EReference pA) {
370 return OppositeDifferentClass.Match.newMatch(pA);
371 }
372
373 /**
374 * Retrieve the set of values that occur in matches for a.
375 * @return the Set of all values or empty set if there are no matches
376 *
377 */
378 protected Stream<EReference> rawStreamAllValuesOfa(final Object[] parameters) {
379 return rawStreamAllValues(POSITION_A, parameters).map(EReference.class::cast);
380 }
381
382 /**
383 * Retrieve the set of values that occur in matches for a.
384 * @return the Set of all values or empty set if there are no matches
385 *
386 */
387 public Set<EReference> getAllValuesOfa() {
388 return rawStreamAllValuesOfa(emptyArray()).collect(Collectors.toSet());
389 }
390
391 /**
392 * Retrieve the set of values that occur in matches for a.
393 * @return the Set of all values or empty set if there are no matches
394 *
395 */
396 public Stream<EReference> streamAllValuesOfa() {
397 return rawStreamAllValuesOfa(emptyArray());
398 }
399
400 @Override
401 protected OppositeDifferentClass.Match tupleToMatch(final Tuple t) {
402 try {
403 return OppositeDifferentClass.Match.newMatch((EReference) t.get(POSITION_A));
404 } catch(ClassCastException e) {
405 LOGGER.error("Element(s) in tuple not properly typed!",e);
406 return null;
407 }
408 }
409
410 @Override
411 protected OppositeDifferentClass.Match arrayToMatch(final Object[] match) {
412 try {
413 return OppositeDifferentClass.Match.newMatch((EReference) match[POSITION_A]);
414 } catch(ClassCastException e) {
415 LOGGER.error("Element(s) in array not properly typed!",e);
416 return null;
417 }
418 }
419
420 @Override
421 protected OppositeDifferentClass.Match arrayToMatchMutable(final Object[] match) {
422 try {
423 return OppositeDifferentClass.Match.newMutableMatch((EReference) match[POSITION_A]);
424 } catch(ClassCastException e) {
425 LOGGER.error("Element(s) in array not properly typed!",e);
426 return null;
427 }
428 }
429
430 /**
431 * @return the singleton instance of the query specification of this pattern
432 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
433 *
434 */
435 public static IQuerySpecification<OppositeDifferentClass.Matcher> querySpecification() {
436 return OppositeDifferentClass.instance();
437 }
438 }
439
440 private OppositeDifferentClass() {
441 super(GeneratedPQuery.INSTANCE);
442 }
443
444 /**
445 * @return the singleton instance of the query specification
446 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
447 *
448 */
449 public static OppositeDifferentClass instance() {
450 try{
451 return LazyHolder.INSTANCE;
452 } catch (ExceptionInInitializerError err) {
453 throw processInitializerError(err);
454 }
455 }
456
457 @Override
458 protected OppositeDifferentClass.Matcher instantiate(final ViatraQueryEngine engine) {
459 return OppositeDifferentClass.Matcher.on(engine);
460 }
461
462 @Override
463 public OppositeDifferentClass.Matcher instantiate() {
464 return OppositeDifferentClass.Matcher.create();
465 }
466
467 @Override
468 public OppositeDifferentClass.Match newEmptyMatch() {
469 return OppositeDifferentClass.Match.newEmptyMatch();
470 }
471
472 @Override
473 public OppositeDifferentClass.Match newMatch(final Object... parameters) {
474 return OppositeDifferentClass.Match.newMatch((org.eclipse.emf.ecore.EReference) parameters[0]);
475 }
476
477 /**
478 * Inner class allowing the singleton instance of {@link JvmGenericType: ecore.OppositeDifferentClass (visibility: PUBLIC, simpleName: OppositeDifferentClass, identifier: ecore.OppositeDifferentClass, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ecore) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
479 * <b>not</b> at the class load time of the outer class,
480 * but rather at the first call to {@link JvmGenericType: ecore.OppositeDifferentClass (visibility: PUBLIC, simpleName: OppositeDifferentClass, identifier: ecore.OppositeDifferentClass, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ecore) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
481 *
482 * <p> This workaround is required e.g. to support recursion.
483 *
484 */
485 private static class LazyHolder {
486 private static final OppositeDifferentClass INSTANCE = new OppositeDifferentClass();
487
488 /**
489 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
490 * This initialization order is required to support indirect recursion.
491 *
492 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
493 *
494 */
495 private static final Object STATIC_INITIALIZER = ensureInitialized();
496
497 public static Object ensureInitialized() {
498 INSTANCE.ensureInitializedInternal();
499 return null;
500 }
501 }
502
503 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
504 private static final OppositeDifferentClass.GeneratedPQuery INSTANCE = new GeneratedPQuery();
505
506 private final PParameter parameter_a = new PParameter("a", "org.eclipse.emf.ecore.EReference", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.eclipse.org/emf/2002/Ecore", "EReference")), PParameterDirection.INOUT);
507
508 private final List<PParameter> parameters = Arrays.asList(parameter_a);
509
510 private GeneratedPQuery() {
511 super(PVisibility.PUBLIC);
512 }
513
514 @Override
515 public String getFullyQualifiedName() {
516 return "ecore.oppositeDifferentClass";
517 }
518
519 @Override
520 public List<String> getParameterNames() {
521 return Arrays.asList("a");
522 }
523
524 @Override
525 public List<PParameter> getParameters() {
526 return parameters;
527 }
528
529 @Override
530 public Set<PBody> doGetContainedBodies() {
531 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
532 Set<PBody> bodies = new LinkedHashSet<>();
533 {
534 PBody body = new PBody(this);
535 PVariable var_a = body.getOrCreateVariableByName("a");
536 PVariable var_b = body.getOrCreateVariableByName("b");
537 PVariable var_aContaining = body.getOrCreateVariableByName("aContaining");
538 PVariable var_bTarget = body.getOrCreateVariableByName("bTarget");
539 new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference")));
540 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
541 new ExportedParameter(body, var_a, parameter_a)
542 ));
543 // EReference.eOpposite(a,b)
544 new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference")));
545 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
546 new TypeConstraint(body, Tuples.flatTupleOf(var_a, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference", "eOpposite")));
547 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference")));
548 new Equality(body, var__virtual_0_, var_b);
549 // EReference.eContainingClass(a,aContaining)
550 new TypeConstraint(body, Tuples.flatTupleOf(var_a), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference")));
551 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
552 new TypeConstraint(body, Tuples.flatTupleOf(var_a, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "EStructuralFeature", "eContainingClass")));
553 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass")));
554 new Equality(body, var__virtual_1_, var_aContaining);
555 // EReference.eType(b,bTarget)
556 new TypeConstraint(body, Tuples.flatTupleOf(var_b), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EReference")));
557 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
558 new TypeConstraint(body, Tuples.flatTupleOf(var_b, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "ETypedElement", "eType")));
559 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClassifier")));
560 new Equality(body, var__virtual_2_, var_bTarget);
561 // aContaining != bTarget
562 new Inequality(body, var_aContaining, var_bTarget);
563 bodies.add(body);
564 }
565 {
566 PAnnotation annotation = new PAnnotation("Constraint");
567 annotation.addAttribute("key", Arrays.asList(new Object[] {
568 new ParameterReference("a")
569 }));
570 annotation.addAttribute("severity", "error");
571 annotation.addAttribute("message", "error");
572 addAnnotation(annotation);
573 }
574 return bodies;
575 }
576 }
577}
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/ecore.ecore b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/ecore.ecore
new file mode 100644
index 00000000..e7dc2768
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/ecore.ecore
@@ -0,0 +1,1016 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="ecore" nsURI="http://www.eclipse.org/emf/2002/Ecore" nsPrefix="ecore">
4 <eClassifiers xsi:type="ecore:EClass" name="EAnnotation" eSuperTypes="#//EModelElement">
5 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
6 <details key="name" value="EAnnotation"/>
7 <details key="kind" value="elementOnly"/>
8 </eAnnotations>
9 <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
10 <details key="constraints" value="WellFormedSourceURI"/>
11 </eAnnotations>
12 <eStructuralFeatures xsi:type="ecore:EReference" name="details" upperBound="-1"
13 eType="#//EStringToStringMapEntry" containment="true" resolveProxies="false">
14 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
15 <details key="kind" value="element"/>
16 <details key="name" value="details"/>
17 </eAnnotations>
18 </eStructuralFeatures>
19 <eStructuralFeatures xsi:type="ecore:EReference" name="contents" upperBound="-1"
20 eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject" containment="true"
21 resolveProxies="false">
22 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
23 <details key="kind" value="element"/>
24 <details key="name" value="contents"/>
25 </eAnnotations>
26 </eStructuralFeatures>
27 <eStructuralFeatures xsi:type="ecore:EReference" name="references" upperBound="-1"
28 eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject">
29 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
30 <details key="kind" value="attribute"/>
31 <details key="name" value="references"/>
32 </eAnnotations>
33 </eStructuralFeatures>
34 <eStructuralFeatures xsi:type="ecore:EAttribute" name="source" eType="#//EString">
35 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
36 <details key="kind" value="attribute"/>
37 <details key="name" value="source"/>
38 </eAnnotations>
39 </eStructuralFeatures>
40 <eStructuralFeatures xsi:type="ecore:EReference" name="eModelElement" eType="#//EModelElement"
41 transient="true" eOpposite="#//EModelElement/eAnnotations"/>
42 </eClassifiers>
43 <eClassifiers xsi:type="ecore:EClass" name="EAttribute" eSuperTypes="#//EStructuralFeature">
44 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
45 <details key="name" value="EAttribute"/>
46 <details key="kind" value="elementOnly"/>
47 </eAnnotations>
48 <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
49 <details key="constraints" value="ConsistentTransient"/>
50 </eAnnotations>
51 <eStructuralFeatures xsi:type="ecore:EReference" name="eAttributeType" lowerBound="1"
52 eType="#//EDataType" changeable="false" volatile="true" transient="true" derived="true">
53 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
54 <details key="kind" value="attribute"/>
55 <details key="name" value="eAttributeType"/>
56 </eAnnotations>
57 </eStructuralFeatures>
58 <eStructuralFeatures xsi:type="ecore:EAttribute" name="iD" eType="#//EBoolean">
59 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
60 <details key="kind" value="attribute"/>
61 <details key="name" value="iD"/>
62 </eAnnotations>
63 </eStructuralFeatures>
64 </eClassifiers>
65 <eClassifiers xsi:type="ecore:EDataType" name="EBigDecimal" instanceClassName="java.math.BigDecimal">
66 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
67 <details key="name" value="EBigDecimal"/>
68 <details key="baseType" value="http://www.eclipse.org/emf/2003/XMLType#decimal"/>
69 </eAnnotations>
70 </eClassifiers>
71 <eClassifiers xsi:type="ecore:EDataType" name="EBigInteger" instanceClassName="java.math.BigInteger">
72 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
73 <details key="name" value="EBigInteger"/>
74 <details key="baseType" value="http://www.eclipse.org/emf/2003/XMLType#integer"/>
75 </eAnnotations>
76 </eClassifiers>
77 <eClassifiers xsi:type="ecore:EDataType" name="EBoolean" instanceClassName="boolean">
78 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
79 <details key="name" value="EBoolean"/>
80 </eAnnotations>
81 </eClassifiers>
82 <eClassifiers xsi:type="ecore:EDataType" name="EBooleanObject" instanceClassName="java.lang.Boolean">
83 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
84 <details key="name" value="EBoolean:Object"/>
85 <details key="baseType" value="EBoolean"/>
86 </eAnnotations>
87 </eClassifiers>
88 <eClassifiers xsi:type="ecore:EDataType" name="EByte" instanceClassName="byte">
89 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
90 <details key="name" value="EByte"/>
91 <details key="baseType" value="http://www.eclipse.org/emf/2003/XMLType#byte"/>
92 </eAnnotations>
93 </eClassifiers>
94 <eClassifiers xsi:type="ecore:EDataType" name="EByteArray" instanceClassName="byte[]">
95 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
96 <details key="name" value="EByteArray"/>
97 <details key="baseType" value="http://www.eclipse.org/emf/2003/XMLType#hexBinary"/>
98 </eAnnotations>
99 </eClassifiers>
100 <eClassifiers xsi:type="ecore:EDataType" name="EByteObject" instanceClassName="java.lang.Byte">
101 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
102 <details key="name" value="EByte:Object"/>
103 <details key="baseType" value="EByte"/>
104 </eAnnotations>
105 </eClassifiers>
106 <eClassifiers xsi:type="ecore:EDataType" name="EChar" instanceClassName="char">
107 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
108 <details key="name" value="EChar"/>
109 </eAnnotations>
110 </eClassifiers>
111 <eClassifiers xsi:type="ecore:EDataType" name="ECharacterObject" instanceClassName="java.lang.Character">
112 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
113 <details key="name" value="EChar:Object"/>
114 <details key="baseType" value="EChar"/>
115 </eAnnotations>
116 </eClassifiers>
117 <eClassifiers xsi:type="ecore:EClass" name="EClass" eSuperTypes="#//EClassifier">
118 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
119 <details key="name" value="EClass"/>
120 <details key="kind" value="elementOnly"/>
121 </eAnnotations>
122 <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
123 <details key="constraints" value="InterfaceIsAbstract AtMostOneID UniqueFeatureNames UniqueOperationSignatures NoCircularSuperTypes WellFormedMapEntryClass ConsistentSuperTypes DisjointFeatureAndOperationSignatures"/>
124 </eAnnotations>
125 <eOperations name="isSuperTypeOf" eType="#//EBoolean">
126 <eParameters name="someClass" eType="#//EClass"/>
127 </eOperations>
128 <eOperations name="getFeatureCount" eType="#//EInt"/>
129 <eOperations name="getEStructuralFeature" eType="#//EStructuralFeature">
130 <eParameters name="featureID" eType="#//EInt"/>
131 </eOperations>
132 <eOperations name="getFeatureID" eType="#//EInt">
133 <eParameters name="feature" eType="#//EStructuralFeature"/>
134 </eOperations>
135 <eOperations name="getEStructuralFeature" eType="#//EStructuralFeature">
136 <eParameters name="featureName" eType="#//EString"/>
137 </eOperations>
138 <eOperations name="getOperationCount" eType="#//EInt"/>
139 <eOperations name="getEOperation" eType="#//EOperation">
140 <eParameters name="operationID" eType="#//EInt"/>
141 </eOperations>
142 <eOperations name="getOperationID" eType="#//EInt">
143 <eParameters name="operation" eType="#//EOperation"/>
144 </eOperations>
145 <eOperations name="getOverride" eType="#//EOperation">
146 <eParameters name="operation" eType="#//EOperation"/>
147 </eOperations>
148 <eStructuralFeatures xsi:type="ecore:EReference" name="eOperations" upperBound="-1"
149 eType="#//EOperation" containment="true" resolveProxies="false" eOpposite="#//EOperation/eContainingClass">
150 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
151 <details key="kind" value="element"/>
152 <details key="name" value="eOperations"/>
153 </eAnnotations>
154 </eStructuralFeatures>
155 <eStructuralFeatures xsi:type="ecore:EReference" name="eStructuralFeatures" upperBound="-1"
156 eType="#//EStructuralFeature" containment="true" resolveProxies="false" eOpposite="#//EStructuralFeature/eContainingClass">
157 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
158 <details key="kind" value="element"/>
159 <details key="name" value="eStructuralFeatures"/>
160 </eAnnotations>
161 </eStructuralFeatures>
162 <eStructuralFeatures xsi:type="ecore:EReference" name="eGenericSuperTypes" upperBound="-1"
163 eType="#//EGenericType" unsettable="true" containment="true" resolveProxies="false">
164 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
165 <details key="kind" value="element"/>
166 <details key="name" value="eGenericSuperTypes"/>
167 </eAnnotations>
168 <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
169 <details key="suppressedIsSetVisibility" value="true"/>
170 <details key="suppressedUnsetVisibility" value="true"/>
171 </eAnnotations>
172 </eStructuralFeatures>
173 <eStructuralFeatures xsi:type="ecore:EAttribute" name="abstract" eType="#//EBoolean">
174 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
175 <details key="kind" value="attribute"/>
176 <details key="name" value="abstract"/>
177 </eAnnotations>
178 </eStructuralFeatures>
179 <eStructuralFeatures xsi:type="ecore:EReference" name="eAllAttributes" upperBound="-1"
180 eType="#//EAttribute" changeable="false" volatile="true" transient="true"
181 derived="true">
182 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
183 <details key="kind" value="attribute"/>
184 <details key="name" value="eAllAttributes"/>
185 </eAnnotations>
186 </eStructuralFeatures>
187 <eStructuralFeatures xsi:type="ecore:EReference" name="eAllContainments" upperBound="-1"
188 eType="#//EReference" changeable="false" volatile="true" transient="true"
189 derived="true">
190 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
191 <details key="kind" value="attribute"/>
192 <details key="name" value="eAllContainments"/>
193 </eAnnotations>
194 </eStructuralFeatures>
195 <eStructuralFeatures xsi:type="ecore:EReference" name="eAllGenericSuperTypes"
196 upperBound="-1" eType="#//EGenericType" changeable="false" volatile="true"
197 transient="true" derived="true">
198 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
199 <details key="kind" value="attribute"/>
200 <details key="name" value="eAllGenericSuperTypes"/>
201 </eAnnotations>
202 </eStructuralFeatures>
203 <eStructuralFeatures xsi:type="ecore:EReference" name="eAllOperations" upperBound="-1"
204 eType="#//EOperation" changeable="false" volatile="true" transient="true"
205 derived="true">
206 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
207 <details key="kind" value="attribute"/>
208 <details key="name" value="eAllOperations"/>
209 </eAnnotations>
210 </eStructuralFeatures>
211 <eStructuralFeatures xsi:type="ecore:EReference" name="eAllReferences" upperBound="-1"
212 eType="#//EReference" changeable="false" volatile="true" transient="true"
213 derived="true">
214 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
215 <details key="kind" value="attribute"/>
216 <details key="name" value="eAllReferences"/>
217 </eAnnotations>
218 </eStructuralFeatures>
219 <eStructuralFeatures xsi:type="ecore:EReference" name="eAllStructuralFeatures"
220 upperBound="-1" eType="#//EStructuralFeature" changeable="false" volatile="true"
221 transient="true" derived="true">
222 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
223 <details key="kind" value="attribute"/>
224 <details key="name" value="eAllStructuralFeatures"/>
225 </eAnnotations>
226 </eStructuralFeatures>
227 <eStructuralFeatures xsi:type="ecore:EReference" name="eAllSuperTypes" upperBound="-1"
228 eType="#//EClass" changeable="false" volatile="true" transient="true" derived="true">
229 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
230 <details key="kind" value="attribute"/>
231 <details key="name" value="eAllSuperTypes"/>
232 </eAnnotations>
233 </eStructuralFeatures>
234 <eStructuralFeatures xsi:type="ecore:EReference" name="eAttributes" upperBound="-1"
235 eType="#//EAttribute" changeable="false" volatile="true" transient="true"
236 derived="true">
237 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
238 <details key="kind" value="attribute"/>
239 <details key="name" value="eAttributes"/>
240 </eAnnotations>
241 </eStructuralFeatures>
242 <eStructuralFeatures xsi:type="ecore:EReference" name="eIDAttribute" eType="#//EAttribute"
243 changeable="false" volatile="true" transient="true" derived="true" resolveProxies="false">
244 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
245 <details key="kind" value="attribute"/>
246 <details key="name" value="eIDAttribute"/>
247 </eAnnotations>
248 </eStructuralFeatures>
249 <eStructuralFeatures xsi:type="ecore:EReference" name="eReferences" upperBound="-1"
250 eType="#//EReference" changeable="false" volatile="true" transient="true"
251 derived="true">
252 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
253 <details key="kind" value="attribute"/>
254 <details key="name" value="eReferences"/>
255 </eAnnotations>
256 </eStructuralFeatures>
257 <eStructuralFeatures xsi:type="ecore:EReference" name="eSuperTypes" upperBound="-1"
258 eType="#//EClass" unsettable="true">
259 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
260 <details key="kind" value="attribute"/>
261 <details key="name" value="eSuperTypes"/>
262 </eAnnotations>
263 <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
264 <details key="suppressedIsSetVisibility" value="true"/>
265 <details key="suppressedUnsetVisibility" value="true"/>
266 </eAnnotations>
267 </eStructuralFeatures>
268 <eStructuralFeatures xsi:type="ecore:EAttribute" name="interface" eType="#//EBoolean">
269 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
270 <details key="kind" value="attribute"/>
271 <details key="name" value="interface"/>
272 </eAnnotations>
273 </eStructuralFeatures>
274 </eClassifiers>
275 <eClassifiers xsi:type="ecore:EClass" name="EClassifier" abstract="true" eSuperTypes="#//ENamedElement">
276 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
277 <details key="name" value="EClassifier"/>
278 <details key="kind" value="elementOnly"/>
279 </eAnnotations>
280 <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
281 <details key="constraints" value="WellFormedInstanceTypeName UniqueTypeParameterNames"/>
282 </eAnnotations>
283 <eOperations name="isInstance" eType="#//EBoolean">
284 <eParameters name="object" eType="#//EJavaObject"/>
285 </eOperations>
286 <eOperations name="getClassifierID" eType="#//EInt"/>
287 <eStructuralFeatures xsi:type="ecore:EReference" name="eTypeParameters" upperBound="-1"
288 eType="#//ETypeParameter" containment="true">
289 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
290 <details key="kind" value="element"/>
291 <details key="name" value="eTypeParameters"/>
292 </eAnnotations>
293 </eStructuralFeatures>
294 <eStructuralFeatures xsi:type="ecore:EAttribute" name="defaultValue" eType="#//EJavaObject"
295 changeable="false" volatile="true" transient="true" derived="true">
296 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
297 <details key="kind" value="attribute"/>
298 <details key="name" value="defaultValue"/>
299 </eAnnotations>
300 </eStructuralFeatures>
301 <eStructuralFeatures xsi:type="ecore:EAttribute" name="instanceClass" changeable="false"
302 volatile="true" transient="true" derived="true">
303 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
304 <details key="kind" value="attribute"/>
305 <details key="name" value="instanceClass"/>
306 </eAnnotations>
307 <eGenericType eClassifier="#//EJavaClass">
308 <eTypeArguments/>
309 </eGenericType>
310 </eStructuralFeatures>
311 <eStructuralFeatures xsi:type="ecore:EAttribute" name="instanceClassName" eType="#//EString"
312 volatile="true" unsettable="true">
313 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
314 <details key="kind" value="attribute"/>
315 <details key="name" value="instanceClassName"/>
316 </eAnnotations>
317 <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
318 <details key="suppressedIsSetVisibility" value="true"/>
319 <details key="suppressedUnsetVisibility" value="true"/>
320 </eAnnotations>
321 </eStructuralFeatures>
322 <eStructuralFeatures xsi:type="ecore:EAttribute" name="instanceTypeName" eType="#//EString"
323 volatile="true" unsettable="true">
324 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
325 <details key="kind" value="attribute"/>
326 <details key="name" value="instanceTypeName"/>
327 </eAnnotations>
328 <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
329 <details key="suppressedIsSetVisibility" value="true"/>
330 <details key="suppressedUnsetVisibility" value="true"/>
331 </eAnnotations>
332 </eStructuralFeatures>
333 <eStructuralFeatures xsi:type="ecore:EReference" name="ePackage" eType="#//EPackage"
334 transient="true" eOpposite="#//EPackage/eClassifiers"/>
335 </eClassifiers>
336 <eClassifiers xsi:type="ecore:EClass" name="EDataType" eSuperTypes="#//EClassifier">
337 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
338 <details key="name" value="EDataType"/>
339 <details key="kind" value="elementOnly"/>
340 </eAnnotations>
341 <eStructuralFeatures xsi:type="ecore:EAttribute" name="serializable" eType="#//EBoolean"
342 defaultValueLiteral="true">
343 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
344 <details key="kind" value="attribute"/>
345 <details key="name" value="serializable"/>
346 </eAnnotations>
347 </eStructuralFeatures>
348 </eClassifiers>
349 <eClassifiers xsi:type="ecore:EDataType" name="EDate" instanceClassName="java.util.Date">
350 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
351 <details key="name" value="EDate"/>
352 </eAnnotations>
353 </eClassifiers>
354 <eClassifiers xsi:type="ecore:EDataType" name="EDiagnosticChain" instanceClassName="org.eclipse.emf.common.util.DiagnosticChain"
355 serializable="false">
356 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
357 <details key="name" value="EDiagnosticChain"/>
358 </eAnnotations>
359 </eClassifiers>
360 <eClassifiers xsi:type="ecore:EDataType" name="EDouble" instanceClassName="double">
361 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
362 <details key="name" value="EDouble"/>
363 <details key="baseType" value="http://www.eclipse.org/emf/2003/XMLType#double"/>
364 </eAnnotations>
365 </eClassifiers>
366 <eClassifiers xsi:type="ecore:EDataType" name="EDoubleObject" instanceClassName="java.lang.Double">
367 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
368 <details key="name" value="EDouble:Object"/>
369 <details key="baseType" value="EDouble"/>
370 </eAnnotations>
371 </eClassifiers>
372 <eClassifiers xsi:type="ecore:EDataType" name="EEList" instanceClassName="org.eclipse.emf.common.util.EList"
373 serializable="false">
374 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
375 <details key="name" value="EEList"/>
376 </eAnnotations>
377 <eTypeParameters name="E"/>
378 </eClassifiers>
379 <eClassifiers xsi:type="ecore:EClass" name="EEnum" eSuperTypes="#//EDataType">
380 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
381 <details key="name" value="EEnum"/>
382 <details key="kind" value="elementOnly"/>
383 </eAnnotations>
384 <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
385 <details key="constraints" value="UniqueEnumeratorNames UniqueEnumeratorLiterals"/>
386 </eAnnotations>
387 <eOperations name="getEEnumLiteral" eType="#//EEnumLiteral">
388 <eParameters name="name" eType="#//EString"/>
389 </eOperations>
390 <eOperations name="getEEnumLiteral" eType="#//EEnumLiteral">
391 <eParameters name="value" eType="#//EInt"/>
392 </eOperations>
393 <eOperations name="getEEnumLiteralByLiteral" eType="#//EEnumLiteral">
394 <eParameters name="literal" eType="#//EString"/>
395 </eOperations>
396 <eStructuralFeatures xsi:type="ecore:EReference" name="eLiterals" upperBound="-1"
397 eType="#//EEnumLiteral" containment="true" resolveProxies="false" eOpposite="#//EEnumLiteral/eEnum">
398 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
399 <details key="kind" value="element"/>
400 <details key="name" value="eLiterals"/>
401 </eAnnotations>
402 </eStructuralFeatures>
403 </eClassifiers>
404 <eClassifiers xsi:type="ecore:EDataType" name="EEnumerator" instanceClassName="org.eclipse.emf.common.util.Enumerator"
405 serializable="false">
406 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
407 <details key="name" value="EEnumerator"/>
408 </eAnnotations>
409 </eClassifiers>
410 <eClassifiers xsi:type="ecore:EClass" name="EEnumLiteral" eSuperTypes="#//ENamedElement">
411 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
412 <details key="name" value="EEnumLiteral"/>
413 <details key="kind" value="elementOnly"/>
414 </eAnnotations>
415 <eStructuralFeatures xsi:type="ecore:EAttribute" name="instance" eType="#//EEnumerator"
416 transient="true">
417 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
418 <details key="kind" value="attribute"/>
419 <details key="name" value="instance"/>
420 </eAnnotations>
421 </eStructuralFeatures>
422 <eStructuralFeatures xsi:type="ecore:EAttribute" name="literal" eType="#//EString">
423 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
424 <details key="kind" value="attribute"/>
425 <details key="name" value="literal"/>
426 </eAnnotations>
427 </eStructuralFeatures>
428 <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="#//EInt">
429 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
430 <details key="kind" value="attribute"/>
431 <details key="name" value="value"/>
432 </eAnnotations>
433 </eStructuralFeatures>
434 <eStructuralFeatures xsi:type="ecore:EReference" name="eEnum" eType="#//EEnum"
435 transient="true" eOpposite="#//EEnum/eLiterals"/>
436 </eClassifiers>
437 <eClassifiers xsi:type="ecore:EClass" name="EFactory" eSuperTypes="#//EModelElement">
438 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
439 <details key="name" value="EFactory"/>
440 <details key="kind" value="elementOnly"/>
441 </eAnnotations>
442 <eOperations name="create" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject">
443 <eParameters name="eClass" eType="#//EClass"/>
444 </eOperations>
445 <eOperations name="createFromString" eType="#//EJavaObject">
446 <eParameters name="eDataType" eType="#//EDataType"/>
447 <eParameters name="literalValue" eType="#//EString"/>
448 </eOperations>
449 <eOperations name="convertToString" eType="#//EString">
450 <eParameters name="eDataType" eType="#//EDataType"/>
451 <eParameters name="instanceValue" eType="#//EJavaObject"/>
452 </eOperations>
453 <eStructuralFeatures xsi:type="ecore:EReference" name="ePackage" lowerBound="1"
454 eType="#//EPackage" transient="true" resolveProxies="false">
455 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
456 <details key="kind" value="attribute"/>
457 <details key="name" value="ePackage"/>
458 </eAnnotations>
459 </eStructuralFeatures>
460 </eClassifiers>
461 <eClassifiers xsi:type="ecore:EDataType" name="EFeatureMap" instanceClassName="org.eclipse.emf.ecore.util.FeatureMap"
462 serializable="false">
463 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
464 <details key="name" value="EFeatureMap"/>
465 </eAnnotations>
466 </eClassifiers>
467 <eClassifiers xsi:type="ecore:EDataType" name="EFeatureMapEntry" instanceClassName="org.eclipse.emf.ecore.util.FeatureMap$Entry"
468 serializable="false">
469 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
470 <details key="name" value="EFeatureMapEntry"/>
471 </eAnnotations>
472 </eClassifiers>
473 <eClassifiers xsi:type="ecore:EDataType" name="EFloat" instanceClassName="float">
474 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
475 <details key="name" value="EFloat"/>
476 <details key="baseType" value="http://www.eclipse.org/emf/2003/XMLType#float"/>
477 </eAnnotations>
478 </eClassifiers>
479 <eClassifiers xsi:type="ecore:EDataType" name="EFloatObject" instanceClassName="java.lang.Float">
480 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
481 <details key="name" value="EFloat:Object"/>
482 <details key="baseType" value="EFloat"/>
483 </eAnnotations>
484 </eClassifiers>
485 <eClassifiers xsi:type="ecore:EClass" name="EGenericType">
486 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
487 <details key="name" value="EGenericType"/>
488 <details key="kind" value="elementOnly"/>
489 </eAnnotations>
490 <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
491 <details key="constraints" value="ConsistentType ConsistentBounds ConsistentArguments"/>
492 </eAnnotations>
493 <eStructuralFeatures xsi:type="ecore:EReference" name="eUpperBound" eType="#//EGenericType"
494 containment="true" resolveProxies="false">
495 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
496 <details key="kind" value="element"/>
497 <details key="name" value="eUpperBound"/>
498 </eAnnotations>
499 </eStructuralFeatures>
500 <eStructuralFeatures xsi:type="ecore:EReference" name="eTypeArguments" upperBound="-1"
501 eType="#//EGenericType" containment="true" resolveProxies="false">
502 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
503 <details key="kind" value="element"/>
504 <details key="name" value="eTypeArguments"/>
505 </eAnnotations>
506 </eStructuralFeatures>
507 <eStructuralFeatures xsi:type="ecore:EReference" name="eLowerBound" eType="#//EGenericType"
508 containment="true" resolveProxies="false">
509 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
510 <details key="kind" value="element"/>
511 <details key="name" value="eLowerBound"/>
512 </eAnnotations>
513 </eStructuralFeatures>
514 <eStructuralFeatures xsi:type="ecore:EReference" name="eClassifier" eType="#//EClassifier">
515 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
516 <details key="kind" value="attribute"/>
517 <details key="name" value="eClassifier"/>
518 </eAnnotations>
519 </eStructuralFeatures>
520 <eStructuralFeatures xsi:type="ecore:EReference" name="eRawType" lowerBound="1"
521 eType="#//EClassifier" changeable="false" transient="true" derived="true">
522 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
523 <details key="kind" value="attribute"/>
524 <details key="name" value="eRawType"/>
525 </eAnnotations>
526 </eStructuralFeatures>
527 <eStructuralFeatures xsi:type="ecore:EReference" name="eTypeParameter" eType="#//ETypeParameter"
528 resolveProxies="false">
529 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
530 <details key="kind" value="attribute"/>
531 <details key="name" value="eTypeParameter"/>
532 </eAnnotations>
533 </eStructuralFeatures>
534 </eClassifiers>
535 <eClassifiers xsi:type="ecore:EDataType" name="EInt" instanceClassName="int">
536 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
537 <details key="name" value="EInt"/>
538 </eAnnotations>
539 </eClassifiers>
540 <eClassifiers xsi:type="ecore:EDataType" name="EIntegerObject" instanceClassName="java.lang.Integer">
541 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
542 <details key="name" value="EInt:Object"/>
543 <details key="baseType" value="EInt"/>
544 </eAnnotations>
545 </eClassifiers>
546 <eClassifiers xsi:type="ecore:EDataType" name="EInvocationTargetException" instanceClassName="java.lang.reflect.InvocationTargetException"
547 serializable="false">
548 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
549 <details key="name" value="EInvocationTargetException"/>
550 </eAnnotations>
551 </eClassifiers>
552 <eClassifiers xsi:type="ecore:EDataType" name="EJavaClass" instanceClassName="java.lang.Class">
553 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
554 <details key="name" value="EJavaClass"/>
555 </eAnnotations>
556 <eTypeParameters name="T"/>
557 </eClassifiers>
558 <eClassifiers xsi:type="ecore:EDataType" name="EJavaObject" instanceClassName="java.lang.Object">
559 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
560 <details key="name" value="EJavaObject"/>
561 </eAnnotations>
562 </eClassifiers>
563 <eClassifiers xsi:type="ecore:EDataType" name="ELong" instanceClassName="long">
564 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
565 <details key="name" value="ELong"/>
566 <details key="baseType" value="http://www.eclipse.org/emf/2003/XMLType#long"/>
567 </eAnnotations>
568 </eClassifiers>
569 <eClassifiers xsi:type="ecore:EDataType" name="ELongObject" instanceClassName="java.lang.Long">
570 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
571 <details key="name" value="ELong:Object"/>
572 <details key="baseType" value="ELong"/>
573 </eAnnotations>
574 </eClassifiers>
575 <eClassifiers xsi:type="ecore:EDataType" name="EMap" instanceClassName="java.util.Map"
576 serializable="false">
577 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
578 <details key="name" value="EMap"/>
579 </eAnnotations>
580 <eTypeParameters name="K"/>
581 <eTypeParameters name="V"/>
582 </eClassifiers>
583 <eClassifiers xsi:type="ecore:EClass" name="EModelElement" abstract="true">
584 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
585 <details key="name" value="EModelElement"/>
586 <details key="kind" value="elementOnly"/>
587 </eAnnotations>
588 <eOperations name="getEAnnotation" eType="#//EAnnotation">
589 <eParameters name="source" eType="#//EString"/>
590 </eOperations>
591 <eStructuralFeatures xsi:type="ecore:EReference" name="eAnnotations" upperBound="-1"
592 eType="#//EAnnotation" containment="true" resolveProxies="false" eOpposite="#//EAnnotation/eModelElement">
593 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
594 <details key="kind" value="element"/>
595 <details key="name" value="eAnnotations"/>
596 </eAnnotations>
597 </eStructuralFeatures>
598 </eClassifiers>
599 <eClassifiers xsi:type="ecore:EClass" name="ENamedElement" abstract="true" eSuperTypes="#//EModelElement">
600 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
601 <details key="name" value="ENamedElement"/>
602 <details key="kind" value="elementOnly"/>
603 </eAnnotations>
604 <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
605 <details key="constraints" value="WellFormedName"/>
606 </eAnnotations>
607 <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="#//EString">
608 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
609 <details key="kind" value="attribute"/>
610 <details key="name" value="name"/>
611 </eAnnotations>
612 </eStructuralFeatures>
613 </eClassifiers>
614 <eClassifiers xsi:type="ecore:EClass" name="EObject">
615 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
616 <details key="name" value="EObject"/>
617 <details key="kind" value="empty"/>
618 </eAnnotations>
619 <eOperations name="eClass" eType="#//EClass"/>
620 <eOperations name="eIsProxy" eType="#//EBoolean"/>
621 <eOperations name="eResource" eType="#//EResource"/>
622 <eOperations name="eContainer" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
623 <eOperations name="eContainingFeature" eType="#//EStructuralFeature"/>
624 <eOperations name="eContainmentFeature" eType="#//EReference"/>
625 <eOperations name="eContents">
626 <eGenericType eClassifier="#//EEList">
627 <eTypeArguments eClassifier="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
628 </eGenericType>
629 </eOperations>
630 <eOperations name="eAllContents">
631 <eGenericType eClassifier="#//ETreeIterator">
632 <eTypeArguments eClassifier="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
633 </eGenericType>
634 </eOperations>
635 <eOperations name="eCrossReferences">
636 <eGenericType eClassifier="#//EEList">
637 <eTypeArguments eClassifier="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
638 </eGenericType>
639 </eOperations>
640 <eOperations name="eGet" eType="#//EJavaObject">
641 <eParameters name="feature" eType="#//EStructuralFeature"/>
642 </eOperations>
643 <eOperations name="eGet" eType="#//EJavaObject">
644 <eParameters name="feature" eType="#//EStructuralFeature"/>
645 <eParameters name="resolve" eType="#//EBoolean"/>
646 </eOperations>
647 <eOperations name="eSet">
648 <eParameters name="feature" eType="#//EStructuralFeature"/>
649 <eParameters name="newValue" eType="#//EJavaObject"/>
650 </eOperations>
651 <eOperations name="eIsSet" eType="#//EBoolean">
652 <eParameters name="feature" eType="#//EStructuralFeature"/>
653 </eOperations>
654 <eOperations name="eUnset">
655 <eParameters name="feature" eType="#//EStructuralFeature"/>
656 </eOperations>
657 <eOperations name="eInvoke" eType="#//EJavaObject" eExceptions="#//EInvocationTargetException">
658 <eParameters name="operation" eType="#//EOperation"/>
659 <eParameters name="arguments">
660 <eGenericType eClassifier="#//EEList">
661 <eTypeArguments/>
662 </eGenericType>
663 </eParameters>
664 </eOperations>
665 </eClassifiers>
666 <eClassifiers xsi:type="ecore:EClass" name="EOperation" eSuperTypes="#//ETypedElement">
667 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
668 <details key="name" value="EOperation"/>
669 <details key="kind" value="elementOnly"/>
670 </eAnnotations>
671 <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
672 <details key="constraints" value="UniqueParameterNames UniqueTypeParameterNames NoRepeatingVoid"/>
673 </eAnnotations>
674 <eOperations name="getOperationID" eType="#//EInt"/>
675 <eOperations name="isOverrideOf" eType="#//EBoolean">
676 <eParameters name="someOperation" eType="#//EOperation"/>
677 </eOperations>
678 <eStructuralFeatures xsi:type="ecore:EReference" name="eTypeParameters" upperBound="-1"
679 eType="#//ETypeParameter" containment="true">
680 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
681 <details key="kind" value="element"/>
682 <details key="name" value="eTypeParameters"/>
683 </eAnnotations>
684 </eStructuralFeatures>
685 <eStructuralFeatures xsi:type="ecore:EReference" name="eParameters" upperBound="-1"
686 eType="#//EParameter" containment="true" resolveProxies="false" eOpposite="#//EParameter/eOperation">
687 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
688 <details key="kind" value="element"/>
689 <details key="name" value="eParameters"/>
690 </eAnnotations>
691 </eStructuralFeatures>
692 <eStructuralFeatures xsi:type="ecore:EReference" name="eGenericExceptions" upperBound="-1"
693 eType="#//EGenericType" unsettable="true" containment="true" resolveProxies="false">
694 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
695 <details key="kind" value="element"/>
696 <details key="name" value="eGenericExceptions"/>
697 </eAnnotations>
698 <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
699 <details key="suppressedIsSetVisibility" value="true"/>
700 <details key="suppressedUnsetVisibility" value="true"/>
701 </eAnnotations>
702 </eStructuralFeatures>
703 <eStructuralFeatures xsi:type="ecore:EReference" name="eExceptions" upperBound="-1"
704 eType="#//EClassifier" unsettable="true">
705 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
706 <details key="kind" value="attribute"/>
707 <details key="name" value="eExceptions"/>
708 </eAnnotations>
709 <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
710 <details key="suppressedIsSetVisibility" value="true"/>
711 <details key="suppressedUnsetVisibility" value="true"/>
712 </eAnnotations>
713 </eStructuralFeatures>
714 <eStructuralFeatures xsi:type="ecore:EReference" name="eContainingClass" eType="#//EClass"
715 transient="true" eOpposite="#//EClass/eOperations"/>
716 </eClassifiers>
717 <eClassifiers xsi:type="ecore:EClass" name="EPackage" eSuperTypes="#//ENamedElement">
718 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
719 <details key="name" value="EPackage"/>
720 <details key="kind" value="elementOnly"/>
721 </eAnnotations>
722 <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
723 <details key="constraints" value="WellFormedNsURI WellFormedNsPrefix UniqueSubpackageNames UniqueClassifierNames UniqueNsURIs"/>
724 </eAnnotations>
725 <eOperations name="getEClassifier" eType="#//EClassifier">
726 <eParameters name="name" eType="#//EString"/>
727 </eOperations>
728 <eStructuralFeatures xsi:type="ecore:EReference" name="eClassifiers" upperBound="-1"
729 eType="#//EClassifier" containment="true" eOpposite="#//EClassifier/ePackage">
730 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
731 <details key="kind" value="element"/>
732 <details key="name" value="eClassifiers"/>
733 </eAnnotations>
734 </eStructuralFeatures>
735 <eStructuralFeatures xsi:type="ecore:EReference" name="eSubpackages" upperBound="-1"
736 eType="#//EPackage" containment="true" eOpposite="#//EPackage/eSuperPackage">
737 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
738 <details key="kind" value="element"/>
739 <details key="name" value="eSubpackages"/>
740 </eAnnotations>
741 </eStructuralFeatures>
742 <eStructuralFeatures xsi:type="ecore:EAttribute" name="nsPrefix" eType="#//EString">
743 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
744 <details key="kind" value="attribute"/>
745 <details key="name" value="nsPrefix"/>
746 </eAnnotations>
747 </eStructuralFeatures>
748 <eStructuralFeatures xsi:type="ecore:EAttribute" name="nsURI" eType="#//EString">
749 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
750 <details key="kind" value="attribute"/>
751 <details key="name" value="nsURI"/>
752 </eAnnotations>
753 </eStructuralFeatures>
754 <eStructuralFeatures xsi:type="ecore:EReference" name="eSuperPackage" eType="#//EPackage"
755 transient="true" eOpposite="#//EPackage/eSubpackages"/>
756 </eClassifiers>
757 <eClassifiers xsi:type="ecore:EClass" name="EParameter" eSuperTypes="#//ETypedElement">
758 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
759 <details key="name" value="EParameter"/>
760 <details key="kind" value="elementOnly"/>
761 </eAnnotations>
762 <eStructuralFeatures xsi:type="ecore:EReference" name="eOperation" eType="#//EOperation"
763 transient="true" eOpposite="#//EOperation/eParameters"/>
764 </eClassifiers>
765 <eClassifiers xsi:type="ecore:EClass" name="EReference" eSuperTypes="#//EStructuralFeature">
766 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
767 <details key="name" value="EReference"/>
768 <details key="kind" value="elementOnly"/>
769 </eAnnotations>
770 <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
771 <details key="constraints" value="ConsistentOpposite SingleContainer ConsistentKeys ConsistentUnique ConsistentContainer"/>
772 </eAnnotations>
773 <eStructuralFeatures xsi:type="ecore:EAttribute" name="container" eType="#//EBoolean"
774 changeable="false" volatile="true" transient="true" derived="true">
775 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
776 <details key="kind" value="attribute"/>
777 <details key="name" value="container"/>
778 </eAnnotations>
779 </eStructuralFeatures>
780 <eStructuralFeatures xsi:type="ecore:EAttribute" name="containment" eType="#//EBoolean">
781 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
782 <details key="kind" value="attribute"/>
783 <details key="name" value="containment"/>
784 </eAnnotations>
785 </eStructuralFeatures>
786 <eStructuralFeatures xsi:type="ecore:EReference" name="eKeys" upperBound="-1"
787 eType="#//EAttribute">
788 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
789 <details key="kind" value="attribute"/>
790 <details key="name" value="eKeys"/>
791 </eAnnotations>
792 </eStructuralFeatures>
793 <eStructuralFeatures xsi:type="ecore:EReference" name="eOpposite" eType="#//EReference">
794 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
795 <details key="kind" value="attribute"/>
796 <details key="name" value="eOpposite"/>
797 </eAnnotations>
798 </eStructuralFeatures>
799 <eStructuralFeatures xsi:type="ecore:EReference" name="eReferenceType" lowerBound="1"
800 eType="#//EClass" changeable="false" volatile="true" transient="true" derived="true">
801 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
802 <details key="kind" value="attribute"/>
803 <details key="name" value="eReferenceType"/>
804 </eAnnotations>
805 </eStructuralFeatures>
806 <eStructuralFeatures xsi:type="ecore:EAttribute" name="resolveProxies" eType="#//EBoolean"
807 defaultValueLiteral="true">
808 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
809 <details key="kind" value="attribute"/>
810 <details key="name" value="resolveProxies"/>
811 </eAnnotations>
812 </eStructuralFeatures>
813 </eClassifiers>
814 <eClassifiers xsi:type="ecore:EDataType" name="EResource" instanceClassName="org.eclipse.emf.ecore.resource.Resource"
815 serializable="false">
816 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
817 <details key="name" value="EResource"/>
818 </eAnnotations>
819 </eClassifiers>
820 <eClassifiers xsi:type="ecore:EDataType" name="EResourceSet" instanceClassName="org.eclipse.emf.ecore.resource.ResourceSet"
821 serializable="false">
822 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
823 <details key="name" value="EResourceSet"/>
824 </eAnnotations>
825 </eClassifiers>
826 <eClassifiers xsi:type="ecore:EDataType" name="EShort" instanceClassName="short">
827 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
828 <details key="name" value="EShort"/>
829 <details key="baseType" value="http://www.eclipse.org/emf/2003/XMLType#short"/>
830 </eAnnotations>
831 </eClassifiers>
832 <eClassifiers xsi:type="ecore:EDataType" name="EShortObject" instanceClassName="java.lang.Short">
833 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
834 <details key="name" value="EShort:Object"/>
835 <details key="baseType" value="EShort"/>
836 </eAnnotations>
837 </eClassifiers>
838 <eClassifiers xsi:type="ecore:EDataType" name="EString" instanceClassName="java.lang.String">
839 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
840 <details key="name" value="EString"/>
841 <details key="baseType" value="http://www.eclipse.org/emf/2003/XMLType#string"/>
842 </eAnnotations>
843 </eClassifiers>
844 <eClassifiers xsi:type="ecore:EClass" name="EStringToStringMapEntry" instanceClassName="java.util.Map$Entry">
845 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
846 <details key="name" value="EStringToStringMapEntry"/>
847 <details key="kind" value="empty"/>
848 </eAnnotations>
849 <eStructuralFeatures xsi:type="ecore:EAttribute" name="key" eType="#//EString">
850 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
851 <details key="kind" value="attribute"/>
852 <details key="name" value="key"/>
853 </eAnnotations>
854 </eStructuralFeatures>
855 <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="#//EString">
856 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
857 <details key="kind" value="attribute"/>
858 <details key="name" value="value"/>
859 </eAnnotations>
860 </eStructuralFeatures>
861 </eClassifiers>
862 <eClassifiers xsi:type="ecore:EClass" name="EStructuralFeature" abstract="true"
863 eSuperTypes="#//ETypedElement">
864 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
865 <details key="name" value="EStructuralFeature"/>
866 <details key="kind" value="elementOnly"/>
867 </eAnnotations>
868 <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
869 <details key="constraints" value="ValidDefaultValueLiteral"/>
870 </eAnnotations>
871 <eOperations name="getFeatureID" eType="#//EInt"/>
872 <eOperations name="getContainerClass">
873 <eGenericType eClassifier="#//EJavaClass">
874 <eTypeArguments/>
875 </eGenericType>
876 </eOperations>
877 <eStructuralFeatures xsi:type="ecore:EAttribute" name="changeable" eType="#//EBoolean"
878 defaultValueLiteral="true">
879 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
880 <details key="kind" value="attribute"/>
881 <details key="name" value="changeable"/>
882 </eAnnotations>
883 </eStructuralFeatures>
884 <eStructuralFeatures xsi:type="ecore:EAttribute" name="defaultValue" eType="#//EJavaObject"
885 changeable="false" volatile="true" transient="true" derived="true">
886 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
887 <details key="kind" value="attribute"/>
888 <details key="name" value="defaultValue"/>
889 </eAnnotations>
890 </eStructuralFeatures>
891 <eStructuralFeatures xsi:type="ecore:EAttribute" name="defaultValueLiteral" eType="#//EString">
892 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
893 <details key="kind" value="attribute"/>
894 <details key="name" value="defaultValueLiteral"/>
895 </eAnnotations>
896 </eStructuralFeatures>
897 <eStructuralFeatures xsi:type="ecore:EAttribute" name="derived" eType="#//EBoolean">
898 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
899 <details key="kind" value="attribute"/>
900 <details key="name" value="derived"/>
901 </eAnnotations>
902 </eStructuralFeatures>
903 <eStructuralFeatures xsi:type="ecore:EAttribute" name="transient" eType="#//EBoolean">
904 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
905 <details key="kind" value="attribute"/>
906 <details key="name" value="transient"/>
907 </eAnnotations>
908 </eStructuralFeatures>
909 <eStructuralFeatures xsi:type="ecore:EAttribute" name="unsettable" eType="#//EBoolean">
910 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
911 <details key="kind" value="attribute"/>
912 <details key="name" value="unsettable"/>
913 </eAnnotations>
914 </eStructuralFeatures>
915 <eStructuralFeatures xsi:type="ecore:EAttribute" name="volatile" eType="#//EBoolean">
916 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
917 <details key="kind" value="attribute"/>
918 <details key="name" value="volatile"/>
919 </eAnnotations>
920 </eStructuralFeatures>
921 <eStructuralFeatures xsi:type="ecore:EReference" name="eContainingClass" eType="#//EClass"
922 transient="true" eOpposite="#//EClass/eStructuralFeatures"/>
923 </eClassifiers>
924 <eClassifiers xsi:type="ecore:EDataType" name="ETreeIterator" instanceClassName="org.eclipse.emf.common.util.TreeIterator"
925 serializable="false">
926 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
927 <details key="name" value="ETreeIterator"/>
928 </eAnnotations>
929 <eTypeParameters name="E"/>
930 </eClassifiers>
931 <eClassifiers xsi:type="ecore:EClass" name="ETypedElement" abstract="true" eSuperTypes="#//ENamedElement">
932 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
933 <details key="name" value="ETypedElement"/>
934 <details key="kind" value="elementOnly"/>
935 </eAnnotations>
936 <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
937 <details key="constraints" value="ValidLowerBound ValidUpperBound ConsistentBounds ValidType"/>
938 </eAnnotations>
939 <eStructuralFeatures xsi:type="ecore:EReference" name="eGenericType" eType="#//EGenericType"
940 volatile="true" unsettable="true" containment="true" resolveProxies="false">
941 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
942 <details key="kind" value="element"/>
943 <details key="name" value="eGenericType"/>
944 </eAnnotations>
945 <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
946 <details key="suppressedIsSetVisibility" value="true"/>
947 <details key="suppressedUnsetVisibility" value="true"/>
948 </eAnnotations>
949 </eStructuralFeatures>
950 <eStructuralFeatures xsi:type="ecore:EReference" name="eType" eType="#//EClassifier"
951 volatile="true" unsettable="true">
952 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
953 <details key="kind" value="attribute"/>
954 <details key="name" value="eType"/>
955 </eAnnotations>
956 <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
957 <details key="suppressedIsSetVisibility" value="true"/>
958 <details key="suppressedUnsetVisibility" value="true"/>
959 </eAnnotations>
960 </eStructuralFeatures>
961 <eStructuralFeatures xsi:type="ecore:EAttribute" name="lowerBound" eType="#//EInt">
962 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
963 <details key="kind" value="attribute"/>
964 <details key="name" value="lowerBound"/>
965 </eAnnotations>
966 </eStructuralFeatures>
967 <eStructuralFeatures xsi:type="ecore:EAttribute" name="many" eType="#//EBoolean"
968 changeable="false" volatile="true" transient="true" derived="true">
969 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
970 <details key="kind" value="attribute"/>
971 <details key="name" value="many"/>
972 </eAnnotations>
973 </eStructuralFeatures>
974 <eStructuralFeatures xsi:type="ecore:EAttribute" name="ordered" eType="#//EBoolean"
975 defaultValueLiteral="true">
976 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
977 <details key="kind" value="attribute"/>
978 <details key="name" value="ordered"/>
979 </eAnnotations>
980 </eStructuralFeatures>
981 <eStructuralFeatures xsi:type="ecore:EAttribute" name="required" eType="#//EBoolean"
982 changeable="false" volatile="true" transient="true" derived="true">
983 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
984 <details key="kind" value="attribute"/>
985 <details key="name" value="required"/>
986 </eAnnotations>
987 </eStructuralFeatures>
988 <eStructuralFeatures xsi:type="ecore:EAttribute" name="unique" eType="#//EBoolean"
989 defaultValueLiteral="true">
990 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
991 <details key="kind" value="attribute"/>
992 <details key="name" value="unique"/>
993 </eAnnotations>
994 </eStructuralFeatures>
995 <eStructuralFeatures xsi:type="ecore:EAttribute" name="upperBound" eType="#//EInt"
996 defaultValueLiteral="1">
997 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
998 <details key="kind" value="attribute"/>
999 <details key="name" value="upperBound"/>
1000 </eAnnotations>
1001 </eStructuralFeatures>
1002 </eClassifiers>
1003 <eClassifiers xsi:type="ecore:EClass" name="ETypeParameter" eSuperTypes="#//ENamedElement">
1004 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
1005 <details key="name" value="ETypeParameter"/>
1006 <details key="kind" value="elementOnly"/>
1007 </eAnnotations>
1008 <eStructuralFeatures xsi:type="ecore:EReference" name="eBounds" upperBound="-1"
1009 eType="#//EGenericType" containment="true" resolveProxies="false">
1010 <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
1011 <details key="kind" value="element"/>
1012 <details key="name" value="eBounds"/>
1013 </eAnnotations>
1014 </eStructuralFeatures>
1015 </eClassifiers>
1016</ecore:EPackage>
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/Domain.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/Domain.xtend
new file mode 100644
index 00000000..c8fd435b
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/Domain.xtend
@@ -0,0 +1,7 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app
2
3enum Domain{
4 Yakindumm,
5 Ecore,
6 Github
7} \ 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/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
new file mode 100644
index 00000000..dfde6593
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/Main.xtend
@@ -0,0 +1,96 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.EMFGraph
4import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io.CsvFileWriter
5import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io.GraphReader
6import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.validation.ViolationCheck
7import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl.YakindummPackageImpl
8import java.io.File
9import java.util.ArrayList
10import org.eclipse.emf.ecore.EPackage
11import org.eclipse.emf.ecore.EcorePackage
12import org.eclipse.viatra.query.runtime.rete.matcher.ReteEngine
13import org.eclipse.emf.ecore.impl.EcorePackageImpl
14import org.eclipse.emf.ecore.EReference
15
16//import yakindumm2.impl.Yakindumm2PackageImpl
17
18class Main {
19 var static Domain d = Domain.Yakindumm;
20 val static String suffix = '.xmi'
21 val static String OUTPUT_FOLDER = "Inputs/measurement2/yakindu/Alloy/";
22 val static String INPUT_FOLDER = "outputs/measurement2/yakindu/Alloy/";
23 val static int NUM_RUNS = 1;
24
25 static class RWInformation{
26 public var String inputFolder;
27 public var String outputFolder;
28 public var int numRuns;
29
30 new(String inputFolder, String outputFolder, int numRuns){
31 this.inputFolder = inputFolder;
32 this.outputFolder = outputFolder;
33 this.numRuns = numRuns;
34 }
35 }
36
37 def static void main(String[] args){
38 //init model
39 var EPackage metamodel;
40 //init viatra engine for the violation checker
41 ReteEngine.getClass();
42
43 if(d == Domain.Yakindumm){
44 YakindummPackageImpl.eINSTANCE.eClass;
45 metamodel = YakindummPackageImpl.eINSTANCE;
46 }else if (d == Domain.Ecore){
47 EcorePackage.eINSTANCE.eClass;
48 metamodel = EcorePackageImpl.eINSTANCE;
49 }else if (d == Domain.Github){
50 //TODO: Initialize Github Package
51 }
52
53
54 println("Start Reading Models...");
55 var reader = new GraphReader(metamodel, suffix);
56
57 val models = new RWInformation(OUTPUT_FOLDER, INPUT_FOLDER, NUM_RUNS);
58 calculateAllModels(models.inputFolder, models.outputFolder,models.numRuns, reader);
59 println("finished");
60 }
61
62 static def calculateAllModels(String inputFolder, String outputFolder, int numRuns, GraphReader reader){
63 (new File(outputFolder)).mkdir();
64 for(var i = 1; i <= numRuns; i++){
65 val models = new ArrayList<EMFGraph>();
66 models.addAll(reader.readModels(inputFolder + "run" + i));
67 for(model : models){
68 calculateAndOutputMetrics(model, YakindummPackageImpl.eNAME, outputFolder+model.name+"_run_"+i+".csv");
69 }
70 }
71 println("output results Ended for: " + outputFolder);
72
73
74 }
75
76 static def calculateAndOutputMetrics(EMFGraph model, String metaModel, String fileName){
77 //println("evaluating for " + model.name);
78 model.metaModel = metaModel;
79
80 //remove eGenericType for Ecore domain
81 if(d == Domain.Ecore){
82 var refsToRemove = EcorePackageImpl.eINSTANCE.eAllContents.filter(EReference).filter[
83 it.name.equals('eGenericType') || it.name.equals('eGenericSuperTypes') || it.name.equals('eFactoryInstance')||
84 it.name.equals('eGenericExceptions') || it.name.equals('references') || it.name.equals('contents');
85 ];
86 refsToRemove.forEach[model.removeReference(it)];
87 }
88
89 var outputs = model.evaluateAllMetrics();
90 var violations = ViolationCheck.calculateViolationCounts(model.root, d);
91 println(violations);
92 var violationsOutput = newArrayList('violations', violations+'');
93 outputs.add(violationsOutput);
94 CsvFileWriter.write(outputs, fileName);
95 }
96} \ 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/app/PartialInterpretationMetric.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/PartialInterpretationMetric.xtend
new file mode 100644
index 00000000..5e62b586
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/PartialInterpretationMetric.xtend
@@ -0,0 +1,85 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance.JSDistance
4import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance.KSDistance
5import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.PartialInterpretationGraph
6import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io.CsvFileWriter
7import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.Metric
8import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MultiplexParticipationCoefficientMetric
9import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.NodeActivityMetric
10import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.OutDegreeMetric
11import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
12import java.io.File
13import java.io.FileNotFoundException
14import java.io.PrintWriter
15import java.util.ArrayList
16import java.util.List
17import org.eclipse.emf.ecore.util.EcoreUtil
18import org.eclipse.viatra.dse.api.Solution
19
20class PartialInterpretationMetric {
21 var static KSDistance ks;
22 var static JSDistance js;
23
24 def static void initPaths(){
25 new File("debug/metric/").mkdir();
26 new File("debug/metric/trajectories/").mkdir();
27 }
28
29 // calculate the metrics for a state
30 def static void calculateMetric(PartialInterpretation partial, String path, String currentStateId, Integer counter){
31 val metrics = new ArrayList<Metric>();
32 metrics.add(new OutDegreeMetric());
33 metrics.add(new NodeActivityMetric());
34 metrics.add(new MultiplexParticipationCoefficientMetric());
35
36 //make dir since the folder can be none existing
37 new File(path).mkdir();
38 val filename = path + "/state_"+currentStateId+"-"+counter+".csv";
39 val metricCalculator = new PartialInterpretationGraph(partial, metrics, currentStateId);
40
41 CsvFileWriter.write(metricCalculator.evaluateAllMetrics(), filename);
42 }
43
44 def static void outputTrajectories(PartialInterpretation empty, List<Solution> solutions){
45 for(solution : solutions){
46
47 //need to copy the empty solution because the transition directly worked on the graph
48 val emptySolutionCopy = EcoreUtil.copy(empty)
49 val trajectory = solution.shortestTrajectory;
50 trajectory.model = emptySolutionCopy
51
52 // state codes that will record the trajectory
53 val stateCodes = newArrayList()
54 var counter = 0
55
56 //transform and record the state codes for each state
57 while(trajectory.doNextTransformation){
58 //println(trajectory.stateCoder.createStateCode)
59 val stateId = trajectory.stateCoder.createStateCode.toString
60 val interpretation = trajectory.getModel();
61 println(stateId)
62 //calculate metrics of current state
63 calculateMetric(interpretation as PartialInterpretation, "debug/metric/output", stateId, counter)
64 stateCodes.add(stateId)
65 counter++
66 }
67
68
69 //output the trajectory
70 try{
71 new File("debug/metric/trajectories/").mkdir();
72 val path = "debug/metric/trajectories/trajectory"+trajectory.stateCoder.createStateCode.toString+".csv"
73 val PrintWriter writer = new PrintWriter(new File(path))
74 val output = new StringBuilder
75 for(stateCode : stateCodes){
76 output.append(stateCode+'\n')
77 }
78 writer.write(output.toString())
79 writer.close()
80 }catch(FileNotFoundException e) {
81 e.printStackTrace()
82 }
83 }
84 }
85} \ 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/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
new file mode 100644
index 00000000..697b2639
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/app/PartialInterpretationMetricDistance.xtend
@@ -0,0 +1,216 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance.EuclideanDistance
4import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance.JSDistance
5import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance.KSDistance
6import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance.StateData
7import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.PartialInterpretationGraph
8import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io.RepMetricsReader
9import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.Metric
10import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MetricSampleGroup
11import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MultiplexParticipationCoefficientMetric
12import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.NodeActivityMetric
13import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.NodeTypeMetric
14import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.OutDegreeMetric
15import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.predictor.LinearModel
16import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
17import java.util.ArrayList
18import java.util.HashMap
19import java.util.List
20import java.util.Map
21import org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression
22import org.eclipse.xtend.lib.annotations.Accessors
23import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.EdgeTypeMetric
24
25class PartialInterpretationMetricDistance {
26
27 var KSDistance ks;
28 var JSDistance js;
29 var EuclideanDistance ed;
30 var Map<Object, StateData> stateAndHistory;
31 var OLSMultipleLinearRegression regression;
32 List<StateData> samples;
33 var MetricSampleGroup g;
34 @Accessors(PUBLIC_GETTER)
35 var LinearModel linearModel;
36
37
38 new(Domain d){
39 var metrics = RepMetricsReader.read(d);
40 this.g = metrics;
41 ks = new KSDistance(g);
42 js = new JSDistance(g);
43 ed = new EuclideanDistance(g);
44 regression = new OLSMultipleLinearRegression();
45 regression.noIntercept = false;
46 stateAndHistory = new HashMap<Object, StateData>();
47 samples = new ArrayList<StateData>();
48 linearModel = new LinearModel(0.01);
49 }
50
51 def MetricDistanceGroup calculateMetricDistanceKS(PartialInterpretation partial){
52 val metrics = new ArrayList<Metric>();
53 metrics.add(new OutDegreeMetric());
54 metrics.add(new NodeActivityMetric());
55 metrics.add(new MultiplexParticipationCoefficientMetric());
56 metrics.add(new NodeTypeMetric());
57 val metricCalculator = new PartialInterpretationGraph(partial, metrics, null);
58 var metricSamples = metricCalculator.evaluateAllMetricsToSamples();
59
60 var mpc = ks.mpcDistance(metricSamples.mpcSamples);
61 var na = ks.naDistance(metricSamples.naSamples);
62 var outDegree = ks.outDegreeDistance(metricSamples.outDegreeSamples);
63 var nodeType = ks.nodeTypeDistance(metricSamples.nodeTypeSamples);
64 //var typedOutDegree = ks.typedOutDegreeDistance(metricSamples.typedOutDegreeSamples);
65 var distance = new MetricDistanceGroup(mpc, na, outDegree, nodeType);
66 distance.nodeTypeInfo = metricSamples.nodeTypeSamples;
67 return distance;
68 }
69
70 def MetricDistanceGroup calculateMetricEuclidean(PartialInterpretation partial){
71 val metrics = new ArrayList<Metric>();
72 metrics.add(new OutDegreeMetric());
73 metrics.add(new NodeActivityMetric());
74 metrics.add(new MultiplexParticipationCoefficientMetric());
75
76 val metricCalculator = new PartialInterpretationGraph(partial, metrics, null);
77 var metricSamples = metricCalculator.evaluateAllMetricsToSamples();
78
79 var mpc = ed.mpcDistance(metricSamples.mpcSamples);
80 var na = ed.naDistance(metricSamples.naSamples);
81 var outDegree = ed.outDegreeDistance(metricSamples.outDegreeSamples);
82
83 return new MetricDistanceGroup(mpc, na, outDegree);
84 }
85
86 def MetricDistanceGroup calculateMetricDistance(PartialInterpretation partial){
87 val metrics = new ArrayList<Metric>();
88 metrics.add(new OutDegreeMetric());
89 metrics.add(new NodeActivityMetric());
90 metrics.add(new MultiplexParticipationCoefficientMetric());
91
92 val metricCalculator = new PartialInterpretationGraph(partial, metrics, null);
93 var metricSamples = metricCalculator.evaluateAllMetricsToSamples();
94
95 var mpc = js.mpcDistance(metricSamples.mpcSamples);
96 var na = js.naDistance(metricSamples.naSamples);
97 var outDegree = js.outDegreeDistance(metricSamples.outDegreeSamples);
98
99 return new MetricDistanceGroup(mpc, na, outDegree);
100 }
101
102 def resetRegression(Object state){
103 samples.clear();
104
105 if(stateAndHistory.containsKey(state)){
106 var data = stateAndHistory.get(state);
107
108 var curState = state;
109
110 samples.add(data);
111
112 while(stateAndHistory.containsKey(data.lastState) && data.lastState != curState){
113 curState = data.lastState;
114 data = stateAndHistory.get(data.lastState);
115 samples.add(data);
116 }
117
118 if(samples.size == 0){
119 println('state: ' + state);
120 println('last state: ' + data.lastState);
121 }
122 }
123 println("trajectory sample size:" + samples.size)
124 }
125
126 def feedData(Object state, double[] features, double value, Object lastState){
127 var data = new StateData(features, value, lastState);
128 stateAndHistory.put(state, data);
129 samples.add(data);
130 }
131
132 def getPredictionForNextDataSample(double[] features, double value, double[] featuresToPredict){
133 if(samples.size <= 4){
134 println('OK');
135 }
136 var data = new StateData(features, value, null);
137 samples.add(data);
138
139 // create training set from current data
140 var double[][] xSamples = samples.map[it.features];
141 var double[] ySamples = samples.map[it.value];
142
143
144 regression.newSampleData(ySamples, xSamples);
145 var prediction = predict(featuresToPredict);
146
147 //remove the last element just added
148 samples.remove(samples.size - 1);
149 return prediction;
150 }
151
152 def private predict(double[] featuresToPredict){
153 var parameters = regression.estimateRegressionParameters();
154 // the regression will add an initial column for 1's, the first parameter is constant term
155 var result = parameters.get(0);
156 for(var i = 0; i < featuresToPredict.length; i++){
157 result += parameters.get(i+1) * featuresToPredict.get(i);
158 }
159 return result;
160 }
161
162 def double[] calculateFeature(int step, int violations){
163 var features = newDoubleArrayOfSize(2);
164 //constant term
165 features.set(0, 1); //a
166 features.set(0, Math.sqrt(step) + 30) // b
167 features.set(1, 1.0 / (step + 30) );// c
168
169
170// features.set(2, violations);
171// features.set(3, Math.pow(violations, 2));
172
173 return features;
174 }
175}
176
177class MetricDistanceGroup{
178 var double mpcDistance;
179 var double naDistance;
180 var double outDegreeDistance;
181 var double nodeTypeDistance;
182 protected var HashMap<String, Double> nodeTypeInfo;
183
184 new(double mpcDistance, double naDistance, double outDegreeDistance, double nodeTypeDistance){
185 this.mpcDistance = mpcDistance;
186 this.naDistance = naDistance;
187 this.outDegreeDistance = outDegreeDistance;
188 this.nodeTypeDistance = nodeTypeDistance;
189 }
190
191 new(double mpcDistance, double naDistance, double outDegreeDistance){
192 this.mpcDistance = mpcDistance;
193 this.naDistance = naDistance;
194 this.outDegreeDistance = outDegreeDistance;
195 }
196
197 def double getNodeTypeDistance(){
198 return this.nodeTypeDistance;
199 }
200
201 def double getMPCDistance(){
202 return this.mpcDistance
203 }
204
205 def double getNADistance(){
206 return this.naDistance
207 }
208
209 def double getOutDegreeDistance(){
210 return this.outDegreeDistance
211 }
212
213 def double getNodeTypePercentage(String typeName){
214 return nodeTypeInfo.getOrDefault(typeName, 0.0);
215 }
216} \ 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/distance/CostDistance.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/distance/CostDistance.xtend
new file mode 100644
index 00000000..613f0f43
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/distance/CostDistance.xtend
@@ -0,0 +1,38 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance
2
3import java.text.DecimalFormat
4import java.util.HashMap
5import java.util.List
6import org.eclipse.xtend.lib.annotations.Accessors
7
8abstract class CostDistance {
9 def abstract double naDistance(List<Double> samples);
10 def abstract double mpcDistance(List<Double> samples);
11 def abstract double outDegreeDistance(List<Double> samples);
12
13 def protected pmfFromSamples(double[] samples, DecimalFormat formatter){
14 var length = samples.length;
15 var pmfMap = new HashMap<String, Double>();
16
17 for(sample : samples){
18 pmfMap.put(formatter.format(sample), pmfMap.getOrDefault(formatter.format(sample), 0.0) + 1.0 / length);
19 }
20
21 return pmfMap;
22 }
23}
24
25class StateData{
26 @Accessors(PUBLIC_GETTER)
27 var double[] features;
28 @Accessors(PUBLIC_GETTER)
29 var double value;
30 @Accessors(PUBLIC_GETTER)
31 var Object lastState;
32
33 new(double[] features, double value, Object lastState){
34 this.features = features;
35 this.value = value
36 this.lastState = lastState;
37 }
38} \ 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/distance/EuclideanDistance.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/distance/EuclideanDistance.xtend
new file mode 100644
index 00000000..d6adcc9a
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/distance/EuclideanDistance.xtend
@@ -0,0 +1,72 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app.Domain
4import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io.RepMetricsReader
5import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MetricSampleGroup
6import com.google.common.collect.Sets
7import java.text.DecimalFormat
8import java.util.ArrayList
9import java.util.HashMap
10import java.util.List
11import java.util.Map
12import java.util.Set
13
14class EuclideanDistance extends CostDistance{
15 var MetricSampleGroup g;
16 var HashMap<String, Double> mpcPMF;
17 var HashMap<String, Double> naPMF;
18 var HashMap<String, Double> outDegreePMF;
19 var DecimalFormat formatter;
20
21 new(MetricSampleGroup g){
22 this.g = g;
23
24 var mpcSamples = g.mpcSamples;
25 var naSamples = g.naSamples.stream.mapToDouble([it]).toArray();
26 var outDegreeSamples = g.outDegreeSamples.stream.mapToDouble([it]).toArray();
27
28 //needs to format the number to string avoid precision issue
29 formatter = new DecimalFormat("#0.00000");
30
31 mpcPMF = pmfFromSamples(mpcSamples, formatter);
32 naPMF = pmfFromSamples(naSamples, formatter);
33 outDegreePMF = pmfFromSamples(outDegreeSamples, formatter);
34 }
35
36 override naDistance(List<Double> samples) {
37 var pmfMap = pmfFromSamples(samples, formatter);
38 return euclideanDistance(pmfMap, naPMF);
39 }
40
41 override mpcDistance(List<Double> samples) {
42 var pmfMap = pmfFromSamples(samples, formatter);
43 return euclideanDistance(pmfMap, mpcPMF);
44 }
45
46 override outDegreeDistance(List<Double> samples) {
47 var pmfMap = pmfFromSamples(samples, formatter);
48 return euclideanDistance(pmfMap, outDegreePMF);
49 }
50
51
52 def private euclideanDistance(HashMap<String, Double> pmf1, HashMap<String, Double> pmf2){
53 var keys = Sets.union(pmf1.keySet(), pmf2.keySet());
54 var pmfList1 = pmfMapToList(pmf1, keys);
55 var pmfList2 = pmfMapToList(pmf2, keys);
56 var distance = 0.0;
57 for(var i = 0; i < pmfList1.size(); i++){
58 distance += Math.pow(pmfList1.get(i) + pmfList2.get(i), 2);
59 }
60
61 return Math.sqrt(distance);
62 }
63
64 def private pmfMapToList(Map<String, Double> map, Set<String> keys){
65 var list = new ArrayList<Double>();
66 for(key : keys){
67 var value = map.getOrDefault(key, 0.0);
68 list.add(value);
69 }
70 return list;
71 }
72} \ 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/distance/JSDistance.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/distance/JSDistance.xtend
new file mode 100644
index 00000000..4a0a0dc3
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/distance/JSDistance.xtend
@@ -0,0 +1,88 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MetricSampleGroup
4import com.google.common.collect.Sets
5import java.text.DecimalFormat
6import java.util.HashMap
7import java.util.List
8
9class JSDistance extends CostDistance {
10 var HashMap<String, Double> mpcPMF;
11 var HashMap<String, Double> naPMF;
12 var HashMap<String, Double> outDegreePMF;
13 var HashMap<String, Double> nodeTypesPMF;
14 var DecimalFormat formatter;
15
16 new(MetricSampleGroup g){
17 var mpcSamples = g.mpcSamples;
18 var naSamples = g.naSamples.stream.mapToDouble([it]).toArray();
19 var outDegreeSamples = g.outDegreeSamples.stream.mapToDouble([it]).toArray();
20
21 //needs to format the number to string avoid precision issue
22 formatter = new DecimalFormat("#0.00000");
23
24 mpcPMF = pmfFromSamples(mpcSamples, formatter);
25 naPMF = pmfFromSamples(naSamples, formatter);
26 outDegreePMF = pmfFromSamples(outDegreeSamples, formatter);
27 nodeTypesPMF = g.nodeTypeSamples;
28 }
29
30 def private combinePMF(HashMap<String, Double> pmf1, HashMap<String, Double> pmf2){
31 var pmfMap = new HashMap<String, Double>();
32
33 var union = Sets.union(pmf1.keySet(), pmf2.keySet());
34
35 for(key : union){
36 // corresponding to M in JS distance
37 var value = 1.0/2 * (pmf1.getOrDefault(key, 0.0) + pmf2.getOrDefault(key, 0.0));
38 pmfMap.put(key, value);
39 }
40 return pmfMap;
41 }
42
43 def private jsDivergence(HashMap<String, Double> p, HashMap<String, Double> q){
44 val m = combinePMF(q, p);
45 var distance = 1.0/2 * klDivergence(p, m) + 1.0/2 * klDivergence(q, m);
46 return distance;
47 }
48
49 def klDivergence(HashMap<String, Double> p, HashMap<String, Double> q){
50 var distance = 0.0;
51 for(key : q.keySet()){
52 //need to convert log e to log 2
53 if(p.containsKey(key)){
54 distance -= p.get(key) * Math.log(q.get(key) / p.get(key)) / Math.log(2);
55 }
56 }
57 return distance;
58 }
59
60 override double mpcDistance(List<Double> samples){
61 // map list to array
62 var map = pmfFromSamples(samples.stream().mapToDouble([it]).toArray(), formatter);
63 //if the size of array is smaller than 2, ks distance cannot be performed, simply return 1
64 if(map.size < 2) return 1;
65 return jsDivergence(map, mpcPMF);
66 }
67
68 override double naDistance(List<Double> samples){
69 // map list to array
70 var map = pmfFromSamples(samples.stream().mapToDouble([it]).toArray(), formatter);
71
72 //if the size of array is smaller than 2, ks distance cannot be performed, simply return 1
73 if(map.size < 2) return 1;
74 return jsDivergence(map, naPMF);
75 }
76
77 override double outDegreeDistance(List<Double> samples){
78 // map list to array
79 var map = pmfFromSamples(samples.stream().mapToDouble([it]).toArray(), formatter);
80 //if the size of array is smaller than 2, ks distance cannot be performed, simply return 1
81 if(map.size < 2) return 1;
82 return jsDivergence(map, outDegreePMF);
83 }
84
85 def nodeTypeDistance(HashMap<String, Double> samples){
86 return klDivergence(samples, nodeTypesPMF);
87 }
88} \ 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/distance/KSDistance.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/distance/KSDistance.xtend
new file mode 100644
index 00000000..c486a328
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/distance/KSDistance.xtend
@@ -0,0 +1,102 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MetricSampleGroup
4import java.util.HashMap
5import java.util.HashSet
6import java.util.List
7import org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest
8
9class KSDistance extends CostDistance {
10 var static ksTester = new KolmogorovSmirnovTest();
11 var MetricSampleGroup g;
12
13 new(MetricSampleGroup g){
14 this.g = g;
15 }
16 override double mpcDistance(List<Double> samples){
17 //if the size of array is smaller than 2, ks distance cannot be performed, simply return 1
18 if(samples.size < 2) return 1;
19 return ksTester.kolmogorovSmirnovStatistic(g.mpcSamples, samples);
20 }
21
22 override double naDistance(List<Double> samples){
23 //if the size of array is smaller than 2, ks distance cannot be performed, simply return 1
24 if(samples.size < 2) return 1;
25 return ksTester.kolmogorovSmirnovStatistic(g.naSamples as double[], samples);
26 }
27
28 override double outDegreeDistance(List<Double> samples){
29 //if the size of array is smaller than 2, ks distance cannot be performed, simply return 1
30 if(samples.size < 2) return 1;
31 return ksTester.kolmogorovSmirnovStatistic(g.outDegreeSamples, samples);
32 }
33
34 def double typedOutDegreeDistance(HashMap<String, List<Integer>> map){
35 var value = 0.0;
36 // map list to array
37 val keySet = new HashSet<String>(map.keySet);
38 keySet.addAll(g.typedOutDegreeSamples.keySet);
39 for(key : keySet){
40 if(!map.containsKey(key) ){
41 value += 1;
42 }else if(!g.typedOutDegreeSamples.containsKey(key)){
43 value += map.get(key).size * 100;
44 }else{
45 var double[] rep = g.typedOutDegreeSamples.get(key).stream().mapToDouble([it|it]).toArray();
46 var double[] ins = map.get(key).stream().mapToDouble([it|it]).toArray();
47 if((rep.size < 2 || ins.size < 2) ){
48 if(rep.size < 2 && rep.containsAll(ins)){
49 value += 0;
50 }else{
51 value += 1;
52 }
53 }else if(rep.size >= 2 && ins.size >= 2){
54 value += ksTester.kolmogorovSmirnovStatistic(rep, ins);
55 }
56 }
57 }
58
59
60 return value;
61 }
62
63 def nodeTypeDistance(HashMap<String, Double> samples){
64 var typesDistMap = g.nodeTypeSamples;
65 var sourceDist = newArrayList();
66 var instanceDist = newArrayList();
67
68 for(key : typesDistMap.keySet()){
69 sourceDist.add(typesDistMap.get(key));
70 instanceDist.add(samples.getOrDefault(key, 0.0));
71 }
72
73 return ks_distance_two_dist(sourceDist, instanceDist);
74 }
75
76 def edgeTypeDistance(HashMap<String, Double> samples){
77 var typesDistMap = g.edgeTypeSamples;
78 var sourceDist = newArrayList();
79 var instanceDist = newArrayList();
80
81 for(key : typesDistMap.keySet()){
82 sourceDist.add(typesDistMap.get(key));
83 instanceDist.add(samples.getOrDefault(key, 0.0));
84 }
85
86 return ks_distance_two_dist(sourceDist, instanceDist);
87 }
88
89 def double ks_distance_two_dist(List<Double> dist1, List<Double> dist2){
90 // Since we already know the pdf, we compute the ks-test manully
91 var ksStatistics = 0.0;
92 var sum1 = 0.0;
93 var sum2 = 0.0;
94 for(var i = 0; i < dist1.size(); i++){
95 sum1 += dist1.get(i);
96 sum2 += dist2.get(i);
97
98 ksStatistics = Math.max(ksStatistics, Math.abs(sum1 - sum2));
99 }
100 return ksStatistics;
101 }
102} \ 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/graph/EMFGraph.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/EMFGraph.xtend
new file mode 100644
index 00000000..8fa29fe6
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/EMFGraph.xtend
@@ -0,0 +1,124 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.Metric
4import java.util.ArrayList
5import java.util.HashSet
6import java.util.List
7import org.eclipse.emf.common.util.EList
8import org.eclipse.emf.ecore.EObject
9import org.eclipse.emf.ecore.EReference
10import org.eclipse.xtend.lib.annotations.Accessors
11
12class EMFGraph extends Graph{
13 @Accessors(PUBLIC_GETTER)
14 var EObject root;
15
16 def void init (EObject root, List<Metric> metrics, String name, List<EReference> referenceTypes){
17 val otherContents = root.eAllContents.toList();
18 this.root = root;
19 otherContents.add(root);
20 init(otherContents, metrics, name, referenceTypes);
21 }
22
23 /**
24 * init the graph with all nodes and reference types in the meta model
25 * @param objects: objects in the instance model (exclude root)
26 * @param metrics: metrics to be evaluated
27 * @param name: name of the instance model
28 * @param ReferenceTypes: reference types defined in the meta model
29 */
30 def void init(List<EObject> objects, List<Metric> metrics, String name, List<EReference> referenceTypes){
31 objects.forEach[it|
32 // TODO: Maybe want to consider all the super types as well
33 var types = new HashSet();
34 types.add(it.eClass.name);
35 statistic.addNodeWithAllTypes(it, types);
36 ]
37
38 referenceTypes.forEach[it|
39 // Only consider the edges that are not derived to preserve the statistical property
40 if(!it.derived){
41 statistic.addEdgeType(it.name);
42 }
43 ];
44
45 objects.forEach[source|
46 source.eClass.EAllReferences.forEach[r|
47 //many references
48 if(r.isMany){
49 source.getNeighbours(r).forEach[target|
50 addEdge(source, target, r);
51 ]
52 }else{
53 //single references
54 val target = source.eGet(r) as EObject;
55 addEdge(source, target, r);
56 }
57 ]
58 ]
59
60 this.metrics = metrics;
61 this.name = name;
62 }
63
64 def void removeReference(EReference r){
65 if (statistic.containsEdgeType(r.name)){
66 statistic.removeReference(r.name, r.containment);
67 }
68 }
69
70 /**
71 * Set basic information for the output
72 */
73 override setBasicInformation(ArrayList<ArrayList<String>> output){
74 val metaInfo = new ArrayList<String>();
75 metaInfo.add(META_MODEL_HEADER);
76 metaInfo.add(this.metaModel);
77
78 val edgeInfo = new ArrayList<String>();
79 edgeInfo.add(NUM_EDGE_TYPE_HEADER);
80 edgeInfo.add(this.statistic.allTypes.size()+"");
81
82 val nodeInfo = new ArrayList<String>();
83 nodeInfo.add(NUM_NODE_HEADER);
84 nodeInfo.add(this.statistic.allNodes.size()+"");
85
86 val stateInfo = new ArrayList<String>();
87 stateInfo.add(STATE_ID_HEADER);
88 stateInfo.add(this.name);
89
90
91 output.add(metaInfo);
92 output.add(edgeInfo);
93 output.add(nodeInfo);
94 output.add(stateInfo);
95 }
96
97 def EList<EObject> getNeighbours(EObject o, EReference r){
98 return (o.eGet(r, true) as EList<EObject>);
99 }
100
101 def addEdge(EObject source, EObject target, EReference r){
102 //Only add the edge if the reference is not derived to preserve the statistical property
103 if(target !== null && r !== null && !r.derived){
104 statistic.addEdge(source, target, r.name);
105 }
106 }
107
108 override GraphStatistic getStatistic(){
109 return this.statistic;
110 }
111
112 override String getName(){
113 return this.name;
114 }
115
116 def void setMetaModel(String model){
117 this.metaModel = model;
118 }
119
120 def String getMetaModel(){
121 return this.metaModel;
122 }
123
124} \ 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/graph/Graph.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/Graph.xtend
new file mode 100644
index 00000000..6b400b0d
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/Graph.xtend
@@ -0,0 +1,71 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.Metric
4import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MetricSampleGroup
5import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MultiplexParticipationCoefficientMetric
6import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.NodeActivityMetric
7import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.OutDegreeMetric
8import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.TypedOutDegree
9import java.util.ArrayList
10import java.util.HashMap
11import java.util.List
12import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.NodeTypeMetric
13import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.EdgeTypeMetric
14
15abstract class Graph {
16
17 protected static val String META_MODEL_HEADER = "Meta Mode"
18 protected static val String NUM_NODE_HEADER = "Number Of Nodes";
19 protected static val String NUM_EDGE_TYPE_HEADER = "Number of Edge types";
20 protected static val String STATE_ID_HEADER = "State Id";
21
22 protected val statistic = new GraphStatistic();
23 protected var List<Metric> metrics;
24 protected var String name = "";
25 protected var String metaModel = "";
26
27 /**
28 * evaluate all metrics for this model
29 * return the result as a two dimentional list
30 */
31 def ArrayList<ArrayList<String>> evaluateAllMetrics(){
32 val result = new ArrayList<ArrayList<String>>();
33 setBasicInformation(result);
34
35 for(metric : this.metrics){
36 val datas = metric.evaluate(this.statistic);
37 for(row : datas){
38 result.add(new ArrayList<String>(row));
39 }
40 }
41 return result;
42 }
43
44 def MetricSampleGroup evaluateAllMetricsToSamples(){
45 var sample = new MetricSampleGroup();
46
47 for(metric : this.metrics){
48 if(metric instanceof MultiplexParticipationCoefficientMetric){
49 sample.mpcSamples = metric.evaluateSamples(this.statistic) as ArrayList<Double>;
50 }else if(metric instanceof NodeActivityMetric){
51 sample.naSamples = metric.evaluateSamples(this.statistic) as ArrayList<Double>;
52 }else if(metric instanceof OutDegreeMetric){
53 sample.outDegreeSamples = metric.evaluateSamples(this.statistic) as ArrayList<Double>;
54 }else if(metric instanceof TypedOutDegree){
55 sample.typedOutDegreeSamples = metric.evaluateSamples(this.statistic) as HashMap<String, List<Integer>>;
56 }else if(metric instanceof NodeTypeMetric){
57 sample.nodeTypeSamples = metric.evaluateSamples(this.statistic) as HashMap<String, Double>;
58 }else if (metric instanceof EdgeTypeMetric){
59 sample.edgeTypeSamples = metric.evaluateSamples(this.statistic) as HashMap<String, Double>;
60 }
61 }
62
63 return sample;
64 }
65
66 def void setBasicInformation(ArrayList<ArrayList<String>> result);
67
68 def GraphStatistic getStatistic();
69
70 def String getName();
71} \ 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/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
new file mode 100644
index 00000000..31788bb2
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/GraphStatistic.xtend
@@ -0,0 +1,194 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph
2
3import com.google.common.collect.ArrayListMultimap
4import com.google.common.collect.Multimap
5import java.util.HashMap
6import java.util.HashSet
7import java.util.List
8import java.util.Map
9import java.util.Set
10import org.eclipse.emf.ecore.EObject
11import org.eclipse.emf.ecore.EReference
12
13class GraphStatistic {
14 val incomingEdges = new HashMap<String, Multimap<EObject, EObject>>;
15 val outgoingEdges = new HashMap<String, Multimap<EObject, EObject>>;
16
17 val edgeTypes = new HashSet<String>();
18 val nodeToType = new HashMap<EObject, Set<String>>();
19
20 /**
21 * Add an edge type to to the graph
22 * @param type: type to add
23 */
24 def void addEdgeType(String type){
25 if(edgeTypes.contains(type)){
26 return;
27 }
28
29 edgeTypes.add(type);
30 incomingEdges.put(type, ArrayListMultimap.create());
31 outgoingEdges.put(type, ArrayListMultimap.create());
32 }
33
34 /**
35 * Add a node to the graph with one type in its type hierarchy
36 * @param node: node to add
37 */
38 def void addNodeWithType(EObject n, String Type){
39 var types = nodeToType.getOrDefault(n, new HashSet<String>());
40 types.add(Type);
41 nodeToType.put(n, types);
42 }
43
44 def boolean containsNode(EObject o){
45 return nodeToType.containsKey(o);
46 }
47
48 def Set<String> getTypesForNode(EObject o){
49 return nodeToType.getOrDefault(o, new HashSet<String>());
50 }
51
52 def void overwriteCurrentType(EObject o, String type){
53 var typeSet = nodeToType.getOrDefault(o, new HashSet<String>());
54
55 // clear current types
56 typeSet.clear();
57 typeSet.add(type);
58 nodeToType.put(o, typeSet);
59 }
60
61 /**
62 * Add a node to the graph with all types in its type hierarchy
63 */
64 def void addNodeWithAllTypes(EObject n, Set<String> types){
65 nodeToType.put(n, types);
66 }
67
68 /**
69 * Add an edge to the graph
70 * @param source: source node
71 * @param target: target node
72 * @param type: type of the reference
73 */
74 def void addEdge(EObject source, EObject target, String type){
75 outgoingEdges.get(type).put(source, target);
76 incomingEdges.get(type).put(target, source);
77 }
78
79 /**
80 * check if this graph contains a specific edge type
81 */
82 def boolean containsEdgeType(String typeName){
83 if(outgoingEdges.containsKey(typeName) && incomingEdges.containsKey(typeName)){
84 return true;
85 }
86 return false;
87 }
88
89 /**
90 * remove references from the statistics, potentially remove the nodes associated with it
91 * @Param name: name of the reference
92 * @Param isContainment: if true then the corresponding nodes on the incoming side will also be removed
93 */
94 def removeReference(String name, boolean isContainment){
95 if(!edgeTypes.contains(name)){
96 return;
97 }
98
99 edgeTypes.remove(name);
100 var incomingSet = incomingEdges.remove(name);
101 outgoingEdges.remove(name);
102
103 // if the reference is not a containment, then removing the reference is enough
104 if(!isContainment){
105 return;
106 }
107
108 // else remove all corresponding nodes
109 val nodesToRemove = incomingSet.keySet();
110
111 //remove nodes from node sets
112 nodesToRemove.forEach[nodeToType.remove(it)];
113
114 val removeForMultimap = [Multimap<EObject, EObject> refMap|
115 nodesToRemove.forEach[refMap.removeAll(it)];
116 var values = refMap.values()
117 //remove the values from the list is equavalent to remove it in the multimap
118 values.removeAll(nodesToRemove);
119 return;
120 ];
121
122 //remove nodes from all other references on incomingEdges
123 incomingEdges.values.forEach(removeForMultimap);
124 outgoingEdges.values.forEach(removeForMultimap);
125 }
126
127 /**
128 * calculate the out degree for an object
129 */
130 def int outDegree(EObject o){
131 var count = 0;
132
133 for (String type : edgeTypes){
134 count += outgoingEdges.get(type).get(o).size();
135 }
136 return count;
137 }
138
139 /**
140 * calculate the in degree of an object
141 */
142 def int inDegree(EObject o){
143 var count = 0;
144
145 for (String type : edgeTypes){
146 count += incomingEdges.get(type).get(o).size();
147 }
148 return count;
149 }
150
151 /**
152 * calculate the dimentional degree of a node
153 */
154 def int dimentionalDegree(EObject o, String type){
155 return incomingEdges.get(type).get(o).size() + outgoingEdges.get(type).get(o).size();
156 }
157
158 /**
159 * calculate the number of edge types for a given node.
160 */
161 def int numOfEdgeTypes(EObject o){
162 var count = 0;
163
164 for(String type : edgeTypes){
165 if(dimentionalDegree(o, type) > 0){
166 count++;
167 }
168 }
169
170 return count;
171 }
172
173 def List<String> getAllTypes(){
174 return edgeTypes.toList();
175 }
176
177 def Map<EObject, Set<String>> getNodeToTypesMap(){
178 return nodeToType;
179 }
180
181 def List<EObject> getAllNodes(){
182 return nodeToType.keySet().toList();
183 }
184
185 def HashMap<String, Multimap<EObject, EObject>> getOutgoingEdges(){
186 return outgoingEdges;
187 }
188
189 def HashMap<String, Multimap<EObject, EObject>> incomingEdges(){
190 return incomingEdges;
191 }
192
193}
194
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/PartialInterpretationGraph.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/PartialInterpretationGraph.xtend
new file mode 100644
index 00000000..a2934eb9
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/graph/PartialInterpretationGraph.xtend
@@ -0,0 +1,134 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.Metric
4import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.RelationDeclaration
5import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.Type
6import hu.bme.mit.inf.dslreasoner.logic.model.logiclanguage.TypeDefinition
7import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.BinaryElementRelationLink
8import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.PartialInterpretation
9import hu.bme.mit.inf.dslreasoner.viatrasolver.partialinterpretationlanguage.partialinterpretation.impl.PartialComplexTypeInterpretationImpl
10import java.util.ArrayList
11import java.util.List
12
13class PartialInterpretationGraph extends Graph{
14 val typeToExclude = "undefinedpart";
15 val classSuffix = " class";
16
17 /**
18 * Define a new PartialInterpretationGraph by parse every element from a PartialInterpretation
19 */
20 new(PartialInterpretation partial, List<Metric> metrics, String name){
21 //the edge types are defined in terms of RelationDeclaration
22 partial.problem.relations.filter(RelationDeclaration).forEach[
23 //only need the name of the reference type (remove everything with and after "reference")
24 var n = it.name.split(" ").get(0);
25 this.statistic.addEdgeType(n);
26 ]
27 // add all elements
28 val typeInterpretations = getTypes(partial);
29 for(type : typeInterpretations){
30 //Only consider the most concrete class
31 if(isConcreteType(type.interpretationOf)){
32 var typeName = type.interpretationOf.name.replace(classSuffix, '');
33 for(node : type.elements){
34 if(!this.statistic.containsNode(node)){
35 this.statistic.addNodeWithType(node, typeName);
36 }else{
37 // if the current type of the node is a super type of the type to check,
38 // substitute the current type with the new type
39 var currentType = statistic.getTypesForNode(node).get(0);
40 if(isSuperType(currentType, type.interpretationOf)){
41 statistic.overwriteCurrentType(node, typeName);
42 }
43 }
44 }
45 }
46 }
47
48 for(relationInterpretation : partial.partialrelationinterpretation) {
49 //only need the name of the reference type (remove everything with and after "reference")
50 val type = relationInterpretation.interpretationOf.name.split(" ").get(0);
51 for(edge : relationInterpretation.relationlinks.filter(BinaryElementRelationLink)){
52 statistic.addEdge(edge.param1, edge.param2, type);
53 }
54 }
55
56 this.name = name;
57 this.metrics = metrics;
58 }
59
60 /**
61 * recursively check if a type is the super type of another
62 */
63 def boolean isSuperType(String typeName, Type subtypeToCheck){
64 var superTypes = subtypeToCheck.supertypes;
65 if(superTypes.size == 0){
66 return false;
67 }else if(subtypeToCheck.supertypes.map[it.name.replace(classSuffix, '')].contains(typeName)){
68 return true;
69 }else{
70 for(superType : superTypes){
71 if(isSuperType(typeName, superType)){
72 return true;
73 }
74 }
75 return false;
76 }
77 }
78
79 /**
80 * Check if a Type object is the class that we want to consider
81 * A type object is to be considered if it satisfy one of the following:
82 * 1. if it is not abstract
83 * 2. if it is abstract but has a subclass of type TypeDefinition (This means the generation is
84 * started with nodes in this type)
85 */
86 def boolean isConcreteType(Type t){
87 if(!t.isAbstract || t.subtypes.findFirst[it instanceof TypeDefinition] !== null){
88 return true;
89 }
90 return false;
91 }
92
93 /**
94 * Set basic information for the output
95 */
96 override setBasicInformation(ArrayList<ArrayList<String>> output){
97 val metaInfo = new ArrayList<String>();
98 metaInfo.add(META_MODEL_HEADER);
99 metaInfo.add(this.metaModel);
100
101 val edgeInfo = new ArrayList<String>();
102 edgeInfo.add(NUM_EDGE_TYPE_HEADER);
103 edgeInfo.add(this.statistic.allTypes.size()+"");
104
105 val nodeInfo = new ArrayList<String>();
106 nodeInfo.add(NUM_NODE_HEADER);
107 nodeInfo.add(this.statistic.allNodes.size()+"");
108
109 val stateInfo = new ArrayList<String>();
110 stateInfo.add(STATE_ID_HEADER);
111 stateInfo.add(this.name);
112
113 output.add(metaInfo);
114 output.add(edgeInfo);
115 output.add(nodeInfo);
116 output.add(stateInfo);
117 }
118
119 private def getTypes(PartialInterpretation partial){
120 //only the complex type interpretations are the ones defined in meta model
121 //do not care about undefined types as it will be included in the class type
122 return partial.partialtypeinterpratation.filter(PartialComplexTypeInterpretationImpl)
123 .filter[!it.interpretationOf.name.toLowerCase.contains(typeToExclude)];
124 }
125
126 override getStatistic() {
127 throw new UnsupportedOperationException("TODO: auto-generated method stub")
128 }
129
130 override getName() {
131 return name;
132 }
133
134} \ 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/io/CsvFileWriter.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/CsvFileWriter.xtend
new file mode 100644
index 00000000..00b38d90
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/CsvFileWriter.xtend
@@ -0,0 +1,52 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io;
2
3import java.io.File
4import java.io.FileNotFoundException
5import java.io.FileOutputStream
6import java.io.PrintWriter
7import java.util.ArrayList
8import java.util.List
9
10class CsvFileWriter {
11
12 def static void write(ArrayList<ArrayList<String>> datas, String uri) {
13 if(datas.size() <= 0) {
14 return;
15 }
16 val PrintWriter writer = new PrintWriter(new File(uri));
17 output(writer, datas, uri);
18 }
19
20 def static void append(ArrayList<ArrayList<String>> datas, String uri) {
21 if(datas.size() <= 0) {
22 return;
23 }
24 val PrintWriter writer = new PrintWriter(new FileOutputStream(new File(uri), true));
25 output(writer, datas, uri);
26 }
27
28
29 def private static void output(PrintWriter writer, ArrayList<ArrayList<String>> datas, String uri) {
30 //println("Output csv for " + uri);
31 try {
32
33 val output = new StringBuilder;
34 for(List<String> datarow : datas){
35 for(var i = 0; i < datarow.size() - 1; i++){
36 output.append(datarow.get(i) + ',');
37 }
38
39 if(datarow.size >= 1){
40 output.append(datarow.get(datarow.size() - 1));
41 output.append('\n');
42 }
43 }
44
45 writer.write(output.toString());
46 writer.close();
47 //println("Output csv finished");
48 }catch(FileNotFoundException e) {
49 e.printStackTrace();
50 }
51 }
52}
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
new file mode 100644
index 00000000..053e0da3
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/GraphReader.xtend
@@ -0,0 +1,112 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io;
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.EMFGraph
4import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.EdgeTypeMetric
5import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.Metric
6import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MultiplexParticipationCoefficientMetric
7import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.NodeActivityMetric
8import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.NodeTypeMetric
9import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.OutDegreeMetric
10import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.TypedOutDegree
11import java.io.File
12import java.io.FileNotFoundException
13import java.util.ArrayList
14import java.util.List
15import org.eclipse.emf.common.util.URI
16import org.eclipse.emf.ecore.EObject
17import org.eclipse.emf.ecore.EPackage
18import org.eclipse.emf.ecore.EReference
19import org.eclipse.emf.ecore.resource.Resource
20import org.eclipse.emf.ecore.resource.ResourceSet
21import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
22import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
23import org.eclipse.emf.ecore.EGenericType
24import org.eclipse.emf.ecore.EStructuralFeature
25import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.TypedClusteringCoefficientMetric
26
27class GraphReader{
28 val ResourceSet resSet = new ResourceSetImpl();
29 val referenceTypes = new ArrayList<EReference>();
30 var String suffix;
31
32 new(EPackage metaModel, String suffix) {
33 Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put("*",new XMIResourceFactoryImpl)
34 this.suffix = suffix;
35
36 //find all reference types in the meta model
37 metaModel.eAllContents.forEach[
38 if(it instanceof EReference){
39 referenceTypes.add(it);
40 }
41 ]
42 }
43
44 def List<EMFGraph> readModels(String path){
45 val dir = new File(path);
46 if(!dir.isDirectory){
47 throw new Exception("expecting a directory");
48 }
49
50 val graphs = new ArrayList<EMFGraph>();
51
52 val metrics = new ArrayList<Metric>();
53 metrics.add(new OutDegreeMetric());
54 metrics.add(new NodeActivityMetric());
55 metrics.add(new MultiplexParticipationCoefficientMetric());
56 metrics.add(new TypedOutDegree());
57 metrics.add(new NodeTypeMetric());
58 metrics.add(new EdgeTypeMetric());
59 var count = 1
60 //check all files in the directory with suffix
61 for(String name : dir.list.filter[it| it.endsWith(suffix)]){
62 val file = new File(name);
63 val roots = readModel(EObject, path, file.name);
64 //add a list of metrics
65 val g = new EMFGraph();
66 for(root : roots){
67 g.init(root, metrics, name.replaceFirst(suffix, ""), referenceTypes);
68 }
69
70 count ++;
71 graphs.add(g);
72 }
73
74 return graphs;
75 }
76
77 def EMFGraph readModel(String path, String filename){
78 val metrics = new ArrayList<Metric>();
79 metrics.add(new OutDegreeMetric());
80 metrics.add(new NodeActivityMetric());
81 metrics.add(new MultiplexParticipationCoefficientMetric());
82 metrics.add(new TypedOutDegree());
83 metrics.add(new NodeTypeMetric());
84 metrics.add(new EdgeTypeMetric());
85
86 val file = new File(filename);
87 val roots = readModel(EObject, path, file.name);
88 //add a list of metrics
89 val g = new EMFGraph();
90 for(root : roots){
91 g.init(root, metrics, filename.replaceFirst(suffix, ""), referenceTypes);
92 }
93 return g
94 }
95
96 def <RootType extends EObject> List<RootType> readModel(Class<RootType> type, String path, String name) {
97 try {
98 val resource = resSet.getResource(getURI(path, name),true);
99 if(resource === null) throw new FileNotFoundException(getURI(path, name).toString)
100 else {
101 return resource.contents as List<RootType>
102 }
103 } catch(Exception e) {
104 e.printStackTrace();
105 throw new Exception(getURI(path, name).toString());
106 }
107 }
108
109 def static getURI(String path, String name) {
110 URI.createFileURI(path + "/" + name)
111 }
112} \ 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/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
new file mode 100644
index 00000000..2e7be586
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/io/RepMetricsReader.xtend
@@ -0,0 +1,100 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app.Domain
4import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MetricSampleGroup
5import github.impl.GithubPackageImpl
6import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl.YakindummPackageImpl
7import java.util.HashMap
8import org.eclipse.emf.ecore.EReference
9import org.eclipse.emf.ecore.impl.EcorePackageImpl
10
11/**
12 * Read the sample of the distribution of a metric provided the csv file of the metric
13 */
14class RepMetricsReader {
15 static var Domain domain;
16 static def read(Domain d){
17 var GraphReader reader;
18 if(d == Domain.Yakindumm){
19 reader = new GraphReader(YakindummPackageImpl.eINSTANCE, '.xmi');
20 }else if (d == Domain.Ecore){
21 reader = new GraphReader(EcorePackageImpl.eINSTANCE, '.ecore');
22 }else if (d == Domain.Github){
23 reader = new GraphReader(GithubPackageImpl.eINSTANCE, '.githubmodel')
24 }
25
26 domain = d;
27
28 var domainRepPath = DataName.REP_PATH + d.name + '/';
29 var rep = new MetricSampleGroup()
30 var out_d = readMetrics(reader, domainRepPath + DataName.OUT_D_REP);
31 var mpc = readMetrics(reader, domainRepPath + DataName.MPC_REP);
32 rep.mpcSamples = mpc.mpcSamples;
33 rep.outDegreeSamples = out_d.outDegreeSamples;
34 rep.naSamples = readMetrics(reader, domainRepPath + DataName.NA_REP).naSamples;
35 rep.typedOutDegreeSamples = out_d.typedOutDegreeSamples;
36 rep.edgeTypeSamples = mpc.edgeTypeSamples;
37
38 //TODO: Parameterize the prior node distribution
39 var nodeTypeSamples = new HashMap<String, Double>();
40 if(d == Domain.Yakindumm){
41 nodeTypeSamples.put('Entry', 0.04257802080554814);
42 nodeTypeSamples.put('Choice', 0.1267671379034409);
43 nodeTypeSamples.put('State', 0.1596092291277674);
44 nodeTypeSamples.put('Transition', 0.6138636969858629);
45 nodeTypeSamples.put('Statechart', 0.010136036276340358);
46 nodeTypeSamples.put('Region', 0.04467858095492131);
47 nodeTypeSamples.put('Exit', 0.0018338223526273673);
48 nodeTypeSamples.put('FinalState', 0.0005334755934915977);
49 }else if(d ==Domain.Ecore){
50 nodeTypeSamples.put('EAttribute', 0.23539778449144008);
51 nodeTypeSamples.put('EClass', 0.33081570996978854);
52 nodeTypeSamples.put('EReference', 0.30996978851963747);
53 nodeTypeSamples.put('EPackage', 0.012789526686807653);
54 nodeTypeSamples.put('EAnnotation', 0.002517623363544813);
55 nodeTypeSamples.put('EEnumLiteral', 0.07275931520644502);
56 nodeTypeSamples.put('EEnum', 0.013645518630412891);
57 nodeTypeSamples.put('EDataType', 0.004028197381671702);
58 nodeTypeSamples.put('EParameter', 0.005941591137965764);
59 nodeTypeSamples.put('EGenericType', 0.002014098690835851);
60 nodeTypeSamples.put('EOperation', 0.009415911379657605);
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);
69 }
70
71
72
73 rep.nodeTypeSamples = nodeTypeSamples;
74 return rep;
75 }
76
77 /**
78 * Read representative model
79 */
80 private static def readMetrics(GraphReader r, String path){
81 val model = r.readModels(path).head;
82 if(domain == Domain.Ecore){
83 var refsToRemove = EcorePackageImpl.eINSTANCE.eAllContents.filter(EReference).filter[
84 it.name.equals('eGenericType') || it.name.equals('eGenericSuperTypes') || it.name.equals('eFactoryInstance') ||
85 it.name.equals('eGenericExceptions') || it.name.equals('references') || it.name.equals('contents');
86 ];
87 refsToRemove.forEach[model.removeReference(it)];
88 }
89 return model.evaluateAllMetricsToSamples();
90 }
91
92}
93
94class DataName{
95 public static val REP_PATH = 'data/';
96 public static val MPC_REP = 'mpc_rep';
97 public static val NA_REP = 'na_rep';
98 public static val OUT_D_REP = 'out_d_rep';
99}
100
diff --git a/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/EdgeTypeMetric.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/EdgeTypeMetric.xtend
new file mode 100644
index 00000000..0c0fe3b8
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/EdgeTypeMetric.xtend
@@ -0,0 +1,41 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.GraphStatistic
4import java.util.ArrayList
5import java.util.HashMap
6
7class EdgeTypeMetric extends Metric {
8
9 override evaluate(GraphStatistic g) {
10 var map = evaluateSamples(g) as HashMap<String, Double>;
11 var output = new ArrayList<String[]>();
12 output.add(newArrayList('Edge Type'));
13
14 var keys = map.keySet;
15 var values = newArrayList();
16 for(key : keys){
17 values.add(map.get(key)+'');
18 }
19
20 output.add(keys);
21 output.add(values);
22
23 return output;
24 }
25
26 override evaluateSamples(GraphStatistic g) {
27 val map = new HashMap<String, Double>();
28 var outgoingEdges = g.outgoingEdges;
29
30 //get the total number of edges
31 val edgeCount = outgoingEdges.values.fold(0, [r, t| r + t.asMap.values.fold(0, [r1, t1| r1 + t1.size])]) as double;
32 outgoingEdges.forEach[k, v|
33 var value = v.asMap.values.fold(0, [r, t| r + t.size]) / edgeCount;
34 map.put(k, value);
35 ]
36
37
38 return map;
39 }
40
41} \ 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/metrics/Metric.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/Metric.xtend
new file mode 100644
index 00000000..cb242a5b
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/Metric.xtend
@@ -0,0 +1,8 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.GraphStatistic
4
5abstract class Metric {
6 abstract def String[][] evaluate(GraphStatistic g);
7 abstract def Object evaluateSamples(GraphStatistic g);
8} \ 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/metrics/MetricSampleGroup.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/MetricSampleGroup.xtend
new file mode 100644
index 00000000..4e25bb86
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/MetricSampleGroup.xtend
@@ -0,0 +1,13 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics
2
3import java.util.HashMap
4import java.util.List
5
6class MetricSampleGroup{
7 public var List<Double> mpcSamples;
8 public var List<Double> naSamples;
9 public var List<Double> outDegreeSamples;
10 public var HashMap<String, List<Integer>> typedOutDegreeSamples;
11 public var HashMap<String, Double> nodeTypeSamples;
12 public var HashMap<String, Double> edgeTypeSamples;
13} \ 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/metrics/MultiplexParticipationCoefficientMetric.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/MultiplexParticipationCoefficientMetric.xtend
new file mode 100644
index 00000000..eafa49b2
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/MultiplexParticipationCoefficientMetric.xtend
@@ -0,0 +1,80 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.GraphStatistic
4import java.text.DecimalFormat
5import java.util.ArrayList
6import java.util.HashMap
7import org.eclipse.emf.ecore.EObject
8
9class MultiplexParticipationCoefficientMetric extends Metric {
10 public static val countName = "MPCCount";
11 public static val valueName = "MPCValue";
12 val formatter = new DecimalFormat("#0.00000");
13
14 override evaluate(GraphStatistic g) {
15 //because the precision issue of double, we translate double values into String to be the key
16
17
18 //get number of different types
19 val typeCounts = g.allTypes.size;
20 val map = new HashMap<String, Integer>();
21 //calculate the metric distribution
22 g.allNodes.forEach[n|
23 var coef = calculateMPC(n, g, typeCounts);
24
25 //format number to String
26 val value = formatter.format(coef);
27 if(!map.containsKey(value)){
28 map.put(value, 1);
29 }else{
30 map.put(value, map.get(value) + 1);
31 }
32
33 ]
34
35 //convert it into a 2 dimentional array
36 val String[][] datas = newArrayOfSize(2, map.size+1);
37 datas.get(0).set(0, valueName);
38 datas.get(1).set(0, countName)
39 var count = 1;
40 for(entry : map.entrySet.sortBy[it.key]){
41 datas.get(0).set(count, entry.key+"");
42 datas.get(1).set(count, entry.value+"");
43 count++;
44 }
45
46 return datas;
47 }
48
49 override evaluateSamples(GraphStatistic g){
50 val samples = new ArrayList<Double>();
51 val typeCounts = g.allTypes.size;
52 //calculate the metric distribution
53 g.allNodes.forEach[
54 samples.add(calculateMPC(it, g, typeCounts));
55 ]
56
57 return samples;
58 }
59
60 def double calculateMPC(EObject n, GraphStatistic g, int typeCounts){
61 val edgeCounts = g.outDegree(n) + g.inDegree(n);
62
63 var coef = 0.0;
64
65 for(type : g.allTypes){
66 val degree = g.dimentionalDegree(n, type) as double;
67 coef += Math.pow(degree / edgeCounts, 2);
68 }
69 coef = 1 - coef;
70 coef = coef * typeCounts / (typeCounts-1);
71
72 //Consider the case that either typeCounts-1 or the edgeCounts could be 0 in some situation
73 //in this case the metric should be evaluated to 0
74 if(Double.isNaN(coef)){
75 coef = 0;
76 }
77
78 return Double.parseDouble(formatter.format(coef));
79 }
80} \ 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/metrics/NodeActivityMetric.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/NodeActivityMetric.xtend
new file mode 100644
index 00000000..fbf06c47
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/NodeActivityMetric.xtend
@@ -0,0 +1,49 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.GraphStatistic
4import java.util.ArrayList
5import java.util.HashMap
6
7class NodeActivityMetric extends Metric {
8 public static val countName = "NACount";
9 public static val valueName = "NAValue";
10
11 override evaluate(GraphStatistic g) {
12 val map = new HashMap<Integer, Integer>();
13
14 //calculate the metric distribution
15 g.allNodes.forEach[
16 val value = g.numOfEdgeTypes(it);
17 if(!map.containsKey(value)){
18 map.put(value, 1);
19 }else{
20 map.put(value, map.get(value) + 1);
21 }
22 ]
23
24 //convert it into a 2 dimentional array
25 val String[][] datas = newArrayOfSize(2, map.size+1);
26 datas.get(0).set(0, valueName);
27 datas.get(1).set(0, countName)
28
29 var count = 1;
30 for(entry : map.entrySet.sortBy[it.key]){
31 datas.get(0).set(count, entry.key+"");
32 datas.get(1).set(count, entry.value+"");
33 count++;
34 }
35
36 return datas;
37 }
38
39 override evaluateSamples(GraphStatistic g){
40 val samples = new ArrayList<Double>();
41
42 //calculate the metric distribution
43 g.allNodes.forEach[
44 samples.add(g.numOfEdgeTypes(it) as double);
45 ]
46
47 return samples;
48 }
49} \ 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/metrics/NodeTypeMetric.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/NodeTypeMetric.xtend
new file mode 100644
index 00000000..7cec2513
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/NodeTypeMetric.xtend
@@ -0,0 +1,42 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.GraphStatistic
4import java.util.ArrayList
5import java.util.HashMap
6
7class NodeTypeMetric extends Metric {
8
9
10 override evaluate(GraphStatistic g) {
11 var map = evaluateSamples(g) as HashMap<String, Double>;
12 var output = new ArrayList<String[]>();
13 output.add(newArrayList('Node Type'));
14 var keys = map.keySet;
15 var values = newArrayList();
16
17 for(key : keys){
18 values.add(map.get(key)+'');
19 }
20
21 output.add(keys);
22 output.add(values);
23
24 return output;
25 }
26
27 override evaluateSamples(GraphStatistic g) {
28 var map = new HashMap<String, Double>();
29 var nodes = g.allNodes;
30 var single = 1.0 / nodes.size();
31 var nodeToType = g.nodeToTypesMap;
32 for(node : nodes){
33 for(cl : nodeToType.get(node)){
34 var value = map.getOrDefault(cl, 0.0);
35 map.put(cl, value + single);
36 }
37 }
38
39 return map;
40 }
41
42} \ 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/metrics/OutDegreeMetric.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/OutDegreeMetric.xtend
new file mode 100644
index 00000000..55046b14
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/OutDegreeMetric.xtend
@@ -0,0 +1,49 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.GraphStatistic
4import java.util.ArrayList
5import java.util.HashMap
6
7class OutDegreeMetric extends Metric {
8 public static val countName = "OutDegreeCount";
9 public static val valueName = "OutDegreeValue";
10
11 override evaluate(GraphStatistic g) {
12 val map = new HashMap<Integer, Integer>();
13
14 //calculate the metric distribution
15 g.allNodes.forEach[
16 val value = g.outDegree(it);
17 if(!map.containsKey(value)){
18 map.put(value, 1);
19 }else{
20 map.put(value, map.get(value) + 1);
21 }
22 ]
23
24 //convert it into a 2 dimentional array
25 val String[][] datas = newArrayOfSize(2, map.size+1);
26 datas.get(0).set(0, valueName);
27 datas.get(1).set(0, countName)
28 var count = 1;
29 for(entry : map.entrySet.sortBy[it.key]){
30 datas.get(0).set(count, entry.key+"");
31 datas.get(1).set(count, entry.value+"");
32 count++;
33 }
34
35 return datas;
36 }
37
38 override evaluateSamples(GraphStatistic g){
39 val samples = new ArrayList<Double>();
40
41 //calculate the metric distribution
42 g.allNodes.forEach[
43 samples.add(g.outDegree(it) as double);
44 ]
45
46 return samples;
47 }
48
49} \ 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/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
new file mode 100644
index 00000000..0b6d61c6
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedClusteringCoefficientMetric.xtend
@@ -0,0 +1,99 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.GraphStatistic
4import java.text.DecimalFormat
5import java.util.ArrayList
6import java.util.HashMap
7import java.util.HashSet
8import org.eclipse.emf.ecore.EObject
9
10class TypedClusteringCoefficientMetric extends Metric {
11 public static val countName = "TCCCount";
12 public static val valueName = "TCCValue";
13 val formatter = new DecimalFormat("#0.00000");
14
15 override evaluate(GraphStatistic g) {
16 //because the precision issue of double, we translate double values into String to be the key
17
18 val map = new HashMap<String, Integer>();
19 //calculate the metric distribution
20 g.allNodes.forEach[n|
21 var coef = calculateTCC1(n, g);
22 if(coef > 0){
23 println(n);
24 }
25 //format number to String
26 val value = formatter.format(coef);
27 if(!map.containsKey(value)){
28 map.put(value, 1);
29 }else{
30 map.put(value, map.get(value) + 1);
31 }
32
33 ]
34
35 //convert it into a 2 dimentional array
36 val String[][] datas = newArrayOfSize(2, map.size+1);
37 datas.get(0).set(0, valueName);
38 datas.get(1).set(0, countName)
39 var count = 1;
40 for(entry : map.entrySet.sortBy[it.key]){
41 datas.get(0).set(count, entry.key+"");
42 datas.get(1).set(count, entry.value+"");
43 count++;
44 }
45
46 return datas;
47 }
48
49 override evaluateSamples(GraphStatistic g){
50 val samples = new ArrayList<Double>();
51 //calculate the metric distribution
52 g.allNodes.forEach[
53 samples.add(calculateTCC1(it, g));
54 ]
55
56 return samples;
57 }
58
59 /**
60 * Compute TCC1 metric for node n
61 */
62 def double calculateTCC1(EObject n, GraphStatistic g){
63 var wedges = 0;
64 var triangles = 0;
65
66 for(type1 : g.allTypes){
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
73
74 // number of wedges
75 val d = typed1RelatedOfN.size
76 wedges += d * (d-1) // we will also count each closed triangle twice
77
78 // pairs of neighbors
79 for (n1: typed1RelatedOfN) {
80 for (n2: typed1RelatedOfN) {
81 for(type2 : g.allTypes){
82 if ((type1 != type2) &&
83 (g.outgoingEdges.get(type2).containsEntry(n1, n2) ||
84 g.outgoingEdges.get(type2).containsEntry(n2, n1)
85 )) {
86 triangles++
87 }
88 }
89 }
90 }
91 }
92
93 if (wedges == 0.0) {
94 return 0.0
95 } else {
96 return (triangles as double)/wedges
97 }
98 }
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/metrics/TypedOutDegree.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedOutDegree.xtend
new file mode 100644
index 00000000..3b5dbcc5
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/metrics/TypedOutDegree.xtend
@@ -0,0 +1,60 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.GraphStatistic
4import java.util.ArrayList
5import java.util.HashMap
6import java.util.List
7
8class TypedOutDegree extends Metric{
9
10 def private calculateMetric(GraphStatistic g){
11 var outgoingEdges = g.outgoingEdges;
12 //record metric as a list of samples for each node type / edge type pair
13 var metric = new HashMap<String, List<Integer>>();
14 var nodeToTypes = g.nodeToTypesMap;
15
16 for(edgeType : outgoingEdges.keySet){
17 for(node : outgoingEdges.get(edgeType).keySet){
18 //find all classes the node belongs to
19 var classes = nodeToTypes.get(node);
20 for(cl : classes){
21 // get or create entry for node type / edge type pair
22 var key = cl + ' ' + edgeType;
23 var typeCount = metric.get(key);
24 if(typeCount === null){
25 typeCount = new ArrayList<Integer>();
26 metric.put(key, typeCount);
27 }
28
29 // get or create sample list
30 typeCount.add(outgoingEdges.get(edgeType).get(node).size);
31 }
32 }
33 }
34
35 return metric;
36 }
37
38 override evaluate(GraphStatistic g) {
39 var metric = calculateMetric(g);
40 var output = new ArrayList<String[]>();
41
42 output.add(newArrayList('Typed Out Degree'));
43 for(key : metric.keySet){
44 var samples = metric.get(key);
45 var String[] outputForOnePair = newArrayOfSize(samples.size+1);
46 outputForOnePair.set(0, key);
47 for(var i = 0; i < samples.size; i++){
48 outputForOnePair.set(i+1, samples.get(i)+'');
49 }
50 output.add(outputForOnePair);
51 }
52
53 return output;
54 }
55
56 override evaluateSamples(GraphStatistic g) {
57 return calculateMetric(g);
58 }
59
60} \ 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/predictor/LinearModel.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/predictor/LinearModel.xtend
new file mode 100644
index 00000000..f0ded347
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/predictor/LinearModel.xtend
@@ -0,0 +1,91 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.predictor
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance.StateData
4import java.util.ArrayList
5import java.util.HashMap
6import java.util.List
7import java.util.Map
8import weka.core.matrix.LinearRegression
9import weka.core.matrix.Matrix
10
11class LinearModel {
12 var double ridge;
13 var Map<Object, StateData> stateAndHistory;
14 List<StateData> samples;
15
16 new(double ridge){
17 this.ridge = ridge;
18 stateAndHistory = new HashMap<Object, StateData>();
19 samples = new ArrayList<StateData>();
20 }
21
22 /**
23 * reset the current train data for regression to a new trajectory
24 * @param state: the last state of the trajectory
25 */
26 def resetRegression(Object state){
27 samples.clear();
28
29 if(stateAndHistory.containsKey(state)){
30 var data = stateAndHistory.get(state);
31 var curState = state;
32
33 samples.add(data);
34
35 //loop through data until the oldest state in the record
36 while(stateAndHistory.containsKey(data.lastState) && data.lastState != curState){
37 curState = data.lastState;
38 data = stateAndHistory.get(data.lastState);
39 samples.add(data);
40 }
41 }
42 }
43
44 /**
45 * Add a new data point to the current training set
46 * @param state: the state on which the new data point is calculated
47 * @param features: the set of feature value(x)
48 * @param value: the value of the state (y)
49 * @param lastState: the state which transformed to current state, used to record the trajectory
50 */
51 def feedData(Object state, double[] features, double value, Object lastState){
52 var data = new StateData(features, value, lastState);
53 stateAndHistory.put(state, data);
54 samples.add(data);
55 }
56
57 /**
58 * get prediction for next state, without storing the data point into the training set
59 * @param features: the feature values of current state
60 * @param value: the value of the current state
61 * @param: featuresToPredict: the features of the state wanted to be predected
62 * @return the value of the state to be predicted
63 */
64 def double getPredictionForNextDataSample(double[] features, double value, double[] featuresToPredict){
65 var data = new StateData(features, value, null);
66 samples.add(data);
67
68 // create training set from current data
69 val double[][] xSamples = samples.map[it.features];
70 val double[] ySamples = samples.map[it.value];
71
72 val x = new Matrix(xSamples);
73 val y = new Matrix(ySamples, ySamples.size());
74
75 val regression = new LinearRegression(x, y, ridge);
76 var prediction = predict(regression.coefficients, featuresToPredict);
77
78 //remove the last element just added
79 samples.remove(samples.size - 1);
80 return prediction;
81 }
82
83 def private predict(double[] parameters, double[] featuresToPredict){
84 // the regression will add an initial column for 1's, the first parameter is constant term
85 var result = parameters.get(0);
86 for(var i = 0; i < featuresToPredict.length; i++){
87 result += parameters.get(i) * featuresToPredict.get(i);
88 }
89 return result;
90 }
91} \ 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/ConstraintCollection.xtend b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/validation/ConstraintCollection.xtend
new file mode 100644
index 00000000..685c5836
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/validation/ConstraintCollection.xtend
@@ -0,0 +1,80 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.validation
2
3import java.util.ArrayList
4import java.util.HashMap
5import java.util.List
6import java.util.Map
7import org.eclipse.emf.common.notify.Notifier
8import org.eclipse.emf.common.util.URI
9import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
10import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification
11import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
12import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup
13import org.eclipse.viatra.query.runtime.emf.EMFScope
14
15class ConstraintCollection{
16 val constraints = new ArrayList<IConstraintSpecification>();
17 var BaseGeneratedPatternGroup patterns;
18 var List<Notifier> resources = new ArrayList<Notifier>();
19
20
21 new(List<IConstraintSpecification> constraints, List<String> uris, BaseGeneratedPatternGroup patterns){
22 this.constraints.addAll(constraints);
23 this.patterns = patterns;
24 setURIs(uris);
25 }
26
27 new(List<IConstraintSpecification> constraints, BaseGeneratedPatternGroup patterns){
28 this.constraints.addAll(constraints);
29 this.patterns = patterns;
30 }
31
32 def addModel(Notifier n ){
33 resources.add(n);
34 }
35
36 def setURIs(List<String> uris){
37 val resSet = new ResourceSetImpl();
38
39 for(uri : uris){
40 var resource = resSet.getResource(URI.createURI(uri), true);
41 resources.add(resource);
42 }
43
44 println('reading model finished')
45 }
46
47 def List<Integer> calculateViolations(){
48 var results = new ArrayList<Integer>();
49
50 for(resource : resources){
51 val engine = initEngine(resource);
52 var matches = constraints.stream.mapToInt([ele| ele.querySpecification.getMatcher(engine).countMatches]).sum();
53 results.add(matches);
54 }
55
56 return results;
57 }
58
59 def ArrayList<Map<String, Integer>> calculateViolationMaps(){
60 val result = new ArrayList<Map<String, Integer>>()
61
62 for(resource : resources){
63 val map = new HashMap<String, Integer>();
64 val engine = initEngine(resource);
65 constraints.forEach[
66 var count = it.querySpecification.getMatcher(engine).countMatches;
67 map.put(it.querySpecification.simpleName, count);
68 ];
69 result.add(map);
70 }
71 return result;
72 }
73
74 private def initEngine(Notifier r){
75 var engine = ViatraQueryEngine.on(new EMFScope(r));
76 //init patterns with the new engine
77 patterns.prepare(engine);
78 return engine;
79 }
80}
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
new file mode 100644
index 00000000..4db5f940
--- /dev/null
+++ b/Metrics/Metrics-Calculation/ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator/src/ca/mcgill/ecse/dslreasoner/realistic/metrics/calculator/validation/ViolationCheck.xtend
@@ -0,0 +1,66 @@
1package ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.validation
2
3import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app.Domain
4import com.google.common.reflect.ClassPath
5import ecore.Ecore
6import hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns
7import java.util.ArrayList
8import org.eclipse.emf.ecore.EObject
9import org.eclipse.viatra.addon.validation.core.api.IConstraintSpecification
10
11class ViolationCheck {
12 /**
13 * Return the total number of violations
14 */
15 def static int calculateViolationCounts(EObject root, Domain d){
16 var packageName = '';
17 if(d == Domain.Yakindumm){
18 packageName = 'constraints.yakindumm';
19 }else if (d == Domain.Ecore){
20 packageName = 'constraints.ecore';
21 }else if (d == Domain.Github){
22 return -1;
23 }
24
25 var constriants = loadConstraints(packageName);
26 var collections = new ConstraintCollection(constriants, Ecore.instance);
27 collections.addModel(root);
28 var results = collections.calculateViolations();
29 if(results.size > 0){
30 return results.get(0);
31 }else{
32 throw new IllegalArgumentException("Calculate Violation Failed");
33 }
34 }
35
36 /**
37 * return a map contain the count for each type of violation
38 */
39 def static violationMaps(EObject root){
40 var constriants = loadConstraints('hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu');
41 var collections = new ConstraintCollection(constriants, Patterns.instance);
42 collections.addModel(root);
43 var results = collections.calculateViolationMaps();
44 if(results.size > 0){
45 return results.get(0);
46 }else{
47 throw new IllegalArgumentException("Calculate Violation Failed");
48 }
49 }
50
51 def static loadConstraints(String packageName){
52 val constraints = new ArrayList<IConstraintSpecification>();
53
54 val classPath = ClassPath.from(ClassLoader.systemClassLoader);
55 val classInfos = classPath.getTopLevelClasses(packageName);
56 for(info : classInfos){
57 if(info.load.interfaces.contains(IConstraintSpecification)){
58 //IConstraintSpecification only has one constructor with empty argument list
59 var constructor = info.load.constructors.get(0);
60 var instance = constructor.newInstance();
61 constraints.add(instance as IConstraintSpecification);
62 }
63 }
64 return constraints
65 }
66}