[R-sig-dyn-mod] Different solutions using deSolve::ode() with 32 and 64 Bit systems: Problem for sensitivity analysis

Thomas Petzoldt thomas.petzoldt at tu-dresden.de
Thu Jun 2 16:40:33 CEST 2016


Hi,

I was able to reproduce your example (R 3.2.4/Windows) and found tiny 
differences, which are in the order of the machine precision, e.g. for 
the state variable TOC:

summary((x64$out[,"TOC"] - x32$out[,"TOC"])/x64$out[,"TOC"])
       Min.    1st Qu.     Median       Mean    3rd Qu.       Max.
-3.463e-15 -7.136e-16 -2.041e-16 -3.409e-16  1.431e-16  4.276e-16


I would not call this "strange", because a numerical solution of a DE is 
an approximation by definition, and it's the tolerance specified by atol 
and rtol that counts.


I remember a related discussion some years ago, see the post of Brian 
Ripley:

https://stat.ethz.ch/pipermail/r-devel/2011-February/059885.html


Thomas


On 02.06.2016 15:38, Johannes Friedrich wrote:
> Dear Ladies and Gentlemen,
>
> during the last days I made a strange observation concerning the package
> "FME" and "deSolve".
> I used a local sensitivity analysis in my R-package and also made a
> little example in the manual of the package. To check the performance, I
> sent my package to the win-builder and I compared the results between
> examples_i386 and examples_x64. And the result was, that the sensitivity
> analysis using the function /FME::sensFun() /produces NOT the same using
> R 32 Bit or R 64 Bit.
>
> I then made a little comparison and a reproducible example (from the FME
> vignette):
> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> /library("deSolve")//
> //library("FME")//
> //pars <- list(gmax = 0.5, eff = 0.5, ks = 0.5, rB = 0.01, dB = 0.01)//
> //
> //solveBact <- function(pars, times=seq(0, 50, by=0.5)) {//
> //    derivs <- function(t, state, pars) {//
> //        with(as.list(c(state, pars)), {//
> //            dBact <- gmax*eff*Sub/(Sub+ks)*Bact - dB*Bact - rB*Bact//
> //              dSub <- -gmax*Sub/(Sub+ks)*Bact + dB*Bact//
> ////
> //                return(list(c(dBact, dSub), TOC = Bact + Sub))//
> //
> //        })//
> //      }//
> //    state <- c(Bact = 0.1, Sub = 100)//
> //      return(ode(y = state, times = times, func = derivs, parms = pars))//
> //}//
> //
> //out <- solveBact(pars)//
> //
> //SnsBact <- sensFun(func = solveBact, //
> //                  parms = pars, //
> //                  sensvar = "Bact", //
> //                  varscale = 1)/
> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> Running  this little example with R (3.3.0) 32 Bit and 64 Bit gives not
> the same results. You can check this, e.g.
> /identical(SnSBact$gmax_x64, SnSBact$gmax_x32)/.
> Also the solution of the differential equations using /deSolve::ode()/
> are not the same (/identical(out[,"TOC"], out_x64[,"TOC"])/)
> In this example this has only little effects, but with bigger models
> (like my package) the differences are enormous.
>
>    * Has someone ever detected the same problems?
>
>    * Comes the problem for the sensitivity analysis from the different
>      ODE solutions, or is the problem also part of the /FME::sensFun()/
>      function?
>
> Thanks for any pointers,
> Johannes
>



More information about the R-sig-dynamic-models mailing list