Skip to content

Commit

Permalink
ensure non-empty inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
wangronin committed Nov 5, 2018
1 parent 0352be8 commit d516166
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
3 changes: 2 additions & 1 deletion pproc.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ summarise_runtime <- function(dataset, ftarget, maximization = TRUE, probs = NUL
mean(., na.rm = T),
median(., na.rm = T),
sd(., na.rm = T),
quantile(., probs = probs, names = F, type = 3, na.rm = T) # type 1 ~ 3 for the discrete r.v.
# type 1 ~ 3 for the discrete r.v.
quantile(., probs = probs, names = F, type = 3, na.rm = T)
)
}
}) %>%
Expand Down
9 changes: 5 additions & 4 deletions readFiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ library(dplyr)
library(reshape2)
library(data.table)
library(Rcpp)
library(ggplot2)

sourceCpp('C/align.cc')
source('global.R')
Expand Down Expand Up @@ -390,9 +391,9 @@ align_by_target <- function(data, targets = 'full', nrow = 100, maximization = T
list(by_target = res)
}

check_contiguous <- function (data) {
check_contiguous <- function(data) {
sapply(data,
function (d) {
function(d) {
v <- d[, idxEvals]
N <- length(v)
v[1] == 1 && v[N] == N
Expand All @@ -404,7 +405,7 @@ align_contiguous <- function(data, idx, rownames) {
N <- length(data)
nrow <- length(rownames)
lapply(data,
function (d) {
function(d) {
v <- d[, idx]
r <- nrow - length(v)
if (r > 0) {
Expand All @@ -421,7 +422,7 @@ align_non_contiguous <- function(data, idx, rownames) {
N <- length(data)
nrow <- length(rownames)
lapply(data,
function (d) {
function(d) {
c_impute(d[, idx], d[, idxEvals], rownames)
}) %>%
unlist %>%
Expand Down
28 changes: 24 additions & 4 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,11 @@ shinyServer(function(input, output, session) {

# The expected runtime plot ---------------------
output$ERT_PER_FUN <- renderPlotly({

# require non-empty input
req(input$ERT_FSTART != "")
req(input$ERT_FSTOP != "")

Fmin <- format_funeval(input$ERT_FSTART) %>% as.numeric %>% reverse_trans_funeval
Fmax <- format_funeval(input$ERT_FSTOP) %>% as.numeric %>% reverse_trans_funeval

Expand All @@ -504,7 +509,8 @@ shinyServer(function(input, output, session) {
colors <- colorspace::rainbow_hcl(n_algorithm)

p <- plot_ly_default(#title = "Expected Runtime Comparison",
x.title = "best-so-far f(x)-value", y.title = "function evaluations")
x.title = "best-so-far f(x)-value",
y.title = "function evaluations")

for (i in seq_along(data)) {
df <- data[[i]]
Expand All @@ -531,14 +537,12 @@ shinyServer(function(input, output, session) {
p %<>% add_trace(data = df_plot, x = ~BestF, y = ~ERT, type = 'scatter',
mode = 'lines+markers', name = paste0(algId, '.mean'),
marker = list(color = rgb_str),
#legendgroup = algId,
line = list(color = rgb_str))

if (input$show.median)
p %<>% add_trace(data = df_plot, x = ~BestF, y = ~median, type = 'scatter',
name = paste0(algId, '.median'), mode = 'lines+markers',
marker = list(color = rgb_str),
#legendgroup = algId,
line = list(color = rgb_str, dash = 'dash'))
}
p %<>%
Expand All @@ -553,6 +557,8 @@ shinyServer(function(input, output, session) {

# empirical p.m.f. of the runtime
output$RT_PMF <- renderPlotly({

req(input$RT_PMF_FTARGET != "") # require non-empty input
ftarget <- format_funeval(input$RT_PMF_FTARGET) %>% as.numeric %>% reverse_trans_funeval
points <- ifelse(input$RT_SHOW_SAMPLE, 'all', FALSE)

Expand Down Expand Up @@ -622,6 +628,7 @@ shinyServer(function(input, output, session) {

# historgram of the running time
output$RT_HIST <- renderPlotly({
req(input$RT_PMF_HIST_FTARGET != "") # require non-empty input
ftarget <- format_funeval(input$RT_PMF_HIST_FTARGET) %>% as.numeric %>% reverse_trans_funeval
plot_mode <- input$ERT_illu_mode

Expand Down Expand Up @@ -689,12 +696,14 @@ shinyServer(function(input, output, session) {
as.numeric %>%
reverse_trans_funeval

ftargets <- ftargets[!is.na(ftargets)]
req(length(ftargets) != 0)

data <- DATA()
n_algorithm <- length(data)
colors <- colorspace::rainbow_hcl(n_algorithm)

p <- plot_ly_default(title = NULL,
# title = "Empirical Cumulative Distribution of the runtime",
x.title = "function evaluations",
y.title = "Proportion of runs")

Expand Down Expand Up @@ -775,6 +784,8 @@ shinyServer(function(input, output, session) {
reverse_trans_funeval %>%
.[. >= (min(fall) - 0.1)] %>% .[. <= (max(fall) + 0.1)]

req(length(fseq) != 0)

data <- DATA()
n_algorithm <- length(data)
colors <- colorspace::rainbow_hcl(n_algorithm)
Expand Down Expand Up @@ -1061,6 +1072,7 @@ shinyServer(function(input, output, session) {

# empirical p.d.f. of the target value
output$FCE_PDF <- renderPlotly({
req(input$FCE_PDF_RUNTIME != "") # require non-empty input
runtime <- input$FCE_PDF_RUNTIME %>% as.integer %>% reverse_trans_runtime
points <- ifelse(input$FCE_SHOW_SAMPLE, 'all', FALSE)

Expand Down Expand Up @@ -1097,6 +1109,7 @@ shinyServer(function(input, output, session) {

# historgram of the target values -----------
output$FCE_HIST <- renderPlotly({
req(input$FCE_HIST_RUNTIME != "") # require non-empty input
runtime <- input$FCE_HIST_RUNTIME %>% as.integer %>% reverse_trans_runtime
plot_mode <- input$FCE_illu_mode

Expand Down Expand Up @@ -1157,6 +1170,8 @@ shinyServer(function(input, output, session) {

# Expected Target Value Convergence
output$FCE_PER_FUN <- renderPlotly({
req(input$FCE_RT_MIN != "") # require non-empty input
req(input$FCE_RT_MAX != "")
rt_min <- input$FCE_RT_MIN %>% as.integer %>% reverse_trans_runtime
rt_max <- input$FCE_RT_MAX %>% as.integer %>% reverse_trans_runtime

Expand Down Expand Up @@ -1215,6 +1230,9 @@ shinyServer(function(input, output, session) {
as.integer(input$FCE_ECDF_RT3)) %>%
reverse_trans_runtime

runtimes <- runtimes[!is.na(runtimes)]
req(length(runtimes) != 0)

data <- DATA()
n_algorithm <- length(data)
colors <- colorspace::rainbow_hcl(n_algorithm)
Expand Down Expand Up @@ -1450,6 +1468,8 @@ shinyServer(function(input, output, session) {

# Expected Evolution of parameters in the algorithm
output$PAR_PER_FUN <- renderPlotly({
req(input$PAR_F_MIN != "") # require non-empty input
req(input$PAR_F_MAX != "")
f_min <- input$PAR_F_MIN %>% as.numeric %>% reverse_trans_funeval
f_max <- input$PAR_F_MAX %>% as.numeric %>% reverse_trans_funeval

Expand Down

0 comments on commit d516166

Please sign in to comment.