From ripley at stats.ox.ac.uk  Wed Apr 21 08:57:34 2004
From: ripley at stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Wed Apr 21 08:57:36 2004
Subject: [Rd] optim-Bug (PR#6720)
Message-ID: <20040421065734.80BA6104C7@slim.kubism.ku.dk>

On 21 Apr 2004, Peter Dalgaard wrote:

> kestler@neuro.informatik.uni-ulm.de writes:
> 
> > Full_Name: Dr. Hans A. Kestler
> > Version: 1.8.1.
> > OS: Linux, Win, Mac OSX
> > Submission from: (NULL) (134.60.73.116)
> > 
> > 
> > The code below produces after a different number of iterations i the following
> > error:
> > 
> > Error in optim(par = rep(0.5, length(edges)), loglik, method = "L-BFGS-B",  :
> >         non-finite value supplied by optim
> > 
> > This was reproducible on different machines (Mac G4 OSX, AMD Opteron Linux SUSE
> > 9.0, Intel P4 Suse 9.0, P4 Windows XP Prof), only with different i.
> > 
> > The non-deterministic behaviour made us recompile R with debug options and use
> > valgrind for memory-leak checking. The result was horrible. We are now in the
> > process of going through the f2c code of lbfgsb.c. The problem seems to be a
> > access violation of wn1 at run time. 
> 
> I have this down to the use of R_alloc in the vect() function (line
> 40, optim.c). Replacing with S_alloc (which zeros memory) removes the
> issue for me on this machine and on the Opteron. Could you please
> verify on other platforms? And if anyone actually understands the code
> could you verify that it makes sense to require the workspace to be
> initialized?

Zeroing the workspace is not a requirement of the original L-BFGS-B code 
that I can see.  Given that it was originally in Fortran, and Fortran 
often does zero it seems a likely symptom, but it does mean that a 
variable is being used uninitialized somewhere in the code (converted to 
C).  It would be better to leave vect alone and to zero the workspace with 
a memset call in lbfgsb.  (Incidentally, I don't know why S_alloc does not 
use memset -- we do require standard C and use in seeral other places.)

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] optim-Bug (PR#6720)
ripley@stats.ox.ac.uk