-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStatisticsByProblem.R
95 lines (86 loc) · 3.31 KB
/
StatisticsByProblem.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
setwd(".")
rm(list = ls(all = TRUE))
library("effsize")#for A12 test https://rdrr.io/cran/effsize/man/VD.A.html
data <- read.table(file = "data/inputDataDiffStructure.txt", head = TRUE)
QIs <- c("HV", "IGD", "EP", "GD", "GS", "ED", "PFS", "C")
ALGs <- c("CELLDE", "MOCELL", "NSGA-II", "PAES", "SMPSO", "SPEA2", "ND")
Problems <- c("RA", "TS", "TRA", "RP", "TM", "TP1", "TP2_1", "TP2_2", "TP2_3", "RM", "ITO")
overallcount <-0
dataDiffStructure <- data.frame()
for (p in Problems)
{
for (qi in QIs)
{
for (alg in ALGs)
{
count <- NROW(subset(data,data$Problem==p & data$QI==qi & data$Algo==alg))
if (p=='RM') {
if(alg=="ND") {
Percent <- count/10
}
else {
Percent <- count/4
}
}
else{
if(alg=="ND") {
Percent <- count/15
}
else {
Percent <- count/5
}
}
if(alg!="CELLDE" | p!='RM'){
row <- data.frame(NameOfProblem = p, QI=qi, Algo = alg, Counter = count, Percentage = Percent)
dataDiffStructure <- rbind(dataDiffStructure, row)
overallcount<-overallcount+count
}
}
}
}
write.table(dataDiffStructure, file = "results/statisticsbyproblem.txt", sep = "\t", quote = FALSE, row.names = FALSE)
for (qi in QIs) {
qiResults <- subset(dataDiffStructure,dataDiffStructure$QI==qi)
write.table(qiResults, file = paste0("results/byProblem/byProblem",qi,".txt"), sep = "\t", quote = FALSE, row.names = FALSE)
for(a in ALGs) {
qiPresults <- subset(qiResults,qiResults$Algo==a)[,c(1,5)]
write.table(qiPresults, file = paste0("results/byProblem/byProblemSplit/byProblem",qi,"_",a,".txt"), sep = "\t", quote = FALSE, row.names = FALSE)
}
}
dataS <- read.table(file = "results/statisticsbyproblem.txt", head = TRUE)
ALGs <- c("CELLDE", "MOCELL", "NSGA-II", "PAES", "SMPSO", "SPEA2")
dataStructureBetter <- data.frame()#only strictly better
dataStructureBetterEq <- data.frame()#better and equal
dataStructureEq <- data.frame()#only equal
for (qi in QIs)
{
dataQI <-subset(dataS, dataS$QI==qi)
for (alg1 in ALGs)
{
a1data <- subset(dataQI, dataQI$Algo==alg1)
for (alg2 in ALGs) {
if (alg1 != alg2) {
a2data <- subset(dataQI, dataQI$Algo == alg2)
UtestPvalue <- wilcox.test(a1data$Percentage, a2data$Percentage, exact = FALSE)$p.value
A12est <- VD.A(a1data$Percentage, a2data$Percentage)$estimate #A12
if (UtestPvalue < 0.05) {
if ( A12est > 0.5)
{
row <- data.frame(QI=qi, Algo1 = alg1, Algo2 = alg2, Preferred = alg1 )
dataStructureBetter <- rbind(dataStructureBetter, row)
dataStructureBetterEq <- rbind(dataStructureBetterEq, row)
}
}
else {
row <- data.frame(QI=qi, Algo1 = alg1, Algo2 = alg2, Preferred = alg1)
dataStructureBetterEq <- rbind(dataStructureBetterEq, row)
dataStructureEq <- rbind(dataStructureEq, row)
}
}
}
}
}
write.table(dataStructureEq, file = "results/pvaluesEq.txt", sep = "\t", quote = FALSE, row.names = FALSE)
write.table(dataStructureBetterEq, file = "results/pvaluesBetterEq.txt", sep = "\t", quote = FALSE, row.names = FALSE)
write.table(dataStructureBetter, file = "results/pvaluesBetter.txt", sep = "\t", quote = FALSE, row.names = FALSE)
print(overallcount)