File: testsetup.R

package info (click to toggle)
r-cran-optimparallel 1.0-2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 336 kB
  • sloc: sh: 13; makefile: 2
file content (18 lines) | stat: -rw-r--r-- 513 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
verbose <- FALSE
if(!exists("cl")){
    cl <- makeCluster(2)
    setDefaultCluster(cl=cl)
}
factr <- .01/.Machine$double.eps
set.seed(13)

compareOptim <- function(optim_args, parallel=NULL, tolerance = 1e-5, verbose=FALSE){
    ref <- do.call("optim", c(method="L-BFGS-B", optim_args))
    o <- do.call("optimParallel",
                 c(optim_args, parallel=list(parallel)))
    if(verbose){
        print(ref)
        print(o)
    }
    expect_equal(ref, o, check.attributes = FALSE, tolerance = tolerance)
}