diff --git a/DESCRIPTION b/DESCRIPTION index 21ccb8d2..bbbc7d99 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,7 +27,6 @@ Depends: R (>= 3.1.0) Imports: checkmate (>= 2.0.0), - cli, data.table, lgr, methods, diff --git a/NAMESPACE b/NAMESPACE index 0de3e464..14bc940b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -97,7 +97,6 @@ export(transform_xdt_to_xss) export(trm) export(trms) import(checkmate) -import(cli) import(data.table) import(mlr3misc) import(paradox) diff --git a/R/Archive.R b/R/Archive.R index 4ed8df1f..e5adf1cc 100644 --- a/R/Archive.R +++ b/R/Archive.R @@ -67,8 +67,8 @@ Archive = R6Class("Archive", #' #' @param ... (ignored). print = function() { - cli_h1(sprintf("%s %s", class(self)[1L], if (is.na(self$label)) "" else paste0("- ", self$label))) - print(as.data.table(self, unnest = "x_domain"), digits = 1) + catf(format(self)) + print(self$data[, setdiff(names(self$data), "x_domain"), with = FALSE], digits = 2) }, #' @description diff --git a/R/Objective.R b/R/Objective.R index fb590c4d..076a2ff9 100644 --- a/R/Objective.R +++ b/R/Objective.R @@ -94,14 +94,14 @@ Objective = R6Class("Objective", #' Print method. #' @return `character()`. print = function() { - cli_h1(class(self)[1L]) - cli_li("Domain:") - print(as.data.table(self$domain)[, c("id", "class", "lower", "upper", "nlevels"), with = FALSE]) - cli_li("Codomain:") - print(as.data.table(self$codomain)[, c("id", "class", "lower", "upper"), with = FALSE]) + catf(self$format()) + catf("Domain:") + print(self$domain) + catf("Codomain:") + print(self$codomain) if (length(self$constants$values) > 0) { - cli_li("Constants:") - print(as.data.table(self$constants)[, c("id", "class", "lower", "upper", "nlevels"), with = FALSE]) + catf("Constants:") + print(self$constants) } }, diff --git a/R/OptimInstance.R b/R/OptimInstance.R index 87f7d3ec..0ff08c8d 100644 --- a/R/OptimInstance.R +++ b/R/OptimInstance.R @@ -78,19 +78,22 @@ OptimInstance = R6Class("OptimInstance", #' #' @param ... (ignored). print = function(...) { - cli_h1(class(self)[1L]) - cli_li(sprintf("State: %s", if (is.null(private$.result)) "Not optimized" else "Optimized")) - cli_li(sprintf("Objective: %s", class(self$objective)[1])) - cli_li("Search Space:") - print(as.data.table(self$search_space)[, c("id", "class", "lower", "upper", "nlevels"), with = FALSE]) - cli_li(sprintf("Terminator: %s %s", class(self$terminator)[1], if (length(self$terminator$param_set$values)) paste0("(", as_short_string(self$terminator$param_set$values), ")") else "")) + + catf(format(self)) + catf(str_indent("* State: ", if (is.null(private$.result)) "Not optimized" else "Optimized")) + catf(str_indent("* Objective:", format(self$objective))) + if (!self$search_space$length) { + catf("* Search Space: Empty") + } else { + catf("* Search Space:") + print(as.data.table(self$search_space)[, c("id", "class", "lower", "upper", "nlevels"), with = FALSE]) + } + catf(str_indent("* Terminator:", format(self$terminator))) if (!is.null(private$.result)) { - cli_li("Result:") + catf("* Result:") print(self$result[, c(self$archive$cols_x, self$archive$cols_y), with = FALSE]) - cli_li("Archive:") - tab = as.data.table(self$archive) - x_domain_ids = names(tab)[grepl("x_domain_" , names(tab))] - print(tab[, c(self$archive$cols_y, self$archive$cols_x, x_domain_ids), with = FALSE], digits = 1) + catf("* Archive:") + print(as.data.table(self$archive)[, c(self$archive$cols_x, self$archive$cols_y), with = FALSE]) } }, diff --git a/R/OptimInstanceAsync.R b/R/OptimInstanceAsync.R index 5a496d6f..9e9f328c 100644 --- a/R/OptimInstanceAsync.R +++ b/R/OptimInstanceAsync.R @@ -74,7 +74,7 @@ OptimInstanceAsync = R6Class("OptimInstanceAsync", #' @param ... (ignored). print = function(...) { super$print() - cli_li(sprintf("Workers: %i", self$rush$n_workers)) + catf(str_indent("* Workers:", self$rush$n_workers)) }, #' @description diff --git a/R/Optimizer.R b/R/Optimizer.R index f91fc20d..bf624ca8 100644 --- a/R/Optimizer.R +++ b/R/Optimizer.R @@ -74,11 +74,11 @@ Optimizer = R6Class("Optimizer", #' #' @return (`character()`). print = function() { - cli_h1(sprintf("%s %s", class(self)[1L], if (is.na(self$label)) "" else paste0("- ", self$label))) - cli_li(sprintf("Parameters: %s", if (length(self$param_set$values)) as_short_string(self$param_set$values) else "-")) - cli_li(sprintf("Parameter classes: %s", paste(self$param_classes, collapse = ", "))) - cli_li(sprintf("Properties: %s", paste(self$properties, collapse = ", "))) - cli_li(sprintf("Packages: %s", paste(self$packages, collapse = ", "))) + catn(format(self), if (is.na(self$label)) "" else paste0(": ", self$label)) + catn(str_indent("* Parameters:", as_short_string(self$param_set$values))) + catn(str_indent("* Parameter classes:", self$param_classes)) + catn(str_indent("* Properties:", self$properties)) + catn(str_indent("* Packages:", self$packages)) }, #' @description diff --git a/R/Terminator.R b/R/Terminator.R index f16101c7..ce2f063c 100644 --- a/R/Terminator.R +++ b/R/Terminator.R @@ -74,8 +74,8 @@ Terminator = R6Class("Terminator", #' #' @param ... (ignored). print = function(...) { - cli_h1(sprintf("%s %s", class(self)[1L], if (is.na(self$label)) "" else paste0("- ", self$label))) - cli_li(sprintf("Parameters: %s", if(length(self$param_set$values)) as_short_string(self$param_set$values) else "-")) + catn(format(self), if (is.na(self$label)) "" else paste0(": ", self$label)) + catn(str_indent("* Parameters:", as_short_string(self$param_set$values))) }, #' @description diff --git a/R/zzz.R b/R/zzz.R index 4405d3a6..0698998b 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -2,7 +2,6 @@ #' @import checkmate #' @import paradox #' @import mlr3misc -#' @import cli #' @importFrom R6 R6Class #' @importFrom utils capture.output head tail #' @importFrom methods formalArgs diff --git a/man/Codomain.Rd b/man/Codomain.Rd index ee7fe0d3..f5cbb275 100644 --- a/man/Codomain.Rd +++ b/man/Codomain.Rd @@ -73,11 +73,14 @@ of a maximization problem to turn it into a minimization problem.}
Inherited methods