Skip to content

Commit

Permalink
refactor: load fims modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea-Havron-NOAA committed Nov 16, 2023
1 parent 980a757 commit 0809515
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 17 deletions.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
export("%>%")
export(FIMSFrame)
export(FIMSFrameAge)
export(Population)
export(clear)
export(create_fims_rcpp_interface)
export(get_fixed)
export(m_agecomp)
export(m_index)
export(m_landings)
Expand Down
3 changes: 3 additions & 0 deletions R/FIMS-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
#' @import methods
#' @importFrom ggplot2 .data
#' @importFrom usethis use_template ui_stop
#' @export Population
#' @export clear
#' @export get_fixed
## usethis namespace: end
NULL
7 changes: 7 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

clear <- function() {
invisible(.Call(`_FIMS_clear`))
}

2 changes: 2 additions & 0 deletions inst/include/interface/init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ SEXP _rcpp_module_boot_fims();
*Callback definition to load the FIMS module.
*
*/
/*
static const R_CallMethodDef CallEntries[] = {
TMB_CALLDEFS,
{"_rcpp_module_boot_fims", (DL_FUNC)&_rcpp_module_boot_fims, 0},
{NULL, NULL, 0}};
*/

/**
*
Expand Down
4 changes: 2 additions & 2 deletions src/FIMS.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

#include <cmath>

#include "../inst/include/interface/rcpp/rcpp_interface.hpp"
#include "rcpp_interface.hpp"
#include "../inst/include/interface/interface.hpp"
#include "../inst/include/interface/init.hpp"
//#include "../inst/include/interface/init.hpp"
#include "../inst/include/common/model.hpp"

/// @cond
Expand Down
35 changes: 35 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#include <RcppEigen.h>
#include <Rcpp.h>

using namespace Rcpp;

#ifdef RCPP_USE_GLOBAL_ROSTREAM
Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// clear
void clear();
RcppExport SEXP _FIMS_clear() {
BEGIN_RCPP
Rcpp::RNGScope rcpp_rngScope_gen;
clear();
return R_NilValue;
END_RCPP
}

RcppExport SEXP _rcpp_module_boot_fims();

static const R_CallMethodDef CallEntries[] = {
{"_FIMS_clear", (DL_FUNC) &_FIMS_clear, 0},
{"_rcpp_module_boot_fims", (DL_FUNC) &_rcpp_module_boot_fims, 0},
{NULL, NULL, 0}
};

RcppExport void R_init_FIMS(DllInfo *dll) {
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
#ifndef FIMS_INTERFACE_RCPP_INTERFACE_HPP
#define FIMS_INTERFACE_RCPP_INTERFACE_HPP

#include "rcpp_objects/rcpp_data.hpp"
#include "rcpp_objects/rcpp_fleet.hpp"
#include "rcpp_objects/rcpp_growth.hpp"
#include "rcpp_objects/rcpp_maturity.hpp"
#include "rcpp_objects/rcpp_natural_mortality.hpp"
#include "../inst/include/interface/rcpp/rcpp_objects/rcpp_data.hpp"
#include "../inst/include/interface/rcpp/rcpp_objects/rcpp_fleet.hpp"
#include "../inst/include/interface/rcpp/rcpp_objects/rcpp_growth.hpp"
#include "../inst/include/interface/rcpp/rcpp_objects/rcpp_maturity.hpp"
#include "../inst/include/interface/rcpp/rcpp_objects/rcpp_natural_mortality.hpp"
//#include "rcpp_objects/rcpp_nll.hpp"
#include "../../common/model.hpp"
#include "rcpp_objects/rcpp_population.hpp"
#include "rcpp_objects/rcpp_recruitment.hpp"
#include "rcpp_objects/rcpp_selectivity.hpp"
#include "rcpp_objects/rcpp_tmb_distribution.hpp"
#include "../inst/include/common/model.hpp"
#include "../inst/include/interface/rcpp/rcpp_objects/rcpp_population.hpp"
#include "../inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp"
#include "../inst/include/interface/rcpp/rcpp_objects/rcpp_selectivity.hpp"
#include "../inst/include/interface/rcpp/rcpp_objects/rcpp_tmb_distribution.hpp"
/**
* @brief Create the TMB model object and add interface objects to it.
*/
Expand Down Expand Up @@ -235,9 +235,10 @@ void clear_internal() {
d0->fixed_effects_parameters.clear();
d0->random_effects_parameters.clear();
}
/**
* Clears the vector of independent variables.
/*
* Clears the vector of independent variables
*/
// [[Rcpp::export]]
void clear() {
// rcpp_interface_base.hpp
FIMSRcppInterfaceBase::fims_interface_objects.clear();
Expand Down Expand Up @@ -321,7 +322,7 @@ RCPP_MODULE(fims) {
Rcpp::function("CreateTMBModel", &CreateTMBModel);
Rcpp::function("get_fixed", &get_fixed_parameters_vector);
Rcpp::function("get_random", &get_random_parameters_vector);
Rcpp::function("clear", clear);
//Rcpp::function("clear", clear);
Rcpp::function("clear_logs", clear_logs);
Rcpp::function("clear_fims_log", clear_fims_log);
Rcpp::function("clear_info_log", clear_info_log);
Expand Down
4 changes: 2 additions & 2 deletions vignettes/fims-path-maturity.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Also restarting or closing out your R session will free up memory.
## The Rcpp Interface

The fields specific to the maturity module that are accessible from R are defined in the
[rcpp_interface.hpp](https://github.com/NOAA-FIMS/FIMS/blob/main/inst/include/interface/rcpp/rcpp_interface.hpp) file in the directory [inst/include/interface/rcpp](https://github.com/NOAA-FIMS/FIMS/tree/main/inst/include/interface/rcpp):
[rcpp_interface.hpp](https://github.com/NOAA-FIMS/FIMS/blob/main/src/rcpp_interface.hpp) file in the directory [inst/include/interface/rcpp](https://github.com/NOAA-FIMS/FIMS/tree/main/inst/include/interface/rcpp):

```{Rcpp, class.source = "rcppchunk", eval = FALSE}
Rcpp::class_<LogisticMaturityInterface>("LogisticMaturity")
Expand Down Expand Up @@ -157,7 +157,7 @@ class Parameter {
}
```
The fields from the `Parameter` class that are accessible from R are defined in the
[rcpp_interface.hpp](https://github.com/NOAA-FIMS/FIMS/blob/main/inst/include/interface/rcpp/rcpp_interface.hpp) file in the directory [inst/include/interface/rcpp](https://github.com/NOAA-FIMS/FIMS/tree/main/inst/include/interface/rcpp):
[rcpp_interface.hpp](https://github.com/NOAA-FIMS/FIMS/blob/main/src/rcpp_interface.hpp) file in the directory [inst/include/interface/rcpp](https://github.com/NOAA-FIMS/FIMS/tree/main/inst/include/interface/rcpp):

```{Rcpp, class.source = "rcppchunk", eval = FALSE}
Rcpp::class_<Parameter>("Parameter")
Expand Down

0 comments on commit 0809515

Please sign in to comment.