It looks like my attached files didn't go through, so I'll put them in a
public Dropbox folder instead;
optim_rhelp.tar.gz<http://dl.dropbox.com/u/1113102/optim_rhelp.tar.gz>

Thanks, I'll run a compiled binary of the C++ code through Valgrind & see
what it reports, then perhaps I'll try an Rscript execution of the R code
calling the C++ in optim (not sure if Valgrind can process that though!).

It does seem to be a memory error of some kind, since occasionally the OS
pops up a crash report referencing a segmentation fault after optim crashes
the R session. Though it is strange that the code has never crashed from a
straight .C call in R, or when run from a compiled C++ binary.

- Paul

On 4 November 2012 09:35, Patrick Burns <pbu...@pburns.seanet.com> wrote:

> That is a symptom of the C/C++ code doing
> something like using memory beyond the proper
> range.  It's entirely possible to have crashes
> in some contexts but not others.
>
> If you can run the C code under valgrind,
> that would be the easiest way to find the
> problem.
>
> Pat
>
>
> On 03/11/2012 18:15, Paul Browne wrote:
>
>> Hello,
>>
>> I am attempting to use optim under the default Nelder-Mead algorithm for
>> model fitting, minimizing a Chi^2 statistic whose value is determined by a
>> .C call to an external shared library compiled from C & C++ code.
>>
>> My problem has been that the R session will immediately crash upon
>> starting
>> the simplex run, without it taking a single step.
>>
>> This is strange, as the .C call itself works, is error-free (as far as I
>> can tell!) & does not return NAN or Inf under any initial starting
>> parameters that I have tested it with in R. It only ever crashes the R
>> session when the Chi^2 function to be minimized is called from optim, not
>> under any other circumstances.
>>
>> In the interests of reproducibility, I attach R code that reads attached
>> data files & attempts a N-M optim run. The required shared library
>> containing the external code (compiled in Ubuntu 12.04 x64 with g++ 4.6.3)
>> is also attached. Calculating an initial Chi^2 value for a starting set of
>> model parameters works, then the R session crashes when the optim call is
>> made.
>>
>> Is there something I'm perhaps doing wrong in the specification of the
>> optim run? Is it inadvisable to use external code with optim? There
>> doesn't
>> seem to be a problem with the external code itself, so I'm very stumped as
>> to the source of the crashes.
>>
>>
>>
>> ______________________________**________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
> --
> Patrick Burns
> pbu...@pburns.seanet.com
> twitter: @portfolioprobe
> http://www.portfolioprobe.com/**blog <http://www.portfolioprobe.com/blog>
> http://www.burns-stat.com
> (home of 'Some hints for the R beginner'
> and 'The R Inferno')
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to