Running ‘argclash.R’ [1s/1s]
  Running ‘bdstest.R’ [0s/1s]
  Running ‘exrosen.R’ [0s/0s]
  Running ‘maxfn.R’ [0s/0s]
  Running ‘maxtest.R’ [2s/2s]
  Running ‘run1param.R’ [2s/2s]
  Running ‘tfnchk.R’ [0s/1s]
  Running ‘tgrchk.R’ [0s/1s]
  Running ‘tkktc.R’ [0s/1s]
Running the tests in ‘tests/bdstest.R’ failed.
Complete output:
  > # rm(list=ls())
  > ##  author: John C. Nash
  > # fname<-paste(format(Sys.time(), "%Y%m%d%H%M"),"-btnvm.out",sep='')
  > # sink(fname, append=TRUE, split=TRUE)
  > require("optimx")
  Loading required package: optimx
  > # Following is used when starting from opx21 directory
  > # source("optimx/tests/simplefun.R")
  > # Following is for use in package testing
  > # Simple Test Function 1:
  > simfun.f = function(x) { 
  +      fun <- sum(x^2 )
  + #	print(c(x = x, fun = fun))
  +      fun
  + }
  > simfun.g = function(x) { 
  +      grad<-2.0*x
  +      grad
  + }
  > simfun.h = function(x) { 
  +      n<-length(x)
  +      t<-rep(2.0,n)
  +      hess<-diag(t)
  + }
  > sessionInfo()
  R version 4.4.2 (2024-10-31)
  Platform: x86_64-pc-linux-gnu
  Running under: Debian GNU/Linux trixie/sid
  
  Matrix products: default
  BLAS:   /home/hornik/tmp/R.check/r-release-gcc/Work/build/lib/libRblas.so 
  LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0
  
  locale:
   [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
   [4] LC_COLLATE=C           LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
   [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
  [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
  
  time zone: Europe/Vienna
  tzcode source: system (glibc)
  
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     
  
  other attached packages:
  [1] optimx_2023-10.21
  
  loaded via a namespace (and not attached):
  [1] compiler_4.4.2      nloptr_2.1.1        numDeriv_2016.8-1.1
  [4] pracma_2.4.4       
  > #####################
  > 
  > # This test script illustrates the use of bounds in optimr() with the
  > # optimizers nvm and L-BFGS-B, as well as a Kuhn Karush Tucker check 
  > # on the final parameters from the second optimization.
  > # Masks are tested at the very end for the two methods for which they are
  > # available. Note that they must be called via the opm() function.
  > 
  > 
  > n<-4
  > lower<-rep(0,n)
  > upper<-lower # to get arrays set
  > bdmsk<-rep(1,n)
  > # bdmsk[(trunc(n/2)+1)]<-0
  > for (i in 1:n) { 
  +     lower[i]<-1.0*(i-1)*(n-1)/n
  +     upper[i]<-1.0*i*(n+1)/n
  + }
  > xx<-0.5*(lower+upper)
  > 
  > cat("lower bounds:")
  lower bounds:> print(lower)
  [1] 0.00 0.75 1.50 2.25
  > cat("start:       ")
  start:       > print(xx)
  [1] 0.625 1.625 2.625 3.625
  > cat("upper bounds:")
  upper bounds:> print(upper)
  [1] 1.25 2.50 3.75 5.00
  > 
  > cat("nvm\n") # changed from Rvmmin 2023-10-22
  nvm
  > 
  > abtrvm <- optimr(xx, simfun.f, simfun.g, lower=lower, upper=upper, 
  +         method="nvm", control=list(trace=0))
  > # Note: use lower=lower etc. because there is a missing hess= argument
  > proptimr(abtrvm)
  Result  abtrvm ( nvm  ->  (no_name) ) calc. min. = 7.875  at 
  0 L   0.75 L   1.5 L   2.25 L   
  After  8  fn evals, and  8  gr evals and  0  hessian evals
  Termination code is  2 : NA 
  
  -------------------------------------------------
  > 
  > cat("Axial search")
  Axial search> axabtrvm <- axsearch(abtrvm$par, fn=simfun.f, fmin=abtrvm$value, lower, upper, bdmsk=NULL)
  > print(axabtrvm)
  $bestfn
  [1] 7.875
  attr(,"fname")
  [1] "(no_name)"
  attr(,"method")
  [1] "nvm"
  attr(,"ptype")
  [1] "C"
  
  $par
  [1] 0.00 0.75 1.50 2.25
  attr(,"status")
  [1] "L" "L" "L" "L"
  
  $details
    par0 fback rep.fmin..npar.     ffwd      parstep tilt roc
  1 0.00    NA           7.875 7.875000 3.666853e-07   90 NaN
  2 0.75    NA           7.875 7.875682 4.545258e-04   90 NaN
  3 1.50    NA           7.875 7.877727 9.086849e-04   90 NaN
  4 2.25    NA           7.875 7.881135 1.362844e-03   90 NaN
  
  > 
  > cat("Now force an early stop\n")
  Now force an early stop
  > abtrvm1 <- optimr(xx, simfun.f, simfun.g, lower=lower, upper=upper, method="nvm", 
  +                   control=list(maxit=1, trace=0))
  Warning message:
  In nvm(par = spar, fn = efn, gr = egr, bds = bdmsk, control = mcontrol) :
    Too many gradient evaluations
  > print(abtrvm1)
  $par
  [1] 0.625 1.625 2.625 3.625
  attr(,"status")
  [1] " " " " " " " "
  
  $value
  [1] 8.884958
  attr(,"fname")
  [1] "(no_name)"
  attr(,"method")
  [1] "nvm"
  attr(,"ptype")
  [1] "C"
  
  $counts
  function gradient 
         2        2 
  
  $convergence
  [1] 1
  
  $message
  [1] NA
  
  $scounts
  [1] 2 2 0
  
  > cat("Axial search")
  Axial search> axabtrvm1 <- axsearch(abtrvm1$par, fn=simfun.f, fmin=abtrvm1$value, lower, upper, bdmsk=NULL)
  > print(axabtrvm1)
  $bestfn
  [1] 8.884958
  attr(,"fname")
  [1] "(no_name)"
  attr(,"method")
  [1] "nvm"
  attr(,"ptype")
  [1] "C"
  
  $par
  [1] 0.625 1.625 2.625 3.625
  attr(,"status")
  [1] " " " " " " " "
  
  $details
     par0    fback rep.fmin..npar.     ffwd      parstep      tilt          roc
  1 0.625 23.06203        8.884958 23.06297 0.0003788326 -51.34019 4.152308e-08
  2 1.625 23.05930        8.884958 23.06570 0.0009843780 -72.89727 2.687203e-06
  3 2.625 23.05416        8.884958 23.07085 0.0015899235 -79.21570 2.721735e-05
  4 3.625 23.04659        8.884958 23.07842 0.0021954689 -82.14669 1.332738e-04
  
  > 
  > 
  > cat("Maximization test\n")
  Maximization test
  > mabtrvm <- optimr(xx, simfun.f, simfun.g, lower=lower, upper=upper, method="nvm", 
  +                  control=list(trace=1, maximize=TRUE))
  admissible =  TRUE 
  maskadded =  FALSE 
  parchanged =  FALSE 
  Parameter scaling:[1] 1 1 1 1
  nvm -- J C Nash 2009-2015 - an R implementation of Alg 21
  Problem of size n= 4 
  Initial fn= -23.0625 
  ig= 1   gnorm= 9.604686     1   1   -23.0625 
  ig= 2   gnorm= 8.689381     2   2   -43.87634 
  No acceptable point
  Reset to gradient search
    2   2   -43.87634 
  ig= 3   gnorm= 4.974424     3   3   -45.24872 
  No acceptable point
  Reset to gradient search
    3   3   -45.24872 
  ig= 4   gnorm= 1.923077     4   4   -46.23706 
  No acceptable point
  Reset to gradient search
    4   4   -46.23706 
  ig= 5   gnorm= 0   Seem to be done nvm
  admissible =  TRUE 
  maskadded =  FALSE 
  parchanged =  FALSE 
  At least one parameter is on a bound
  existing parameter status:[1] "?" "?" "?" "?"
  > # Note: use lower=lower etc. because there is a missing hess= argument
  > print(mabtrvm)
  $par
  [1] 1.25 2.50 3.75 5.00
  attr(,"status")
  [1] "U" "U" "U" "U"
  
  $value
  [1] 46.875
  attr(,"fname")
  [1] "(no_name)"
  attr(,"method")
  [1] "nvm"
  attr(,"ptype")
  [1] "C"
  
  $counts
  function gradient 
         5        5 
  
  $convergence
  [1] 2
  
  $message
  [1] NA
  
  $scounts
  [1] 5 5 0
  
  > cat("Do NOT try axsearch() with maximize\n")
  Do NOT try axsearch() with maximize
  > cat("KKT condition check\n")
  KKT condition check
  > akktm <- kktchk(mabtrvm$par, simfun.f, simfun.g, hess=NULL, upper=upper, lower=lower,  
  +               maximize=TRUE, control=list(trace=0))
  Warning message:
  In kktchk(mabtrvm$par, simfun.f, simfun.g, hess = NULL, upper = upper,  :
    All parameters are constrained
  > print(akktm)
  $gmax
  [1] 0
  
  $evratio
  [1] NA
  
  $kkt1
  [1] TRUE
  
  $kkt2
  [1] TRUE
  
  $hev
  [1] 0 0 0 0
  
  $ngatend
  [1]  2.5  5.0  7.5 10.0
  attr(,"status")
  [1] "U" "U" "U" "U"
  
  $nhatend
       [,1] [,2] [,3] [,4]
  [1,]   -2    0    0    0
  [2,]    0   -2    0    0
  [3,]    0    0   -2    0
  [4,]    0    0    0   -2
  
  > 
  > alb<-optimr(xx,simfun.f, simfun.g, lower=lower, upper=upper, method="L-BFGS-B", 
  +             control=list(trace=0))
  > print(alb)
  $par
  [1] 0.00 0.75 1.50 2.25
  attr(,"status")
  [1] "L" "L" "L" "L"
  
  $value
  [1] 7.875
  attr(,"fname")
  [1] "(no_name)"
  attr(,"method")
  [1] "L-BFGS-B"
  attr(,"ptype")
  [1] "C"
  
  $counts
  function gradient 
         2        2 
  
  $convergence
  [1] 0
  
  $message
  [1] "CONVERGENCE: NORM OF PROJECTED GRADIENT <= PGTOL"
  
  $scounts
  [1] 2 2 0
  
  > 
  > cat("KKT condition check\n")
  KKT condition check
  > alkkt <- kktchk(alb$par, simfun.f, simfun.g, hess=NULL, upper=upper, lower=lower,  maximize=FALSE, control=list(trace=0))
  Warning message:
  In kktchk(alb$par, simfun.f, simfun.g, hess = NULL, upper = upper,  :
    All parameters are constrained
  > print(alkkt)
  $gmax
  [1] 0
  
  $evratio
  [1] NA
  
  $kkt1
  [1] TRUE
  
  $kkt2
  [1] TRUE
  
  $hev
  [1] 0 0 0 0
  
  $ngatend
  [1] 0.0 1.5 3.0 4.5
  attr(,"status")
  [1] "L" "L" "L" "L"
  
  $nhatend
       [,1] [,2] [,3] [,4]
  [1,]    2    0    0    0
  [2,]    0    2    0    0
  [3,]    0    0    2    0
  [4,]    0    0    0    2
  
  > 
  > alhn<-optimr(xx, simfun.f, lower=lower, upper=upper, method="hjn", 
  +              control=list(trace=0))
  > print(alhn)
  $par
  [1] 0.00 0.75 1.50 2.25
  attr(,"status")
  [1] "L" "L" "L" "L"
  
  $value
  [1] 7.875
  attr(,"fname")
  [1] "(no_name)"
  attr(,"method")
  [1] "hjn"
  attr(,"ptype")
  [1] "C"
  
  $counts
  [1] 70 NA
  
  $convergence
  [1] 0
  
  $message
  [1] "hjn success"
  
  $scounts
  [1] 70  0  0
  
  > 
  > #sink()
  > cat("All bounded methods attempt with opm\n") # ?? should give errors
  All bounded methods attempt with opm
  > allbds <- opm(xx, simfun.f, simfun.g, lower=lower, upper=upper, method="MOST", control=list(trace=0))
  Non-bounds methods requested:[1] "Nelder-Mead" "nlm"         "ucminf"      "subplex"     "mla"        
  [6] "pracmanm"   
  Error in loadNamespace(x) : there is no package called 'lbfgsb3c'
  In addition: Warning messages:
  1: In opm(xx, simfun.f, simfun.g, lower = lower, upper = upper, method = "MOST",  :
    A method requested does not handle bounds
  2: In opm(xx, simfun.f, simfun.g, lower = lower, upper = upper, method = "MOST",  :
    'snewtm' removed from 'method' -- no hess()
  3: In checksolver(method, control$allmeth, control$allpkg) :
    Package lbfgsb3c for method lbfgsb3c( is not available
  Error in ans$convergence : $ operator is invalid for atomic vectors
  Calls: opm -> system.time -> optimr
  Timing stopped at: 0.002 0 0.002
  Execution halted