Skip to content

Commit

Permalink
proceed implementing new parallel fct where several optimizsations ar…
Browse files Browse the repository at this point in the history
…e conducted by one background process
  • Loading branch information
Konrad1991 committed Sep 5, 2024
1 parent 461988f commit 800bbee
Show file tree
Hide file tree
Showing 14 changed files with 630 additions and 486 deletions.
Binary file modified Rplots.pdf
Binary file not shown.
10 changes: 6 additions & 4 deletions ToDo.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Running IDA with Host, Dye and KaHD all set to 0 in batch mode results in
Error: ! Could not evaluate the loss function --> is not shown to user

--> The error messages from the callr r_bg have to be catched and reported
- [x] interrupt partially run batch process (first optimisation not yet finished)
- [x] interrupt partially run batch process (at least one dataset finished)
- [x] interrupt batch process within initialisation phase
- [x] adapt plotting functions
* [x] plotly functionality
* [x] ggplot functionality
177 changes: 55 additions & 122 deletions tsf/R/BatchPlotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,9 @@ combinePlots <- function(p1, p2, p3, index, base_size = 6) {
return(p)
}

plotStates <- function(list, num_rep = 1) {
plotStates <- function(list) {
base_size <- baseSize()
list <- list[[1]]
num_data_sets <- length(list) / num_rep
repetitions <- (seq_len(length(list)) - 1) %% num_rep + 1
data_sets <- rep(1:num_data_sets, each = num_rep)
for (i in seq_along(list)) {
list[[i]]$dataset <- data_sets[i]
list[[i]]$repetition <- repetitions[i]
}
df <- Reduce(rbind, list)
groups <- unique(df$dataset)
plot_list <- lapply(groups, function(x) {
Expand All @@ -151,15 +144,8 @@ plotStates <- function(list, num_rep = 1) {
return(plot_list)
}

plotParams <- function(list, num_rep = 1, base_size = 12) {
plotParams <- function(list) {
list <- list[[2]]
num_data_sets <- length(list) / num_rep
repetitions <- (seq_len(length(list)) - 1) %% num_rep + 1
data_sets <- rep(1:num_data_sets, each = num_rep)
for (i in seq_along(list)) {
list[[i]]$dataset <- data_sets[i]
list[[i]]$repetition <- repetitions[i]
}
df <- Reduce(rbind, list)
data <- data.frame(
x = rep(df[, 5], 4),
Expand All @@ -172,72 +158,42 @@ plotParams <- function(list, num_rep = 1, base_size = 12) {
),
repetition = rep(df$repetition, 4)
)
if (num_rep > 1) {
p <- ggplot() +
geom_boxplot(
data = data,
aes(
y = y, fill = "Entire data", x = factor(0)
)
) +
geom_boxplot(
data = data,
aes(
x = factor(x), y = y,
group = factor(x),
fill = factor(x)
)
) +
facet_wrap(. ~ names,
scales = "free_y",
strip.position = "left"
) +
xlab(NULL) +
ylab(NULL) +
theme(
panel.spacing = unit(2, "lines"),
strip.background = element_blank(),
strip.placement = "outside"
) +
guides(fill = guide_legend(title = "Datasets"))
} else {
p <- ggplot() +
geom_boxplot(
data = data,
aes(
x = factor(x),
y = y,
group = names
)
) +
facet_wrap(~names,
scales = "free_y",
strip.position = "left"
) +
xlab(NULL) +
ylab(NULL) +
theme(
panel.spacing = unit(2, "lines"),
strip.background = element_blank(),
strip.placement = "outside"
p <- ggplot() +
geom_boxplot(
data = data,
aes(
y = y, fill = "Entire data", x = factor(0)
)
) +
geom_boxplot(
data = data,
aes(
x = factor(x), y = y,
group = factor(x),
fill = factor(x)
)
}
) +
facet_wrap(. ~ names,
scales = "free_y",
strip.position = "left"
) +
xlab(NULL) +
ylab(NULL) +
theme(
panel.spacing = unit(2, "lines"),
strip.background = element_blank(),
strip.placement = "outside"
) +
guides(fill = guide_legend(title = "Datasets"))
p <- addTheme(p)
p <- p + theme(
plot.background = element_rect(color = "grey", fill = NA, size = 2)
)
return(p)
}

plotMetrices <- function(list, num_rep = 1, base_size = 12) {
plotMetrices <- function(list) {
list <- list[[3]]
num_data_sets <- length(list) / num_rep
repetitions <- (seq_len(length(list)) - 1) %% num_rep + 1
data_sets <- rep(1:num_data_sets, each = num_rep)
for (i in seq_along(list)) {
list[[i]]$dataset <- data_sets[i]
list[[i]]$repetition <- repetitions[i]
}
df <- Reduce(rbind, list)
data <- data.frame(
x = rep(df[, 6], 5),
Expand All @@ -251,56 +207,33 @@ plotMetrices <- function(list, num_rep = 1, base_size = 12) {
),
repetition = rep(df$repetition, 5)
)
if (num_rep > 1) {
p <- ggplot() +
geom_boxplot(
data = data,
aes(
y = y, fill = "Entire data", x = factor(0)
)
) +
geom_boxplot(
data = data,
aes(
x = factor(x), y = y,
group = factor(x),
fill = factor(x)
)
) +
facet_wrap(. ~ names,
scales = "free_y",
strip.position = "left"
) +
xlab(NULL) +
ylab(NULL) +
theme(
panel.spacing = unit(2, "lines"),
strip.background = element_blank(),
strip.placement = "outside"
) +
guides(fill = guide_legend(title = "Datasets"))
} else {
p <- ggplot() +
geom_boxplot(
data = data,
aes(
x = factor(x),
y = y,
group = names
)
) +
facet_wrap(~names,
scales = "free_y",
strip.position = "left"
) +
xlab(NULL) +
ylab(NULL) +
theme(
panel.spacing = unit(2, "lines"),
strip.background = element_blank(),
strip.placement = "outside"
p <- ggplot() +
geom_boxplot(
data = data,
aes(
y = y, fill = "Entire data", x = factor(0)
)
) +
geom_boxplot(
data = data,
aes(
x = factor(x), y = y,
group = factor(x),
fill = factor(x)
)
}
) +
facet_wrap(. ~ names,
scales = "free_y",
strip.position = "left"
) +
xlab(NULL) +
ylab(NULL) +
theme(
panel.spacing = unit(2, "lines"),
strip.background = element_blank(),
strip.placement = "outside"
) +
guides(fill = guide_legend(title = "Datasets"))
p <- addTheme(p)
p <- p + theme(
plot.background = element_rect(color = "grey", fill = NA, size = 2)
Expand Down
41 changes: 10 additions & 31 deletions tsf/R/BatchPlottingPlotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,8 @@ plotHostDyePlotly <- function(df, Dataset) {
return(p)
}

plotStatesPlotly <- function(list, num_rep = 1, ncols = 4) {
plotStatesPlotly <- function(list) {
list <- list[[1]]
num_data_sets <- length(list) / num_rep
repetitions <- (seq_len(length(list)) - 1) %% num_rep + 1
data_sets <- rep(1:num_data_sets, each = num_rep)
for (i in seq_along(list)) {
list[[i]]$dataset <- data_sets[i]
list[[i]]$repetition <- repetitions[i]
}
df <- Reduce(rbind, list)
groups <- unique(df$dataset)
plot_list <- lapply(groups, function(x) {
Expand Down Expand Up @@ -187,15 +180,8 @@ plotStatesPlotly <- function(list, num_rep = 1, ncols = 4) {
return(p)
}

plotParamsPlotly <- function(list, num_rep = 1) {
plotParamsPlotly <- function(list) {
list <- list[[2]]
num_data_sets <- length(list) / num_rep
repetitions <- (seq_len(length(list)) - 1) %% num_rep + 1
data_sets <- rep(1:num_data_sets, each = num_rep)
for (i in seq_along(list)) {
list[[i]]$dataset <- data_sets[i]
list[[i]]$repetition <- repetitions[i]
}
df <- Reduce(rbind, list)
data <- data.frame(
x = rep(df$dataset, 4),
Expand Down Expand Up @@ -240,15 +226,8 @@ plotParamsPlotly <- function(list, num_rep = 1) {
return(p)
}

plotMetricesPlotly <- function(list, num_rep = 1, base_size = 12) {
plotMetricesPlotly <- function(list) {
list <- list[[3]]
num_data_sets <- length(list) / num_rep
repetitions <- (seq_len(length(list)) - 1) %% num_rep + 1
data_sets <- rep(1:num_data_sets, each = num_rep)
for (i in seq_along(list)) {
list[[i]]$dataset <- data_sets[i]
list[[i]]$repetition <- repetitions[i]
}
df <- Reduce(rbind, list)
data <- data.frame(
x = rep(df[, 6], 5),
Expand Down Expand Up @@ -295,12 +274,12 @@ plotMetricesPlotly <- function(list, num_rep = 1, base_size = 12) {

}

entirePlotPlotly <- function(list, num_rep = 1, ncols = 4) {
states <- plotStatesPlotly(list, num_rep, ncols)
params <- plotParamsPlotly(list, num_rep)
metrices <- plotMetricesPlotly(list, num_rep)
entirePlotPlotly <- function(list) {
states <- plotStatesPlotly(list)
params <- plotParamsPlotly(list)
metrices <- plotMetricesPlotly(list)
subplot(states, params, metrices, nrows = 1,
shareX = FALSE, titleX = TRUE, titleY = TRUE,
widths = c(0.7, 0.15, 0.15),
margin = 0.02)
shareX = FALSE, titleX = TRUE, titleY = TRUE,
widths = c(0.7, 0.15, 0.15),
margin = 0.02)
}
Loading

0 comments on commit 800bbee

Please sign in to comment.