Skip to content

Commit

Permalink
Rework function name usage as ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Dvermetten committed Jun 28, 2023
1 parent f32cb21 commit 6bbd9d5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 48 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: IOHanalyzer
Type: Package
Title: Data Analysis Part of 'IOHprofiler'
Version: 0.1.7.1
Version: 0.1.7.4
Maintainer: Diederick Vermetten <d.l.vermetten@liacs.leidenuniv.nl>
Authors@R: c(
person("Hao", "Wang", email = "h.wang@liacs.leidenuniv.nl", role = "aut", comment = c(ORCID = "0000-0002-4933-5181")),
Expand Down
3 changes: 3 additions & 0 deletions R/DataSet.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ DataSet <- function(info, verbose = F, maximization = NULL, format = IOHprofiler
else {
attr(temp, 'contains_full_FV') <- FALSE
}
if (getOption('IOHanalyzer.function_representation', 'funcId') == 'funcName') {
attr(temp, 'funcId') <- attr(temp, 'funcName')
}
return(temp)
}
else
Expand Down
4 changes: 2 additions & 2 deletions R/DataSetList.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ DataSetList <- function(path = NULL, verbose = T, print_fun = NULL, maximization
}

copy_flag <- TRUE
if (isTRUE(info$version >= "0.3.3")) {
if (ifelse(is.null(info$version), F, (compareVersion(info$version, "0.3.3") >= 0))) {
tryCatch(
data <- read_IOH_v1plus(info),
error = function(e) {
Expand All @@ -125,7 +125,7 @@ DataSetList <- function(path = NULL, verbose = T, print_fun = NULL, maximization
format = format, subsampling = subsampling)
}
DIM[i] <- attr(data, 'DIM')
funcId[i] <- attr(data, 'funcId')
funcId[i] <- attr(data, getOption('IOHanalyzer.function_representation', 'funcId'))
algId[i] <- attr(data, 'algId')

# TODO: double-check the following treatment on `instance`!!!
Expand Down
5 changes: 4 additions & 1 deletion R/readFiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ read_IOH_v1plus <- function(info, full_sampling = FALSE){

algId <- info$algId
DIM <- info$dim
funcId <- info$funcId
funcId <- attr(info, getOption('IOHanalyzer.function_representation', 'funcId'))

if (impute_evalnrs) {
data$evaluations <- ave(data$raw_y, data$runnr, FUN = seq_along)
Expand Down Expand Up @@ -1391,6 +1391,9 @@ read_IOH_v1plus <- function(info, full_sampling = FALSE){
c(info, list(maxRT = max(runtimes), finalFV = min(FV), format = IOHprofiler,
ID = info$algId))
)
if (getOption('IOHanalyzer.function_representation', 'funcId') == 'funcName') {
attr(ds, 'funcId') <- attr(ds, 'funcName')
}


if (full_sampling || 'violation' %in% info$attributes) {
Expand Down
6 changes: 1 addition & 5 deletions inst/shiny-server/server/settings_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,9 @@ observe({

observe({
if (input$Settings.Use_Funcname) {
shinyjs::show(id = "overall_funcname_box")
shinyjs::hide(id = "overall_funcid_box")
options('IOHanalyzer.function_representation' = 'funcname')
options('IOHanalyzer.function_representation' = 'funcName')
}
else {
shinyjs::hide(id = "overall_funcname_box")
shinyjs::show(id = "overall_funcid_box")
options('IOHanalyzer.function_representation' = 'funcId')
}
})
Expand Down
36 changes: 9 additions & 27 deletions inst/shiny-server/server/upload.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ observeEvent(input$repository.load_button, {
} else {
temp_data <- change_id(data, 'algId')
}

if (getOption('IOHanalyzer.function_representation', 'funcId') == 'funcName') {
for (ds in temp_data){
attr(ds, 'funcId') <- attr(ds, 'funcName')
}
}

# DataList$data <- change_id(DataList$data, getOption("IOHanalyzer.ID_vars", c("algId")))
update_menu_visibility(attr(temp_data, 'suite'))
# set_format_func(attr(DataList$data, 'suite'))
Expand Down Expand Up @@ -383,10 +390,6 @@ update_menu_visibility <- function(suite){
else {
session$sendCustomMessage(type = "manipulateMenuItem", message = list(action = "hide", tabName = "Positions"))
}
if (!is.null(get_funcName(DataList$data)))
shinyjs::enable("Settings.Use_Funcname")
else
shinyjs::disable("Settings.Use_Funcname")
}

observeEvent(input$Upload.Add_to_repo, {
Expand Down Expand Up @@ -420,7 +423,6 @@ observeEvent(input$upload.remove_data, {

updateSelectInput(session, 'Overall.Dim', choices = c(), selected = '')
updateSelectInput(session, 'Overall.Funcid', choices = c(), selected = '')
updateSelectInput(session, 'Overall.Funcname', choices = c(), selected = '')
updateSelectInput(session, 'Overall.ID', choices = c(), selected = '')

print_html('<p style="color:red;">all data are removed!</p>')
Expand Down Expand Up @@ -465,8 +467,6 @@ observe({

updateSelectInput(session, 'Overall.Dim', choices = DIMs, selected = selected_dim)
updateSelectInput(session, 'Overall.Funcid', choices = funcIds, selected = selected_f)
if (input$Settings.Use_Funcname)
updateSelectInput(session, 'Overall.Funcname', choices = get_funcName(data), selected = get_funcName(data[1]))

if ('algId' %in% input$Settings.ID.Variables)
updateSelectInput(session, 'Overall.ID', choices = NULL, selected = NULL)
Expand Down Expand Up @@ -608,14 +608,10 @@ DATA <- reactive({
if (!is.null(algid)) d <- subset(d, algId == algid)
}

if (input$Settings.Use_Funcname) {
fname <- input$Overall.Funcname
if (!is.null(fname)) d <- subset(d, funcname == fname)
}
else {

fid <- input$Overall.Funcid
if (!is.null(fid)) d <- subset(d, funcId == fid)
}


if (length(DataList$data) == 0) return(NULL)

Expand All @@ -630,20 +626,6 @@ DATA_RAW <- reactive({
DataList$data
})

# This observe statement tries to match funcid and funcname seletions so funcId can still be used internally.
# TODO: think of a better solution to ensure this matching doesn't break.
observe({
req(length(DATA_RAW()) > 0)
fname <- input$Overall.Funcname
req(fname)
req(getOption('IOHanalyzer.function_representation', 'funcId') == 'funcname')
dsl_sub <- subset(DATA_RAW(), funcName == fname)
fids <- get_funcId(dsl_sub)
if (length(fids) == 1) {
updateSelectInput(session, 'Overall.Funcid', selected = fids)
}
})

MAX_ERTS_FUNC <- reactive({
dim <- input$Overall.Dim
data <- subset(DataList$data, DIM == dim)
Expand Down
12 changes: 0 additions & 12 deletions inst/shiny-server/ui/DIM_fID_panel.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ DIM_fID_panel <- function() {
)
)
),
div(id = 'overall_funcname_box',
# style = "padding: 0px 0px; margin-top:-5em; margin:0%",
fluidRow(
column(
width = 11,
selectInput(
"Overall.Funcname",
label = HTML('<p style="font-size:90%;">Function Name:</p>'),
choices = NULL, selected = NULL)
)
)
),
div(
# style = "padding: 0px 0px; margin-top:-50em;",
fluidRow(
Expand Down

0 comments on commit 6bbd9d5

Please sign in to comment.