Open-Systems-Pharmacology / OSPSuite.CPP-Toolbox

0 stars 3 forks source link

R interface extension for compiled models #9

Closed hdiedam closed 1 year ago

hdiedam commented 3 years ago

(@Yuri05 @msevestre @PavelBal as probably the most interested ones ;-))

Hi everyone, while taking a look at the version 10 beta, I saw that you exposed the C++ export via the R interface. To tried out the export a bit and because I saw the usage within the R interface on the roadmap, I extended the OSPsuite.R package by an interface to the compiled simulations. This introduces an additional dependency to Rcpp and the RTools, therefore I set it up as an additional package "ospsuiteCpp" for now and integrated it into the CPP-Toolbox repository. An example to try it out is contained in the vignette.

The interface is rudimentary, but as one can export multiple functions with Rcpp, it's a lot more straight forward to maintain and extend compared to the existing Matlab interface. I tried to document the functions and keep the directory structure as tidy as possible. For the integration, the precompiled CVODES is used and therefore I also added exactly those headers via a submodule. Performance-wise a nice to have would be the KLU library linked in CVODES in one of the next updates to enable the sparse Jacobians.

One issue that remains it that the old Matlab and R interface relied on DCI and the corresponding row indices. Therefore, the exported model used the long id's in SimModelNative to map to the internal ones. In the exported R interface I only saw the string ids. This makes it currently hard to determine the correct order in the parameter vector.

I hope that helps and best regards, Holger

PavelBal commented 3 years ago

@hdiedam Awesome!

@Yuri05 @msevestre What do you think - should it be part of ospsuite-r or remain as a separate package?

msevestre commented 1 year ago

I am going to close this PR as this has been open for almost 2 years. We can revisit and recreate from the branch if we are ready eventually