Skip to content

Commit

Permalink
refactor: Remove code that is commented out
Browse files Browse the repository at this point in the history
  • Loading branch information
kellijohnson-NOAA committed Dec 18, 2024
1 parent 569c590 commit 0b952b1
Show file tree
Hide file tree
Showing 12 changed files with 0 additions and 76 deletions.
45 changes: 0 additions & 45 deletions R/initialize_modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down
1 change: 0 additions & 1 deletion inst/include/common/def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@

#ifdef FIMS_WINDOWS
#include <Windows.h>
//#define __PRETTY_FUNCTION__ __FUNCSIG__
#endif

#if !defined(__PRETTY_FUNCTION__) && !defined(__GNUC__)
Expand Down
2 changes: 0 additions & 2 deletions inst/include/common/fims_math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// note: this is modeling platform specific, must be controlled by
// preprocessing macros
//#include "def.hpp"
#include <cmath>
#include <random>
#include <sstream>
Expand Down Expand Up @@ -61,7 +60,6 @@ inline const Type pow(const Type &x, const Type &y) {
#endif

#ifdef TMB_MODEL
// #include <TMB.hpp>

/**
* @brief The exponential function.
Expand Down
2 changes: 0 additions & 2 deletions inst/include/common/model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 0 additions & 9 deletions inst/include/distributions/functors/lognormal_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Type> lognormal_x = this->x;
Expand Down
4 changes: 0 additions & 4 deletions inst/include/distributions/functors/multinomial_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ namespace fims_distributions
Type lpdf = 0.0; /**< total negative log-likelihood contribution of the distribution */
fims::Vector<size_t> dims; /**< Dimensions of the number of rows and columns of the multivariate dataset */

// data_indicator<tmbutils::vector<Type> , Type> keep; /**< Indicator used in TMB one-step-ahead residual calculations */

/** @brief Constructor.
*/
MultinomialLPMF() : DensityComponentBase<Type>()
Expand Down Expand Up @@ -119,8 +117,6 @@ namespace fims_distributions
}
}
#ifdef TMB_MODEL
// vector<Type> x = this->observed_values->data;
// FIMS_REPORT_F(x, this->of);
#endif
return (lpdf);
}
Expand Down
4 changes: 0 additions & 4 deletions inst/include/distributions/functors/normal_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ struct NormalLPDF : public DensityComponentBase<Type> {
fims::Vector<Type> 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<tmbutils::vector<Type> , Type> keep; /**< Indicator used in TMB one-step-ahead residual calculations */

/** @brief Constructor.
*/
NormalLPDF() : DensityComponentBase<Type>() {
Expand Down Expand Up @@ -57,7 +55,6 @@ struct NormalLPDF : public DensityComponentBase<Type> {
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;
Expand Down Expand Up @@ -87,7 +84,6 @@ struct NormalLPDF : public DensityComponentBase<Type> {
}
#ifdef TMB_MODEL
vector<Type> normal_x = this->x;
//FIMS_REPORT_F(normal_x, this->of);
#endif
return(lpdf);
}
Expand Down
4 changes: 0 additions & 4 deletions inst/include/interface/rcpp/rcpp_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,6 @@ void log_error(std::string log_entry) {

std::string ret = ss_ret.str(); //"find error";//Rcpp::as<std::string>(result);


// Rcpp::Environment base = Rcpp::Environment::global_env();
// Rcpp::Function f = base["traceback"];
// std::string ret = Rcpp::as<std::string>(f());
fims::FIMSLog::fims_log->error_message(log_entry, -1, "R_env", ret.c_str());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ class DlnormDistributionsInterface : public DistributionsInterfaceBase {
* dmultinom_ <- new(DmultinomDistribution)
*
*/
// template <typename Type>

class DmultinomDistributionsInterface : public DistributionsInterfaceBase {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ class ParameterVector{
ParameterVector(){
this->id_m = ParameterVector::id_g++;
this->storage_m = std::make_shared<std::vector<Parameter> >();
// Parameter p;
this->storage_m->resize(1); //push_back(Rcpp::wrap(p));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions inst/include/population_dynamics/population/population.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0b952b1

Please sign in to comment.