From @te|@nML @end|ng |rom co||oc@t|on@@de  Sat Feb  2 10:47:50 2019
From: @te|@nML @end|ng |rom co||oc@t|on@@de (Stefan Evert)
Date: Sat, 2 Feb 2019 10:47:50 +0100
Subject: [Rd] nlminb with constraints failing on some platforms
In-Reply-To: <CAL6gwnJUGZ+r6aD6EnKG=6s8s-WU12tw60eWbOTULhexRFgWYQ@mail.gmail.com>
References: <b83bb3a0e9674e198eb53d3682171804@dtu.dk>
 <23636.2761.752118.1610@stat.math.ethz.ch>
 <4e92eee6-a8f2-02bc-5e11-3c27b18e2339@sapo.pt>
 <CAL6gwnJUGZ+r6aD6EnKG=6s8s-WU12tw60eWbOTULhexRFgWYQ@mail.gmail.com>
Message-ID: <772BF803-96C8-4CFF-9D8D-5738D5DE3974@collocations.de>

Also no error on MacOS 10.13.6, R 3.5.1 with system-supplied VecLib BLAS.

> > f <- function(x) sum( log(diff(x)^2+.01) + (x[1]-1)^2 )
> > opt <- nlminb(rep(0, 10), f, lower=-1, upper=3)
> > str(opt)
> List of 6
>  $ par        : num [1:10] 1 1 1 1 1 ...
>  $ objective  : num -41.4
>  $ convergence: int 0
>  $ iterations : int 65
>  $ evaluations: Named int [1:2] 92 773
>   ..- attr(*, "names")= chr [1:2] "function" "gradient"
>  $ message    : chr "relative convergence (4)"
> > xhat <- rep(1, 10)
> > all.equal(opt$par,         xhat,  tol=0) # good: 5.53 e-7
> [1] "Mean relative difference: 3.368798e-06"
> > all.equal(opt$objective, f(xhat), tol=0) # good: 1.8 e-12
> [1] "Mean relative difference: 1.09683e-11"
> > abs( opt$objective - f(xhat) ) < 1e-4  ## Must be TRUE
> [1] TRUE



[Rd] nlminb with constraints failing on some platforms
Stefan Evert