Skip to contents

Use this to change the saveFile parameter in a pre-existing bayesOpt object.

Usage

changeSaveFile(optObj, saveFile = NULL)

Arguments

optObj

An object of class bayesOpt

saveFile

A filepath stored as a character. Must include the filename and extension as a .RDS.

Value

The same optObj with the updated saveFile.

Examples

scoringFunction <- function(x) {
  a <- exp(-(2-x)^2)*1.5
  b <- exp(-(4-x)^2)*2
  c <- exp(-(6-x)^2)*1
  return(list(Score = a+b+c))
}

bounds <- list(x = c(0,8))

Results <- bayesOpt(
    FUN = scoringFunction
  , bounds = bounds
  , initPoints = 3
  , iters.n = 2
  , gsPoints = 10
  , saveFile = tempfile(fileext = ".RDS")
)
#> Ran initial scoring function 3 times in 1 thread: 0.673000000000002 seconds.
#> Starting Epoch 1
#>   1) Fitting Gaussian Process...
#>   - Convergence Not Found. Trying again with tighter parameters...
#>   - Convergence Not Found. Trying again with tighter parameters...
#>   - Convergence Not Found. Trying again with tighter parameters...
#>   - Maximum convergence attempts exceeded - process is probably sampling random
#>   points.
#>   2) Ran local optimum search: 1.025 seconds.
#>   3) Ran `FUN()` 1 time in 1 thread: 0.232999999999997 seconds.
#>   4) Saved intermediary results to /tmp/Rtmp9Na8qo/file1a722389c80f.RDS.
#> Starting Epoch 2
#>   1) Fitting Gaussian Process...
#>   2) Ran local optimum search: 0.0760000000000005 seconds.
#>   3) Ran `FUN()` 1 time in 1 thread: 0.233999999999998 seconds.
#>   4) Saved intermediary results to /tmp/Rtmp9Na8qo/file1a722389c80f.RDS.
Results <- changeSaveFile(Results,saveFile = tempfile(fileext = ".RDS"))