reload_model: Reload a VAST model

View source: R/reload_model.R

reload_modelR Documentation

Reload a VAST model

Description

reload_model allows a user to save a fitted model, reload it in a new R terminal, and then relink the DLLs so that it functions as expected.

Usage

reload_model(
  x,
  check_gradient = TRUE,
  CompileDir = system.file("executables", package = "VAST"),
  Version = x$settings$Version,
  framework = x$input_args$model_args_input$framework,
  Obj = x$tmb_list$Obj
)

Arguments

x

Output from fit_model, potentially with DLLs not linked

check_gradient

Whether to check the gradients of the reloaded model

CompileDir

a directory where the CPP file is copied, copiled, and run (must have write privileges or else the function will crash); by default uses TmbDir (OPTIONAL)

Version

Which CPP version to use. If missing, defaults to latest version using get_latest_version. Can be used to specify using an older CPP, to maintain backwards compatibility.

framework

Which AD framework to use ('TMBad' or 'CppAD')

Value

Output from fit_model with DLLs relinked

Examples

## Not run: 
# Run model
fit = fit_model( ... )
saveRDS( object=fit, file="path_and_name.rds" )

# Reload and relink
fit_new = readRDS( file="path_and_name.rds" )
fit_new = reload_model( x = fit_new )

## End(Not run)


James-Thorson/VAST documentation built on Jan. 31, 2024, 12:13 p.m.