Generate code to build stock-and-flow model
get_build_code.Rd
Create R code to rebuild an existing stock-and-flow model. This may help to understand how a model is built, or to modify an existing one.
Examples
sfm = xmile("SIR")
get_build_code(sfm)
#> Warning: Could not use `colored = TRUE`, as the package prettycode is not installed.
#> Please install it if you want to see colored output or see
#> `?styler::print.vertical()` for more information.
#> sfm <- xmile() %>%
#> sim_specs(stop = "20.0", saveat = "0.01", seed = NULL) %>%
#> header(name = "Susceptible-Infected-Recovered (SIR)", caption = "My Model Description", created = Sys.time(), author = "Me", version = "1.0", URL = "", doi = "") %>%
#> build("Susceptible", "stock", eqn = "99999") %>%
#> build("Infected", "stock", eqn = "1") %>%
#> build("Recovered", "stock") %>%
#> build("Total_Population", "constant", eqn = "100000") %>%
#> build("Effective_Contact_Rate", "constant", eqn = "2") %>%
#> build("Delay", "constant", eqn = "2") %>%
#> build("Beta", "aux", eqn = "Effective_Contact_Rate / Total_Population") %>%
#> build("Lambda", "aux", eqn = "Beta * Infected") %>%
#> build("Infection_Rate", "flow", eqn = "Susceptible * Lambda") %>%
#> build("Recovery_Rate", "flow", eqn = "Infected / Delay")