<div dir="ltr"><span style="font-size:12.8px">Frank - </span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">In the code you provided, it looks like it is "poped.db.compiled.rcpp", not "poped.db.compiled".  </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">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.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">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. </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">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?</div><div style="font-size:12.8px">I maintain mrgsolve: <a href="https://github.com/metrumresearchgroup/mrgsolve" target="_blank">https://github.com/<wbr>metrumresearchgroup/mrgsolve</a></div><div style="font-size:12.8px">You could also look at RxODE: <a href="https://cran.r-project.org/web/packages/RxODE/index.html" target="_blank">https://cran.r-project.<wbr>org/web/packages/RxODE/index.<wbr>html</a></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Hope that helps ...</div><div style="font-size:12.8px">Kyle</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 22, 2017 at 7:50 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Frank,<br>
<br>
That's a pretty long message and a lot of code.  Can you try to distill it<br>
down to a particular (smaller?) issue?<br>
<br>
And FWIW I cannot run. After saving your attachment, and installing PopED, I<br>
get<br>
<br>
R> source("/tmp/myExampleODE.<wbr>compiled.R")<br>
<br>
Attaching package: ‘deSolve’<br>
<br>
The following object is masked from ‘package:graphics’:<br>
<br>
    matplot<br>
<br>
Elapsed time: 10.425 seconds.<br>
Error in poped.db$settings$optsw[2] <- opt_xt :<br>
  object 'poped.db.compiled' not found<br>
R><br>
<br>
I also recommend the rbenchmark and microbenchmark packages over tic() and toc().<br>
<br>
Sorry that I have no quick fix.<br>
<span class="HOEnZb"><font color="#888888"><br>
Dirk<br>
<br>
--<br>
<a href="http://dirk.eddelbuettel.com" rel="noreferrer" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
______________________________<wbr>_________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-<wbr>project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-<wbr>project.org/cgi-bin/mailman/<wbr>listinfo/rcpp-devel</a></font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Kyle Baron<div><div>Metrum Research Group</div><div><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice"><span title="Call with Google Voice">860-735-7043, Ext. 202<br></span></span></span></span></span></span></span></span></span></span></span></div><div><span style="font-family:Helvetica;font-size:12px"><a href="mailto:kyleb@metrumrg.com" target="_blank">kyleb@metrumrg.com</a></span></div><div><br></div></div></div></div>
</div>