From f0ffffef9e735a8210c1b43b1524cfe10d81c0ef Mon Sep 17 00:00:00 2001 From: Bai Li - NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com> Date: Thu, 21 Sep 2023 13:33:37 -0400 Subject: [PATCH] fix: refactor parameter constructor (#455) * fix: refactor parameter constructor * refactor: update members in the Parameter class --- .../include/interface/rcpp/rcpp_interface.hpp | 10 +- .../rcpp/rcpp_objects/rcpp_fleet.hpp | 16 +- .../rcpp/rcpp_objects/rcpp_interface_base.hpp | 16 +- .../rcpp/rcpp_objects/rcpp_maturity.hpp | 52 +++--- .../rcpp/rcpp_objects/rcpp_recruitment.hpp | 80 ++++----- .../rcpp/rcpp_objects/rcpp_selectivity.hpp | 156 +++++++++--------- .../rcpp_objects/rcpp_tmb_distribution.hpp | 60 +++---- 7 files changed, 195 insertions(+), 195 deletions(-) diff --git a/inst/include/interface/rcpp/rcpp_interface.hpp b/inst/include/interface/rcpp/rcpp_interface.hpp index 7b85c2f3e..06690d811 100644 --- a/inst/include/interface/rcpp/rcpp_interface.hpp +++ b/inst/include/interface/rcpp/rcpp_interface.hpp @@ -174,11 +174,11 @@ RCPP_MODULE(fims) { .constructor() .constructor() .constructor() - .field("value", &Parameter::value) - .field("min", &Parameter::min) - .field("max", &Parameter::max) - .field("is_random_effect", &Parameter::is_random_effect) - .field("estimated", &Parameter::estimated); + .field("value", &Parameter::value_m) + .field("min", &Parameter::min_m) + .field("max", &Parameter::max_m) + .field("is_random_effect", &Parameter::is_random_effect_m) + .field("estimated", &Parameter::estimated_m); Rcpp::class_("BevertonHoltRecruitment") .constructor() diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_fleet.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_fleet.hpp index 689ea09f1..afb0a8045 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_fleet.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_fleet.hpp @@ -115,8 +115,8 @@ class FleetInterface : public FIMSRcppInterfaceBase { f0->observed_index_data_id = this->observed_index_data_id; f0->selectivity_id = this->selectivity_id; - f0->log_obs_error = this->log_obs_error.value; - if (this->log_obs_error.estimated) { + f0->log_obs_error = this->log_obs_error.value_m; + if (this->log_obs_error.estimated_m) { d0->RegisterParameter(f0->log_obs_error); } f0->log_q = this->log_q; @@ -158,8 +158,8 @@ class FleetInterface : public FIMSRcppInterfaceBase { f1->index_likelihood_id = this->index_likelihood_id; f1->observed_agecomp_data_id = this->observed_agecomp_data_id; f1->observed_index_data_id = this->observed_index_data_id; - f1->log_obs_error = this->log_obs_error.value; - if (this->log_obs_error.estimated) { + f1->log_obs_error = this->log_obs_error.value_m; + if (this->log_obs_error.estimated_m) { d1->RegisterParameter(f1->log_obs_error); } f1->selectivity_id = this->selectivity_id; @@ -203,8 +203,8 @@ class FleetInterface : public FIMSRcppInterfaceBase { f2->index_likelihood_id = this->index_likelihood_id; f2->observed_agecomp_data_id = this->observed_agecomp_data_id; f2->observed_index_data_id = this->observed_index_data_id; - f2->log_obs_error = this->log_obs_error.value; - if (this->log_obs_error.estimated) { + f2->log_obs_error = this->log_obs_error.value_m; + if (this->log_obs_error.estimated_m) { d2->RegisterParameter(f2->log_obs_error); } f2->selectivity_id = this->selectivity_id; @@ -248,8 +248,8 @@ class FleetInterface : public FIMSRcppInterfaceBase { f3->observed_agecomp_data_id = this->observed_agecomp_data_id; f3->observed_index_data_id = this->observed_index_data_id; f3->selectivity_id = this->selectivity_id; - f3->log_obs_error = this->log_obs_error.value; - if (this->log_obs_error.estimated) { + f3->log_obs_error = this->log_obs_error.value_m; + if (this->log_obs_error.estimated_m) { d3->RegisterParameter(f3->log_obs_error); } f3->log_q = this->log_q; 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 9fa1b6d9e..ca40f1122 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_interface_base.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_interface_base.hpp @@ -25,14 +25,14 @@ */ class Parameter { public: - double value; /**< initial value of the parameter*/ - double min = + double value_m; /**< initial value of the parameter*/ + double min_m = std::numeric_limits::min(); /**< min value of the parameter*/ - double max = + double max_m = std::numeric_limits::max(); /**< max value of the parameter*/ - bool is_random_effect = false; /**< Is the parameter a random effect + bool is_random_effect_m = false; /**< Is the parameter a random effect parameter? Default value is false.*/ - bool estimated = + bool estimated_m = false; /**< Is the parameter estimated? Default value is false.*/ /** @@ -40,19 +40,19 @@ class Parameter { * @details Inputs include value, min, max, estimated. */ Parameter(double value, double min, double max, bool estimated) - : value(value), min(min), max(max), estimated(estimated) {} + : value_m(value), min_m(min), max_m(max), estimated_m(estimated) {} /** * @brief Constructor for initializing Parameter. * @details Inputs include value. */ - Parameter(double value) { this->value = value; } + Parameter(double value) { value_m = value; } /** * @brief Constructor for initializing Parameter. * @details Set value to 0 when there is no input value. */ - Parameter() { this->value = 0; } + Parameter() { value_m = 0; } }; /** diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_maturity.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_maturity.hpp index 1d1e27d40..f2cc78ff7 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_maturity.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_maturity.hpp @@ -74,8 +74,8 @@ class LogisticMaturityInterface : public MaturityInterfaceBase { virtual double evaluate(double x) { fims::LogisticMaturity LogisticMat; - LogisticMat.median = this->median.value; - LogisticMat.slope = this->slope.value; + LogisticMat.median = this->median.value_m; + LogisticMat.slope = this->slope.value_m; return LogisticMat.evaluate(x); } @@ -90,17 +90,17 @@ class LogisticMaturityInterface : public MaturityInterfaceBase { // set relative info lm0->id = this->id; - lm0->median = this->median.value; - if (this->median.estimated) { - if (this->median.is_random_effect) { + lm0->median = this->median.value_m; + if (this->median.estimated_m) { + if (this->median.is_random_effect_m) { d0->RegisterRandomEffect(lm0->median); } else { d0->RegisterParameter(lm0->median); } } - lm0->slope = this->slope.value; - if (this->slope.estimated) { - if (this->slope.is_random_effect) { + lm0->slope = this->slope.value_m; + if (this->slope.estimated_m) { + if (this->slope.is_random_effect_m) { d0->RegisterRandomEffect(lm0->slope); } else { d0->RegisterParameter(lm0->slope); @@ -118,17 +118,17 @@ class LogisticMaturityInterface : public MaturityInterfaceBase { // set relative info lm1->id = this->id; - lm1->median = this->median.value; - if (this->median.estimated) { - if (this->median.is_random_effect) { + lm1->median = this->median.value_m; + if (this->median.estimated_m) { + if (this->median.is_random_effect_m) { d1->RegisterRandomEffect(lm1->median); } else { d1->RegisterParameter(lm1->median); } } - lm1->slope = this->slope.value; - if (this->slope.estimated) { - if (this->slope.is_random_effect) { + lm1->slope = this->slope.value_m; + if (this->slope.estimated_m) { + if (this->slope.is_random_effect_m) { d1->RegisterRandomEffect(lm1->slope); } else { d1->RegisterParameter(lm1->slope); @@ -146,17 +146,17 @@ class LogisticMaturityInterface : public MaturityInterfaceBase { // set relative info lm2->id = this->id; - lm2->median = this->median.value; - if (this->median.estimated) { - if (this->median.is_random_effect) { + lm2->median = this->median.value_m; + if (this->median.estimated_m) { + if (this->median.is_random_effect_m) { d2->RegisterRandomEffect(lm2->median); } else { d2->RegisterParameter(lm2->median); } } - lm2->slope = this->slope.value; - if (this->slope.estimated) { - if (this->slope.is_random_effect) { + lm2->slope = this->slope.value_m; + if (this->slope.estimated_m) { + if (this->slope.is_random_effect_m) { d2->RegisterRandomEffect(lm2->slope); } else { d2->RegisterParameter(lm2->slope); @@ -174,17 +174,17 @@ class LogisticMaturityInterface : public MaturityInterfaceBase { // set relative info lm3->id = this->id; - lm3->median = this->median.value; - if (this->median.estimated) { - if (this->median.is_random_effect) { + lm3->median = this->median.value_m; + if (this->median.estimated_m) { + if (this->median.is_random_effect_m) { d3->RegisterRandomEffect(lm3->median); } else { d3->RegisterParameter(lm3->median); } } - lm3->slope = this->slope.value; - if (this->slope.estimated) { - if (this->slope.is_random_effect) { + lm3->slope = this->slope.value_m; + if (this->slope.estimated_m) { + if (this->slope.is_random_effect_m) { d3->RegisterRandomEffect(lm3->slope); } else { d3->RegisterParameter(lm3->slope); diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp index ffe2e7bb9..a9ae8d57b 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_recruitment.hpp @@ -83,14 +83,14 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase { virtual double evaluate(double spawners, double ssbzero) { fims::SRBevertonHolt BevHolt; - BevHolt.logit_steep = this->logit_steep.value; - if (this->logit_steep.value == 1.0) { + BevHolt.logit_steep = this->logit_steep.value_m; + if (this->logit_steep.value_m == 1.0) { warning( "Steepness is subject to a logit transformation, so its value is " "0.7848469. Fixing it at 1.0 is not currently possible."); } - BevHolt.log_rzero = this->log_rzero.value; + BevHolt.log_rzero = this->log_rzero.value_m; return BevHolt.evaluate(spawners, ssbzero); } @@ -98,7 +98,7 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase { virtual double evaluate_nll() { fims::SRBevertonHolt NLL; - NLL.log_sigma_recruit = this->log_sigma_recruit.value; + NLL.log_sigma_recruit = this->log_sigma_recruit.value_m; NLL.recruit_deviations.resize(deviations.size()); // Vector from TMB for (int i = 0; i < deviations.size(); i++) { NLL.recruit_deviations[i] = deviations[i]; @@ -121,25 +121,25 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase { // set relative info b0->id = this->id; - b0->logit_steep = this->logit_steep.value; - if (this->logit_steep.estimated) { - if (this->logit_steep.is_random_effect) { + b0->logit_steep = this->logit_steep.value_m; + if (this->logit_steep.estimated_m) { + if (this->logit_steep.is_random_effect_m) { d0->RegisterRandomEffect(b0->logit_steep); } else { d0->RegisterParameter(b0->logit_steep); } } - b0->log_rzero = this->log_rzero.value; - if (this->log_rzero.estimated) { - if (this->log_rzero.is_random_effect) { + b0->log_rzero = this->log_rzero.value_m; + if (this->log_rzero.estimated_m) { + if (this->log_rzero.is_random_effect_m) { d0->RegisterRandomEffect(b0->log_rzero); } else { d0->RegisterParameter(b0->log_rzero); } } - b0->log_sigma_recruit = this->log_sigma_recruit.value; - if (this->log_sigma_recruit.estimated) { - if (this->log_sigma_recruit.is_random_effect) { + b0->log_sigma_recruit = this->log_sigma_recruit.value_m; + if (this->log_sigma_recruit.estimated_m) { + if (this->log_sigma_recruit.is_random_effect_m) { d0->RegisterRandomEffect(b0->log_sigma_recruit); } else { d0->RegisterParameter(b0->log_sigma_recruit); @@ -170,25 +170,25 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase { // set relative info b1->id = this->id; - b1->logit_steep = this->logit_steep.value; - if (this->logit_steep.estimated) { - if (this->logit_steep.is_random_effect) { + b1->logit_steep = this->logit_steep.value_m; + if (this->logit_steep.estimated_m) { + if (this->logit_steep.is_random_effect_m) { d1->RegisterRandomEffect(b1->logit_steep); } else { d1->RegisterParameter(b1->logit_steep); } } - b1->log_rzero = this->log_rzero.value; - if (this->log_rzero.estimated) { - if (this->log_rzero.is_random_effect) { + b1->log_rzero = this->log_rzero.value_m; + if (this->log_rzero.estimated_m) { + if (this->log_rzero.is_random_effect_m) { d1->RegisterRandomEffect(b1->log_rzero); } else { d1->RegisterParameter(b1->log_rzero); } } - b1->log_sigma_recruit = this->log_sigma_recruit.value; - if (this->log_sigma_recruit.estimated) { - if (this->log_sigma_recruit.is_random_effect) { + b1->log_sigma_recruit = this->log_sigma_recruit.value_m; + if (this->log_sigma_recruit.estimated_m) { + if (this->log_sigma_recruit.is_random_effect_m) { d1->RegisterRandomEffect(b1->log_sigma_recruit); } else { d1->RegisterParameter(b1->log_sigma_recruit); @@ -219,25 +219,25 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase { // set relative info b2->id = this->id; - b2->logit_steep = this->logit_steep.value; - if (this->logit_steep.estimated) { - if (this->logit_steep.is_random_effect) { + b2->logit_steep = this->logit_steep.value_m; + if (this->logit_steep.estimated_m) { + if (this->logit_steep.is_random_effect_m) { d2->RegisterRandomEffect(b2->logit_steep); } else { d2->RegisterParameter(b2->logit_steep); } } - b2->log_rzero = this->log_rzero.value; - if (this->log_rzero.estimated) { - if (this->log_rzero.is_random_effect) { + b2->log_rzero = this->log_rzero.value_m; + if (this->log_rzero.estimated_m) { + if (this->log_rzero.is_random_effect_m) { d2->RegisterRandomEffect(b2->log_rzero); } else { d2->RegisterParameter(b2->log_rzero); } } - b2->log_sigma_recruit = this->log_sigma_recruit.value; - if (this->log_sigma_recruit.estimated) { - if (this->log_sigma_recruit.is_random_effect) { + b2->log_sigma_recruit = this->log_sigma_recruit.value_m; + if (this->log_sigma_recruit.estimated_m) { + if (this->log_sigma_recruit.is_random_effect_m) { d2->RegisterRandomEffect(b2->log_sigma_recruit); } else { d2->RegisterParameter(b2->log_sigma_recruit); @@ -268,25 +268,25 @@ class BevertonHoltRecruitmentInterface : public RecruitmentInterfaceBase { // set relative info b3->id = this->id; - b3->logit_steep = this->logit_steep.value; - if (this->logit_steep.estimated) { - if (this->logit_steep.is_random_effect) { + b3->logit_steep = this->logit_steep.value_m; + if (this->logit_steep.estimated_m) { + if (this->logit_steep.is_random_effect_m) { d3->RegisterRandomEffect(b3->logit_steep); } else { d3->RegisterParameter(b3->logit_steep); } } - b3->log_rzero = this->log_rzero.value; - if (this->log_rzero.estimated) { - if (this->log_rzero.is_random_effect) { + b3->log_rzero = this->log_rzero.value_m; + if (this->log_rzero.estimated_m) { + if (this->log_rzero.is_random_effect_m) { d3->RegisterRandomEffect(b3->log_rzero); } else { d3->RegisterParameter(b3->log_rzero); } } - b3->log_sigma_recruit = this->log_sigma_recruit.value; - if (this->log_sigma_recruit.estimated) { - if (this->log_sigma_recruit.is_random_effect) { + b3->log_sigma_recruit = this->log_sigma_recruit.value_m; + if (this->log_sigma_recruit.estimated_m) { + if (this->log_sigma_recruit.is_random_effect_m) { d3->RegisterRandomEffect(b3->log_sigma_recruit); } else { d3->RegisterParameter(b3->log_sigma_recruit); diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_selectivity.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_selectivity.hpp index d33cd0b70..1cba55852 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_selectivity.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_selectivity.hpp @@ -73,8 +73,8 @@ class LogisticSelectivityInterface : public SelectivityInterfaceBase { virtual double evaluate(double x) { fims::LogisticSelectivity LogisticSel; - LogisticSel.median = this->median.value; - LogisticSel.slope = this->slope.value; + LogisticSel.median = this->median.value_m; + LogisticSel.slope = this->slope.value_m; return LogisticSel.evaluate(x); } @@ -89,17 +89,17 @@ class LogisticSelectivityInterface : public SelectivityInterfaceBase { // set relative info ls0->id = this->id; - ls0->median = this->median.value; - if (this->median.estimated) { - if (this->median.is_random_effect) { + ls0->median = this->median.value_m; + if (this->median.estimated_m) { + if (this->median.is_random_effect_m) { d0->RegisterRandomEffect(ls0->median); } else { d0->RegisterParameter(ls0->median); } } - ls0->slope = this->slope.value; - if (this->slope.estimated) { - if (this->slope.is_random_effect) { + ls0->slope = this->slope.value_m; + if (this->slope.estimated_m) { + if (this->slope.is_random_effect_m) { d0->RegisterRandomEffect(ls0->slope); } else { d0->RegisterParameter(ls0->slope); @@ -117,17 +117,17 @@ class LogisticSelectivityInterface : public SelectivityInterfaceBase { // set relative info ls1->id = this->id; - ls1->median = this->median.value; - if (this->median.estimated) { - if (this->median.is_random_effect) { + ls1->median = this->median.value_m; + if (this->median.estimated_m) { + if (this->median.is_random_effect_m) { d1->RegisterRandomEffect(ls1->median); } else { d1->RegisterParameter(ls1->median); } } - ls1->slope = this->slope.value; - if (this->slope.estimated) { - if (this->slope.is_random_effect) { + ls1->slope = this->slope.value_m; + if (this->slope.estimated_m) { + if (this->slope.is_random_effect_m) { d1->RegisterRandomEffect(ls1->slope); } else { d1->RegisterParameter(ls1->slope); @@ -145,17 +145,17 @@ class LogisticSelectivityInterface : public SelectivityInterfaceBase { // set relative info ls2->id = this->id; - ls2->median = this->median.value; - if (this->median.estimated) { - if (this->median.is_random_effect) { + ls2->median = this->median.value_m; + if (this->median.estimated_m) { + if (this->median.is_random_effect_m) { d2->RegisterRandomEffect(ls2->median); } else { d2->RegisterParameter(ls2->median); } } - ls2->slope = this->slope.value; - if (this->slope.estimated) { - if (this->slope.is_random_effect) { + ls2->slope = this->slope.value_m; + if (this->slope.estimated_m) { + if (this->slope.is_random_effect_m) { d2->RegisterRandomEffect(ls2->slope); } else { d2->RegisterParameter(ls2->slope); @@ -173,17 +173,17 @@ class LogisticSelectivityInterface : public SelectivityInterfaceBase { // set relative info ls3->id = this->id; - ls3->median = this->median.value; - if (this->median.estimated) { - if (this->median.is_random_effect) { + ls3->median = this->median.value_m; + if (this->median.estimated_m) { + if (this->median.is_random_effect_m) { d3->RegisterRandomEffect(ls3->median); } else { d3->RegisterParameter(ls3->median); } } - ls3->slope = this->slope.value; - if (this->slope.estimated) { - if (this->slope.is_random_effect) { + ls3->slope = this->slope.value_m; + if (this->slope.estimated_m) { + if (this->slope.is_random_effect_m) { d3->RegisterRandomEffect(ls3->slope); } else { d3->RegisterParameter(ls3->slope); @@ -223,10 +223,10 @@ class DoubleLogisticSelectivityInterface : public SelectivityInterfaceBase { virtual double evaluate(double x) { fims::DoubleLogisticSelectivity DoubleLogisticSel; - DoubleLogisticSel.median_asc = this->median_asc.value; - DoubleLogisticSel.slope_asc = this->slope_asc.value; - DoubleLogisticSel.median_desc = this->median_desc.value; - DoubleLogisticSel.slope_desc = this->slope_desc.value; + DoubleLogisticSel.median_asc = this->median_asc.value_m; + DoubleLogisticSel.slope_asc = this->slope_asc.value_m; + DoubleLogisticSel.median_desc = this->median_desc.value_m; + DoubleLogisticSel.slope_desc = this->slope_desc.value_m; return DoubleLogisticSel.evaluate(x); } @@ -242,33 +242,33 @@ class DoubleLogisticSelectivityInterface : public SelectivityInterfaceBase { // set relative info ls0->id = this->id; - ls0->median_asc = this->median_asc.value; - if (this->median_asc.estimated) { - if (this->median_asc.is_random_effect) { + ls0->median_asc = this->median_asc.value_m; + if (this->median_asc.estimated_m) { + if (this->median_asc.is_random_effect_m) { d0->RegisterRandomEffect(ls0->median_asc); } else { d0->RegisterParameter(ls0->median_asc); } } - ls0->slope_asc = this->slope_asc.value; - if (this->slope_asc.estimated) { - if (this->slope_asc.is_random_effect) { + ls0->slope_asc = this->slope_asc.value_m; + if (this->slope_asc.estimated_m) { + if (this->slope_asc.is_random_effect_m) { d0->RegisterRandomEffect(ls0->slope_asc); } else { d0->RegisterParameter(ls0->slope_asc); } } - ls0->median_desc = this->median_desc.value; - if (this->median_desc.estimated) { - if (this->median_desc.is_random_effect) { + ls0->median_desc = this->median_desc.value_m; + if (this->median_desc.estimated_m) { + if (this->median_desc.is_random_effect_m) { d0->RegisterRandomEffect(ls0->median_desc); } else { d0->RegisterParameter(ls0->median_desc); } } - ls0->slope_desc = this->slope_desc.value; - if (this->slope_desc.estimated) { - if (this->slope_desc.is_random_effect) { + ls0->slope_desc = this->slope_desc.value_m; + if (this->slope_desc.estimated_m) { + if (this->slope_desc.is_random_effect_m) { d0->RegisterRandomEffect(ls0->slope_desc); } else { d0->RegisterParameter(ls0->slope_desc); @@ -287,33 +287,33 @@ class DoubleLogisticSelectivityInterface : public SelectivityInterfaceBase { // set relative info ls1->id = this->id; - ls1->median_asc = this->median_asc.value; - if (this->median_asc.estimated) { - if (this->median_asc.is_random_effect) { + ls1->median_asc = this->median_asc.value_m; + if (this->median_asc.estimated_m) { + if (this->median_asc.is_random_effect_m) { d1->RegisterRandomEffect(ls1->median_asc); } else { d1->RegisterParameter(ls1->median_asc); } } - ls1->slope_asc = this->slope_asc.value; - if (this->slope_asc.estimated) { - if (this->slope_asc.is_random_effect) { + ls1->slope_asc = this->slope_asc.value_m; + if (this->slope_asc.estimated_m) { + if (this->slope_asc.is_random_effect_m) { d1->RegisterRandomEffect(ls1->slope_asc); } else { d1->RegisterParameter(ls1->slope_asc); } } - ls1->median_desc = this->median_desc.value; - if (this->median_desc.estimated) { - if (this->median_desc.is_random_effect) { + ls1->median_desc = this->median_desc.value_m; + if (this->median_desc.estimated_m) { + if (this->median_desc.is_random_effect_m) { d1->RegisterRandomEffect(ls1->median_desc); } else { d1->RegisterParameter(ls1->median_desc); } } - ls1->slope_desc = this->slope_desc.value; - if (this->slope_desc.estimated) { - if (this->slope_desc.is_random_effect) { + ls1->slope_desc = this->slope_desc.value_m; + if (this->slope_desc.estimated_m) { + if (this->slope_desc.is_random_effect_m) { d1->RegisterRandomEffect(ls1->slope_desc); } else { d1->RegisterParameter(ls1->slope_desc); @@ -332,34 +332,34 @@ class DoubleLogisticSelectivityInterface : public SelectivityInterfaceBase { // set relative info ls2->id = this->id; - ls2->median_asc = this->median_asc.value; - if (this->median_asc.estimated) { - if (this->median_asc.is_random_effect) { + ls2->median_asc = this->median_asc.value_m; + if (this->median_asc.estimated_m) { + if (this->median_asc.is_random_effect_m) { d2->RegisterRandomEffect(ls2->median_asc); } else { d2->RegisterParameter(ls2->median_asc); } } - ls2->slope_asc = this->slope_asc.value; - if (this->slope_asc.estimated) { - if (this->slope_asc.is_random_effect) { + ls2->slope_asc = this->slope_asc.value_m; + if (this->slope_asc.estimated_m) { + if (this->slope_asc.is_random_effect_m) { d2->RegisterRandomEffect(ls2->slope_asc); } else { d2->RegisterParameter(ls2->slope_asc); } } - ls2->median_desc = this->median_desc.value; - if (this->median_desc.estimated) { - if (this->median_desc.is_random_effect) { + ls2->median_desc = this->median_desc.value_m; + if (this->median_desc.estimated_m) { + if (this->median_desc.is_random_effect_m) { d2->RegisterRandomEffect(ls2->median_desc); } else { d2->RegisterParameter(ls2->median_desc); } } - ls2->slope_desc = this->slope_desc.value; - if (this->slope_desc.estimated) { - if (this->slope_desc.is_random_effect) { + ls2->slope_desc = this->slope_desc.value_m; + if (this->slope_desc.estimated_m) { + if (this->slope_desc.is_random_effect_m) { d2->RegisterRandomEffect(ls2->slope_desc); } else { d2->RegisterParameter(ls2->slope_desc); @@ -378,34 +378,34 @@ class DoubleLogisticSelectivityInterface : public SelectivityInterfaceBase { // set relative info ls3->id = this->id; - ls3->median_asc = this->median_asc.value; - if (this->median_asc.estimated) { - if (this->median_asc.is_random_effect) { + ls3->median_asc = this->median_asc.value_m; + if (this->median_asc.estimated_m) { + if (this->median_asc.is_random_effect_m) { d3->RegisterRandomEffect(ls3->median_asc); } else { d3->RegisterParameter(ls3->median_asc); } } - ls3->slope_asc = this->slope_asc.value; - if (this->slope_asc.estimated) { - if (this->slope_asc.is_random_effect) { + ls3->slope_asc = this->slope_asc.value_m; + if (this->slope_asc.estimated_m) { + if (this->slope_asc.is_random_effect_m) { d3->RegisterRandomEffect(ls3->slope_asc); } else { d3->RegisterParameter(ls3->slope_asc); } } - ls3->median_desc = this->median_desc.value; - if (this->median_desc.estimated) { - if (this->median_desc.is_random_effect) { + ls3->median_desc = this->median_desc.value_m; + if (this->median_desc.estimated_m) { + if (this->median_desc.is_random_effect_m) { d3->RegisterRandomEffect(ls3->median_desc); } else { d3->RegisterParameter(ls3->median_desc); } } - ls3->slope_desc = this->slope_desc.value; - if (this->slope_desc.estimated) { - if (this->slope_desc.is_random_effect) { + ls3->slope_desc = this->slope_desc.value_m; + if (this->slope_desc.estimated_m) { + if (this->slope_desc.is_random_effect_m) { d3->RegisterRandomEffect(ls3->slope_desc); } else { d3->RegisterParameter(ls3->slope_desc); diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_tmb_distribution.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_tmb_distribution.hpp index 596c3479d..df31ab353 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_tmb_distribution.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_tmb_distribution.hpp @@ -79,9 +79,9 @@ class DnormDistributionsInterface : public DistributionsInterfaceBase { */ virtual double evaluate(bool do_log) { fims::Dnorm dnorm; - dnorm.x = this->x.value; - dnorm.mean = this->mean.value; - dnorm.sd = this->sd.value; + dnorm.x = this->x.value_m; + dnorm.mean = this->mean.value_m; + dnorm.sd = this->sd.value_m; return dnorm.evaluate(do_log); } @@ -97,10 +97,10 @@ class DnormDistributionsInterface : public DistributionsInterfaceBase { // interface to data/parameter value model0->id = this->id; - model0->x = this->x.value; + model0->x = this->x.value_m; // set relative info - model0->mean = this->mean.value; - model0->sd = this->sd.value; + model0->mean = this->mean.value_m; + model0->sd = this->sd.value_m; d0->distribution_models[model0->id] = model0; @@ -112,9 +112,9 @@ class DnormDistributionsInterface : public DistributionsInterfaceBase { // interface to data/parameter first derivative model1->id = this->id; - model1->x = this->x.value; - model1->mean = this->mean.value; - model1->sd = this->sd.value; + model1->x = this->x.value_m; + model1->mean = this->mean.value_m; + model1->sd = this->sd.value_m; d1->distribution_models[model1->id] = model1; @@ -126,9 +126,9 @@ class DnormDistributionsInterface : public DistributionsInterfaceBase { // interface to data/parameter second derivative model2->id = this->id; - model2->x = this->x.value; - model2->mean = this->mean.value; - model2->sd = this->sd.value; + model2->x = this->x.value_m; + model2->mean = this->mean.value_m; + model2->sd = this->sd.value_m; d2->distribution_models[model2->id] = model2; @@ -140,9 +140,9 @@ class DnormDistributionsInterface : public DistributionsInterfaceBase { // interface to data/parameter third derivative model3->id = this->id; - model3->x = this->x.value; - model3->mean = this->mean.value; - model3->sd = this->sd.value; + model3->x = this->x.value_m; + model3->mean = this->mean.value_m; + model3->sd = this->sd.value_m; d3->distribution_models[model3->id] = model3; @@ -180,9 +180,9 @@ class DlnormDistributionsInterface : public DistributionsInterfaceBase { */ virtual double evaluate(bool do_log) { fims::Dlnorm dlnorm; - dlnorm.x = this->x.value; - dlnorm.meanlog = this->meanlog.value; - dlnorm.sdlog = this->sdlog.value; + dlnorm.x = this->x.value_m; + dlnorm.meanlog = this->meanlog.value_m; + dlnorm.sdlog = this->sdlog.value_m; return dlnorm.evaluate(do_log); } @@ -198,9 +198,9 @@ class DlnormDistributionsInterface : public DistributionsInterfaceBase { // set relative info model0->id = this->id; - model0->x = this->x.value; - model0->meanlog = this->meanlog.value; - model0->sdlog = this->sdlog.value; + model0->x = this->x.value_m; + model0->meanlog = this->meanlog.value_m; + model0->sdlog = this->sdlog.value_m; d0->distribution_models[model0->id] = model0; @@ -213,9 +213,9 @@ class DlnormDistributionsInterface : public DistributionsInterfaceBase { // set relative info model1->id = this->id; - model1->x = this->x.value; - model1->meanlog = this->meanlog.value; - model1->sdlog = this->sdlog.value; + model1->x = this->x.value_m; + model1->meanlog = this->meanlog.value_m; + model1->sdlog = this->sdlog.value_m; d1->distribution_models[model1->id] = model1; @@ -228,9 +228,9 @@ class DlnormDistributionsInterface : public DistributionsInterfaceBase { // set relative info model2->id = this->id; - model2->x = this->x.value; - model2->meanlog = this->meanlog.value; - model2->sdlog = this->sdlog.value; + model2->x = this->x.value_m; + model2->meanlog = this->meanlog.value_m; + model2->sdlog = this->sdlog.value_m; d2->distribution_models[model2->id] = model2; @@ -243,9 +243,9 @@ class DlnormDistributionsInterface : public DistributionsInterfaceBase { // set relative info model3->id = this->id; - model3->x = this->x.value; - model3->meanlog = this->meanlog.value; - model3->sdlog = this->sdlog.value; + model3->x = this->x.value_m; + model3->meanlog = this->meanlog.value_m; + model3->sdlog = this->sdlog.value_m; d3->distribution_models[model3->id] = model3;