From 2b679d32ec084db51674068c71133d6bfd2f17b5 Mon Sep 17 00:00:00 2001 From: Christine Stawitz - NOAA <47904621+ChristineStawitz-NOAA@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:11:30 -0700 Subject: [PATCH] style: run clang format (#509) Co-authored-by: nathanvaughan-NOAA --- inst/include/common/def.hpp | 28 +-- inst/include/common/fims_math.hpp | 20 +- inst/include/common/information.hpp | 186 +++++++++++------- inst/include/common/model.hpp | 25 ++- .../functors/tmb_distributions.hpp | 4 +- .../include/interface/rcpp/rcpp_interface.hpp | 147 +++++++------- .../rcpp/rcpp_objects/rcpp_maturity.hpp | 5 +- .../rcpp/rcpp_objects/rcpp_recruitment.hpp | 3 +- .../rcpp/rcpp_objects/rcpp_selectivity.hpp | 17 +- .../population_dynamics/fleet/fleet.hpp | 28 ++- .../maturity/functors/logistic.hpp | 10 +- .../population/population.hpp | 98 ++++----- .../selectivity/functors/double_logistic.hpp | 32 +-- .../selectivity/functors/logistic.hpp | 8 +- tests/gtest/test_population_test_fixture.hpp | 3 +- 15 files changed, 336 insertions(+), 278 deletions(-) diff --git a/inst/include/common/def.hpp b/inst/include/common/def.hpp index 74d0c512a..85756b93b 100644 --- a/inst/include/common/def.hpp +++ b/inst/include/common/def.hpp @@ -15,21 +15,27 @@ #include #include -//The following rows initialize default log files for outputing model progress -//comments used to assist in diagnosing model issues and tracking progress. These -//files will only be created if a logs folder is added to the root model directory. -std::ofstream FIMS_LOG ("logs/fims.log"); /**< Generic log file */ -std::ofstream INFO_LOG("logs/info.log"); /**< Information.hpp log file */ +// The following rows initialize default log files for outputing model progress +// comments used to assist in diagnosing model issues and tracking progress. +// These files will only be created if a logs folder is added to the root model +// directory. +std::ofstream FIMS_LOG("logs/fims.log"); /**< Generic log file */ +std::ofstream INFO_LOG("logs/info.log"); /**< Information.hpp log file */ std::ofstream ERROR_LOG("logs/error.log"); /**< Error tracking log file */ -std::ofstream DATA_LOG("logs/data.log"); /**< Data input tracking log file */ +std::ofstream DATA_LOG("logs/data.log"); /**< Data input tracking log file */ std::ofstream MODEL_LOG("logs/model.log"); /**< Model.hpp log file */ std::ofstream FLEET_LOG("logs/fleet.log"); /**< Fleet module log file */ -std::ofstream POPULATION_LOG("logs/population.log"); /**< Populations module log file */ -std::ofstream RECRUITMENT_LOG("logs/recruitment.log"); /**< Recruitment module log file */ +std::ofstream POPULATION_LOG( + "logs/population.log"); /**< Populations module log file */ +std::ofstream RECRUITMENT_LOG( + "logs/recruitment.log"); /**< Recruitment module log file */ std::ofstream GROWTH_LOG("logs/growth.log"); /**< Growth module log file */ -std::ofstream MATURITY_LOG("logs/maturity.log"); /**< Maturity module log file */ -std::ofstream SELECTIVITY_LOG("logs/selectivity.log"); /**< Selectivity module log file */ -std::ofstream DEBUG_LOG("logs/debug/debug.log"); /**< Development debugging log file */ +std::ofstream MATURITY_LOG( + "logs/maturity.log"); /**< Maturity module log file */ +std::ofstream SELECTIVITY_LOG( + "logs/selectivity.log"); /**< Selectivity module log file */ +std::ofstream DEBUG_LOG( + "logs/debug/debug.log"); /**< Development debugging log file */ #ifdef TMB_MODEL // simplify access to singletons diff --git a/inst/include/common/fims_math.hpp b/inst/include/common/fims_math.hpp index ffcd743e9..6665406bf 100644 --- a/inst/include/common/fims_math.hpp +++ b/inst/include/common/fims_math.hpp @@ -100,7 +100,8 @@ inline const double log(const double &x) { * @return */ template -inline const Type logistic(const Type &inflection_point, const Type &slope, const Type &x) { +inline const Type logistic(const Type &inflection_point, const Type &slope, + const Type &x) { return (1.0) / (1.0 + exp(-1.0 * slope * (x - inflection_point))); } @@ -138,15 +139,16 @@ inline const Type inv_logit(const Type &a, const Type &b, const Type &logit_x) { * @brief The general double logistic function * * \f$ \frac{1.0}{ 1.0 + exp(-1.0 * slope_{asc} (x - inflection_point_{asc}))} - * \left(1-\frac{1.0}{ 1.0 + exp(-1.0 * slope_{desc} (x - inflection_point_{desc}))} - * \right)\f$ + * \left(1-\frac{1.0}{ 1.0 + exp(-1.0 * slope_{desc} (x - + * inflection_point_{desc}))} \right)\f$ * * @param inflection_point_asc the inflection point of the ascending limb of the * double logistic function * @param slope_asc the slope of the ascending limb of the double logistic * function * @param inflection_point_desc the inflection point of the descending limb of - * the double logistic function, where inflection_point_desc > inflection_point_asc + * the double logistic function, where inflection_point_desc > + * inflection_point_asc * @param slope_desc the slope of the descending limb of the double logistic * function * @param x the index the logistic function should be evaluated at @@ -154,11 +156,13 @@ inline const Type inv_logit(const Type &a, const Type &b, const Type &logit_x) { */ template -inline const Type double_logistic(const Type &inflection_point_asc, const Type &slope_asc, - const Type &inflection_point_desc, const Type &slope_desc, - const Type &x) { +inline const Type double_logistic(const Type &inflection_point_asc, + const Type &slope_asc, + const Type &inflection_point_desc, + const Type &slope_desc, const Type &x) { return (1.0) / (1.0 + exp(-1.0 * slope_asc * (x - inflection_point_asc))) * - (1.0 - (1.0) / (1.0 + exp(-1.0 * slope_desc * (x - inflection_point_desc)))); + (1.0 - + (1.0) / (1.0 + exp(-1.0 * slope_desc * (x - inflection_point_desc)))); } /** diff --git a/inst/include/common/information.hpp b/inst/include/common/information.hpp index 516cad9af..9111d1219 100644 --- a/inst/include/common/information.hpp +++ b/inst/include/common/information.hpp @@ -152,16 +152,20 @@ class Information { * Create the generalized stock assessment model that will evaluate the * objective function. Does error checking to make sure the program has * all necessary components for the model and that they're in the right - * dimensions. This sets up pointers to all memory objects and initializes + * dimensions. This sets up pointers to all memory objects and initializes * fleet and population objects. * - * @return True if valid model, False if invalid model, check fims.log for errors. + * @return True if valid model, False if invalid model, check fims.log for + * errors. */ bool CreateModel() { bool valid_model = true; INFO_LOG << "" << std::endl; - INFO_LOG << "Beginning to create FIMS model in information.hpp CreateModel(). " << std::endl; - INFO_LOG << "Initializing fleet objects for " << this->fleets.size() << " fleets." << std::endl; + INFO_LOG + << "Beginning to create FIMS model in information.hpp CreateModel(). " + << std::endl; + INFO_LOG << "Initializing fleet objects for " << this->fleets.size() + << " fleets." << std::endl; for (fleet_iterator it = this->fleets.begin(); it != this->fleets.end(); ++it) { // Initialize fleet object @@ -170,11 +174,12 @@ class Information { INFO_LOG << "Initializing fleet " << f->id << "." << std::endl; f->Initialize(f->nyears, f->nages); - + INFO_LOG << "Expecting to import " << this->data_objects.size() - << " data objects." << std::endl; + << " data objects." << std::endl; - INFO_LOG << "Checking for available fleet index data objects." << std::endl; + INFO_LOG << "Checking for available fleet index data objects." + << std::endl; // set index data if (f->fleet_observed_index_data_id_m != -999) { uint32_t observed_index_id = @@ -187,24 +192,26 @@ class Information { f->observed_index_data = (*it).second; INFO_LOG << "Index data successfully set." << std::endl; DATA_LOG << "" << std::endl; - DATA_LOG << "Observed input for fleet " << f->id << ", index " << observed_index_id << ": \n " << f->observed_index_data->at(1) - << std::endl; + DATA_LOG << "Observed input for fleet " << f->id << ", index " + << observed_index_id << ": \n " + << f->observed_index_data->at(1) << std::endl; } else { valid_model = false; ERROR_LOG << "Error: Expected data observations not defined for fleet" - << f->id << ", index " << observed_index_id << std::endl; + << f->id << ", index " << observed_index_id << std::endl; exit(1); } } else { valid_model = false; - ERROR_LOG << "Error: No index data observed for fleet " << f->id - << ". FIMS requires index data for all fleets." << std::endl; + ERROR_LOG << "Error: No index data observed for fleet " << f->id + << ". FIMS requires index data for all fleets." << std::endl; exit(1); } // end set index data - - INFO_LOG << "Checking for available fleet age comp data objects." << std::endl; + + INFO_LOG << "Checking for available fleet age comp data objects." + << std::endl; // set age composition data if (f->fleet_observed_agecomp_data_id_m != -999) { uint32_t observed_agecomp_id = @@ -217,32 +224,36 @@ class Information { f->observed_agecomp_data = (*it).second; INFO_LOG << "Age comp data successfully set." << std::endl; DATA_LOG << "" << std::endl; - DATA_LOG << "Observed input age comp for fleet " << f->id << ", comp " << observed_agecomp_id << ": \n " << f->observed_agecomp_data->at(1) - << std::endl; + DATA_LOG << "Observed input age comp for fleet " << f->id << ", comp " + << observed_agecomp_id << ": \n " + << f->observed_agecomp_data->at(1) << std::endl; } else { valid_model = false; - ERROR_LOG << "Error: Expected age comp data observations not defined for fleet " - << f->id << ", index " << observed_agecomp_id << std::endl; + ERROR_LOG << "Error: Expected age comp data observations not defined " + "for fleet " + << f->id << ", index " << observed_agecomp_id << std::endl; exit(1); } } else { valid_model = false; - ERROR_LOG << "Error: No age comp data observed for fleet " << f->id - << ". FIMS requires age comp data for all fleets." << std::endl; + ERROR_LOG << "Error: No age comp data observed for fleet " << f->id + << ". FIMS requires age comp data for all fleets." + << std::endl; exit(1); } // end set composition data - INFO_LOG << "Checking for available fleet selectivity pattern." << std::endl; + INFO_LOG << "Checking for available fleet selectivity pattern." + << std::endl; // set selectivity model if (f->fleet_selectivity_id_m != -999) { uint32_t sel_id = static_cast( f->fleet_selectivity_id_m); // cast as unsigned integer selectivity_models_iterator it = this->selectivity_models.find( sel_id); // if find, set it, otherwise invalid - INFO_LOG << "Input fleet selectivity pattern id = " << sel_id - << "." << std::endl; + INFO_LOG << "Input fleet selectivity pattern id = " << sel_id << "." + << std::endl; if (it != this->selectivity_models.end()) { f->selectivity = (*it).second; // elements in container held in pair @@ -251,20 +262,23 @@ class Information { INFO_LOG << "Selectivity successfully set." << std::endl; } else { valid_model = false; - ERROR_LOG << "Error: Expected selectivity pattern not defined for fleet " - << f->id << ", selectivity pattern " << sel_id << std::endl; + ERROR_LOG + << "Error: Expected selectivity pattern not defined for fleet " + << f->id << ", selectivity pattern " << sel_id << std::endl; exit(1); } } else { valid_model = false; - ERROR_LOG << "Error: No selectivity pattern defined for fleet " << f->id - << ". FIMS requires selectivity be defined for all fleets." << std::endl; + ERROR_LOG << "Error: No selectivity pattern defined for fleet " << f->id + << ". FIMS requires selectivity be defined for all fleets." + << std::endl; exit(1); } // end set selectivity - INFO_LOG << "Checking for available index likelihood function." << std::endl; + INFO_LOG << "Checking for available index likelihood function." + << std::endl; // set index likelihood if (f->fleet_index_likelihood_id_m != -999) { uint32_t ind_like_id = static_cast( @@ -272,32 +286,36 @@ class Information { distribution_models_iterator it = this->distribution_models.find( ind_like_id); // if find, set it, otherwise invalid INFO_LOG << "Input index likelihood function id = " << ind_like_id - << "." << std::endl; + << "." << std::endl; if (it != this->distribution_models.end()) { f->index_likelihood = (*it).second; // elements in container held in pair (first is // id, second is object - shared pointer to // distribution) - INFO_LOG << "Index likelihood function successfully set." << std::endl; + INFO_LOG << "Index likelihood function successfully set." + << std::endl; } else { - //Commented out for now as code uses single likelihood function making this fail - //valid_model = false; - //ERROR_LOG << "Error: Expected index likelihood function not defined for fleet " - // << f->id << ", likelihood function " << ind_like_id << std::endl; - //exit(1); + // Commented out for now as code uses single likelihood function + // making this fail valid_model = false; ERROR_LOG << "Error: Expected + // index likelihood function not defined for fleet " + // << f->id << ", likelihood function " << ind_like_id << + // std::endl; + // exit(1); } } else { - //Commented out for now as code uses single likelihood function making this fail - //valid_model = false; - //ERROR_LOG << "Error: No index likelihood function defined for fleet " << f->id - // << ". FIMS requires likelihood functions be defined for all data." << std::endl; - //exit(1); + // Commented out for now as code uses single likelihood function making + // this fail valid_model = false; ERROR_LOG << "Error: No index + // likelihood function defined for fleet " << f->id + // << ". FIMS requires likelihood functions be defined for all + // data." << std::endl; + // exit(1); } // end set index likelihood - INFO_LOG << "Checking for available age comp likelihood function." << std::endl; + INFO_LOG << "Checking for available age comp likelihood function." + << std::endl; // set agecomp likelihood if (f->fleet_agecomp_likelihood_id_m != -999) { uint32_t ac_like_id = static_cast( @@ -305,40 +323,44 @@ class Information { distribution_models_iterator it = this->distribution_models.find( ac_like_id); // if find, set it, otherwise invalid INFO_LOG << "Input age comp likelihood function id = " << ac_like_id - << "." << std::endl; + << "." << std::endl; if (it != this->distribution_models.end()) { f->agecomp_likelihood = (*it).second; // elements in container held in pair (first is // id, second is object - shared pointer to // distribution) - INFO_LOG << "Age comp likelihood function successfully set." << std::endl; + INFO_LOG << "Age comp likelihood function successfully set." + << std::endl; } else { - //Commented out for now as code uses single likelihood function making this fail - //valid_model = false; - //ERROR_LOG << "Error: Expected age comp likelihood function not defined for fleet " - // << f->id << ", likelihood function " << ac_like_id << std::endl; - //exit(1); + // Commented out for now as code uses single likelihood function + // making this fail valid_model = false; ERROR_LOG << "Error: Expected + // age comp likelihood function not defined for fleet " + // << f->id << ", likelihood function " << ac_like_id << + // std::endl; + // exit(1); } } else { - //Commented out for now as code uses single likelihood function making this fail - //valid_model = false; - //ERROR_LOG << "Error: No age comp likelihood function defined for fleet " << f->id - // << ". FIMS requires likelihood functions be defined for all data." << std::endl; - //exit(1); + // Commented out for now as code uses single likelihood function making + // this fail valid_model = false; ERROR_LOG << "Error: No age comp + // likelihood function defined for fleet " << f->id + // << ". FIMS requires likelihood functions be defined for all + // data." << std::endl; + // exit(1); } // end set agecomp likelihood - INFO_LOG << "Completed initialization for fleet " << f->id << "." << std::endl; + INFO_LOG << "Completed initialization for fleet " << f->id << "." + << std::endl; } // close fleet iterator loop INFO_LOG << "Completed initialization of all fleets." << std::endl; - - INFO_LOG << "Initializing population objects for " << this->populations.size() << " populations." << std::endl; + + INFO_LOG << "Initializing population objects for " + << this->populations.size() << " populations." << std::endl; for (population_iterator it = this->populations.begin(); it != this->populations.end(); ++it) { - std::shared_ptr > p = (*it).second; INFO_LOG << "Setting up links from population " << p->id @@ -355,34 +377,39 @@ class Information { p->fleets.push_back(f); INFO_LOG << f->id << " " << std::flush; } - INFO_LOG << "]" << std::endl; + INFO_LOG << "]" << std::endl; INFO_LOG << "Initializing population " << p->id << "." << std::endl; p->Initialize(p->nyears, p->nseasons, p->nages); - + INFO_LOG << "Checking for available recruitment function." << std::endl; // set recruitment if (p->recruitment_id != -999) { uint32_t recruitment_uint = static_cast(p->recruitment_id); recruitment_models_iterator it = this->recruitment_models.find(recruitment_uint); - INFO_LOG << "Input recruitment id = " << recruitment_uint << "." << std::endl; + INFO_LOG << "Input recruitment id = " << recruitment_uint << "." + << std::endl; if (it != this->recruitment_models.end()) { p->recruitment = (*it).second; // recruitment defined in population.hpp INFO_LOG << "Recruitment function successfully set." << std::endl; } else { valid_model = false; - ERROR_LOG << "Error: Expected recruitment function not defined for population " - << p->id << ", recruitment function " << recruitment_uint << std::endl; + ERROR_LOG << "Error: Expected recruitment function not defined for " + "population " + << p->id << ", recruitment function " << recruitment_uint + << std::endl; exit(1); } } else { valid_model = false; - ERROR_LOG << "Error: No recruitment function defined for population " << p->id - << ". FIMS requires recruitment functions be defined for all populations." - << std::endl; + ERROR_LOG << "Error: No recruitment function defined for population " + << p->id + << ". FIMS requires recruitment functions be defined for all " + "populations." + << std::endl; exit(1); } @@ -403,16 +430,19 @@ class Information { INFO_LOG << "Growth function successfully set." << std::endl; } else { valid_model = false; - ERROR_LOG << "Error: Expected growth function not defined for population " - << p->id << ", growth function " << growth_uint << std::endl; + ERROR_LOG + << "Error: Expected growth function not defined for population " + << p->id << ", growth function " << growth_uint << std::endl; exit(1); } } else { valid_model = false; - ERROR_LOG << "Error: No growth function defined for population " << p->id - << ". FIMS requires growth functions be defined for all populations." - << std::endl; + ERROR_LOG << "Error: No growth function defined for population " + << p->id + << ". FIMS requires growth functions be defined for all " + "populations." + << std::endl; exit(1); } @@ -429,19 +459,23 @@ class Information { INFO_LOG << "Maturity function successfully set." << std::endl; } else { valid_model = false; - ERROR_LOG << "Error: Expected maturity function not defined for population " - << p->id << ", maturity function " << maturity_uint << std::endl; + ERROR_LOG + << "Error: Expected maturity function not defined for population " + << p->id << ", maturity function " << maturity_uint << std::endl; exit(1); } } else { valid_model = false; - ERROR_LOG << "Error: No maturity function defined for population " << p->id - << ". FIMS requires maturity functions be defined for all populations." - << std::endl; + ERROR_LOG << "Error: No maturity function defined for population " + << p->id + << ". FIMS requires maturity functions be defined for all " + "populations." + << std::endl; exit(1); } - INFO_LOG << "Completed initialization for population " << p->id << "." << std::endl; + INFO_LOG << "Completed initialization for population " << p->id << "." + << std::endl; } INFO_LOG << "Completed initialization of all populations." << std::endl; INFO_LOG << "Completed FIMS model creation." << std::endl; diff --git a/inst/include/common/model.hpp b/inst/include/common/model.hpp index 061ae216a..e1130014a 100644 --- a/inst/include/common/model.hpp +++ b/inst/include/common/model.hpp @@ -91,17 +91,20 @@ class Model { // may need singleton // Loop over populations, evaluate, and sum up the recruitment likelihood // component - typename fims_info::Information::population_iterator it; - MODEL_LOG << "Evaluating expected values and summing recruitment nlls for " << this->fims_information->populations.size() << " populations." << std::endl; + MODEL_LOG << "Evaluating expected values and summing recruitment nlls for " + << this->fims_information->populations.size() << " populations." + << std::endl; for (it = this->fims_information->populations.begin(); it != this->fims_information->populations.end(); ++it) { //(*it).second points to the Population module - MODEL_LOG << "Setting up pointer to population " << (*it).second->id << "." << std::endl; + MODEL_LOG << "Setting up pointer to population " << (*it).second->id + << "." << std::endl; // Prepare recruitment (*it).second->recruitment->Prepare(); - MODEL_LOG << "Recruitment for population successfully prepared" << std::endl; + MODEL_LOG << "Recruitment for population successfully prepared" + << std::endl; // link to TMB objective function #ifdef TMB_MODEL (*it).second->of = this->of; @@ -110,14 +113,17 @@ class Model { // may need singleton (*it).second->Evaluate(); // Recrtuiment negative log-likelihood rec_nll += (*it).second->recruitment->evaluate_nll(); - MODEL_LOG << "Recruitment negative log-likelihood is: " << rec_nll << std::endl; + MODEL_LOG << "Recruitment negative log-likelihood is: " << rec_nll + << std::endl; } MODEL_LOG << "All populations successfully evaluated." << std::endl; // Loop over fleets/surveys, and sum up age comp and index nlls typename fims_info::Information::fleet_iterator jt; - MODEL_LOG << "Evaluating expected values and summing nlls for " << this->fims_information->fleets.size() << " fleets." << std::endl; + MODEL_LOG << "Evaluating expected values and summing nlls for " + << this->fims_information->fleets.size() << " fleets." + << std::endl; for (jt = this->fims_information->fleets.begin(); jt != this->fims_information->fleets.end(); ++jt) { @@ -125,10 +131,11 @@ class Model { // may need singleton #ifdef TMB_MODEL (*jt).second->of = this->of; #endif - MODEL_LOG << "Setting up pointer to fleet " << (*jt).second->id << "." << std::endl; + MODEL_LOG << "Setting up pointer to fleet " << (*jt).second->id << "." + << std::endl; age_comp_nll += (*jt).second->evaluate_age_comp_nll(); - MODEL_LOG << "Sum of survey and age comp negative log-likelihood is: " << age_comp_nll - << std::endl; + MODEL_LOG << "Sum of survey and age comp negative log-likelihood is: " + << age_comp_nll << std::endl; index_nll += (*jt).second->evaluate_index_nll(); } MODEL_LOG << "All fleets successfully evaluated." << std::endl; diff --git a/inst/include/distributions/functors/tmb_distributions.hpp b/inst/include/distributions/functors/tmb_distributions.hpp index 13877eb19..b3a0ee8c1 100644 --- a/inst/include/distributions/functors/tmb_distributions.hpp +++ b/inst/include/distributions/functors/tmb_distributions.hpp @@ -83,8 +83,8 @@ struct Dlnorm : public DistributionsBase { /** * @brief Probability density function of the lognormal distribution. * - * \f[ \frac{1.0}{ xsd\sqrt{2.0\pi} }exp(-\frac{(ln(x) - mean)^{2.0}}{2.0sd^{2.0}}) - * \f] + * \f[ \frac{1.0}{ xsd\sqrt{2.0\pi} }exp(-\frac{(ln(x) - + * mean)^{2.0}}{2.0sd^{2.0}}) \f] * * @param do_log Boolean; if true, log densities are returned */ diff --git a/inst/include/interface/rcpp/rcpp_interface.hpp b/inst/include/interface/rcpp/rcpp_interface.hpp index 7b11e9597..45711e9da 100644 --- a/inst/include/interface/rcpp/rcpp_interface.hpp +++ b/inst/include/interface/rcpp/rcpp_interface.hpp @@ -82,152 +82,150 @@ Rcpp::NumericVector get_random_parameters_vector() { return p; } - /** * Clears the contents of info log file. */ void clear_info_log() { - //First flush the output stream to make sure nothing - //is left in the stream memory bufffer. - INFO_LOG.flush(); - - //Next an new stream is opened and closed to - //overwrite the file. - std::ofstream CLEAR_LOG("logs/info.log"); - CLEAR_LOG.close(); - - //Finally the stream output location is reset back to the start - //of the file. - INFO_LOG.seekp(0); + // First flush the output stream to make sure nothing + // is left in the stream memory bufffer. + INFO_LOG.flush(); + + // Next an new stream is opened and closed to + // overwrite the file. + std::ofstream CLEAR_LOG("logs/info.log"); + CLEAR_LOG.close(); + + // Finally the stream output location is reset back to the start + // of the file. + INFO_LOG.seekp(0); } /** * Clears the contents of fims log file. */ void clear_fims_log() { - FIMS_LOG.flush(); - std::ofstream CLEAR_LOG("logs/fims.log"); - CLEAR_LOG.close(); - FIMS_LOG.seekp(0); + FIMS_LOG.flush(); + std::ofstream CLEAR_LOG("logs/fims.log"); + CLEAR_LOG.close(); + FIMS_LOG.seekp(0); } /** * Clears the contents of data log file. */ void clear_data_log() { - DATA_LOG.flush(); - std::ofstream CLEAR_LOG("logs/data.log"); - CLEAR_LOG.close(); - DATA_LOG.seekp(0); + DATA_LOG.flush(); + std::ofstream CLEAR_LOG("logs/data.log"); + CLEAR_LOG.close(); + DATA_LOG.seekp(0); } /** * Clears the contents of error log file. */ void clear_error_log() { - ERROR_LOG.flush(); - std::ofstream CLEAR_LOG("logs/error.log"); - CLEAR_LOG.close(); - ERROR_LOG.seekp(0); + ERROR_LOG.flush(); + std::ofstream CLEAR_LOG("logs/error.log"); + CLEAR_LOG.close(); + ERROR_LOG.seekp(0); } /** * Clears the contents of model log file. */ void clear_model_log() { - MODEL_LOG.flush(); - std::ofstream CLEAR_LOG("logs/model.log"); - CLEAR_LOG.close(); - MODEL_LOG.seekp(0); + MODEL_LOG.flush(); + std::ofstream CLEAR_LOG("logs/model.log"); + CLEAR_LOG.close(); + MODEL_LOG.seekp(0); } /** * Clears the contents of fleet log file. */ void clear_fleet_log() { - FLEET_LOG.flush(); - std::ofstream CLEAR_LOG("logs/fleet.log"); - CLEAR_LOG.close(); - FLEET_LOG.seekp(0); + FLEET_LOG.flush(); + std::ofstream CLEAR_LOG("logs/fleet.log"); + CLEAR_LOG.close(); + FLEET_LOG.seekp(0); } /** * Clears the contents of population log file. */ void clear_population_log() { - POPULATION_LOG.flush(); - std::ofstream CLEAR_LOG("logs/population.log"); - CLEAR_LOG.close(); - POPULATION_LOG.seekp(0); + POPULATION_LOG.flush(); + std::ofstream CLEAR_LOG("logs/population.log"); + CLEAR_LOG.close(); + POPULATION_LOG.seekp(0); } /** * Clears the contents of maturity log file. */ void clear_maturity_log() { - MATURITY_LOG.flush(); - std::ofstream CLEAR_LOG("logs/maturity.log"); - CLEAR_LOG.close(); - MATURITY_LOG.seekp(0); + MATURITY_LOG.flush(); + std::ofstream CLEAR_LOG("logs/maturity.log"); + CLEAR_LOG.close(); + MATURITY_LOG.seekp(0); } /** * Clears the contents of recruitment log file. */ void clear_recruitment_log() { - RECRUITMENT_LOG.flush(); - std::ofstream CLEAR_LOG("logs/recruitment.log"); - CLEAR_LOG.close(); - RECRUITMENT_LOG.seekp(0); + RECRUITMENT_LOG.flush(); + std::ofstream CLEAR_LOG("logs/recruitment.log"); + CLEAR_LOG.close(); + RECRUITMENT_LOG.seekp(0); } /** * Clears the contents of growth log file. */ void clear_growth_log() { - GROWTH_LOG.flush(); - std::ofstream CLEAR_LOG("logs/growth.log"); - CLEAR_LOG.close(); - GROWTH_LOG.seekp(0); + GROWTH_LOG.flush(); + std::ofstream CLEAR_LOG("logs/growth.log"); + CLEAR_LOG.close(); + GROWTH_LOG.seekp(0); } /** * Clears the contents of selectivity log file. */ void clear_selectivity_log() { - SELECTIVITY_LOG.flush(); - std::ofstream CLEAR_LOG("logs/selectivity.log"); - CLEAR_LOG.close(); - SELECTIVITY_LOG.seekp(0); + SELECTIVITY_LOG.flush(); + std::ofstream CLEAR_LOG("logs/selectivity.log"); + CLEAR_LOG.close(); + SELECTIVITY_LOG.seekp(0); } /** * Clears the contents of debug log file. */ void clear_debug_log() { - DEBUG_LOG.flush(); - std::ofstream CLEAR_LOG("logs/debug/debug.log"); - CLEAR_LOG.close(); - DEBUG_LOG.seekp(0); + DEBUG_LOG.flush(); + std::ofstream CLEAR_LOG("logs/debug/debug.log"); + CLEAR_LOG.close(); + DEBUG_LOG.seekp(0); } - /** * Clears the contents of log files. */ void clear_logs() { - clear_fims_log(); - clear_info_log(); - clear_data_log(); - clear_error_log(); - clear_model_log(); - clear_fleet_log(); - clear_population_log(); - clear_recruitment_log(); - clear_growth_log(); - clear_maturity_log(); - clear_selectivity_log(); - clear_debug_log(); + clear_fims_log(); + clear_info_log(); + clear_data_log(); + clear_error_log(); + clear_model_log(); + clear_fleet_log(); + clear_population_log(); + clear_recruitment_log(); + clear_growth_log(); + clear_maturity_log(); + clear_selectivity_log(); + clear_debug_log(); } template @@ -425,16 +423,19 @@ RCPP_MODULE(fims) { Rcpp::class_("LogisticSelectivity") .constructor() - .field("inflection_point", &LogisticSelectivityInterface::inflection_point) + .field("inflection_point", + &LogisticSelectivityInterface::inflection_point) .field("slope", &LogisticSelectivityInterface::slope) .method("get_id", &LogisticSelectivityInterface::get_id) .method("evaluate", &LogisticSelectivityInterface::evaluate); Rcpp::class_("DoubleLogisticSelectivity") .constructor() - .field("inflection_point_asc", &DoubleLogisticSelectivityInterface::inflection_point_asc) + .field("inflection_point_asc", + &DoubleLogisticSelectivityInterface::inflection_point_asc) .field("slope_asc", &DoubleLogisticSelectivityInterface::slope_asc) - .field("inflection_point_desc", &DoubleLogisticSelectivityInterface::inflection_point_desc) + .field("inflection_point_desc", + &DoubleLogisticSelectivityInterface::inflection_point_desc) .field("slope_desc", &DoubleLogisticSelectivityInterface::slope_desc) .method("get_id", &DoubleLogisticSelectivityInterface::get_id) .method("evaluate", &DoubleLogisticSelectivityInterface::evaluate); diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_maturity.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_maturity.hpp index 4ac17ded4..83cf499bf 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_maturity.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_maturity.hpp @@ -60,8 +60,9 @@ std::map MaturityInterfaceBase::live_objects; */ class LogisticMaturityInterface : public MaturityInterfaceBase { public: - Parameter inflection_point; /**< the index value at which the response reaches .5 */ - Parameter slope; /**< the width of the curve at the inflection_point */ + Parameter + inflection_point; /**< the index value at which the response reaches .5 */ + Parameter slope; /**< the width of the curve at the inflection_point */ LogisticMaturityInterface() : MaturityInterfaceBase() {} diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp index 93d0580af..8eb351d3e 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp @@ -106,7 +106,8 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase { for (int i = 0; i < deviations.size(); i++) { NLL.recruit_deviations[i] = deviations[i]; } - RECRUITMENT_LOG << "Rec devs being passed to C++ are " << deviations << std::endl; + RECRUITMENT_LOG << "Rec devs being passed to C++ are " << deviations + << std::endl; NLL.estimate_recruit_deviations = this->estimate_deviations; return NLL.evaluate_nll(); } diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_selectivity.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_selectivity.hpp index d77337ff7..5f282cebc 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_selectivity.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_selectivity.hpp @@ -60,8 +60,9 @@ std::map */ class LogisticSelectivityInterface : public SelectivityInterfaceBase { public: - Parameter inflection_point; /**< the index value at which the response reaches .5 */ - Parameter slope; /**< the width of the curve at the inflection_point */ + Parameter + inflection_point; /**< the index value at which the response reaches .5 */ + Parameter slope; /**< the width of the curve at the inflection_point */ LogisticSelectivityInterface() : SelectivityInterfaceBase() {} @@ -136,10 +137,11 @@ class LogisticSelectivityInterface : public SelectivityInterfaceBase { */ class DoubleLogisticSelectivityInterface : public SelectivityInterfaceBase { public: - Parameter inflection_point_asc; /**< the index value at which the response reaches .5 */ - Parameter slope_asc; /**< the width of the curve at the inflection_point */ - Parameter - inflection_point_desc; /**< the index value at which the response reaches .5 */ + Parameter inflection_point_asc; /**< the index value at which the response + reaches .5 */ + Parameter slope_asc; /**< the width of the curve at the inflection_point */ + Parameter inflection_point_desc; /**< the index value at which the response + reaches .5 */ Parameter slope_desc; /**< the width of the curve at the inflection_point */ DoubleLogisticSelectivityInterface() : SelectivityInterfaceBase() {} @@ -157,7 +159,8 @@ class DoubleLogisticSelectivityInterface : public SelectivityInterfaceBase { fims_popdy::DoubleLogisticSelectivity DoubleLogisticSel; DoubleLogisticSel.inflection_point_asc = this->inflection_point_asc.value_m; DoubleLogisticSel.slope_asc = this->slope_asc.value_m; - DoubleLogisticSel.inflection_point_desc = this->inflection_point_desc.value_m; + DoubleLogisticSel.inflection_point_desc = + this->inflection_point_desc.value_m; DoubleLogisticSel.slope_desc = this->slope_desc.value_m; return DoubleLogisticSel.evaluate(x); } diff --git a/inst/include/population_dynamics/fleet/fleet.hpp b/inst/include/population_dynamics/fleet/fleet.hpp index 962c98119..cd452333b 100644 --- a/inst/include/population_dynamics/fleet/fleet.hpp +++ b/inst/include/population_dynamics/fleet/fleet.hpp @@ -140,11 +140,9 @@ struct Fleet : public fims_model_object::FIMSObject { 0); /*!q = fims_math::exp(this->log_q); for (size_t year = 0; year < this->nyears; year++) { - FLEET_LOG << "input F mort " << this->log_Fmort[year] << std::endl; FLEET_LOG << "input q " << this->log_q << std::endl; this->Fmort[year] = fims_math::exp(this->log_Fmort[year]); - } } @@ -155,11 +153,10 @@ struct Fleet : public fims_model_object::FIMSObject { size_t dims = this->observed_agecomp_data->get_imax() * this->observed_agecomp_data->get_jmax(); if (dims != this->catch_numbers_at_age.size()) { - - ERROR_LOG << "Error: observed age comp is of size " - << dims << " and expected is of size " - << this->age_composition.size() << std::endl; - exit(1); + ERROR_LOG << "Error: observed age comp is of size " << dims + << " and expected is of size " << this->age_composition.size() + << std::endl; + exit(1); } else { for (size_t y = 0; y < this->nyears; y++) { @@ -185,15 +182,16 @@ struct Fleet : public fims_model_object::FIMSObject { observed_acomp[a] = this->observed_agecomp_data->at(y, a); FLEET_LOG << " age " << a << " in year " << y - << "has expected: " << expected_acomp[a] - << " and observed: " << observed_acomp[a] << std::endl; + << "has expected: " << expected_acomp[a] + << " and observed: " << observed_acomp[a] << std::endl; } dmultinom.x = observed_acomp; dmultinom.p = expected_acomp; nll -= dmultinom.evaluate(true); } } - FLEET_LOG << "Age comp negative log-likelihood for fleet," << this->id << nll << std::endl; + FLEET_LOG << "Age comp negative log-likelihood for fleet," << this->id + << nll << std::endl; #endif return nll; } @@ -209,13 +207,11 @@ struct Fleet : public fims_model_object::FIMSObject { dnorm.mean = fims_math::log(this->expected_index[i]); nll -= dnorm.evaluate(true); - FLEET_LOG - << "observed index data: " << i << " is " - << this->observed_index_data->at(i) - << " and expected is: " << this->expected_index[i] << std::endl; + FLEET_LOG << "observed index data: " << i << " is " + << this->observed_index_data->at(i) + << " and expected is: " << this->expected_index[i] << std::endl; } - FLEET_LOG - << " log obs error is: " << this->log_obs_error << std::endl; + FLEET_LOG << " log obs error is: " << this->log_obs_error << std::endl; FLEET_LOG << " sd is: " << dnorm.sd << std::endl; FLEET_LOG << " index nll: " << nll << std::endl; diff --git a/inst/include/population_dynamics/maturity/functors/logistic.hpp b/inst/include/population_dynamics/maturity/functors/logistic.hpp index 38ddb85f9..d17167dd0 100644 --- a/inst/include/population_dynamics/maturity/functors/logistic.hpp +++ b/inst/include/population_dynamics/maturity/functors/logistic.hpp @@ -21,10 +21,10 @@ namespace fims_popdy { */ template struct LogisticMaturity : public MaturityBase { - Type inflection_point; /*!< 50% quantile of the value of the quantity of interest (x); - e.g. age at which 50% of the fish are mature */ - Type slope; /*!() {} @@ -38,7 +38,7 @@ struct LogisticMaturity : public MaturityBase { * size at maturity). */ - virtual const Type evaluate(const Type & x) { + virtual const Type evaluate(const Type& x) { return fims_math::logistic(inflection_point, slope, x); } }; diff --git a/inst/include/population_dynamics/population/population.hpp b/inst/include/population_dynamics/population/population.hpp index d0ce72122..9cc08966a 100644 --- a/inst/include/population_dynamics/population/population.hpp +++ b/inst/include/population_dynamics/population/population.hpp @@ -215,14 +215,16 @@ struct Population : public fims_model_object::FIMSObject { this->fleets[fleet_]->Fmort[year] * // evaluate is a member function of the selectivity class this->fleets[fleet_]->selectivity->evaluate(ages[age]); - POPULATION_LOG << " selectivity at age " << ages[age] << " for fleet " << fleet_ << " is " - << this->fleets[fleet_]->selectivity->evaluate(ages[age]) - << " apical fishing mortality F for the fleet in year " << year << " is " - << this->fleets[fleet_]->Fmort[year] << std::endl; + POPULATION_LOG << " selectivity at age " << ages[age] << " for fleet " + << fleet_ << " is " + << this->fleets[fleet_]->selectivity->evaluate(ages[age]) + << " apical fishing mortality F for the fleet in year " + << year << " is " << this->fleets[fleet_]->Fmort[year] + << std::endl; } } POPULATION_LOG << "M in calculate mortality is " << this->M[i_age_year] - << std::endl; + << std::endl; this->mortality_Z[i_age_year] = this->M[i_age_year] + this->mortality_F[i_age_year]; } @@ -242,7 +244,7 @@ struct Population : public fims_model_object::FIMSObject { (fims_math::exp(-this->mortality_Z[i_agem1_yearm1])); POPULATION_LOG << " z at i_agem1_yearm1 = " << i_agem1_yearm1 << " is " - << this->mortality_Z[i_agem1_yearm1] << std::endl; + << this->mortality_Z[i_agem1_yearm1] << std::endl; // Plus group calculation if (age == (this->nages - 1)) { this->numbers_at_age[i_age_year] = @@ -267,7 +269,7 @@ struct Population : public fims_model_object::FIMSObject { (fims_math::exp(-this->M[i_agem1_yearm1])); POPULATION_LOG << "survival rate at index " << i_agem1_yearm1 << " is " - << fims_math::exp(-(this->M[i_agem1_yearm1])) << std::endl; + << fims_math::exp(-(this->M[i_agem1_yearm1])) << std::endl; // Plus group calculation if (age == (this->nages - 1)) { @@ -290,7 +292,7 @@ struct Population : public fims_model_object::FIMSObject { this->numbers_at_age[i_age_year] * this->weight_at_age[age]; POPULATION_LOG << " age " << ages[age] << std::endl; POPULATION_LOG << "growth evaluate: " << this->weight_at_age[age] - << " biomass inputs----- +++\n"; + << " biomass inputs----- +++\n"; } /** @@ -302,8 +304,8 @@ struct Population : public fims_model_object::FIMSObject { * @param age the age of unfished biomass to add */ void CalculateUnfishedBiomass(size_t i_age_year, size_t year, size_t age) { - this->unfished_biomass[year] += this->unfished_numbers_at_age[i_age_year] * - this->weight_at_age[age]; + this->unfished_biomass[year] += + this->unfished_numbers_at_age[i_age_year] * this->weight_at_age[age]; } /** @@ -314,17 +316,18 @@ struct Population : public fims_model_object::FIMSObject { * @param age the age who's biomass is being added into total spawning biomass */ void CalculateSpawningBiomass(size_t i_age_year, size_t year, size_t age) { - this->spawning_biomass[year] += this->proportion_female * - this->numbers_at_age[i_age_year] * - this->proportion_mature_at_age[i_age_year] * - this->weight_at_age[age]; + this->spawning_biomass[year] += + this->proportion_female * this->numbers_at_age[i_age_year] * + this->proportion_mature_at_age[i_age_year] * this->weight_at_age[age]; POPULATION_LOG << " proportion female " << this->proportion_female << " " - << " mature age " << age << " is " - << this->proportion_mature_at_age[i_age_year] << " " - << " numbers at age " << this->numbers_at_age[i_age_year] << " " - << " growth " << this->weight_at_age[age] << " " - << " spawning biomass " << this->spawning_biomass[year] << " " - << " spawning biomass inputs----- +++\n"; + << " mature age " << age << " is " + << this->proportion_mature_at_age[i_age_year] << " " + << " numbers at age " << this->numbers_at_age[i_age_year] + << " " + << " growth " << this->weight_at_age[age] << " " + << " spawning biomass " << this->spawning_biomass[year] + << " " + << " spawning biomass inputs----- +++\n"; } /** @@ -339,8 +342,7 @@ struct Population : public fims_model_object::FIMSObject { size_t age) { this->unfished_spawning_biomass[year] += this->proportion_female * this->unfished_numbers_at_age[i_age_year] * - this->proportion_mature_at_age[i_age_year] * - this->weight_at_age[age]; + this->proportion_mature_at_age[i_age_year] * this->weight_at_age[age]; } /** @@ -382,19 +384,20 @@ struct Population : public fims_model_object::FIMSObject { POPULATION_LOG << "recruitment 2" << std::endl; POPULATION_LOG << "phi0 = " << phi0 << std::endl; POPULATION_LOG << "spawning biomass = " << this->spawning_biomass[year] - << std::endl; - POPULATION_LOG << "rec devs = " << this->recruitment->recruit_deviations[year - 1] - << std::endl; + << std::endl; + POPULATION_LOG << "rec devs = " + << this->recruitment->recruit_deviations[year - 1] + << std::endl; POPULATION_LOG << "rec eval = " - << this->recruitment->evaluate(this->spawning_biomass[year - 1], - phi0) - << std::endl; + << this->recruitment->evaluate( + this->spawning_biomass[year - 1], phi0) + << std::endl; this->numbers_at_age[i_age_year] = this->recruitment->evaluate(this->spawning_biomass[year - 1], phi0) * this->recruitment->recruit_deviations[year]; this->expected_recruitment[year] = this->numbers_at_age[i_age_year]; POPULATION_LOG << " numbers at age at indexya " << i_age_year << " is " - << this->numbers_at_age[i_age_year] << std::endl; + << this->numbers_at_age[i_age_year] << std::endl; } /** @@ -410,15 +413,15 @@ struct Population : public fims_model_object::FIMSObject { fleet_; // index by fleet and years to dimension fold size_t i_age_year = year * this->nages + age; - POPULATION_LOG << " fleet " << fleet_ << " year " << year << " age " << age - << std::endl; + POPULATION_LOG << " fleet " << fleet_ << " year " << year << " age " + << age << std::endl; this->expected_catch[index_yf] += this->fleets[fleet_]->catch_weight_at_age[i_age_year]; POPULATION_LOG << "expected catch: " << this->expected_catch[index_yf] - << std::endl; + << std::endl; POPULATION_LOG << "----------------------------------------------" - << std::endl; + << std::endl; fleets[fleet_]->expected_catch[year] += this->fleets[fleet_]->catch_weight_at_age[i_age_year]; @@ -449,7 +452,7 @@ struct Population : public fims_model_object::FIMSObject { } fleets[fleet_]->expected_index[year] += index_; POPULATION_LOG << " expected index in year " << year << " is " - << fleets[fleet_]->expected_index[year] << std::endl; + << fleets[fleet_]->expected_index[year] << std::endl; } } @@ -478,11 +481,11 @@ struct Population : public fims_model_object::FIMSObject { catch_ = (this->fleets[fleet_]->selectivity->evaluate(ages[age])) * this->numbers_at_age[i_age_year]; } - POPULATION_LOG << " F " << fleet_ << " " << this->fleets[fleet_]->Fmort[year] - << std::endl; + POPULATION_LOG << " F " << fleet_ << " " + << this->fleets[fleet_]->Fmort[year] << std::endl; POPULATION_LOG << " selectivity " - << this->fleets[fleet_]->selectivity->evaluate(ages[age]) - << std::endl; + << this->fleets[fleet_]->selectivity->evaluate(ages[age]) + << std::endl; POPULATION_LOG << " catch " << catch_ << std::endl; // this->catch_numbers_at_age[i_age_yearf] += catch_; // catch_numbers_at_age for the fleet module has different @@ -503,14 +506,15 @@ struct Population : public fims_model_object::FIMSObject { for (size_t fleet_ = 0; fleet_ < this->nfleets; fleet_++) { POPULATION_LOG << " fleet " << fleet_ << std::endl; POPULATION_LOG << " catchnaa " - << this->fleets[fleet_]->catch_numbers_at_age[year] << std::endl; + << this->fleets[fleet_]->catch_numbers_at_age[year] + << std::endl; POPULATION_LOG << " weight " << this->weight_at_age[age] << std::endl; this->fleets[fleet_]->catch_weight_at_age[i_age_year] = this->fleets[fleet_]->catch_numbers_at_age[i_age_year] * - this->weight_at_age[age]; + this->weight_at_age[age]; POPULATION_LOG << " catch_waa " - << this->fleets[fleet_]->catch_weight_at_age[i_age_year] - << std::endl; + << this->fleets[fleet_]->catch_weight_at_age[i_age_year] + << std::endl; } } @@ -528,13 +532,13 @@ struct Population : public fims_model_object::FIMSObject { POPULATION_LOG << " ages size " << this->ages.size() << std::endl; POPULATION_LOG << " i_age_year " << i_age_year << std::endl; POPULATION_LOG << "p mature" << this->proportion_mature_at_age[i_age_year] - << std::endl; + << std::endl; POPULATION_LOG << this->ages[age] << std::endl; this->proportion_mature_at_age[i_age_year] = this->maturity->evaluate(ages[age]); - POPULATION_LOG << "p mature set to " << this->proportion_mature_at_age[i_age_year] - << std::endl; + POPULATION_LOG << "p mature set to " + << this->proportion_mature_at_age[i_age_year] << std::endl; } /** @@ -687,9 +691,9 @@ struct Population : public fims_model_object::FIMSObject { for (size_t fleet_ = 0; fleet_ < this->nfleets; fleet_++) { for (size_t i = 0; i < nyears; i++) { for (size_t j = 0; j < nages; j++) { - POPULATION_LOG << "Fleet " << fleet_ + 1 << "\n"; + POPULATION_LOG << "Fleet " << fleet_ + 1 << "\n"; POPULATION_LOG << fleets[fleet_]->catch_numbers_at_age[i * nages + j] - << "\t"; + << "\t"; } POPULATION_LOG << "\n"; } diff --git a/inst/include/population_dynamics/selectivity/functors/double_logistic.hpp b/inst/include/population_dynamics/selectivity/functors/double_logistic.hpp index a8bce516a..51bee5e8a 100644 --- a/inst/include/population_dynamics/selectivity/functors/double_logistic.hpp +++ b/inst/include/population_dynamics/selectivity/functors/double_logistic.hpp @@ -19,18 +19,18 @@ namespace fims_popdy { */ template struct DoubleLogisticSelectivity : public SelectivityBase { - Type inflection_point_asc; /*!< 50% quantile of the value of the quantity of interest - (x) on the ascending limb of the double logistic curve; e.g. age - at which 50% of the fish are selected */ - Type slope_asc; /*!() {} @@ -40,15 +40,15 @@ struct DoubleLogisticSelectivity : public SelectivityBase { * double logistic function from FIMS math. * * \f$ \frac{1.0}{ 1.0 + exp(-1.0 * slope_{asc} (x - inflection_point_{asc}))} - * \left(1.0-\frac{1.0}{ 1.0 + exp(-1.0 * slope_{desc} (x - inflection_point_{desc}))} - * \right)\f$ + * \left(1.0-\frac{1.0}{ 1.0 + exp(-1.0 * slope_{desc} (x - + * inflection_point_{desc}))} \right)\f$ * * @param x The independent variable in the double logistic function (e.g., * age or size in selectivity). */ virtual const Type evaluate(const Type &x) { - return fims_math::double_logistic(inflection_point_asc, slope_asc, inflection_point_desc, - slope_desc, x); + return fims_math::double_logistic( + inflection_point_asc, slope_asc, inflection_point_desc, slope_desc, x); } }; diff --git a/inst/include/population_dynamics/selectivity/functors/logistic.hpp b/inst/include/population_dynamics/selectivity/functors/logistic.hpp index 27bbc77ce..cd50a4fd6 100644 --- a/inst/include/population_dynamics/selectivity/functors/logistic.hpp +++ b/inst/include/population_dynamics/selectivity/functors/logistic.hpp @@ -22,10 +22,10 @@ namespace fims_popdy { */ template struct LogisticSelectivity : public SelectivityBase { - Type inflection_point; /*!< 50% quantile of the value of the quantity of interest (x); - e.g. age at which 50% of the fish are selected */ - Type slope; /*!() {} diff --git a/tests/gtest/test_population_test_fixture.hpp b/tests/gtest/test_population_test_fixture.hpp index 0b30f770a..e87476856 100644 --- a/tests/gtest/test_population_test_fixture.hpp +++ b/tests/gtest/test_population_test_fixture.hpp @@ -77,7 +77,8 @@ class PopulationPrepareTestFixture : public testing::Test { // Does Fmort need to be in side of the year loop like log_q? for (int i = 0; i < nfleets; i++) { auto fleet = std::make_shared>(); - auto selectivity = std::make_shared>(); + auto selectivity = + std::make_shared>(); selectivity->inflection_point = 7; selectivity->slope = 0.5;