[Rcpp-devel] Using Rcpp to solve ODEs: LSODE (deSolve) says "Confusion over the length of parms"

Tim Keitt tkeitt at utexas.edu
Wed Jan 25 19:13:52 CET 2017


There's also https://github.com/thk686/odeintr (use the devel version, not
CRAN -- need to upload a bug fix).

THK

http://www.keittlab.org/

On Wed, Jan 25, 2017 at 11:33 AM, Gibbons, Frank <
Frank.Gibbons at astrazeneca.com> wrote:

> Kyle,
>
>
>
> D’oh! You’re absolutely right. Embarrassing. :-}
>
> (I’m told that’s the emoticon for ‘sheepish grin’.)
>
>
>
> I did try going the way suggested by deSolve, but find that (for reasons
> unknown to me), “R CMD SHLIB” compiles the object file but not the DLL
> (error about not having permission).
>
>
>
> I wasn’t aware of RxODE at all (and only vaguely familiar with mrgsolve),
> but installed it, read through the tutorial (from the journal CPT-PSP), and
> within a few hours was in business. It won’t be for everyone of course,
> since it’s specialized for PK/PD modeling, but it enabled me to get a 15x
> performance improvement in my application (which requires repeated model
> evaluation to optimize a study design). This is huge: over-lunchbreak vs
> over-night. If the speedup reported by the authors in their tutorial
> applies to my situation, this improvement factor will improve as the model
> grows (currently just 2 ODEs).
>
>
>
> For those with similar goals as mine (PK/PD models), highly recommend it.
> Much like Rcpp, it enables specification of both the compiled and
> non-compiled parts of the code in a single file. But like SHLIB, it
> compiles behind the scenes (few seconds), and while I don’t fully
> understand what’s going on under the hood, it performs as if there’s a
> minimum of back-and-forth between R and C.
>
>
>
> Many thanks to you both
>
>
>
> -Frank
>
>
>
> *From:* Kyle Baron [mailto:kyleb at metrumrg.com]
> *Sent:* Monday, January 23, 2017 1:35 PM
> *To:* Dirk Eddelbuettel <edd at debian.org>
> *Cc:* Gibbons, Frank <Frank.Gibbons at astrazeneca.com>;
> rcpp-devel at lists.r-forge.r-project.org
> *Subject:* Re: [Rcpp-devel] Using Rcpp to solve ODEs: LSODE (deSolve)
> says "Confusion over the length of parms"
>
>
>
> Frank -
>
>
>
> In the code you provided, it looks like it is "poped.db.compiled.rcpp",
> not "poped.db.compiled".
>
>
>
> I found that, after making the change to fix the error that Dirk pointed
> out, the code appears to work with no error (attached).  I don't know if
> the results are what you were intending, however.
>
>
>
> Also: I would not set up the optimization like this.  When you create
> the one_comp_oral_ode function with cppFunction and hand that off to
> deSolve, you are still passing along an R function to get called.  Even if
> the calculations are accomplished with Rcpp, it still an R function.  So
> every step the solver takes, it will have to call an R function.  I don't
> think this is what you want. When you write the ode function as suggested
> by the deSolve package vignette, you pass off the name of a C function and
> the solver calls that C function directly as the system advances.  It will
> be faster than what you are doing with cppFunction.
>
>
>
> Finally, I'll ask if you have looked at one of the more-modern simulation
> packages for R that are designed for PK/PD work?
>
> I maintain mrgsolve: https://github.com/metrumresearchgroup/mrgsolve
>
> You could also look at RxODE: https://cran.r-project.
> org/web/packages/RxODE/index.html
>
>
>
> Hope that helps ...
>
> Kyle
>
>
>
>
>
>
>
> On Sun, Jan 22, 2017 at 7:50 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
>
> Frank,
>
> That's a pretty long message and a lot of code.  Can you try to distill it
> down to a particular (smaller?) issue?
>
> And FWIW I cannot run. After saving your attachment, and installing PopED,
> I
> get
>
> R> source("/tmp/myExampleODE.compiled.R")
>
> Attaching package: ‘deSolve’
>
> The following object is masked from ‘package:graphics’:
>
>     matplot
>
> Elapsed time: 10.425 seconds.
> Error in poped.db$settings$optsw[2] <- opt_xt :
>   object 'poped.db.compiled' not found
> R>
>
> I also recommend the rbenchmark and microbenchmark packages over tic() and
> toc().
>
> Sorry that I have no quick fix.
>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
>
>
>
>
> --
>
> Kyle Baron
>
> Metrum Research Group
>
> 860-735-7043, Ext. 202 <(860)%20735-7043>
>
> kyleb at metrumrg.com
>
>
> ------------------------------
>
> *Confidentiality Notice: *This message is private and may contain
> confidential and proprietary information. If you have received this message
> in error, please notify us and remove it from your system and note that you
> must not copy, distribute or take any action in reliance on it. Any
> unauthorized use or disclosure of the contents of this message is not
> permitted and may be unlawful.
>
>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20170125/6c008d42/attachment-0001.html>


More information about the Rcpp-devel mailing list