<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Lucida Console";
        panose-1:2 11 6 9 4 5 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Just joined the list. I’ve searched online for help, and could find little mention of the problem I’m having, and zero solutions. I’m getting a strange error message when using Rcpp to combine a C-implementation of some simple linear ODEs
 with deSolve in package “popED”. (It’s a package for optimal design of experiments. Because it relies on repeated solution of the ODEs at each iterative step, a pure-R implementation is too slow for me on non-trivial problems.)
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’ve attached the R code (it implements a pure-R/deSolve solution, then a deSolve/Rcpp implementation). The problem is one of pharmacokinetics: what’s the optimal time (or dose) to use in order to best estimate parameters that describe
 drug absorption, distribution and elimination from the body, using the parameters KA, V, and CL respectively. The design can be constrained in a number of ways. The script does two things for each model implementation: first it evaluates an initial design,
 second it attempts to optimize that design by parameter search, which requires repeated evaluation of the (ODE-based) model. Strange thing is: it all works fine for the initial model evaluation, so the code works (and Rcpp is 3x faster, expect bigger gains
 in the optimization step). But then it falls over in the model optimization step:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:blue">> tic(); output <- poped_optim(poped.db.compiled, opt_xt =TRUE, parallel=F, method = c("LS")); toc()<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:#C5060B">Error in lsoda(y, times, func, parms, ...) :
<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:#C5060B">  Confusion over the length of parms<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:#C5060B">In addition: Warning message:<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:#C5060B">In lsoda(y, times, func, parms, ...) :<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:#C5060B">  Number of parameters passed to solver, 3; number in DLL, 5<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">Called from: lsoda(y, times, func, parms, ...)<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt">How can it run to evaluate the model, then fail when it comes to optimization? Since the error is coming from LSODA (the solver that is wrapped by deSolve), I’m guessing the problem
 lies in interface between deSolve and the code I’ve got. I’m no stranger to language extension (years ago, I used SWIG to extend some Python libraries with C code), but I’m struggling to understand where to look for the source of this problem. In particular,
 it’s telling me the DLL has 5 parameters, but I just don’t see where that could be coming from: I explicitly pass in three parameters (the KA, V, and CL from above). Does Rcpp inject extras that are somehow being exposed inappropriately?<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt">One last thing: you may look at this model and ask why I’m not using the obvious closed-form solution for the concentration profile – that’s the fastest way to the answer. The
 answer is that this isn’t really the problem I’m interested in, and those don’t have an easy closed-form solution.<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt">Would really appreciate any pointers you can give. Many thanks and kind regards,<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt">-Frank<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="1110" style="width:9.25in;background:white">
<tbody>
<tr>
<td width="1110" valign="top" style="width:9.25in;padding:0in 0in 6.0pt 4.5pt">
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="1103" style="width:661.5pt">
<tbody>
<tr>
<td width="1011" valign="top" style="width:606.75pt;padding:0in 0in 0in 0in">
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Lucida Console";color:blue"><o:p></o:p></span></p>
</td>
<td style="border:none;padding:0in 0in 0in 0in" width="91">
<p class="MsoNormal"> </p>
</td>
</tr>
<tr>
<td width="1103" colspan="2" valign="top" style="width:661.5pt;background:white;padding:0in 0in 6.0pt 4.5pt">
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt">P.S.<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:blue">> R.Version()<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$platform<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "x86_64-w64-mingw32"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$arch<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "x86_64"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$os<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "mingw32"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$system<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "x86_64, mingw32"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$status<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] ""<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$major<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "3"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$minor<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "3.2"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$year<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "2016"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$month<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "10"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$day<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "31"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$`svn rev`<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "71607"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$language<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "R"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$version.string<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "R version 3.3.2 (2016-10-31)"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">$nickname<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black">[1] "Sincere Pumpkin Patch"<o:p></o:p></span></p>
<p class="MsoNormal" style="word-break:break-all"><span style="font-size:10.0pt;font-family:"Lucida Console";color:black"><o:p> </o:p></span></p>
</td>
</tr>
<tr>
<td width="1103" colspan="2" valign="top" style="width:661.5pt;background:white;padding:0in 0in 6.0pt 4.5pt">
</td>
</tr>
<tr>
<td width="1103" colspan="2" valign="top" style="width:661.5pt;background:white;padding:0in 0in 6.0pt 4.5pt">
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="1011" style="width:606.75pt">
<tbody>
<tr>
<td width="1" valign="top" style="width:.6pt;padding:0in 0in 0in 0in">
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Lucida Console";color:blue">>
<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#8B0051">Frank Gibbons, PhD</span></b><b><span style="font-size:8.0pt;font-family:"Arial",sans-serif"><o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Arial",sans-serif">Principal Scientist<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Arial",sans-serif">_____________________________________________________________________________________________<o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:8.0pt;font-family:"Arial",sans-serif;color:#8B0051">DMPK Modeling & Simulation</span></b><b><span style="font-size:8.0pt;font-family:"Verdana",sans-serif;color:#8B0051">
</span></b><b><span style="font-size:8.0pt;font-family:"Arial",sans-serif;color:#8B0051">| IMED Oncology | AstraZeneca<o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Arial",sans-serif">35 Gatehouse Lane, Waltham MA  02451, USA<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:"Arial",sans-serif">+1-781-839-4032  
<u><span style="color:#3F1E68"><a href="mailto:frank.gibbons@astrazeneca.com">frank.gibbons@astrazeneca.com</a></span></u><span style="color:#3F1E68">
</span> <o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<hr>
<p class="{Imprint.UniqueID}" style="FONT-SIZE: 8pt"><font face="Arial" size="1"></font></p>
<p class="{Imprint.UniqueID}" style="FONT-SIZE: 8pt"><font face="Arial"><strong>Confidentiality Notice:
</strong>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.</font></p>
<p class="{Imprint.UniqueID}" style="FONT-SIZE: 8pt"><font face="Arial"></font></p>
<p class="{Imprint.UniqueID}" style="FONT-SIZE: 8pt"><font face="Arial"></font></p>
<p class="{Imprint.UniqueID}" style="FONT-SIZE: 8pt"><font face="Arial"></font></p>
<p class="{Imprint.UniqueID}" style="FONT-SIZE: 8pt"><font face="Arial"></font></p>
<p class="{Imprint.UniqueID}" style="FONT-SIZE: 8pt"><font face="Arial"></font></p>
<p class="{Imprint.UniqueID}" style="FONT-SIZE: 8pt"><font face="Arial"></font><font size="+0"></font></p>
<p class="{Imprint.UniqueID}" style="FONT-SIZE: 8pt"><font face="Arial"></font></p>
<p class="{Imprint.UniqueID}" style="FONT-SIZE: 8pt"></p>
<p class="{Imprint.UniqueID}" style="FONT-SIZE: 8pt"></p>
</body>
</html>