mread_yaml: Read a model from yaml format

View source: R/mwrite.R

mread_yamlR Documentation

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)

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.

Value

A model object.

See Also

mwrite_yaml()

Examples

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)


mrgsolve documentation built on Oct. 18, 2024, 5:12 p.m.