FIMS  v0.8.0
Loading...
Searching...
No Matches
rcpp_interface.hpp File Reference

The Rcpp interface to declare things. More...

Go to the source code of this file.

Functions

void init_logging ()
 
bool CreateTMBModel ()
 Initialize and construct the FIMS model using TMB.
 
void set_fixed_parameters (Rcpp::NumericVector par)
 Update fixed parameters in the tape, so the output is correct.
 
Rcpp::NumericVector get_fixed_parameters_vector ()
 Gets the fixed parameters vector object.
 
void set_random_parameters (Rcpp::NumericVector par)
 Update random effect parameters in the tape, so the output is correct.
 
Rcpp::NumericVector get_random_parameters_vector ()
 Gets the random parameters vector object.
 
Rcpp::List get_parameter_names (Rcpp::List pars)
 Gets the parameter names object.
 
Rcpp::List get_random_names (Rcpp::List pars)
 Gets the random effects names object.
 
template<typename Type >
void clear_internal ()
 Clears the internal objects.
 
void clear ()
 Clears the vector of independent variables.
 
std::string get_log ()
 Gets the log entries as a string in JSON format.
 
std::string get_log_errors ()
 Gets the error entries from the log as a string in JSON format.
 
std::string get_log_warnings ()
 Gets the warning entries from the log as a string in JSON format.
 
std::string get_log_info ()
 Gets the info entries from the log as a string in JSON format.
 
std::string get_log_module (const std::string &module)
 Gets log entries by module as a string in JSON format.
 
void write_log (bool write)
 If true, writes the log on exit.
 
void set_log_path (const std::string &path)
 Sets the path for the log file to be written to.
 
void set_log_throw_on_error (bool throw_on_error)
 If true, throws a runtime exception when an error is logged.
 
void log_info (std::string log_entry)
 Adds an info entry to the log from the R environment.
 
void log_warning (std::string log_entry)
 Adds a warning entry to the log from the R environment.
 
std::string escapeQuotes (const std::string &input)
 Escapes quotations.
 
void log_error (std::string log_entry)
 Adds a error entry to the log from the R environment.
 

Detailed Description

The Rcpp interface to declare things.

Function Documentation

◆ clear_internal()

template<typename Type >
void clear_internal ( )

Clears the internal objects.

Template Parameters
Type

◆ CreateTMBModel()

bool CreateTMBModel ( )

Initialize and construct the FIMS model using TMB.

This function sets up the core C++ objects required for building the objective function with TMB before optimizing a FIMS model. The main steps of the function are as follows:

  • The logging system is initialized and any existing model structures are cleared, ensuring a clean slate for a new model.
  • It resets and prepares the main model information objects (fims_info::Information singletons), ensuring all internal data and settings are cleared and ready for a new model run. This step is essential for both initializing the model structure and avoiding conflicts from previous runs.
  • It iterates over all registered FIMS interface objects and adds them to the TMB model context.
  • After all of the objects are registered, it calls fims_info::Information::CreateModel() and fims_info::Information::CheckModel() on the base fims_info::Information object.
  • It instantiates the singleton fims_model::Model object which represents the constructed TMB model.

Typically the average user does not interact with this function because it is called within initialize_fims.

See also
init_logging()
fims_info::Information::Clear()
fims_info::Information::CreateModel()
fims_info::Information::CheckModel()
fims_info::Information::GetInstance()
initialize_fims()
Returns
A boolean is returned, where true indicates that the model was successfully created.

◆ escapeQuotes()

std::string escapeQuotes ( const std::string &  input)

Escapes quotations.

Parameters
inputA string.
Returns
std::string

◆ get_fixed_parameters_vector()

Rcpp::NumericVector get_fixed_parameters_vector ( )

Gets the fixed parameters vector object.

Returns
Rcpp::NumericVector

◆ get_parameter_names()

Rcpp::List get_parameter_names ( Rcpp::List  pars)

Gets the parameter names object.

Parameters
pars
Returns
Rcpp::List

◆ get_random_names()

Rcpp::List get_random_names ( Rcpp::List  pars)

Gets the random effects names object.

Parameters
pars
Returns
Rcpp::List

◆ get_random_parameters_vector()

Rcpp::NumericVector get_random_parameters_vector ( )

Gets the random parameters vector object.

Returns
Rcpp::NumericVector

◆ init_logging()

void init_logging ( )

Initializes the logging system, setting all signal handling.

◆ set_fixed_parameters()

void set_fixed_parameters ( Rcpp::NumericVector  par)

Update fixed parameters in the tape, so the output is correct.

Updates the internal parameter values for the model base of type TMB_FIMS_REAL_TYPE. It is typically called before finalize() or `get_output()` to ensure the correct values are used because TMB doesn't always keep the updated parameters in the "double" version of the tape. So we need to update those first.

Usage example in R:

set_fixed_parameters(c(1, 2, 3))
set_random_parameters(c(1, 2, 3))
catch_at_age$get_output(do_sd_report = FALSE)
Parameters
parA vector of parameter values.

See also
set_random_parameters()

◆ set_random_parameters()

void set_random_parameters ( Rcpp::NumericVector  par)

Update random effect parameters in the tape, so the output is correct.

Updates the internal parameter values for the model base of type TMB_FIMS_REAL_TYPE. It is typically called before finalize() or `get_output()` to ensure the correct values are used because TMB doesn't always keep the updated parameters in the "double" version of the tape. So we need to update those first.

Usage example in R:

set_fixed_parameters(c(1, 2, 3))
set_random_parameters(c(1, 2, 3))
catch_at_age$get_output(do_sd_report = FALSE)
Parameters
parA vector of parameter values.

See also
set_fixed_parameters()