Learn R Programming

RxODE (version 0.6-1)

rx.initCmpMgr: A compilation manager for RxODE models

Description

This function parses, compiles, links, and loads the shared object that implements an RxODE model.

Usage

rx.initCmpMgr(model, modName, wd, extraC = NULL, debug = TRUE,
  mmod = FALSE, calcJac = NULL, calcSens = NULL, collapseModel = FALSE)

Arguments

model

This is the ODE model specification. It can be:

  • a string containing the set of ordinary differential equations (ODE) and other expressions defining the changes in the dynamic system.

  • a file name where the ODE system equation is contained

  • An ODE expression enclosed in {}

(see also the filename argument). For details, see the sections “Details” and “RxODE Syntax” below.

modName

a string to be used as the model name. This string is used for naming various aspects of the computations, including generating C symbol names, dynamic libraries, etc. Therefore, it is necessary that modName consists of simple ASCII alphanumeric characters starting with a letter.

wd

character string with a working directory where to create a subdirectory according to modName. When specified, a subdirectoy named after the “modName.d” will be created and populated with a C file, a dynamic loading library, plus various other working files. If missing, the files are created (and removed) in the temporary directory, and the RxODE DLL for the model is created in the current directory named rx_????_platform, for example rx_129f8f97fb94a87ca49ca8dafe691e1e_i386.dll

extraC

Extra c code to include in the model. This can be useful to specify functions in the model. These C functions should usually take double precision arguments, and return double precision values.

debug

is a boolean indicating if the executable should be compiled with verbose debugging information turned on.

mmod

A boolean telling if the modName from RxODE was missing. This affects how the model is created and used.

calcJac

boolean indicating if RxODE will calculate the Jacobain according to the specified ODEs.

calcSens

boolean indicating if RxODE will calculate the sennsitivities according to the specified ODEs.

collapseModel

boolean indicating if RxODE will remove all LHS variables when calculating sensitivites.

Value

An object (closure) with the following member functions:

parse

this function parses (translates) the ODE-based model specification and generates a C file to implement the model.

compile

compiles the generated C file for the ODE system and dynamically loads the machine code in the shared object.

dynLoad

if needed, dynamically loads the dynamic library produced in the compile() step. Note that the shared object persists across R sessions, thus the dynLoad needs to be issued as needed.

dynUnload

this function unloads the previously dynamically loaded model object code. Mainly for internal use.

ode_solver

a string with the name of the C symbol for this model solver.

dllfile

a string with the name of the dynamic link (or shared object) file.

get.modelVars

function that returns a list with 3 character vectors, params, state, and lhs of variable names (identifiers) used in the model specification. These will be output when the model is computed (i.e., the ODE solved).

isValid

a function that (naively) checks for model validity, namely that the C object code reflects the latest model specification.

get.index

helper function to extract the index of one or more system variables (state, parameter, or other).

getObj

internal (not user callable) function.

Details

The function parses and compiles (if needed) the RxODE model specified in the string model into a dynamic link library (DLL on Windows) or a shared object (*.so on Unix-like systems).

It then dynamically loads this code into the current R session. (Models previously parsed and compiled in previous R sessions only need to be dynamically loaded into the current R session.)

See Also

RxODE

Examples

Run this code
# NOT RUN {
  cmpMgt <- rx.initCmpMgr(model, "tst1", wd = ".")
# }

Run the code above in your browser using DataLab