jakobbossek / smoof

Single- and Multi-Objective Optimization Test Functions
http://jakobbossek.github.io/smoof/
Other
36 stars 16 forks source link

generateDataframeForGGPlot2 lacks method for "integervector" #121

Closed bryanhanson closed 4 years ago

bryanhanson commented 5 years ago

I think the unexported generateDataframeForGGPlot2 lacks a method for integervector type:

library("mlrMBO")

myfun <- function(x) {
    if (!is.integer(x)) stop("")
    value <- sqrt(sum(x^2))
    value
}

objF <- makeSingleObjectiveFunction(
  name = "Test Integer Input Function",
  fn = myfun,
  par.set = makeParamSet(
    makeIntegerVectorParam(
      len = 2L,
      id = "x",
      lower = c(-5, -5),
      upper = c(5, 5)
      )
  )
)

objF # output looks right as far as I can tell

objF(c(3L, 2L)) # OK

pl <- autoplot(objF) # error

Looking at the code for generateDataframeForGGPlot2 it looks like the particular case of integervector is handled, and NULL is apparently returned, leading to the complaint about the wrong number of names for the data frame being created.

bryanhanson commented 5 years ago

Forgot to add:

sessionInfo() R version 3.6.0 Patched (2019-04-26 r76431) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Mojave 10.14.4

Matrix products: default BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] mlrMBO_1.1.2 smoof_1.5.1 checkmate_1.9.1 BBmisc_1.11
[5] mlr_2.14.0 ParamHelpers_1.12

loaded via a namespace (and not attached): [1] parallelMap_1.3 Rcpp_1.0.1 pillar_1.3.1 compiler_3.6.0
[5] RColorBrewer_1.1-2 plyr_1.8.4 lhs_1.0.1 tools_3.6.0
[9] digest_0.6.18 viridisLite_0.3.0 jsonlite_1.6 tibble_2.1.1
[13] gtable_0.3.0 lattice_0.20-38 pkgconfig_2.0.2 rlang_0.3.4
[17] Matrix_1.2-17 fastmatch_1.1-0 parallel_3.6.0 httr_1.4.0
[21] dplyr_0.8.0.1 htmlwidgets_1.3 plot3D_1.1.1 grid_3.6.0
[25] tidyselect_0.2.5 glue_1.3.1 data.table_1.12.2 R6_2.4.0
[29] plotly_4.9.0 survival_2.44-1.1 mco_1.0-15.1 RJSONIO_1.3-1.1
[33] tidyr_0.8.3 ggplot2_3.1.1 purrr_0.3.2 magrittr_1.5
[37] htmltools_0.3.6 backports_1.1.4 scales_1.0.0 splines_3.6.0
[41] assertthat_0.2.1 misc3d_0.8-4 colorspace_1.4-1 stringi_1.4.3
[45] lazyeval_0.2.2 munsell_0.5.0 crayon_1.3.4

jakobbossek commented 4 years ago

Just merged PR #128. This should fix the problem. Thanks for the report by the way!