Running ‘bdstest.R’ [1s/2s]
  Running ‘hobbs.R’ [6s/8s]
  Running ‘jonesrun.R’ [3s/5s]
  Running ‘maxfn.R’ [0s/1s]
  Running ‘rosenbrock.R’ [5s/7s]
  Running ‘run1param.R’ [0s/1s]
  Running ‘simplefuntst.R’ [0s/1s]
  Running ‘snsimple.R’ [0s/1s]
  Running ‘snwood.R’ [0s/1s]
  Running ‘ssqbtest.R’ [2s/3s]
  Running ‘tfnchk.R’ [0s/1s]
  Running ‘tgrchk.R’ [0s/1s]
  Running ‘tkktc.R’ [0s/1s]
  Running ‘trig1507.R’ [6s/9s]
Running the tests in ‘tests/ssqbtest.R’ failed.
Complete output:
  > require(optimx)
  Loading required package: optimx
  > ssqb.f<-function(x){
  +   nn<-length(x)
  +   yy <- 1:nn
  +   f<-sum((yy-x)^2)
  +   f
  + }
  > ssqb.g <- function(x){
  +   nn<-length(x)
  +   yy<-1:nn
  +   gg<- 2*(x - yy)
  + }
  > ssqb.h <- function(x){
  +   nn<-length(x)
  +   hh<- 2*diag(nn)
  + }
  > xx <- rep(pi, 4)
  > all4b <- opm(xx, ssqb.f, ssqb.g, hess=ssqb.h, method="ALL")
  This problem is unconstrained.
  Small gradient
  Warning message:
  In optimr(par, fn, gr, hess = hess, method = meth, lower = lower,  :
    Successful convergence  Restarts for stagnation =0
  > summary(all4b, order=value)
                     p1       p2       p3       p4        value fevals gevals
  L-BFGS-B    1.0000000 2.000000 3.000000 4.000000 0.000000e+00      4      4
  nlminb      1.0000000 2.000000 3.000000 4.000000 0.000000e+00      4      3
  snewton     1.0000000 2.000000 3.000000 4.000000 0.000000e+00      2      2
  snewtonm    1.0000000 2.000000 3.000000 4.000000 0.000000e+00      5      5
  spg         1.0000000 2.000000 3.000000 4.000000 0.000000e+00      3      2
  lbfgs       1.0000000 2.000000 3.000000 4.000000 0.000000e+00     NA     NA
  nlm         1.0000000 2.000000 3.000000 4.000000 1.972152e-31     NA      1
  lbfgsb3     1.0000000 2.000000 3.000000 4.000000 6.409495e-31      3      3
  subplex     1.0000000 2.000000 3.000000 4.000000 7.888609e-31    765     NA
  Rvmmin      1.0000000 2.000000 3.000000 4.000000 1.774937e-30      4      3
  ucminf      1.0000000 2.000000 3.000000 4.000000 2.415887e-30      4      4
  Rcgmin      1.0000000 2.000000 3.000000 4.000000 2.761013e-30      4      2
  BFGS        1.0000000 2.000000 3.000000 4.000000 3.451266e-30      6      3
  Rtnmin      1.0000000 2.000000 3.000000 4.000000 9.171569e-20      2      2
  hjn         1.0000000 2.000000 3.000000 4.000000 2.462186e-15    371     NA
  bobyqa      0.9999999 2.000000 3.000000 4.000000 2.118904e-14     71     NA
  newuoa      1.0000001 2.000000 3.000000 4.000000 7.432020e-14     53     NA
  CG          1.0000005 2.000000 3.000000 4.000000 3.229863e-13     15      8
  hjkb        0.9999987 1.999999 2.999999 3.999999 6.548641e-12    308     NA
  Nelder-Mead 1.0001164 1.999886 3.000012 3.999906 3.548762e-08    157     NA
  nmkb        1.0003126 2.000353 3.000301 4.000037 3.144460e-07    130     NA
              convergence kkt1 kkt2 xtime
  L-BFGS-B              0 TRUE TRUE 0.001
  nlminb                0 TRUE TRUE 0.001
  snewton               0 TRUE TRUE 0.002
  snewtonm              0 TRUE TRUE 0.002
  spg                   0 TRUE TRUE 0.006
  lbfgs                 0 TRUE TRUE 0.004
  nlm                   0 TRUE TRUE 0.006
  lbfgsb3               0 TRUE TRUE 0.002
  subplex               0 TRUE TRUE 0.009
  Rvmmin                2 TRUE TRUE 0.004
  ucminf                0 TRUE TRUE 0.005
  Rcgmin                0 TRUE TRUE 0.001
  BFGS                  0 TRUE TRUE 0.036
  Rtnmin                0 TRUE TRUE 0.003
  hjn                   0 TRUE TRUE 0.005
  bobyqa                0 TRUE TRUE 0.002
  newuoa                0 TRUE TRUE 0.122
  CG                    0 TRUE TRUE 0.001
  hjkb                  0 TRUE TRUE 0.005
  Nelder-Mead           0 TRUE TRUE 0.001
  nmkb                  0 TRUE TRUE 0.013
  > 
  > all4bx <- optimx(xx, ssqb.f, ssqb.g, control=list(all.methods=TRUE))
   ----------- FAILURE REPORT -------------- 
   --- failure: the condition has length > 1 ---
   --- srcref --- 
  : 
   --- package (from environment) --- 
  optimx
   --- call from context --- 
  optimx.run(par, optcfg$ufn, optcfg$ugr, optcfg$uhess, lower, 
      upper, optcfg$method, itnmax, hessian, optcfg$ctrl, ...)
   --- call from argument --- 
  if (class(nhatend) != "try-error") {
      hessOK <- TRUE
  }
   --- R stacktrace ---
  where 1: optimx.run(par, optcfg$ufn, optcfg$ugr, optcfg$uhess, lower, 
      upper, optcfg$method, itnmax, hessian, optcfg$ctrl, ...)
  where 2: optimx(xx, ssqb.f, ssqb.g, control = list(all.methods = TRUE))
  
   --- value of length: 2 type: logical ---
  [1] TRUE TRUE
   --- function from context --- 
  function (par, ufn, ugr = NULL, uhess = NULL, lower = -Inf, upper = Inf, 
      method = c("Nelder-Mead", "BFGS"), itnmax = NULL, hessian = FALSE, 
      ctrl, ...) 
  {
      have.bounds <- ctrl$have.bounds
      ctrl$have.bounds <- NULL
      npar <- length(par)
      if (length(lower) == 1 && is.finite(lower)) 
          lower <- rep(lower, npar)
      if (length(upper) == 1 && is.finite(upper)) 
          upper <- rep(upper, npar)
      nmeth <- length(method)
      pstring <- names(par)
      if (is.null(pstring)) {
          pstring <- NULL
          for (j in 1:npar) {
              pstring[[j]] <- paste("p", j, sep = "")
          }
      }
      cnames <- c(pstring, "value", "fevals", "gevals", "niter", 
          "convcode", "kkt1", "kkt2", "xtime")
      ans.ret <- matrix(NA, nrow = nmeth, ncol = npar + 8)
      colnames(ans.ret) <- cnames
      row.names(ans.ret) <- method
      ans.details <- list()
      ansout <- NULL
      for (i in 1:nmeth) {
          meth <- method[i]
          conv <- -1
          if (!is.null(itnmax)) {
              if (length(itnmax) == 1) {
                  ctrl$maxit <- itnmax
              }
              else {
                  if (length(itnmax) != nmeth) {
                    stop("Length of itnmax =", length(itnmax), 
                      " but should be ", nmeth)
                  }
                  else {
                    ctrl$maxit <- itnmax[i]
                  }
              }
              if (ctrl$follow.on && (ctrl$trace > 0)) 
                  cat("Do ", ctrl$maxit, " steps of ")
          }
          if (ctrl$trace > 0) 
              cat("Method: ", meth, "\n")
          mcontrol <- ctrl
          mcontrol$follow.on <- NULL
          mcontrol$usenumDeriv <- NULL
          mcontrol$save.failures <- NULL
          mcontrol$kkt <- NULL
          mcontrol$starttests <- NULL
          mcontrol$all.methods <- NULL
          mcontrol$dowarn <- NULL
          mcontrol$kkttol <- NULL
          mcontrol$kkt2tol <- NULL
          mcontrol$maximize <- NULL
          mcontrol$badval <- NULL
          mcontrol$scaletol <- NULL
          ans.ret[i, "value"] <- .Machine$double.xmax
          if (meth == "Nelder-Mead" || meth == "BFGS" || meth == 
              "L-BFGS-B" || meth == "CG" || meth == "SANN") {
              if (have.bounds) {
                  if (meth != "L-BFGS-B") 
                    stop("Bounds constraints for optim() require L-BFGS-B")
                  else {
                    time <- system.time(ans <- try(optim(par = par, 
                      fn = ufn, gr = ugr, lower = lower, upper = upper, 
                      method = meth, control = mcontrol, ...), 
                      silent = TRUE))[1]
                  }
              }
              else {
                  time <- system.time(ans <- try(optim(par = par, 
                    fn = ufn, gr = ugr, method = meth, control = mcontrol, 
                    ...), silent = TRUE))[1]
              }
              if (class(ans)[1] != "try-error") {
                  ans$convcode <- ans$convergence
                  ans$convergence <- NULL
                  ans$fevals <- ans$counts[1]
                  ans$gevals <- ans$counts[2]
                  ans$counts <- NULL
              }
              else {
                  ans <- list(fevals = NA)
                  ans$convcode <- 9999
                  if (ctrl$trace > 0) 
                    cat("optim function evaluation failure\n")
                  ans$value = ctrl$badval
                  ans$par <- rep(NA, npar)
                  ans$fevals <- NA
                  ans$gevals <- NA
              }
              ans$nitns <- NA
          }
          else if (meth == "nlminb") {
              mcontrol$iter.max <- mcontrol$maxit
              mcontrol$maxit <- NULL
              mcontrol$abs.tol <- 0
              if (is.null(mcontrol$trace) || is.na(mcontrol$trace) || 
                  mcontrol$trace == 0) {
                  mcontrol$trace = 0
              }
              else {
                  mcontrol$trace = 1
              }
              time <- system.time(ans <- try(nlminb(start = par, 
                  objective = ufn, gradient = ugr, lower = lower, 
                  upper = upper, control = mcontrol, ...), silent = TRUE))[1]
              if (class(ans)[1] != "try-error") {
                  ans$convcode <- ans$convergence
                  ans$value <- ans$objective
                  ans$objective <- NULL
                  ans$fevals <- ans$evaluations[1]
                  ans$gevals <- ans$evaluations[2]
                  ans$evaluations <- NULL
                  ans$nitns <- ans$iterations
                  ans$iterations <- NULL
              }
              else {
                  ans <- list(fevals = NA)
                  ans$convcode <- 9999
                  if (ctrl$trace > 0) 
                    cat("nlminb function evaluation failure\n")
                  ans$value = ctrl$badval
                  ans$objective <- NULL
                  ans$par <- rep(NA, npar)
                  ans$nitns <- NA
                  ans$gevals <- NA
                  ans$gevals <- NA
                  ans$objective <- NULL
                  ans$evaluations <- NULL
                  ans$iterations <- NULL
                  ans$message <- "nlminb failure"
              }
              ans$convergence <- NULL
          }
          else if (meth == "nlm") {
              if (!is.null(ugr)) {
                  tufn <- function(x, ...) {
                    res <- ufn(x, ...)
                    attr(res, "gradient") <- ugr(x, ...)
                    return(res)
                  }
              }
              else {
                  tufn <- ufn
              }
              if (!is.null(mcontrol$maxit)) {
                  iterlim <- mcontrol$maxit
                  mcontrol$maxit <- NULL
              }
              else {
                  iterlim = 100
              }
              if (is.null(mcontrol$trace)) {
                  print.level <- 0
              }
              else {
                  print.level <- mcontrol$trace
                  mcontrol$trace <- NULL
              }
              time <- system.time(ans <- try(nlm(f = tufn, p = par, 
                  ..., iterlim = iterlim, print.level = print.level), 
                  silent = TRUE))[1]
              if (class(ans)[1] != "try-error") {
                  if (ctrl$trace > 1) {
                    cat("nlm output ans:\n")
                    print(ans)
                  }
                  ans$convcode <- ans$code
                  if (ans$convcode == 1 || ans$convcode == 2 || 
                    ans$convcode == 3) 
                    ans$convcode <- 0
                  if (ans$convcode == 4) 
                    ans$convcode <- 1
                  ans$value <- ans$minimum
                  ans$par <- ans$estimate
                  ans$estimate <- NULL
                  ans$minimum <- NULL
                  ans$fevals <- NA
                  ans$gevals <- NA
                  ans$nitns <- ans$iterations
                  ans$iterations <- NULL
              }
              else {
                  if (ctrl$trace > 0) 
                    cat("nlm failed for this problem\n")
                  ans <- list(fevals = NA)
                  ans$value = ctrl$badval
                  ans$par <- rep(NA, npar)
                  ans$convcode <- 9999
                  ans$gevals <- NA
                  ans$nitns <- NA
              }
          }
          else if (meth == "spg") {
              mcontrol$maximize <- NULL
              time <- system.time(ans <- try(BB::spg(par = par, 
                  fn = ufn, gr = ugr, lower = lower, upper = upper, 
                  control = mcontrol, ...), silent = TRUE))[1]
              if (class(ans)[1] != "try-error") {
                  ans$convcode <- ans$convergence
                  ans$fevals <- ans$feval
                  ans$feval <- NULL
                  ans$gevals <- NA
                  ans$nitns <- ans$iter
                  ans$iter <- NULL
              }
              else {
                  if (ctrl$trace > 0) 
                    cat("spg failed for this problem\n")
                  ans <- list(fevals = NA)
                  ans$value = ctrl$badval
                  ans$par <- rep(NA, npar)
                  ans$convcode <- 9999
                  ans$gevals <- NA
                  ans$nitns <- NA
              }
              ans$convergence <- NULL
          }
          else if (meth == "ucminf") {
              if (is.null(ctrl$maxit)) 
                  mcontrol$maxit <- 500
              mcontrol$maxeval <- mcontrol$maxit
              mcontrol$maxit <- NULL
              time <- system.time(ans <- try(ucminf::ucminf(par = par, 
                  fn = ufn, gr = ugr, control = mcontrol, ...), 
                  silent = TRUE))[1]
              if (class(ans)[1] != "try-error") {
                  ans$convcode <- ans$convergence
                  if (ans$convcode == 1 || ans$convcode == 2 || 
                    ans$convcode == 4) {
                    ans$convcode <- 0
                  }
                  else {
                    ans$convcode <- ans$convergence
                  }
                  ans$fevals <- ans$info[4]
                  ans$gevals <- ans$info[4]
                  ans$info <- NULL
                  ans$nitns <- NA
                  if (ctrl$trace > 0) 
                    cat("ucminf message:", ans$message, "\n")
              }
              else {
                  if (ctrl$trace > 0) 
                    cat("ucminf failed for this problem\n")
                  ans <- list(fevals = NA)
                  ans$value = ctrl$badval
                  ans$par <- rep(NA, npar)
                  ans$convcode <- 9999
                  ans$gevals <- NA
                  ans$nitns <- NA
              }
              ans$convergence <- NULL
          }
          else if (meth == "Rcgmin") {
              bdmsk <- rep(1, npar)
              mcontrol$trace <- NULL
              if (ctrl$trace > 0) 
                  mcontrol$trace <- 1
              tugr <- ugr
              if (is.null(ugr)) {
                  tugr <- "grfwd"
                  if (ctrl$trace > 0) 
                    cat("Rcgmin using grfwd\n")
              }
              if (have.bounds) {
                  time <- system.time(ans <- try(Rcgminb(par = par, 
                    fn = ufn, gr = tugr, lower = lower, upper = upper, 
                    bdmsk = bdmsk, control = mcontrol, ...), silent = TRUE))[1]
              }
              else {
                  time <- system.time(ans <- try(Rcgminu(par = par, 
                    fn = ufn, gr = tugr, control = mcontrol, ...), 
                    silent = TRUE))[1]
              }
              if (class(ans)[1] != "try-error") {
                  ans$convcode <- ans$convergence
                  ans$fevals <- ans$counts[1]
                  ans$gevals <- ans$counts[2]
                  ans$counts <- NULL
              }
              else {
                  if (ctrl$trace > 0) 
                    cat("Rcgmin failed for current problem \n")
                  ans <- list(fevals = NA)
                  ans$value = ctrl$badval
                  ans$par <- rep(NA, npar)
                  ans$convcode <- 9999
                  ans$fevals <- NA
                  ans$gevals <- NA
              }
              ans$nitns <- NA
              ans$convergence <- NULL
          }
          else if (meth == "Rvmmin") {
              bdmsk <- rep(1, npar)
              mcontrol$trace <- NULL
              if (ctrl$trace > 0) 
                  mcontrol$trace <- ctrl$trace
              tugr <- ugr
              if (is.null(ugr)) {
                  tugr <- "grfwd"
                  if (ctrl$trace > 0) 
                    cat("Rvmmin using grfwd\n")
              }
              if (have.bounds) {
                  time <- system.time(ans <- try(Rvmminb(par = par, 
                    fn = ufn, gr = tugr, lower = lower, upper = upper, 
                    bdmsk = bdmsk, control = mcontrol, ...), silent = TRUE))[1]
              }
              else {
                  time <- system.time(ans <- try(Rvmminu(par = par, 
                    fn = ufn, gr = tugr, control = mcontrol, ...), 
                    silent = TRUE))[1]
              }
              if (class(ans)[1] != "try-error") {
                  ans$convcode <- ans$convergence
                  ans$fevals <- ans$counts[1]
                  ans$gevals <- ans$counts[2]
              }
              else {
                  if (ctrl$trace > 0) 
                    cat("Rvmmin failed for current problem \n")
                  ans <- list(fevals = NA)
                  ans$value = ctrl$badval
                  ans$par <- rep(NA, npar)
                  ans$convcode <- 9999
                  ans$gevals <- NA
              }
              ans$nitns <- NA
              ans$convergence <- NULL
          }
          else if (meth == "lbfgsb3") {
              mcontrol$maxit <- NULL
              mcontrol$maxfeval <- NULL
              mcontrol$trace <- NULL
              mcontrol$iprint <- -1L
              if (ctrl$trace > 0) {
                  mcontrol$trace <- 1
                  mcontrol$iprint <- 1
              }
              time <- system.time(ans <- try(lbfgsb3::lbfgsb3(prm = par, 
                  fn = ufn, gr = ugr, lower = lower, upper = upper, 
                  control = mcontrol, ...), silent = TRUE))[1]
              if ((class(ans)[1] != "try-error")) {
                  ans$convcode <- 0
                  ans$fevals <- ans$info$isave[34]
                  ans$gevals <- ans$fevals
                  ans$value <- ans$f
                  ans$par <- ans$prm
                  ans$prm <- NULL
                  ans$f <- NULL
                  ans$info <- NULL
              }
              else {
                  if (ctrl$trace > 0) 
                    cat("lbfgsb3 failed for current problem \n")
                  ans <- list(fevals = NA)
                  ans$value = ctrl$badval
                  ans$par <- rep(NA, npar)
                  ans$convcode <- 9999
                  ans$gevals <- NA
                  ans$fevals <- NA
              }
              ans$nitns <- NA
              ans$convergence <- NULL
          }
          else if (meth == "bobyqa") {
              if (!is.null(mcontrol$maxit)) {
                  mcontrol$maxfun <- mcontrol$maxit
              }
              else {
                  mcontrol$maxfun <- 5000 * round(sqrt(npar + 1))
              }
              mcontrol$iprint <- 0
              if (mcontrol$trace) 
                  mcontrol$iprint <- 1
              mcontrol$trace <- NULL
              time <- system.time(ans <- try(minqa::bobyqa(par = par, 
                  fn = ufn, lower = lower, upper = upper, control = mcontrol, 
                  ...), silent = TRUE))[1]
              if (class(ans)[1] != "try-error") {
                  ans$convcode <- 0
                  if (ans$feval > mcontrol$maxfun) {
                    ans$convcode <- 1
                  }
                  ans$fevals <- ans$feval
                  ans$gevals <- NA
                  ans$value <- ans$fval
                  ans$nitns <- NA
              }
              else {
                  if (ctrl$trace > 0) 
                    cat("bobyqa failed for current problem \n")
                  ans <- list(fevals = NA)
                  ans$value = ctrl$badval
                  ans$par <- rep(NA, npar)
                  ans$convcode <- 9999
                  ans$gevals <- NA
                  ans$nitns <- NA
              }
          }
          else if (meth == "uobyqa") {
              if (!is.null(mcontrol$maxit)) {
                  mcontrol$maxfun <- mcontrol$maxit
              }
              else {
                  mcontrol$maxfun <- 5000 * round(sqrt(npar + 1))
              }
              mcontrol$iprint <- 0
              if (mcontrol$trace) 
                  mcontrol$iprint <- 1
              mcontrol$trace <- NULL
              time <- system.time(ans <- try(minqa::uobyqa(par = par, 
                  fn = ufn, control = mcontrol, ...), silent = TRUE))[1]
              if (class(ans)[1] != "try-error") {
                  ans$convcode <- 0
                  if (ans$feval > mcontrol$maxfun) {
                    ans$convcode <- 1
                  }
                  ans$fevals <- ans$feval
                  ans$gevals <- NA
                  ans$value <- ans$fval
                  ans$nitns <- NA
              }
              else {
                  if (ctrl$trace > 0) 
                    cat("uobyqa failed for current problem \n")
                  ans <- list(fevals = NA)
                  ans$value = ctrl$badval
                  ans$par <- rep(NA, npar)
                  ans$convcode <- 9999
                  ans$gevals <- NA
                  ans$nitns <- NA
              }
          }
          else if (meth == "newuoa") {
              if (!is.null(mcontrol$maxit)) {
                  mcontrol$maxfun <- mcontrol$maxit
              }
              else {
                  mcontrol$maxfun <- 5000 * round(sqrt(npar + 1))
              }
              mcontrol$iprint <- 0
              if (mcontrol$trace) 
                  mcontrol$iprint <- 1
              mcontrol$trace <- NULL
              time <- system.time(ans <- try(minqa::newuoa(par = par, 
                  fn = ufn, control = mcontrol, ...), silent = TRUE))[1]
              if (class(ans)[1] != "try-error") {
                  ans$convcode <- 0
                  if (ans$feval > mcontrol$maxfun) {
                    ans$convcode <- 1
                  }
                  ans$fevals <- ans$feval
                  ans$gevals <- NA
                  ans$value <- ans$fval
                  ans$nitns <- NA
              }
              else {
                  if (ctrl$trace > 0) 
                    cat("newuoa failed for current problem \n")
                  ans <- list(fevals = NA)
                  ans$value = ctrl$badval
                  ans$par <- rep(NA, npar)
                  ans$convcode <- 9999
                  ans$gevals <- NA
                  ans$nitns <- NA
              }
          }
          else if (meth == "nmkb") {
              if (any(par == lower) || any(par == upper)) {
                  if (ctrl$trace > 0) 
                    cat("nmkb cannot start if on any bound \n")
                  warning("nmkb() cannot be started if any parameter on a bound")
                  ans <- list(fevals = NA)
                  ans$value = ctrl$badval
                  ans$par <- rep(NA, npar)
                  ans$convcode <- 9999
                  ans$fevals <- NA
                  ans$gevals <- NA
                  ans$nitns <- NA
              }
              else {
                  if (!is.null(mcontrol$maxit)) {
                    mcontrol$maxfeval <- mcontrol$maxit
                  }
                  else {
                    mcontrol$maxfeval <- 5000 * round(sqrt(npar + 
                      1))
                  }
                  mcontrol$maxit <- NULL
                  if (mcontrol$trace > 0) {
                    mcontrol$trace <- TRUE
                  }
                  else {
                    mcontrol$trace <- FALSE
                  }
                  mcontrol$usenumDeriv <- NULL
                  mcontrol$maximize <- NULL
                  mcontrol$parscale <- NULL
                  mcontrol$fnscale <- NULL
                  if (have.bounds) {
                    time <- system.time(ans <- try(dfoptim::nmkb(par = par, 
                      fn = ufn, lower = lower, upper = upper, control = mcontrol, 
                      ...), silent = TRUE))[1]
                  }
                  else {
                    time <- system.time(ans <- try(dfoptim::nmk(par = par, 
                      fn = ufn, control = mcontrol, ...), silent = TRUE))[1]
                  }
                  if (class(ans)[1] != "try-error") {
                    ans$convcode <- ans$convergence
                    ans$convergence <- NULL
                    ans$value <- as.numeric(ans$value)
                    ans$fevals <- ans$feval
                    ans$feval <- NULL
                    ans$gevals <- NA
                    if (ans$fevals > mcontrol$maxfeval) {
                      ans$convcode <- 1
                    }
                    ans$nitns <- NA
                    ans$message <- NULL
                    ans$restarts <- NULL
                  }
                  else {
                    if (ctrl$trace > 0) 
                      cat("nmkb failed for current problem \n")
                    ans <- list(fevals = NA)
                    ans$value = ctrl$badval
                    ans$par <- rep(NA, npar)
                    ans$convcode <- 9999
                    ans$fevals <- NA
                    ans$gevals <- NA
                    ans$nitns <- NA
                  }
              }
          }
          else if (meth == "hjkb") {
              if (!is.null(mcontrol$maxit)) {
                  mcontrol$maxfeval <- mcontrol$maxit
              }
              else {
                  mcontrol$maxfeval <- 5000 * round(sqrt(npar + 
                    1))
              }
              mcontrol$info <- FALSE
              if (mcontrol$trace > 0) {
                  mcontrol$info <- TRUE
              }
              else {
                  mcontrol$info <- FALSE
              }
              mcontrol$trace = NULL
              mcontrol$usenumDeriv <- NULL
              mcontrol$maximize <- NULL
              mcontrol$parscale <- NULL
              mcontrol$fnscale <- NULL
              if (!is.null(mcontrol$maxit)) {
                  mcontrol$maxfeval <- mcontrol$maxit
              }
              else {
                  mcontrol$maxfeval <- 5000 * round(sqrt(npar + 
                    1))
              }
              mcontrol$maxit <- NULL
              if (have.bounds) {
                  time <- system.time(ans <- try(dfoptim::hjkb(par = par, 
                    fn = ufn, lower = lower, upper = upper, control = mcontrol, 
                    ...), silent = TRUE))[1]
              }
              else {
                  time <- system.time(ans <- try(dfoptim::hjk(par = par, 
                    fn = ufn, control = mcontrol, ...), silent = TRUE))[1]
              }
              if (class(ans)[1] != "try-error") {
                  ans$convcode <- ans$convergence
                  if (ans$convcode == 1) 
                    ans$convcode = 9999
                  ans$convergence <- NULL
                  ans$value <- as.numeric(ans$value)
                  ans$fevals <- ans$feval
                  ans$feval <- NULL
                  if (ans$fevals > mcontrol$maxfeval) {
                    ans$convcode <- 1
                  }
                  ans$gevals <- NA
                  ans$nitns <- ans$niter
                  ans$niter <- NULL
              }
              else {
                  if (ctrl$trace > 0) 
                    cat("hjkb failed for current problem \n")
                  ans <- list(fevals = NA)
                  ans$value = ctrl$badval
                  ans$par <- rep(NA, npar)
                  ans$convcode <- 9999
                  ans$gevals <- NA
                  ans$nitns <- NA
              }
          }
          else {
              errmsg <- paste("UNDEFINED METHOD: ", meth, sep = "")
              stop(errmsg, call. = FALSE)
          }
          if (ctrl$trace > 0) {
              cat("Post processing for method ", meth, "\n")
          }
          if (exists("ans$message")) {
              amsg <- ans$message
              ans$message <- NULL
          }
          else {
              amsg <- "none"
          }
          ngatend <- NA
          nhatend <- NA
          hev <- NA
          if (ctrl$save.failures || (ans$convcode < 1)) {
              if (ctrl$trace && ans$convcode == 0) 
                  cat("Successful convergence! \n")
              hessOK <- FALSE
              gradOK <- FALSE
              if ((ctrl$kkt || hessian) && (ans$convcode != 9999)) {
                  if (ctrl$trace > 0) 
                    cat("Compute Hessian approximation at finish of ", 
                      method[i], "\n")
                  if (!is.null(uhess)) {
                    nhatend <- try(uhess(ans$par, ...), silent = TRUE)
                    if (class(nhatend) != "try-error") {
                      hessOK <- TRUE
                    }
                  }
                  else {
                    if (is.null(ugr)) {
                      nhatend <- try(hessian(ufn, ans$par, ...), 
                        silent = TRUE)
                    }
                    else {
                      nhatend <- try(jacobian(ugr, ans$par, ...), 
                        silent = TRUE)
                    }
                    if (class(nhatend) != "try-error") {
                      hessOK <- TRUE
                    }
                  }
              }
              ans$kkt1 <- NA
              ans$kkt2 <- NA
              if ((hessian || ctrl$kkt) && (ans$convcode != 9999)) {
                  if (ctrl$trace > 0) 
                    cat("Compute gradient approximation at finish of ", 
                      method[i], "\n")
                  if (is.null(ugr)) {
                    ngatend <- try(grad(ufn, ans$par, ...), silent = TRUE)
                  }
                  else {
                    ngatend <- try(ugr(ans$par, ...), silent = TRUE)
                  }
                  if (class(ngatend) != "try-error") 
                    gradOK <- TRUE
                  if ((!gradOK) && (ctrl$trace > 0)) 
                    cat("Gradient computation failure!\n")
                  if (gradOK) {
                    ans$kkt1 <- (max(abs(ngatend)) <= ctrl$kkttol * 
                      (1 + abs(ans$value)))
                    if (hessOK) {
                      bset <- sort(unique(c(which(ans$par <= lower), 
                        which(ans$par >= upper))))
                      nbds <- length(bset)
                      ngatend[bset] <- 0
                      nhatend[bset, ] <- 0
                      nhatend[, bset] <- 0
                      if (!isSymmetric(nhatend, tol = sqrt(.Machine$double.eps))) {
                        asym <- sum(abs(t(nhatend) - nhatend))/sum(abs(nhatend))
                        asw <- paste("Hessian is reported non-symmetric with asymmetry ratio ", 
                          asym, sep = "")
                        if (ctrl$trace > 1) 
                          cat(asw, "\n")
                        if (ctrl$dowarn) 
                          warning(asw)
                        if (ctrl$trace > 1) 
                          cat("Force Hessian symmetric\n")
                        if (ctrl$dowarn) 
                          warning("Hessian forced symmetric", call. = FALSE)
                        nhatend <- 0.5 * (t(nhatend) + nhatend)
                      }
                      hev <- try(eigen(nhatend)$values, silent = TRUE)
                      if (ctrl$kkt) {
                        if (class(hev) != "try-error") {
                          if (any(is.complex(hev))) {
                            hessOK <- FALSE
                            cat("Complex eigenvalues found for method =", 
                              meth, "\n")
                            cat("coefficients for function value", 
                              ans$value, " :\n")
                            print(ans$par)
                            dput(nhatend, file = "badhess.txt")
                            warning("Complex eigenvalues found for method =", 
                              meth)
                          }
                          if (hessOK) {
                            negeig <- (hev[npar] <= (-1) * ctrl$kkt2tol * 
                              (1 + abs(ans$value)))
                            evratio <- hev[npar - nbds]/hev[1]
                            ans$kkt2 <- (evratio > ctrl$kkt2tol) && 
                              (!negeig)
                          }
                        }
                        else {
                          warnstr <- paste("Eigenvalue failure after method ", 
                            method[i], sep = "")
                          if (ctrl$dowarn) 
                            warning(warnstr)
                          if (ctrl$trace > 0) {
                            cat("Hessian eigenvalue calculation failure!\n")
                            print(nhatend)
                          }
                        }
                      }
                    }
                    else {
                      warnstr <- paste("Hessian not computable after method ", 
                        method[i], sep = "")
                      if (ctrl$dowarn) 
                        warning(warnstr)
                      if (ctrl$trace > 0) 
                        cat(warnstr, "\n")
                    }
                  }
                  else {
                    warnstr <- paste("Gradient not computable after method ", 
                      method[i], sep = "")
                    if (ctrl$dowarn) 
                      warning(warnstr)
                    if (ctrl$trace > 0) 
                      cat(warnstr, "\n")
                  }
              }
              ans$xtimes <- time
              if (ctrl$trace > 0) {
                  cat("Save results from method ", meth, "\n")
                  print(ans)
              }
              if (ctrl$trace > 0) {
                  cat("Assemble the answers\n")
              }
              ans.ret[meth, ] <- c(ans$par, ans$value, ans$fevals, 
                  ans$gevals, ans$nitns, ans$convcode, ans$kkt1, 
                  ans$kkt2, ans$xtimes)
              if (!gradOK) 
                  ngatend <- NA
              if (!hessOK) {
                  nhatend <- NA
                  hev <- NA
              }
          }
          ans.details <- rbind(ans.details, list(method = meth, 
              ngatend = ngatend, nhatend = nhatend, hev = hev, 
              message = amsg))
          row.names(ans.details)[[i]] >= meth
          if (ctrl$follow.on) {
              par <- ans$par
              if (i < nmeth && (ctrl$trace > 0)) 
                  cat("FOLLOW ON!\n")
          }
      }
      ansout <- NULL
      if (length(ans$par) > 0) {
          ansout <- data.frame(ans.ret)
          attr(ansout, "details") <- ans.details
      }
      ansout
  }
  <bytecode: 0x5624e237ce90>
  <environment: namespace:optimx>
   --- function search by body ---
  Function optimx.run in namespace optimx has this body.
   ----------- END OF FAILURE REPORT -------------- 
  Fatal error: the condition has length > 1