-
Notifications
You must be signed in to change notification settings - Fork 1
/
5-statistics.R
116 lines (98 loc) · 4.69 KB
/
5-statistics.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
library(tidyverse)
library(xtable)
xtable_sanitize_highlight <- function(x, alpha = 0.01) {
if(!is.numeric(x)) return(sanitize(x, type = "latex"))
return(ifelse(x < alpha, paste0("\\hls{", formatC(x,format="e", digits = 2), "}"),
formatC(x,format="e", digits = 2)))
}
get.end.fitness <- function (x) {
return ((x %>% group_by(seed) %>% summarise(.groups='drop_last', min.fitness=min(Fitness)))$min.fitness)
}
read.data <- function (folder, instance, er, alg, distance = "") {
if (distance != "") distance <- paste0("-", distance)
filename <- paste0(alg, distance,".csv.xz")
if (er != "") er <- paste0("-er", er)
subfolder <- paste0('m400', er)
path <- paste(folder, subfolder, instance, filename, sep='/')
return(read.csv(path))
}
read_end_fitness <- function(...) {
return(get.end.fitness(read.data(...)))
}
compute.bb.stats <- function() {
result <- data.frame(instance=character(),
cego.bb.repr=numeric(),
umm.bb.repr=numeric(),
best.bb.alg=numeric())
# Ranking is er=0, Order is er=1
for (ins in instances) {
cego_ranking <- read_end_fitness('results', ins, 0, 'cego', 'maxmindist')
cego_order <- read_end_fitness('results', ins, 1, 'cego', 'maxmindist')
umm_ranking <- read_end_fitness('results', ins, 0, 'umm', 'maxmindist')
umm_order <- read_end_fitness('results', ins, 1, 'umm', 'maxmindist')
randomsearch <- read_end_fitness('results', ins, "", 'randomsearch', '')
cego.bb.repr <- wilcox.test(cego_ranking, cego_order)$p.value
umm.bb.repr <- wilcox.test(umm_ranking, umm_order)$p.value
best.bb.alg <- wilcox.test(cego_order, umm_ranking)$p.value
result <- rbind(result, cbind.data.frame(instance = ins,
cego.bb.repr = cego.bb.repr,
umm.bb.repr = umm.bb.repr,
best.bb.alg = best.bb.alg))
}
res_latex <- result %>% mutate(across(everything(), xtable_sanitize_highlight))
print(xtable(res_latex, display=c("d","s","e","e","e")), include.rownames=FALSE,
sanitize.text.function = function(x) x)
return (result)
}
compute.informed.stats <- function() {
result <- data.frame(instance=character(), umm.rank.greedy=numeric(), cego.order.greedy=numeric())
# Ranking is er=0, Order is er=1
for (ins in instances) {
cego_bb <- read_end_fitness('results', ins, 1, 'cego', 'maxmindist')
cego_greedy <- read_end_fitness('results', ins, 1, 'cego', 'greedy_euclidean')
umm_bb <- read_end_fitness('results', ins, 0, 'umm', 'maxmindist')
umm_greedy <- read_end_fitness('results', ins, 0, 'umm', 'greedy_euclidean')
umm.rank.greedy <- wilcox.test(umm_bb, umm_greedy)$p.value
cego.order.greedy <- wilcox.test(cego_bb, cego_greedy)$p.value
result <- rbind(result, cbind.data.frame(instance = ins,
umm.rank.greedy = umm.rank.greedy,
cego.order.greedy = cego.order.greedy))
}
res_latex <- result %>% mutate(across(everything(), xtable_sanitize_highlight))
print(xtable(res_latex,display=c("d","s","e","e")), include.rownames=FALSE,
sanitize.text.function = function(x) x)
return (result)
}
instances <- character()
for (s in c(10,15,20,25,30)) {
for (seed in c(42,73)) {
instances <- c(instances, paste("arp", s, seed, sep='_'))
}
}
boxplots <- function() {
library(ggplot2)
result <- data.frame(instance=character(),
algo=character(),
fitness=numeric())
# Ranking is er=0, Order is er=1
for (ins in instances) {
tmp <- cbind(instance = ins,
rbind(data.frame(algo = "CEGO-rank",
fitness = read_end_fitness('results', ins, 0, 'cego', 'maxmindist')),
data.frame(algo = "CEGO-order",
fitness = read_end_fitness('results', ins, 1, 'cego', 'maxmindist')),
data.frame(algo = "UMM-rank",
fitness = read_end_fitness('results', ins, 0, 'umm', 'maxmindist')),
data.frame(algo = "UMM-order",
fitness = read_end_fitness('results', ins, 1, 'umm', 'maxmindist')),
data.frame(algo = "RandomSearch",
fitness = read_end_fitness('results', ins, "", 'randomsearch', ''))))
tmp$fitness <- (tmp$fitness - min(tmp$fitness)) / min(tmp$fitness)
result <- rbind(result, tmp)
}
g <- ggplot(result, aes(x=instance, y=fitness, color=algo)) + geom_boxplot() + coord_flip()
return(g)
}
boxplots()
compute.bb.stats()
compute.informed.stats()