View source: R/plainMethod_buildFromText.r
buildFromText | R Documentation |
The function builds a rodeo
-based model by importing
all declarations and equations from tables stored as delimited text.
buildFromText(
declarations,
equations,
sep = "\t",
dim = 1,
set_defaults = TRUE,
fortran = FALSE,
sources = NULL,
...
)
declarations |
File path of a delimited text file holding the declaration of state variables, parameters, and functions. See below for details about the expected file contents. |
equations |
File path of a delimited text file holding mathematical expressions of process rates and stoichiometric factors forming the right hand sides of a system of simultaneous ODE. See below for details about the expected file contents. |
sep |
The column delimiter used in the input text files. |
dim |
The number of spatial compartments, possibly in multiple
dimensions. For single-box models without spatial resolution, use
|
set_defaults |
If |
fortran |
Controls the language of code generation. The default
( |
sources |
Only relevant if |
... |
Optional arguments passed to |
An object of class rodeo
.
The delimited text files provided as input are parsed by
read.table
with header=TRUE
and the delimiter
specified by sep
. The files must contain the following:
'declarations' Declares the identifiers of state variables,
parameters, and functions used in the model equations. Mandatory columns
are 'type', 'name', 'unit', 'description', and 'default'. Entries in
the type column must be one of 'variable', 'parameter', or 'function'.
If source code is generated for R (fortran=FALSE
), any declared
functions must be accessible in the environment where the model is
run. If fortran=TRUE
, the functions must be implemented in the
file(s) listed in sources
to be included in compilation.
Entries in the 'name' column must be unique, valid identifier names
(character followed by characters, digits, underscore).
Entries in the 'default' column shall be numeric.
'equations' Specifies the model equations. Mandatory columns are 'name', 'unit', 'description', 'rate' plus one column for every state variable of the model. The 'rate' columns holds math expressions for the process rates and columns named after state variables contain the corresponding expressions representing stoichiometric factors. All columns are of type character.
The best way to understand the contents of the input files is to study
the examples in the folder 'models' shipped with the package. Type
system.file("models", package="rodeo")
at the R prompt to see
where this folder is installed on your system. A full example is given below.
David Kneis david.kneis@tu-dresden.de
buildFromWorkbook
provides similar functionality
# Build and run a SEIR type epidemic model
decl <- system.file("models/SEIR_declarations.txt", package="rodeo")
eqns <- system.file("models/SEIR_equations.txt", package="rodeo")
m <- buildFromText(decl, eqns)
x <- m$dynamics(times=0:30, fortran=FALSE)
print(head(x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.