Learn R Programming

mrgsolve (version 1.5.1)

mread_yaml: Read a model from yaml format

Description

Read back models written to file using mwrite_yaml(). Function yaml_to_cpp() is also provided to convert the yaml file to mrgsolve cpp file format.

Usage

mread_yaml(
  file,
  model = basename(file),
  project = tempdir(),
  update = FALSE,
  ...
)

yaml_to_cpp(file, model = basename(file), project = getwd(), update = TRUE)

Value

A model object.

Arguments

file

the yaml file name.

model

a new model name to use when calling mread_yaml().

project

the directory where the model should be built.

update

TRUE if model settings should be written into the cpp file in a $SET block.

...

passed to mread().

Details

Note that yaml_to_cpp() by default writes model settings into the cpp file. mread_yaml() does not write model settings into the file but rather update the model object directly with data read back from the yaml file.

See Also

mwrite_yaml()

Examples

Run this code
mod <- house()

temp <- tempfile(fileext = ".yaml")

mwrite_yaml(mod, file = temp)

# Note: this model is not compiled
mod <- mread_yaml(temp, model = "new-house", compile = FALSE)
mod

cppfile <- yaml_to_cpp(temp, project = tempdir())

readLines(cppfile)

Run the code above in your browser using DataLab