From 0b952b18f3bf41847527502a1f036558c2f2ccbd Mon Sep 17 00:00:00 2001 From: kellijohnson-NOAA Date: Tue, 17 Dec 2024 21:16:01 -0800 Subject: [PATCH] refactor: Remove code that is commented out --- R/initialize_modules.R | 45 ------------------- inst/include/common/def.hpp | 1 - inst/include/common/fims_math.hpp | 2 - inst/include/common/model.hpp | 2 - .../distributions/functors/lognormal_lpdf.hpp | 9 ---- .../functors/multinomial_lpmf.hpp | 4 -- .../distributions/functors/normal_lpdf.hpp | 4 -- .../include/interface/rcpp/rcpp_interface.hpp | 4 -- .../rcpp/rcpp_objects/rcpp_distribution.hpp | 1 - .../rcpp/rcpp_objects/rcpp_interface_base.hpp | 1 - .../maturity/functors/logistic.hpp | 1 - .../population/population.hpp | 2 - 12 files changed, 76 deletions(-) diff --git a/R/initialize_modules.R b/R/initialize_modules.R index 542d599a..fc817c02 100644 --- a/R/initialize_modules.R +++ b/R/initialize_modules.R @@ -112,14 +112,6 @@ initialize_module <- function(parameters, data, module_name) { "nlengths", "proportion_catch_numbers_at_length" )) - # else { - # module_fields <- setdiff(module_fields, c( - # "age_length_conversion_matrix", - # # Right now we can also remove nlengths because the default is 0 - # "nlength", - # "proportion_catch_numbers_at_length" - # )) - # } } # Populate fields based on common and specific settings @@ -654,19 +646,6 @@ initialize_fims <- function(parameters, data) { linked_ids = fleet_module_ids ) - # Set up fishery index data using the lognormal - # fleet_index_distribution[[i]] <- initialize_distribution( - # module_input = parameters[["parameters"]][[fleet_names[i]]], - # distribution_name = parameters[["modules"]][["fleets"]][[ - # fleet_names[i] - # ]][["data_distribution"]]["Index"], - # distribution_type = "data", - # linked_ids = c( - # data_link = fleet[[i]]$GetObservedIndexDataID(), - # fleet_link = fleet[[i]]$log_expected_index$get_id() - # ) - # ) - # TODO: update argument sd to log_sd to match the Rcpp interface parameter_value_name <- grep( paste0("log_sd", ".value"), @@ -699,21 +678,6 @@ initialize_fims <- function(parameters, data) { data_type = "index" ) - # Set up fishery age-composition data using the multinomial - # fleet_agecomp_distribution[[i]] <- initialize_distribution( - # module_input = NULL, - # distribution_name = parameters[["modules"]][["fleets"]][[ - # fleet_names[i] - # ]][["data_distribution"]]["AgeComp"], - # distribution_type = "data", - # linked_ids = c( - # data_link = fleet[[i]]$GetObservedAgeCompDataID(), - # fleet_link = fleet[[ - # i - # ]]$proportion_catch_numbers_at_age$get_id() - # ) - # ) - fleet_agecomp_distribution[[i]] <- initialize_data_distribution( module = fleet[[i]], family = multinomial(link = "logit"), @@ -740,15 +704,6 @@ initialize_fims <- function(parameters, data) { data = data ) - # recruitment_distribution <- initialize_distribution( - # module_input = parameters[["parameters"]][["recruitment"]], - # distribution_name = parameters[["modules"]][[ - # "recruitment" - # ]][["process_distribution"]], - # distribution_type = "process", - # linked_ids = recruitment$get_id() - # ) - parameter_name <- names(parameters$modules$recruitment$process_distribution) field_value_name <- grep( paste0("log_sd.value"), diff --git a/inst/include/common/def.hpp b/inst/include/common/def.hpp index 9fb106e0..75a31f74 100644 --- a/inst/include/common/def.hpp +++ b/inst/include/common/def.hpp @@ -63,7 +63,6 @@ #ifdef FIMS_WINDOWS #include -//#define __PRETTY_FUNCTION__ __FUNCSIG__ #endif #if !defined(__PRETTY_FUNCTION__) && !defined(__GNUC__) diff --git a/inst/include/common/fims_math.hpp b/inst/include/common/fims_math.hpp index 205235f8..7b7823b2 100644 --- a/inst/include/common/fims_math.hpp +++ b/inst/include/common/fims_math.hpp @@ -10,7 +10,6 @@ // note: this is modeling platform specific, must be controlled by // preprocessing macros -//#include "def.hpp" #include #include #include @@ -61,7 +60,6 @@ inline const Type pow(const Type &x, const Type &y) { #endif #ifdef TMB_MODEL -// #include /** * @brief The exponential function. diff --git a/inst/include/common/model.hpp b/inst/include/common/model.hpp index 98fccd3b..5aa5bf2c 100644 --- a/inst/include/common/model.hpp +++ b/inst/include/common/model.hpp @@ -222,8 +222,6 @@ namespace fims_model { fleet_idx += 1; } - // jnll = rec_nll + age_comp_nll + index_nll; - // Reporting #ifdef TMB_MODEL //FIMS_REPORT_F(rec_nll, of); diff --git a/inst/include/distributions/functors/lognormal_lpdf.hpp b/inst/include/distributions/functors/lognormal_lpdf.hpp index 6aafc40a..14637a73 100644 --- a/inst/include/distributions/functors/lognormal_lpdf.hpp +++ b/inst/include/distributions/functors/lognormal_lpdf.hpp @@ -61,8 +61,6 @@ namespace fims_distributions // See Deroba and Miller, 2016 (https://doi.org/10.1016/j.fishres.2015.12.002) for // the use of lognormal constant if(this->observed_values->at(i) != this->observed_values->na_value){ - // this->lpdf_vec[i] = this->keep[i] * -dnorm(log(this->observed_values->at(i)), this->expected_values.get_force_scalar(i), - // fims_math::exp(log_sd.get_force_scalar(i)), true) - log(this->observed_values->->at(i)); this->lpdf_vec[i] = dnorm(log(this->observed_values->at(i)), this->expected_values.get_force_scalar(i), fims_math::exp(log_sd.get_force_scalar(i)), true) - log(this->observed_values->at(i)); } else { @@ -90,13 +88,6 @@ namespace fims_distributions } } #endif - - /* osa not working yet - if(osa_flag){//data observation type implements osa residuals - //code for osa cdf method - this->lpdf_vec[i] = this->keep.cdf_lower[i] * log( pnorm(this->x[i], this->expected_values.get_force_scalar(i), fims_math::exp(log_sd.get_force_scalar(i))) ); - this->lpdf_vec[i] = this->keep.cdf_upper[i] * log( 1.0 - pnorm(this->x[i], this->expected_values.get_force_scalar(i), fims_math::exp(log_sd.get_force_scalar(i))) ); - } */ } #ifdef TMB_MODEL vector lognormal_x = this->x; diff --git a/inst/include/distributions/functors/multinomial_lpmf.hpp b/inst/include/distributions/functors/multinomial_lpmf.hpp index 88dfbea7..4c6f9137 100644 --- a/inst/include/distributions/functors/multinomial_lpmf.hpp +++ b/inst/include/distributions/functors/multinomial_lpmf.hpp @@ -25,8 +25,6 @@ namespace fims_distributions Type lpdf = 0.0; /**< total negative log-likelihood contribution of the distribution */ fims::Vector dims; /**< Dimensions of the number of rows and columns of the multivariate dataset */ - // data_indicator , Type> keep; /**< Indicator used in TMB one-step-ahead residual calculations */ - /** @brief Constructor. */ MultinomialLPMF() : DensityComponentBase() @@ -119,8 +117,6 @@ namespace fims_distributions } } #ifdef TMB_MODEL - // vector x = this->observed_values->data; - // FIMS_REPORT_F(x, this->of); #endif return (lpdf); } diff --git a/inst/include/distributions/functors/normal_lpdf.hpp b/inst/include/distributions/functors/normal_lpdf.hpp index 5ce9dde1..c1bc76f0 100644 --- a/inst/include/distributions/functors/normal_lpdf.hpp +++ b/inst/include/distributions/functors/normal_lpdf.hpp @@ -24,8 +24,6 @@ struct NormalLPDF : public DensityComponentBase { fims::Vector log_sd; /**< log of the standard deviation of the distribution; can be a vector or scalar */ Type lpdf = 0.0; /**< total log probability density contribution of the distribution */ - //data_indicator , Type> keep; /**< Indicator used in TMB one-step-ahead residual calculations */ - /** @brief Constructor. */ NormalLPDF() : DensityComponentBase() { @@ -57,7 +55,6 @@ struct NormalLPDF : public DensityComponentBase { if(this->input_type == "data"){ // if data, check if there are any NA values and skip lpdf calculation if there are if(this->observed_values->at(i) != this->observed_values->na_value){ - // this->lpdf_vec[i] = this->keep[i] * -dnorm(this->observed_values->at(i), this->expected_values.get_force_scalar(i), sd[i], true); this->lpdf_vec[i] = dnorm(this->observed_values->at(i), this->expected_values.get_force_scalar(i), fims_math::exp(log_sd.get_force_scalar(i)), true); } else { this->lpdf_vec[i] = 0; @@ -87,7 +84,6 @@ struct NormalLPDF : public DensityComponentBase { } #ifdef TMB_MODEL vector normal_x = this->x; - //FIMS_REPORT_F(normal_x, this->of); #endif return(lpdf); } diff --git a/inst/include/interface/rcpp/rcpp_interface.hpp b/inst/include/interface/rcpp/rcpp_interface.hpp index 3e78ac78..24d9e5d5 100644 --- a/inst/include/interface/rcpp/rcpp_interface.hpp +++ b/inst/include/interface/rcpp/rcpp_interface.hpp @@ -644,10 +644,6 @@ void log_error(std::string log_entry) { std::string ret = ss_ret.str(); //"find error";//Rcpp::as(result); - - // Rcpp::Environment base = Rcpp::Environment::global_env(); - // Rcpp::Function f = base["traceback"]; - // std::string ret = Rcpp::as(f()); fims::FIMSLog::fims_log->error_message(log_entry, -1, "R_env", ret.c_str()); } diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_distribution.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_distribution.hpp index d0e9a8b3..258f2867 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_distribution.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_distribution.hpp @@ -486,7 +486,6 @@ class DlnormDistributionsInterface : public DistributionsInterfaceBase { * dmultinom_ <- new(DmultinomDistribution) * */ -// template class DmultinomDistributionsInterface : public DistributionsInterfaceBase { public: diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_interface_base.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_interface_base.hpp index cf147976..8668f66e 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_interface_base.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_interface_base.hpp @@ -142,7 +142,6 @@ class ParameterVector{ ParameterVector(){ this->id_m = ParameterVector::id_g++; this->storage_m = std::make_shared >(); - // Parameter p; this->storage_m->resize(1); //push_back(Rcpp::wrap(p)); } diff --git a/inst/include/population_dynamics/maturity/functors/logistic.hpp b/inst/include/population_dynamics/maturity/functors/logistic.hpp index ca4ff172..d2cbcd46 100644 --- a/inst/include/population_dynamics/maturity/functors/logistic.hpp +++ b/inst/include/population_dynamics/maturity/functors/logistic.hpp @@ -10,7 +10,6 @@ #ifndef POPULATION_DYNAMICS_MATURITY_LOGISTIC_HPP #define POPULATION_DYNAMICS_MATURITY_LOGISTIC_HPP -//#include "../../../interface/interface.hpp" #include "../../../common/fims_math.hpp" #include "../../../common/fims_vector.hpp" #include "maturity_base.hpp" diff --git a/inst/include/population_dynamics/population/population.hpp b/inst/include/population_dynamics/population/population.hpp index c7c7dc2e..478e1379 100644 --- a/inst/include/population_dynamics/population/population.hpp +++ b/inst/include/population_dynamics/population/population.hpp @@ -12,7 +12,6 @@ #include "../fleet/fleet.hpp" #include "../growth/growth.hpp" #include "../recruitment/recruitment.hpp" -//#include "subpopulation.hpp" #include "../../interface/interface.hpp" #include "../maturity/maturity.hpp" @@ -548,7 +547,6 @@ namespace fims_popdy { CalculateInitialNumbersAA(i_age_year, a); if (a == 0) { - // this->numbers_at_age[i_age_year] = this->recruitment->rzero; this->unfished_numbers_at_age[i_age_year] = fims_math::exp(this->recruitment->log_rzero[0]); } else {