diff options
Diffstat (limited to 'Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Main.java')
-rw-r--r-- | Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Main.java | 168 |
1 files changed, 85 insertions, 83 deletions
diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Main.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Main.java index 383852f1..e4e5b61f 100644 --- a/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Main.java +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Main.java | |||
@@ -15,7 +15,6 @@ import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io.GraphReader; | |||
15 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io.RepMetricsReader; | 15 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io.RepMetricsReader; |
16 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MetricSampleGroup; | 16 | import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MetricSampleGroup; |
17 | import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor; | 17 | import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor; |
18 | import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.validation.ViolationCheck; | ||
19 | import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage; | 18 | import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage; |
20 | import socialnetwork.Person; | 19 | import socialnetwork.Person; |
21 | 20 | ||
@@ -34,10 +33,13 @@ public class Main { | |||
34 | public static void main(String args[]) { | 33 | public static void main(String args[]) { |
35 | String ecoreFile = args[0]; | 34 | String ecoreFile = args[0]; |
36 | System.out.println("Generation Started"); | 35 | System.out.println("Generation Started"); |
36 | |||
37 | System.out.println(System.getProperty("java.library.path")); | ||
38 | |||
37 | long begin = System.currentTimeMillis(); | 39 | long begin = System.currentTimeMillis(); |
38 | String message = runWithPath(ecoreFile); | 40 | String message = runWithPath(ecoreFile); |
39 | long elapsed = System.currentTimeMillis() - begin; | 41 | long elapsed = System.currentTimeMillis() - begin; |
40 | 42 | ||
41 | if(message != null) { | 43 | if(message != null) { |
42 | System.out.println(message); | 44 | System.out.println(message); |
43 | return; | 45 | return; |
@@ -62,87 +64,87 @@ public class Main { | |||
62 | System.out.println("Finished"); | 64 | System.out.println("Finished"); |
63 | } | 65 | } |
64 | 66 | ||
65 | public static void generateModel(int run) { | 67 | // public static void generateModel(int run) { |
66 | String filename = run+"_1.xmi"; | 68 | // String filename = run+"_1.xmi"; |
67 | //prepare initial info | 69 | // //prepare initial info |
68 | ArrayList<ArrayList<String>> output = new ArrayList<ArrayList<String>>(); | 70 | // ArrayList<ArrayList<String>> output = new ArrayList<ArrayList<String>>(); |
69 | ArrayList<String> infoOutput = new ArrayList<String>(); | 71 | // ArrayList<String> infoOutput = new ArrayList<String>(); |
70 | infoOutput.add(run+ ""); | 72 | // infoOutput.add(run+ ""); |
71 | infoOutput.addAll(calculateMetric(run)); | 73 | // infoOutput.addAll(calculateMetric(run)); |
72 | 74 | // | |
73 | YakinduumModel model = new YakinduumModel(fileReadFolder +"run" +run + "/" + filename); | 75 | // YakinduumModel model = new YakinduumModel(fileReadFolder +"run" +run + "/" + filename); |
74 | int violationCount = ViolationCheck.calculateViolationCounts(model.yakinduum); | 76 | // int violationCount = ViolationCheck.calculateViolationCounts(model.yakinduum); |
75 | infoOutput.add(violationCount + ""); | 77 | // infoOutput.add(violationCount + ""); |
76 | 78 | // | |
77 | 79 | // | |
78 | 80 | // | |
79 | //save model to another directory | 81 | // //save model to another directory |
80 | model.save(configFolder + run + ".xmi"); | 82 | // model.save(configFolder + run + ".xmi"); |
81 | output.add(infoOutput); | 83 | // output.add(infoOutput); |
82 | CsvFileWriter.append(output, configFileName); | 84 | // CsvFileWriter.append(output, configFileName); |
83 | } | 85 | // } |
84 | 86 | // | |
85 | public static void singleModelViolationMeasure(int run) { | 87 | // public static void singleModelViolationMeasure(int run) { |
86 | String filename = run+"_1.xmi"; | 88 | // String filename = run+"_1.xmi"; |
87 | //prepare initial info | 89 | // //prepare initial info |
88 | ArrayList<ArrayList<String>> output = new ArrayList<ArrayList<String>>(); | 90 | // ArrayList<ArrayList<String>> output = new ArrayList<ArrayList<String>>(); |
89 | ArrayList<String> infoOutput = new ArrayList<String>(); | 91 | // ArrayList<String> infoOutput = new ArrayList<String>(); |
90 | infoOutput.add(run+ ""); | 92 | // infoOutput.add(run+ ""); |
91 | 93 | // | |
92 | YakinduumModel model = new YakinduumModel(fileReadFolder+"/run"+run+"/"+ filename); | 94 | // YakinduumModel model = new YakinduumModel(fileReadFolder+"/run"+run+"/"+ filename); |
93 | 95 | // | |
94 | //parse map of violation counts to two list and add them to the result list | 96 | // //parse map of violation counts to two list and add them to the result list |
95 | Map<String, Integer> map = ViolationCheck.violationMaps(model.yakinduum); | 97 | // Map<String, Integer> map = ViolationCheck.violationMaps(model.yakinduum); |
96 | ArrayList<String> counts = new ArrayList<String>(); | 98 | // ArrayList<String> counts = new ArrayList<String>(); |
97 | ArrayList<String> violationNames = new ArrayList<String>(map.keySet()); | 99 | // ArrayList<String> violationNames = new ArrayList<String>(map.keySet()); |
98 | for(int i = 0; i < violationNames.size(); i++) { | 100 | // for(int i = 0; i < violationNames.size(); i++) { |
99 | String name = violationNames.get(i); | 101 | // String name = violationNames.get(i); |
100 | int total = map.get(name); | 102 | // int total = map.get(name); |
101 | counts.add(total + ""); | 103 | // counts.add(total + ""); |
102 | } | 104 | // } |
103 | output.add(infoOutput); | 105 | // output.add(infoOutput); |
104 | output.add(violationNames); | 106 | // output.add(violationNames); |
105 | output.add(counts); | 107 | // output.add(counts); |
106 | 108 | // | |
107 | CsvFileWriter.append(output, configFileName); | 109 | // CsvFileWriter.append(output, configFileName); |
108 | } | 110 | // } |
109 | 111 | // | |
110 | public static void aggregateViolationMeasure(int size) { | 112 | // public static void aggregateViolationMeasure(int size) { |
111 | ArrayList<ArrayList<String>> output = new ArrayList<ArrayList<String>>(); | 113 | // ArrayList<ArrayList<String>> output = new ArrayList<ArrayList<String>>(); |
112 | ArrayList<String> counts = new ArrayList<String>(); | 114 | // ArrayList<String> counts = new ArrayList<String>(); |
113 | ArrayList<String> violationNames = null; | 115 | // ArrayList<String> violationNames = null; |
114 | for(int run = 1; run < size+1; run++) { | 116 | // for(int run = 1; run < size+1; run++) { |
115 | String filename = run+"_1.xmi"; | 117 | // String filename = run+"_1.xmi"; |
116 | YakinduumModel model = new YakinduumModel(fileReadFolder+"/run"+run+"/"+ filename); | 118 | // YakinduumModel model = new YakinduumModel(fileReadFolder+"/run"+run+"/"+ filename); |
117 | 119 | // | |
118 | Map<String, Integer> map = ViolationCheck.violationMaps(model.yakinduum); | 120 | // Map<String, Integer> map = ViolationCheck.violationMaps(model.yakinduum); |
119 | if(run == 1) { | 121 | // if(run == 1) { |
120 | violationNames = new ArrayList<String>(map.keySet()); | 122 | // violationNames = new ArrayList<String>(map.keySet()); |
121 | for(int i = 0; i < violationNames.size(); i++) { | 123 | // for(int i = 0; i < violationNames.size(); i++) { |
122 | String name = violationNames.get(i); | 124 | // String name = violationNames.get(i); |
123 | int total = map.get(name); | 125 | // int total = map.get(name); |
124 | counts.add(total + ""); | 126 | // counts.add(total + ""); |
125 | } | 127 | // } |
126 | }else { | 128 | // }else { |
127 | for(int i = 0; i < violationNames.size(); i++) { | 129 | // for(int i = 0; i < violationNames.size(); i++) { |
128 | int count = Integer.parseInt(counts.get(i)); | 130 | // int count = Integer.parseInt(counts.get(i)); |
129 | String name = violationNames.get(i); | 131 | // String name = violationNames.get(i); |
130 | int total = count + map.get(name); | 132 | // int total = count + map.get(name); |
131 | counts.set(i, total + ""); | 133 | // counts.set(i, total + ""); |
132 | } | 134 | // } |
133 | } | 135 | // } |
134 | } | 136 | // } |
135 | 137 | // | |
136 | for(int i = 0; i < counts.size(); i++) { | 138 | // for(int i = 0; i < counts.size(); i++) { |
137 | double count = Integer.parseInt(counts.get(i)) / (double) size; | 139 | // double count = Integer.parseInt(counts.get(i)) / (double) size; |
138 | counts.set(i, count + ""); | 140 | // counts.set(i, count + ""); |
139 | } | 141 | // } |
140 | 142 | // | |
141 | output.add(violationNames); | 143 | // output.add(violationNames); |
142 | output.add(counts); | 144 | // output.add(counts); |
143 | CsvFileWriter.write(output, aggregateViolationMeasureFileName); | 145 | // CsvFileWriter.write(output, aggregateViolationMeasureFileName); |
144 | } | 146 | // } |
145 | 147 | // | |
146 | public static ArrayList<String> calculateMetric(int run) { | 148 | public static ArrayList<String> calculateMetric(int run) { |
147 | //read model and metric | 149 | //read model and metric |
148 | ArrayList<String> output = new ArrayList<String>(); | 150 | ArrayList<String> output = new ArrayList<String>(); |