diff --git a/docs/def_8hpp_source.html b/docs/def_8hpp_source.html index 5f0e5b6..3af0851 100644 --- a/docs/def_8hpp_source.html +++ b/docs/def_8hpp_source.html @@ -91,68 +91,74 @@
15 #include <memory>
16 #include <vector>
17 
-
18 //The following rows initialize default log files for outputing model progress
-
19 //comments used to assist in diagnosing model issues and tracking progress. These
-
20 //files will only be created if a logs folder is added to the root model directory.
-
21 std::ofstream FIMS_LOG ("logs/fims.log");
-
22 std::ofstream INFO_LOG("logs/info.log");
-
23 std::ofstream ERROR_LOG("logs/error.log");
-
24 std::ofstream DATA_LOG("logs/data.log");
-
25 std::ofstream MODEL_LOG("logs/model.log");
-
26 std::ofstream FLEET_LOG("logs/fleet.log");
-
27 std::ofstream POPULATION_LOG("logs/population.log");
-
28 std::ofstream RECRUITMENT_LOG("logs/recruitment.log");
-
29 std::ofstream GROWTH_LOG("logs/growth.log");
-
30 std::ofstream MATURITY_LOG("logs/maturity.log");
-
31 std::ofstream SELECTIVITY_LOG("logs/selectivity.log");
-
32 std::ofstream DEBUG_LOG("logs/debug/debug.log");
-
34 #ifdef TMB_MODEL
-
35 // simplify access to singletons
-
36 #define TMB_FIMS_REAL_TYPE double
-
37 #define TMB_FIMS_FIRST_ORDER AD<TMB_FIMS_REAL_TYPE>
-
38 #define TMB_FIMS_SECOND_ORDER AD<TMB_FIMS_FIRST_ORDER>
-
39 #define TMB_FIMS_THIRD_ORDER AD<TMB_FIMS_SECOND_ORDER>
-
40 #endif
-
41 
-
42 namespace fims {
-
43 
-
48 class fims_log {
-
49  public:
-
50  static std::map<std::string, std::ofstream>
-
51  FIMS_LOGS;
-
55  static std::ofstream& get(const std::string& l) {
-
56  typename std::map<std::string, std::ofstream>::iterator it;
-
57  it = fims_log::FIMS_LOGS.find(l);
-
58  if (it == fims_log::FIMS_LOGS.end()) {
-
59  std::ofstream& of = fims_log::FIMS_LOGS[l];
-
60  of.open(l.c_str());
-
61  }
-
62 
-
63  return fims_log::FIMS_LOGS[l];
-
64  }
-
65 };
-
66 
-
67 std::map<std::string, std::ofstream> fims_log::FIMS_LOGS;
+
18 // The following rows initialize default log files for outputing model progress
+
19 // comments used to assist in diagnosing model issues and tracking progress.
+
20 // These files will only be created if a logs folder is added to the root model
+
21 // directory.
+
22 std::ofstream FIMS_LOG("logs/fims.log");
+
23 std::ofstream INFO_LOG("logs/info.log");
+
24 std::ofstream ERROR_LOG("logs/error.log");
+
25 std::ofstream DATA_LOG("logs/data.log");
+
26 std::ofstream MODEL_LOG("logs/model.log");
+
27 std::ofstream FLEET_LOG("logs/fleet.log");
+
28 std::ofstream POPULATION_LOG(
+
29  "logs/population.log");
+
30 std::ofstream RECRUITMENT_LOG(
+
31  "logs/recruitment.log");
+
32 std::ofstream GROWTH_LOG("logs/growth.log");
+
33 std::ofstream MATURITY_LOG(
+
34  "logs/maturity.log");
+
35 std::ofstream SELECTIVITY_LOG(
+
36  "logs/selectivity.log");
+
37 std::ofstream DEBUG_LOG(
+
38  "logs/debug/debug.log");
+
40 #ifdef TMB_MODEL
+
41 // simplify access to singletons
+
42 #define TMB_FIMS_REAL_TYPE double
+
43 #define TMB_FIMS_FIRST_ORDER AD<TMB_FIMS_REAL_TYPE>
+
44 #define TMB_FIMS_SECOND_ORDER AD<TMB_FIMS_FIRST_ORDER>
+
45 #define TMB_FIMS_THIRD_ORDER AD<TMB_FIMS_SECOND_ORDER>
+
46 #endif
+
47 
+
48 namespace fims {
+
49 
+
54 class fims_log {
+
55  public:
+
56  static std::map<std::string, std::ofstream>
+
57  FIMS_LOGS;
+
61  static std::ofstream& get(const std::string& l) {
+
62  typename std::map<std::string, std::ofstream>::iterator it;
+
63  it = fims_log::FIMS_LOGS.find(l);
+
64  if (it == fims_log::FIMS_LOGS.end()) {
+
65  std::ofstream& of = fims_log::FIMS_LOGS[l];
+
66  of.open(l.c_str());
+
67  }
68 
-
69 #ifdef STD_LIB
-
70 
-
75 template <typename Type>
-
76 struct ModelTraits {
-
77  typedef double real_t;
-
78  typedef double variable_t;
-
79  typedef typename std::vector<double> DataVector;
-
80  typedef typename std::vector<double> ParameterVector;
-
82  typedef typename std::vector<std::vector<double> > DataMatrix;
-
84  typedef typename std::vector<std::vector<double> > VariableMatrix;
-
86 };
-
87 
-
88 #endif
-
89 } // namespace fims
-
90 
-
91 #endif /* TRAITS_HPP */
-
fims::fims_log
Definition: def.hpp:48
-
fims::fims_log::FIMS_LOGS
static std::map< std::string, std::ofstream > FIMS_LOGS
Definition: def.hpp:51
-
fims::fims_log::get
static std::ofstream & get(const std::string &l)
Definition: def.hpp:55
+
69  return fims_log::FIMS_LOGS[l];
+
70  }
+
71 };
+
72 
+
73 std::map<std::string, std::ofstream> fims_log::FIMS_LOGS;
+
74 
+
75 #ifdef STD_LIB
+
76 
+
81 template <typename Type>
+
82 struct ModelTraits {
+
83  typedef double real_t;
+
84  typedef double variable_t;
+
85  typedef typename std::vector<double> DataVector;
+
86  typedef typename std::vector<double> ParameterVector;
+
88  typedef typename std::vector<std::vector<double> > DataMatrix;
+
90  typedef typename std::vector<std::vector<double> > VariableMatrix;
+
92 };
+
93 
+
94 #endif
+
95 } // namespace fims
+
96 
+
97 #endif /* TRAITS_HPP */
+
fims::fims_log
Definition: def.hpp:54
+
fims::fims_log::FIMS_LOGS
static std::map< std::string, std::ofstream > FIMS_LOGS
Definition: def.hpp:57
+
fims::fims_log::get
static std::ofstream & get(const std::string &l)
Definition: def.hpp:61
MODEL_LOG
std::ofstream MODEL_LOG("logs/model.log")
GROWTH_LOG
std::ofstream GROWTH_LOG("logs/growth.log")
ERROR_LOG
std::ofstream ERROR_LOG("logs/error.log")
diff --git a/docs/double__logistic_8hpp_source.html b/docs/double__logistic_8hpp_source.html index 4054ab1..c2bd6f2 100644 --- a/docs/double__logistic_8hpp_source.html +++ b/docs/double__logistic_8hpp_source.html @@ -93,16 +93,16 @@
15 
20 template <typename Type>
21 struct DoubleLogisticSelectivity : public SelectivityBase<Type> {
-
22  Type inflection_point_asc;
-
25  Type slope_asc;
+
22  Type inflection_point_asc;
+
25  Type slope_asc;
28  Type inflection_point_desc;
-
31  Type slope_desc;
+
31  Type slope_desc;
35  DoubleLogisticSelectivity() : SelectivityBase<Type>() {}
36 
37  virtual ~DoubleLogisticSelectivity() {}
49  virtual const Type evaluate(const Type &x) {
-
50  return fims_math::double_logistic<Type>(inflection_point_asc, slope_asc, inflection_point_desc,
-
51  slope_desc, x);
+
50  return fims_math::double_logistic<Type>(
+
51  inflection_point_asc, slope_asc, inflection_point_desc, slope_desc, x);
52  }
53 };
54 
diff --git a/docs/fims__math_8hpp_source.html b/docs/fims__math_8hpp_source.html index 31bc228..43a8817 100644 --- a/docs/fims__math_8hpp_source.html +++ b/docs/fims__math_8hpp_source.html @@ -138,52 +138,55 @@
90 #endif
91 
102 template <class Type>
-
103 inline const Type logistic(const Type &inflection_point, const Type &slope, const Type &x) {
-
104  return (1.0) / (1.0 + exp(-1.0 * slope * (x - inflection_point)));
-
105 }
-
106 
-
117 template <class Type>
-
118 inline const Type logit(const Type &a, const Type &b, const Type &x) {
-
119  return -fims_math::log(b - x) + fims_math::log(x - a);
-
120 }
-
121 
-
132 template <class Type>
-
133 inline const Type inv_logit(const Type &a, const Type &b, const Type &logit_x) {
-
134  return a + (b - a) / (1.0 + fims_math::exp(-logit_x));
-
135 }
-
136 
-
156 template <class Type>
-
157 inline const Type double_logistic(const Type &inflection_point_asc, const Type &slope_asc,
-
158  const Type &inflection_point_desc, const Type &slope_desc,
-
159  const Type &x) {
-
160  return (1.0) / (1.0 + exp(-1.0 * slope_asc * (x - inflection_point_asc))) *
-
161  (1.0 - (1.0) / (1.0 + exp(-1.0 * slope_desc * (x - inflection_point_desc))));
-
162 }
-
163 
-
177 template <class Type>
-
178 const Type ad_fabs(const Type &x, Type C = 1e-5) {
-
179  return sqrt((x * x) + C); //, .5);
-
180 }
-
181 
-
197 template <typename Type>
-
198 inline const Type ad_min(const Type &a, const Type &b, Type C = 1e-5) {
-
199  return (a + b - fims_math::ad_fabs(a - b, C)) * 0.5;
-
200 }
-
201 
-
214 template <typename Type>
-
215 inline const Type ad_max(const Type &a, const Type &b, Type C = 1e-5) {
-
216  return (a + b + fims_math::ad_fabs(a - b, C)) * static_cast<Type>(.5);
-
217 }
-
218 
-
219 } // namespace fims_math
-
220 
-
221 #endif /* FIMS_MATH_HPP */
-
fims_math::logit
const Type logit(const Type &a, const Type &b, const Type &x)
A logit function for bounding of parameters.
Definition: fims_math.hpp:118
-
fims_math::ad_min
const Type ad_min(const Type &a, const Type &b, Type C=1e-5)
Definition: fims_math.hpp:198
-
fims_math::double_logistic
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)
The general double logistic function.
Definition: fims_math.hpp:157
-
fims_math::ad_max
const Type ad_max(const Type &a, const Type &b, Type C=1e-5)
Definition: fims_math.hpp:215
-
fims_math::inv_logit
const Type inv_logit(const Type &a, const Type &b, const Type &logit_x)
An inverse logit function for bounding of parameters.
Definition: fims_math.hpp:133
-
fims_math::ad_fabs
const Type ad_fabs(const Type &x, Type C=1e-5)
Definition: fims_math.hpp:178
+
103 inline const Type logistic(const Type &inflection_point, const Type &slope,
+
104  const Type &x) {
+
105  return (1.0) / (1.0 + exp(-1.0 * slope * (x - inflection_point)));
+
106 }
+
107 
+
118 template <class Type>
+
119 inline const Type logit(const Type &a, const Type &b, const Type &x) {
+
120  return -fims_math::log(b - x) + fims_math::log(x - a);
+
121 }
+
122 
+
133 template <class Type>
+
134 inline const Type inv_logit(const Type &a, const Type &b, const Type &logit_x) {
+
135  return a + (b - a) / (1.0 + fims_math::exp(-logit_x));
+
136 }
+
137 
+
158 template <class Type>
+
159 inline const Type double_logistic(const Type &inflection_point_asc,
+
160  const Type &slope_asc,
+
161  const Type &inflection_point_desc,
+
162  const Type &slope_desc, const Type &x) {
+
163  return (1.0) / (1.0 + exp(-1.0 * slope_asc * (x - inflection_point_asc))) *
+
164  (1.0 -
+
165  (1.0) / (1.0 + exp(-1.0 * slope_desc * (x - inflection_point_desc))));
+
166 }
+
167 
+
181 template <class Type>
+
182 const Type ad_fabs(const Type &x, Type C = 1e-5) {
+
183  return sqrt((x * x) + C); //, .5);
+
184 }
+
185 
+
201 template <typename Type>
+
202 inline const Type ad_min(const Type &a, const Type &b, Type C = 1e-5) {
+
203  return (a + b - fims_math::ad_fabs(a - b, C)) * 0.5;
+
204 }
+
205 
+
218 template <typename Type>
+
219 inline const Type ad_max(const Type &a, const Type &b, Type C = 1e-5) {
+
220  return (a + b + fims_math::ad_fabs(a - b, C)) * static_cast<Type>(.5);
+
221 }
+
222 
+
223 } // namespace fims_math
+
224 
+
225 #endif /* FIMS_MATH_HPP */
+
fims_math::logit
const Type logit(const Type &a, const Type &b, const Type &x)
A logit function for bounding of parameters.
Definition: fims_math.hpp:119
+
fims_math::ad_min
const Type ad_min(const Type &a, const Type &b, Type C=1e-5)
Definition: fims_math.hpp:202
+
fims_math::double_logistic
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)
The general double logistic function.
Definition: fims_math.hpp:159
+
fims_math::ad_max
const Type ad_max(const Type &a, const Type &b, Type C=1e-5)
Definition: fims_math.hpp:219
+
fims_math::inv_logit
const Type inv_logit(const Type &a, const Type &b, const Type &logit_x)
An inverse logit function for bounding of parameters.
Definition: fims_math.hpp:134
+
fims_math::ad_fabs
const Type ad_fabs(const Type &x, Type C=1e-5)
Definition: fims_math.hpp:182
fims_math::logistic
const Type logistic(const Type &inflection_point, const Type &slope, const Type &x)
The general logistic function.
Definition: fims_math.hpp:103
diff --git a/docs/fleet_8hpp_source.html b/docs/fleet_8hpp_source.html index 75f976c..00c0235 100644 --- a/docs/fleet_8hpp_source.html +++ b/docs/fleet_8hpp_source.html @@ -176,96 +176,92 @@
140  0);
141  this->q = fims_math::exp(this->log_q);
142  for (size_t year = 0; year < this->nyears; year++) {
-
143 
-
144  FLEET_LOG << "input F mort " << this->log_Fmort[year] << std::endl;
-
145  FLEET_LOG << "input q " << this->log_q << std::endl;
-
146  this->Fmort[year] = fims_math::exp(this->log_Fmort[year]);
-
147 
-
148  }
-
149  }
-
150 
-
151  virtual const Type evaluate_age_comp_nll() {
-
152  Type nll = 0.0;
-
153 #ifdef TMB_MODEL
-
154  fims_distributions::Dmultinom<Type> dmultinom;
-
155  size_t dims = this->observed_agecomp_data->get_imax() *
-
156  this->observed_agecomp_data->get_jmax();
-
157  if (dims != this->catch_numbers_at_age.size()) {
-
158 
-
159  ERROR_LOG << "Error: observed age comp is of size "
-
160  << dims << " and expected is of size "
-
161  << this->age_composition.size() << std::endl;
-
162  exit(1);
-
163 
-
164  } else {
-
165  for (size_t y = 0; y < this->nyears; y++) {
-
166  // EigenVector declares a vector type from the Eigen library, which is
-
167  // the expected type for TMB's dmultinom
-
168  using Vector = typename fims::ModelTraits<Type>::EigenVector;
-
169  Vector observed_acomp;
-
170  Vector expected_acomp;
-
171 
-
172  observed_acomp.resize(this->nages);
-
173  expected_acomp.resize(this->nages);
-
174  Type sum = 0.0;
-
175  for (size_t a = 0; a < this->nages; a++) {
-
176  size_t i_age_year = y * this->nages + a;
-
177  sum += this->catch_numbers_at_age[i_age_year];
-
178  }
-
179 
-
180  for (size_t a = 0; a < this->nages; a++) {
-
181  size_t i_age_year = y * this->nages + a;
-
182  expected_acomp[a] = this->catch_numbers_at_age[i_age_year] /
-
183  sum; // probabilities for ages
-
184 
-
185  observed_acomp[a] = this->observed_agecomp_data->at(y, a);
-
186 
-
187  FLEET_LOG << " age " << a << " in year " << y
-
188  << "has expected: " << expected_acomp[a]
-
189  << " and observed: " << observed_acomp[a] << std::endl;
-
190  }
-
191  dmultinom.x = observed_acomp;
-
192  dmultinom.p = expected_acomp;
-
193  nll -= dmultinom.evaluate(true);
-
194  }
-
195  }
-
196  FLEET_LOG << "Age comp negative log-likelihood for fleet," << this->id << nll << std::endl;
-
197 #endif
-
198  return nll;
-
199  }
-
200 
-
201  virtual const Type evaluate_index_nll() {
-
202  Type nll = 0.0;
-
204 #ifdef TMB_MODEL
-
205  fims_distributions::Dnorm<Type> dnorm;
-
206  dnorm.sd = fims_math::exp(this->log_obs_error);
-
207  for (size_t i = 0; i < this->expected_index.size(); i++) {
-
208  dnorm.x = fims_math::log(this->observed_index_data->at(i));
-
209  dnorm.mean = fims_math::log(this->expected_index[i]);
-
210  nll -= dnorm.evaluate(true);
-
211 
-
212  FLEET_LOG
-
213  << "observed index data: " << i << " is "
-
214  << this->observed_index_data->at(i)
-
215  << " and expected is: " << this->expected_index[i] << std::endl;
-
216  }
-
217  FLEET_LOG
-
218  << " log obs error is: " << this->log_obs_error << std::endl;
-
219  FLEET_LOG << " sd is: " << dnorm.sd << std::endl;
-
220  FLEET_LOG << " index nll: " << nll << std::endl;
-
221 
-
222 #endif
-
223  return nll;
-
224  }
-
225 };
+
143  FLEET_LOG << "input F mort " << this->log_Fmort[year] << std::endl;
+
144  FLEET_LOG << "input q " << this->log_q << std::endl;
+
145  this->Fmort[year] = fims_math::exp(this->log_Fmort[year]);
+
146  }
+
147  }
+
148 
+
149  virtual const Type evaluate_age_comp_nll() {
+
150  Type nll = 0.0;
+
151 #ifdef TMB_MODEL
+
152  fims_distributions::Dmultinom<Type> dmultinom;
+
153  size_t dims = this->observed_agecomp_data->get_imax() *
+
154  this->observed_agecomp_data->get_jmax();
+
155  if (dims != this->catch_numbers_at_age.size()) {
+
156  ERROR_LOG << "Error: observed age comp is of size " << dims
+
157  << " and expected is of size " << this->age_composition.size()
+
158  << std::endl;
+
159  exit(1);
+
160 
+
161  } else {
+
162  for (size_t y = 0; y < this->nyears; y++) {
+
163  // EigenVector declares a vector type from the Eigen library, which is
+
164  // the expected type for TMB's dmultinom
+
165  using Vector = typename fims::ModelTraits<Type>::EigenVector;
+
166  Vector observed_acomp;
+
167  Vector expected_acomp;
+
168 
+
169  observed_acomp.resize(this->nages);
+
170  expected_acomp.resize(this->nages);
+
171  Type sum = 0.0;
+
172  for (size_t a = 0; a < this->nages; a++) {
+
173  size_t i_age_year = y * this->nages + a;
+
174  sum += this->catch_numbers_at_age[i_age_year];
+
175  }
+
176 
+
177  for (size_t a = 0; a < this->nages; a++) {
+
178  size_t i_age_year = y * this->nages + a;
+
179  expected_acomp[a] = this->catch_numbers_at_age[i_age_year] /
+
180  sum; // probabilities for ages
+
181 
+
182  observed_acomp[a] = this->observed_agecomp_data->at(y, a);
+
183 
+
184  FLEET_LOG << " age " << a << " in year " << y
+
185  << "has expected: " << expected_acomp[a]
+
186  << " and observed: " << observed_acomp[a] << std::endl;
+
187  }
+
188  dmultinom.x = observed_acomp;
+
189  dmultinom.p = expected_acomp;
+
190  nll -= dmultinom.evaluate(true);
+
191  }
+
192  }
+
193  FLEET_LOG << "Age comp negative log-likelihood for fleet," << this->id
+
194  << nll << std::endl;
+
195 #endif
+
196  return nll;
+
197  }
+
198 
+
199  virtual const Type evaluate_index_nll() {
+
200  Type nll = 0.0;
+
202 #ifdef TMB_MODEL
+
203  fims_distributions::Dnorm<Type> dnorm;
+
204  dnorm.sd = fims_math::exp(this->log_obs_error);
+
205  for (size_t i = 0; i < this->expected_index.size(); i++) {
+
206  dnorm.x = fims_math::log(this->observed_index_data->at(i));
+
207  dnorm.mean = fims_math::log(this->expected_index[i]);
+
208  nll -= dnorm.evaluate(true);
+
209 
+
210  FLEET_LOG << "observed index data: " << i << " is "
+
211  << this->observed_index_data->at(i)
+
212  << " and expected is: " << this->expected_index[i] << std::endl;
+
213  }
+
214  FLEET_LOG << " log obs error is: " << this->log_obs_error << std::endl;
+
215  FLEET_LOG << " sd is: " << dnorm.sd << std::endl;
+
216  FLEET_LOG << " index nll: " << nll << std::endl;
+
217 
+
218 #endif
+
219  return nll;
+
220  }
+
221 };
+
222 
+
223 // default id of the singleton fleet class
+
224 template <class Type>
+
225 uint32_t Fleet<Type>::id_g = 0;
226 
-
227 // default id of the singleton fleet class
-
228 template <class Type>
-
229 uint32_t Fleet<Type>::id_g = 0;
-
230 
-
231 } // end namespace fims_popdy
-
232 
-
233 #endif /* FIMS_POPULATION_DYNAMICS_FLEET_HPP */
+
227 } // end namespace fims_popdy
+
228 
+
229 #endif /* FIMS_POPULATION_DYNAMICS_FLEET_HPP */
ERROR_LOG
std::ofstream ERROR_LOG("logs/error.log")
FLEET_LOG
std::ofstream FLEET_LOG("logs/fleet.log")
fims_model_object::FIMSObject
FIMSObject struct that defines member types and returns the unique id.
Definition: model_object.hpp:25
@@ -279,7 +275,7 @@
fims_popdy::Fleet::id_g
static uint32_t id_g
Definition: fleet.hpp:26
fims_popdy::Fleet::nages
size_t nages
Definition: fleet.hpp:28
fims_popdy::Fleet::catch_numbers_at_age
std::vector< Type > catch_numbers_at_age
Definition: fleet.hpp:79
-
fims_popdy::Fleet::evaluate_index_nll
virtual const Type evaluate_index_nll()
Definition: fleet.hpp:201
+
fims_popdy::Fleet::evaluate_index_nll
virtual const Type evaluate_index_nll()
Definition: fleet.hpp:199
fims_popdy::Fleet::fleet_selectivity_id_m
int fleet_selectivity_id_m
Definition: fleet.hpp:50
fims_popdy::Fleet::q
Type q
Definition: fleet.hpp:69
fims_popdy::Fleet::catch_at_age
std::vector< Type > catch_at_age
Definition: fleet.hpp:72
@@ -289,7 +285,7 @@
fims_popdy::Fleet::fleet_observed_agecomp_data_id_m
int fleet_observed_agecomp_data_id_m
Definition: fleet.hpp:58
fims_popdy::Fleet::observed_index_data
std::shared_ptr< fims_data_object::DataObject< Type > > observed_index_data
Definition: fleet.hpp:56
fims_popdy::Fleet::index_likelihood
std::shared_ptr< fims_distributions::DistributionsBase< Type > > index_likelihood
Definition: fleet.hpp:40
-
fims_popdy::Fleet::evaluate_age_comp_nll
virtual const Type evaluate_age_comp_nll()
Definition: fleet.hpp:151
+
fims_popdy::Fleet::evaluate_age_comp_nll
virtual const Type evaluate_age_comp_nll()
Definition: fleet.hpp:149
fims_popdy::Fleet::expected_index
std::vector< Type > expected_index
Definition: fleet.hpp:78
fims_popdy::Fleet::fleet_index_likelihood_id_m
int fleet_index_likelihood_id_m
Definition: fleet.hpp:35
fims_popdy::Fleet::Prepare
void Prepare()
Prepare to run the fleet module. Called at each model itartion, and used to exponentiate the log q an...
Definition: fleet.hpp:123
diff --git a/docs/information_8hpp_source.html b/docs/information_8hpp_source.html index 99fe5ef..dcb18a1 100644 --- a/docs/information_8hpp_source.html +++ b/docs/information_8hpp_source.html @@ -176,327 +176,360 @@
148  this->random_effects_parameters.push_back(&re);
149  }
150 
-
160  bool CreateModel() {
-
161  bool valid_model = true;
-
162  INFO_LOG << "" << std::endl;
-
163  INFO_LOG << "Beginning to create FIMS model in information.hpp CreateModel(). " << std::endl;
-
164  INFO_LOG << "Initializing fleet objects for " << this->fleets.size() << " fleets." << std::endl;
-
165  for (fleet_iterator it = this->fleets.begin(); it != this->fleets.end();
-
166  ++it) {
-
167  // Initialize fleet object
-
168 
-
169  std::shared_ptr<fims_popdy::Fleet<Type> > f = (*it).second;
-
170  INFO_LOG << "Initializing fleet " << f->id << "." << std::endl;
-
171 
-
172  f->Initialize(f->nyears, f->nages);
-
173 
-
174  INFO_LOG << "Expecting to import " << this->data_objects.size()
-
175  << " data objects." << std::endl;
-
176 
-
177  INFO_LOG << "Checking for available fleet index data objects." << std::endl;
-
178  // set index data
-
179  if (f->fleet_observed_index_data_id_m != -999) {
-
180  uint32_t observed_index_id =
-
181  static_cast<uint32_t>(f->fleet_observed_index_data_id_m);
-
182  data_iterator it = this->data_objects.find(observed_index_id);
-
183  INFO_LOG << "Input fleet index id = " << observed_index_id << "."
-
184  << std::endl;
-
185 
-
186  if (it != this->data_objects.end()) {
-
187  f->observed_index_data = (*it).second;
-
188  INFO_LOG << "Index data successfully set." << std::endl;
-
189  DATA_LOG << "" << std::endl;
-
190  DATA_LOG << "Observed input for fleet " << f->id << ", index " << observed_index_id << ": \n " << f->observed_index_data->at(1)
-
191  << std::endl;
-
192  } else {
-
193  valid_model = false;
-
194  ERROR_LOG << "Error: Expected data observations not defined for fleet"
-
195  << f->id << ", index " << observed_index_id << std::endl;
-
196  exit(1);
-
197  }
-
198 
-
199  } else {
-
200  valid_model = false;
-
201  ERROR_LOG << "Error: No index data observed for fleet " << f->id
-
202  << ". FIMS requires index data for all fleets." << std::endl;
-
203  exit(1);
-
204  }
-
205  // end set index data
-
206 
-
207  INFO_LOG << "Checking for available fleet age comp data objects." << std::endl;
-
208  // set age composition data
-
209  if (f->fleet_observed_agecomp_data_id_m != -999) {
-
210  uint32_t observed_agecomp_id =
-
211  static_cast<uint32_t>(f->fleet_observed_agecomp_data_id_m);
-
212  data_iterator it = this->data_objects.find(observed_agecomp_id);
-
213  INFO_LOG << "Input fleet age comp id = " << observed_agecomp_id << "."
-
214  << std::endl;
-
215 
-
216  if (it != this->data_objects.end()) {
-
217  f->observed_agecomp_data = (*it).second;
-
218  INFO_LOG << "Age comp data successfully set." << std::endl;
-
219  DATA_LOG << "" << std::endl;
-
220  DATA_LOG << "Observed input age comp for fleet " << f->id << ", comp " << observed_agecomp_id << ": \n " << f->observed_agecomp_data->at(1)
-
221  << std::endl;
-
222  } else {
-
223  valid_model = false;
-
224  ERROR_LOG << "Error: Expected age comp data observations not defined for fleet "
-
225  << f->id << ", index " << observed_agecomp_id << std::endl;
-
226  exit(1);
-
227  }
-
228 
-
229  } else {
-
230  valid_model = false;
-
231  ERROR_LOG << "Error: No age comp data observed for fleet " << f->id
-
232  << ". FIMS requires age comp data for all fleets." << std::endl;
-
233  exit(1);
-
234  }
-
235  // end set composition data
-
236 
-
237  INFO_LOG << "Checking for available fleet selectivity pattern." << std::endl;
-
238  // set selectivity model
-
239  if (f->fleet_selectivity_id_m != -999) {
-
240  uint32_t sel_id = static_cast<uint32_t>(
-
241  f->fleet_selectivity_id_m); // cast as unsigned integer
-
242  selectivity_models_iterator it = this->selectivity_models.find(
-
243  sel_id); // if find, set it, otherwise invalid
-
244  INFO_LOG << "Input fleet selectivity pattern id = " << sel_id
-
245  << "." << std::endl;
+
161  bool CreateModel() {
+
162  bool valid_model = true;
+
163  INFO_LOG << "" << std::endl;
+
164  INFO_LOG
+
165  << "Beginning to create FIMS model in information.hpp CreateModel(). "
+
166  << std::endl;
+
167  INFO_LOG << "Initializing fleet objects for " << this->fleets.size()
+
168  << " fleets." << std::endl;
+
169  for (fleet_iterator it = this->fleets.begin(); it != this->fleets.end();
+
170  ++it) {
+
171  // Initialize fleet object
+
172 
+
173  std::shared_ptr<fims_popdy::Fleet<Type> > f = (*it).second;
+
174  INFO_LOG << "Initializing fleet " << f->id << "." << std::endl;
+
175 
+
176  f->Initialize(f->nyears, f->nages);
+
177 
+
178  INFO_LOG << "Expecting to import " << this->data_objects.size()
+
179  << " data objects." << std::endl;
+
180 
+
181  INFO_LOG << "Checking for available fleet index data objects."
+
182  << std::endl;
+
183  // set index data
+
184  if (f->fleet_observed_index_data_id_m != -999) {
+
185  uint32_t observed_index_id =
+
186  static_cast<uint32_t>(f->fleet_observed_index_data_id_m);
+
187  data_iterator it = this->data_objects.find(observed_index_id);
+
188  INFO_LOG << "Input fleet index id = " << observed_index_id << "."
+
189  << std::endl;
+
190 
+
191  if (it != this->data_objects.end()) {
+
192  f->observed_index_data = (*it).second;
+
193  INFO_LOG << "Index data successfully set." << std::endl;
+
194  DATA_LOG << "" << std::endl;
+
195  DATA_LOG << "Observed input for fleet " << f->id << ", index "
+
196  << observed_index_id << ": \n "
+
197  << f->observed_index_data->at(1) << std::endl;
+
198  } else {
+
199  valid_model = false;
+
200  ERROR_LOG << "Error: Expected data observations not defined for fleet"
+
201  << f->id << ", index " << observed_index_id << std::endl;
+
202  exit(1);
+
203  }
+
204 
+
205  } else {
+
206  valid_model = false;
+
207  ERROR_LOG << "Error: No index data observed for fleet " << f->id
+
208  << ". FIMS requires index data for all fleets." << std::endl;
+
209  exit(1);
+
210  }
+
211  // end set index data
+
212 
+
213  INFO_LOG << "Checking for available fleet age comp data objects."
+
214  << std::endl;
+
215  // set age composition data
+
216  if (f->fleet_observed_agecomp_data_id_m != -999) {
+
217  uint32_t observed_agecomp_id =
+
218  static_cast<uint32_t>(f->fleet_observed_agecomp_data_id_m);
+
219  data_iterator it = this->data_objects.find(observed_agecomp_id);
+
220  INFO_LOG << "Input fleet age comp id = " << observed_agecomp_id << "."
+
221  << std::endl;
+
222 
+
223  if (it != this->data_objects.end()) {
+
224  f->observed_agecomp_data = (*it).second;
+
225  INFO_LOG << "Age comp data successfully set." << std::endl;
+
226  DATA_LOG << "" << std::endl;
+
227  DATA_LOG << "Observed input age comp for fleet " << f->id << ", comp "
+
228  << observed_agecomp_id << ": \n "
+
229  << f->observed_agecomp_data->at(1) << std::endl;
+
230  } else {
+
231  valid_model = false;
+
232  ERROR_LOG << "Error: Expected age comp data observations not defined "
+
233  "for fleet "
+
234  << f->id << ", index " << observed_agecomp_id << std::endl;
+
235  exit(1);
+
236  }
+
237 
+
238  } else {
+
239  valid_model = false;
+
240  ERROR_LOG << "Error: No age comp data observed for fleet " << f->id
+
241  << ". FIMS requires age comp data for all fleets."
+
242  << std::endl;
+
243  exit(1);
+
244  }
+
245  // end set composition data
246 
-
247  if (it != this->selectivity_models.end()) {
-
248  f->selectivity = (*it).second; // elements in container held in pair
-
249  // (first is id, second is object -
-
250  // shared pointer to distribution)
-
251  INFO_LOG << "Selectivity successfully set." << std::endl;
-
252  } else {
-
253  valid_model = false;
-
254  ERROR_LOG << "Error: Expected selectivity pattern not defined for fleet "
-
255  << f->id << ", selectivity pattern " << sel_id << std::endl;
-
256  exit(1);
-
257  }
-
258 
-
259  } else {
-
260  valid_model = false;
-
261  ERROR_LOG << "Error: No selectivity pattern defined for fleet " << f->id
-
262  << ". FIMS requires selectivity be defined for all fleets." << std::endl;
-
263  exit(1);
-
264  }
-
265  // end set selectivity
-
266 
-
267  INFO_LOG << "Checking for available index likelihood function." << std::endl;
-
268  // set index likelihood
-
269  if (f->fleet_index_likelihood_id_m != -999) {
-
270  uint32_t ind_like_id = static_cast<uint32_t>(
-
271  f->fleet_index_likelihood_id_m); // cast as unsigned integer
-
272  distribution_models_iterator it = this->distribution_models.find(
-
273  ind_like_id); // if find, set it, otherwise invalid
-
274  INFO_LOG << "Input index likelihood function id = " << ind_like_id
-
275  << "." << std::endl;
-
276 
-
277  if (it != this->distribution_models.end()) {
-
278  f->index_likelihood =
-
279  (*it).second; // elements in container held in pair (first is
-
280  // id, second is object - shared pointer to
-
281  // distribution)
-
282  INFO_LOG << "Index likelihood function successfully set." << std::endl;
-
283  } else {
-
284  //Commented out for now as code uses single likelihood function making this fail
-
285  //valid_model = false;
-
286  //ERROR_LOG << "Error: Expected index likelihood function not defined for fleet "
-
287  // << f->id << ", likelihood function " << ind_like_id << std::endl;
-
288  //exit(1);
-
289  }
+
247  INFO_LOG << "Checking for available fleet selectivity pattern."
+
248  << std::endl;
+
249  // set selectivity model
+
250  if (f->fleet_selectivity_id_m != -999) {
+
251  uint32_t sel_id = static_cast<uint32_t>(
+
252  f->fleet_selectivity_id_m); // cast as unsigned integer
+
253  selectivity_models_iterator it = this->selectivity_models.find(
+
254  sel_id); // if find, set it, otherwise invalid
+
255  INFO_LOG << "Input fleet selectivity pattern id = " << sel_id << "."
+
256  << std::endl;
+
257 
+
258  if (it != this->selectivity_models.end()) {
+
259  f->selectivity = (*it).second; // elements in container held in pair
+
260  // (first is id, second is object -
+
261  // shared pointer to distribution)
+
262  INFO_LOG << "Selectivity successfully set." << std::endl;
+
263  } else {
+
264  valid_model = false;
+
265  ERROR_LOG
+
266  << "Error: Expected selectivity pattern not defined for fleet "
+
267  << f->id << ", selectivity pattern " << sel_id << std::endl;
+
268  exit(1);
+
269  }
+
270 
+
271  } else {
+
272  valid_model = false;
+
273  ERROR_LOG << "Error: No selectivity pattern defined for fleet " << f->id
+
274  << ". FIMS requires selectivity be defined for all fleets."
+
275  << std::endl;
+
276  exit(1);
+
277  }
+
278  // end set selectivity
+
279 
+
280  INFO_LOG << "Checking for available index likelihood function."
+
281  << std::endl;
+
282  // set index likelihood
+
283  if (f->fleet_index_likelihood_id_m != -999) {
+
284  uint32_t ind_like_id = static_cast<uint32_t>(
+
285  f->fleet_index_likelihood_id_m); // cast as unsigned integer
+
286  distribution_models_iterator it = this->distribution_models.find(
+
287  ind_like_id); // if find, set it, otherwise invalid
+
288  INFO_LOG << "Input index likelihood function id = " << ind_like_id
+
289  << "." << std::endl;
290 
-
291  } else {
-
292  //Commented out for now as code uses single likelihood function making this fail
-
293  //valid_model = false;
-
294  //ERROR_LOG << "Error: No index likelihood function defined for fleet " << f->id
-
295  // << ". FIMS requires likelihood functions be defined for all data." << std::endl;
-
296  //exit(1);
-
297  }
-
298  // end set index likelihood
-
299 
-
300  INFO_LOG << "Checking for available age comp likelihood function." << std::endl;
-
301  // set agecomp likelihood
-
302  if (f->fleet_agecomp_likelihood_id_m != -999) {
-
303  uint32_t ac_like_id = static_cast<uint32_t>(
-
304  f->fleet_agecomp_likelihood_id_m); // cast as unsigned integer
-
305  distribution_models_iterator it = this->distribution_models.find(
-
306  ac_like_id); // if find, set it, otherwise invalid
-
307  INFO_LOG << "Input age comp likelihood function id = " << ac_like_id
-
308  << "." << std::endl;
-
309 
-
310  if (it != this->distribution_models.end()) {
-
311  f->agecomp_likelihood =
-
312  (*it).second; // elements in container held in pair (first is
-
313  // id, second is object - shared pointer to
-
314  // distribution)
-
315  INFO_LOG << "Age comp likelihood function successfully set." << std::endl;
-
316  } else {
-
317  //Commented out for now as code uses single likelihood function making this fail
-
318  //valid_model = false;
-
319  //ERROR_LOG << "Error: Expected age comp likelihood function not defined for fleet "
-
320  // << f->id << ", likelihood function " << ac_like_id << std::endl;
-
321  //exit(1);
-
322  }
-
323 
-
324  } else {
-
325  //Commented out for now as code uses single likelihood function making this fail
-
326  //valid_model = false;
-
327  //ERROR_LOG << "Error: No age comp likelihood function defined for fleet " << f->id
-
328  // << ". FIMS requires likelihood functions be defined for all data." << std::endl;
-
329  //exit(1);
-
330  }
-
331  // end set agecomp likelihood
-
332 
-
333  INFO_LOG << "Completed initialization for fleet " << f->id << "." << std::endl;
-
334 
-
335  } // close fleet iterator loop
-
336  INFO_LOG << "Completed initialization of all fleets." << std::endl;
-
337 
-
338  INFO_LOG << "Initializing population objects for " << this->populations.size() << " populations." << std::endl;
-
339  for (population_iterator it = this->populations.begin();
-
340  it != this->populations.end(); ++it) {
-
341 
-
342  std::shared_ptr<fims_popdy::Population<Type> > p = (*it).second;
+
291  if (it != this->distribution_models.end()) {
+
292  f->index_likelihood =
+
293  (*it).second; // elements in container held in pair (first is
+
294  // id, second is object - shared pointer to
+
295  // distribution)
+
296  INFO_LOG << "Index likelihood function successfully set."
+
297  << std::endl;
+
298  } else {
+
299  // Commented out for now as code uses single likelihood function
+
300  // making this fail valid_model = false; ERROR_LOG << "Error: Expected
+
301  // index likelihood function not defined for fleet "
+
302  // << f->id << ", likelihood function " << ind_like_id <<
+
303  // std::endl;
+
304  // exit(1);
+
305  }
+
306 
+
307  } else {
+
308  // Commented out for now as code uses single likelihood function making
+
309  // this fail valid_model = false; ERROR_LOG << "Error: No index
+
310  // likelihood function defined for fleet " << f->id
+
311  // << ". FIMS requires likelihood functions be defined for all
+
312  // data." << std::endl;
+
313  // exit(1);
+
314  }
+
315  // end set index likelihood
+
316 
+
317  INFO_LOG << "Checking for available age comp likelihood function."
+
318  << std::endl;
+
319  // set agecomp likelihood
+
320  if (f->fleet_agecomp_likelihood_id_m != -999) {
+
321  uint32_t ac_like_id = static_cast<uint32_t>(
+
322  f->fleet_agecomp_likelihood_id_m); // cast as unsigned integer
+
323  distribution_models_iterator it = this->distribution_models.find(
+
324  ac_like_id); // if find, set it, otherwise invalid
+
325  INFO_LOG << "Input age comp likelihood function id = " << ac_like_id
+
326  << "." << std::endl;
+
327 
+
328  if (it != this->distribution_models.end()) {
+
329  f->agecomp_likelihood =
+
330  (*it).second; // elements in container held in pair (first is
+
331  // id, second is object - shared pointer to
+
332  // distribution)
+
333  INFO_LOG << "Age comp likelihood function successfully set."
+
334  << std::endl;
+
335  } else {
+
336  // Commented out for now as code uses single likelihood function
+
337  // making this fail valid_model = false; ERROR_LOG << "Error: Expected
+
338  // age comp likelihood function not defined for fleet "
+
339  // << f->id << ", likelihood function " << ac_like_id <<
+
340  // std::endl;
+
341  // exit(1);
+
342  }
343 
-
344  INFO_LOG << "Setting up links from population " << p->id
-
345  << " to fleets [ " << std::flush;
-
346  // error check and set population elements
-
347  // check me - add another fleet iterator to push information from
-
348  for (fleet_iterator it = this->fleets.begin(); it != this->fleets.end();
-
349  ++it) {
-
350  // Initialize fleet object
-
351  std::shared_ptr<fims_popdy::Fleet<Type> > f = (*it).second;
-
352  // population to the individual fleets This is to pass catch at age
-
353  // from population to fleets?
-
354  // any shared member in p (population is pushed into fleets)
-
355  p->fleets.push_back(f);
-
356  INFO_LOG << f->id << " " << std::flush;
-
357  }
-
358  INFO_LOG << "]" << std::endl;
+
344  } else {
+
345  // Commented out for now as code uses single likelihood function making
+
346  // this fail valid_model = false; ERROR_LOG << "Error: No age comp
+
347  // likelihood function defined for fleet " << f->id
+
348  // << ". FIMS requires likelihood functions be defined for all
+
349  // data." << std::endl;
+
350  // exit(1);
+
351  }
+
352  // end set agecomp likelihood
+
353 
+
354  INFO_LOG << "Completed initialization for fleet " << f->id << "."
+
355  << std::endl;
+
356 
+
357  } // close fleet iterator loop
+
358  INFO_LOG << "Completed initialization of all fleets." << std::endl;
359 
-
360  INFO_LOG << "Initializing population " << p->id << "." << std::endl;
-
361  p->Initialize(p->nyears, p->nseasons, p->nages);
-
362 
-
363  INFO_LOG << "Checking for available recruitment function." << std::endl;
-
364  // set recruitment
-
365  if (p->recruitment_id != -999) {
-
366  uint32_t recruitment_uint = static_cast<uint32_t>(p->recruitment_id);
-
367  recruitment_models_iterator it =
-
368  this->recruitment_models.find(recruitment_uint);
-
369  INFO_LOG << "Input recruitment id = " << recruitment_uint << "." << std::endl;
-
370  if (it != this->recruitment_models.end()) {
-
371  p->recruitment =
-
372  (*it).second; // recruitment defined in population.hpp
-
373  INFO_LOG << "Recruitment function successfully set." << std::endl;
-
374  } else {
-
375  valid_model = false;
-
376  ERROR_LOG << "Error: Expected recruitment function not defined for population "
-
377  << p->id << ", recruitment function " << recruitment_uint << std::endl;
-
378  exit(1);
-
379  }
-
380 
-
381  } else {
-
382  valid_model = false;
-
383  ERROR_LOG << "Error: No recruitment function defined for population " << p->id
-
384  << ". FIMS requires recruitment functions be defined for all populations."
-
385  << std::endl;
-
386  exit(1);
-
387  }
-
388 
-
389  INFO_LOG << "Checking for available growth function." << std::endl;
-
390  // set growth
-
391  if (p->growth_id != -999) {
-
392  uint32_t growth_uint = static_cast<uint32_t>(p->growth_id);
-
393  growth_models_iterator it = this->growth_models.find(
-
394  growth_uint); // growth_models is specified in information.hpp
-
395  // and used in rcpp
-
396  // at the head of information.hpp; are the
-
397  // dimensions of ages defined in rcpp or where?
-
398  INFO_LOG << "Input growth id = " << growth_uint << "." << std::endl;
-
399  if (it != this->growth_models.end()) {
-
400  p->growth =
-
401  (*it).second; // growth defined in population.hpp (the object
-
402  // is called p, growth is within p)
-
403  INFO_LOG << "Growth function successfully set." << std::endl;
-
404  } else {
-
405  valid_model = false;
-
406  ERROR_LOG << "Error: Expected growth function not defined for population "
-
407  << p->id << ", growth function " << growth_uint << std::endl;
-
408  exit(1);
-
409  }
-
410 
-
411  } else {
-
412  valid_model = false;
-
413  ERROR_LOG << "Error: No growth function defined for population " << p->id
-
414  << ". FIMS requires growth functions be defined for all populations."
-
415  << std::endl;
-
416  exit(1);
-
417  }
-
418 
-
419  INFO_LOG << "Checking for available maturity function." << std::endl;
-
420  // set maturity
-
421  if (p->maturity_id != -999) {
-
422  uint32_t maturity_uint = static_cast<uint32_t>(p->maturity_id);
-
423  maturity_models_iterator it = this->maturity_models.find(
-
424  maturity_uint); // >maturity_models is specified in
-
425  // information.hpp and used in rcpp
-
426  INFO_LOG << "Input maturity id = " << maturity_uint << "." << std::endl;
-
427  if (it != this->maturity_models.end()) {
-
428  p->maturity = (*it).second; // >maturity defined in population.hpp
-
429  INFO_LOG << "Maturity function successfully set." << std::endl;
-
430  } else {
-
431  valid_model = false;
-
432  ERROR_LOG << "Error: Expected maturity function not defined for population "
-
433  << p->id << ", maturity function " << maturity_uint << std::endl;
-
434  exit(1);
-
435  }
-
436 
-
437  } else {
-
438  valid_model = false;
-
439  ERROR_LOG << "Error: No maturity function defined for population " << p->id
-
440  << ". FIMS requires maturity functions be defined for all populations."
-
441  << std::endl;
-
442  exit(1);
-
443  }
-
444  INFO_LOG << "Completed initialization for population " << p->id << "." << std::endl;
-
445  }
-
446  INFO_LOG << "Completed initialization of all populations." << std::endl;
-
447  INFO_LOG << "Completed FIMS model creation." << std::endl;
-
448  return valid_model;
-
449  }
-
450 
-
456  size_t GetNages() const { return nages; }
-
457 
-
463  void SetNages(size_t nages) { this->nages = nages; }
-
464 
-
470  size_t GetNseasons() const { return nseasons; }
-
471 
-
477  void SetNseasons(size_t nseasons) { this->nseasons = nseasons; }
-
478 
-
484  size_t GetNyears() const { return nyears; }
-
485 
-
491  void SetNyears(size_t nyears) { this->nyears = nyears; }
-
492 
-
498  std::vector<Type*>& GetParameters() { return parameters; }
-
499 
-
505  std::vector<Type*>& GetFixedEffectsParameters() {
-
506  return fixed_effects_parameters;
-
507  }
-
508 
-
514  std::vector<Type*>& GetRandomEffectsParameters() {
-
515  return random_effects_parameters;
-
516  }
-
517 };
-
518 
-
519 template <typename Type>
-
520 std::shared_ptr<Information<Type> > Information<Type>::fims_information =
-
521  nullptr; // singleton instance
-
522 
-
523 } // namespace fims_info
-
524 
-
525 #endif /* FIMS_COMMON_INFORMATION_HPP */
+
360  INFO_LOG << "Initializing population objects for "
+
361  << this->populations.size() << " populations." << std::endl;
+
362  for (population_iterator it = this->populations.begin();
+
363  it != this->populations.end(); ++it) {
+
364  std::shared_ptr<fims_popdy::Population<Type> > p = (*it).second;
+
365 
+
366  INFO_LOG << "Setting up links from population " << p->id
+
367  << " to fleets [ " << std::flush;
+
368  // error check and set population elements
+
369  // check me - add another fleet iterator to push information from
+
370  for (fleet_iterator it = this->fleets.begin(); it != this->fleets.end();
+
371  ++it) {
+
372  // Initialize fleet object
+
373  std::shared_ptr<fims_popdy::Fleet<Type> > f = (*it).second;
+
374  // population to the individual fleets This is to pass catch at age
+
375  // from population to fleets?
+
376  // any shared member in p (population is pushed into fleets)
+
377  p->fleets.push_back(f);
+
378  INFO_LOG << f->id << " " << std::flush;
+
379  }
+
380  INFO_LOG << "]" << std::endl;
+
381 
+
382  INFO_LOG << "Initializing population " << p->id << "." << std::endl;
+
383  p->Initialize(p->nyears, p->nseasons, p->nages);
+
384 
+
385  INFO_LOG << "Checking for available recruitment function." << std::endl;
+
386  // set recruitment
+
387  if (p->recruitment_id != -999) {
+
388  uint32_t recruitment_uint = static_cast<uint32_t>(p->recruitment_id);
+
389  recruitment_models_iterator it =
+
390  this->recruitment_models.find(recruitment_uint);
+
391  INFO_LOG << "Input recruitment id = " << recruitment_uint << "."
+
392  << std::endl;
+
393  if (it != this->recruitment_models.end()) {
+
394  p->recruitment =
+
395  (*it).second; // recruitment defined in population.hpp
+
396  INFO_LOG << "Recruitment function successfully set." << std::endl;
+
397  } else {
+
398  valid_model = false;
+
399  ERROR_LOG << "Error: Expected recruitment function not defined for "
+
400  "population "
+
401  << p->id << ", recruitment function " << recruitment_uint
+
402  << std::endl;
+
403  exit(1);
+
404  }
+
405 
+
406  } else {
+
407  valid_model = false;
+
408  ERROR_LOG << "Error: No recruitment function defined for population "
+
409  << p->id
+
410  << ". FIMS requires recruitment functions be defined for all "
+
411  "populations."
+
412  << std::endl;
+
413  exit(1);
+
414  }
+
415 
+
416  INFO_LOG << "Checking for available growth function." << std::endl;
+
417  // set growth
+
418  if (p->growth_id != -999) {
+
419  uint32_t growth_uint = static_cast<uint32_t>(p->growth_id);
+
420  growth_models_iterator it = this->growth_models.find(
+
421  growth_uint); // growth_models is specified in information.hpp
+
422  // and used in rcpp
+
423  // at the head of information.hpp; are the
+
424  // dimensions of ages defined in rcpp or where?
+
425  INFO_LOG << "Input growth id = " << growth_uint << "." << std::endl;
+
426  if (it != this->growth_models.end()) {
+
427  p->growth =
+
428  (*it).second; // growth defined in population.hpp (the object
+
429  // is called p, growth is within p)
+
430  INFO_LOG << "Growth function successfully set." << std::endl;
+
431  } else {
+
432  valid_model = false;
+
433  ERROR_LOG
+
434  << "Error: Expected growth function not defined for population "
+
435  << p->id << ", growth function " << growth_uint << std::endl;
+
436  exit(1);
+
437  }
+
438 
+
439  } else {
+
440  valid_model = false;
+
441  ERROR_LOG << "Error: No growth function defined for population "
+
442  << p->id
+
443  << ". FIMS requires growth functions be defined for all "
+
444  "populations."
+
445  << std::endl;
+
446  exit(1);
+
447  }
+
448 
+
449  INFO_LOG << "Checking for available maturity function." << std::endl;
+
450  // set maturity
+
451  if (p->maturity_id != -999) {
+
452  uint32_t maturity_uint = static_cast<uint32_t>(p->maturity_id);
+
453  maturity_models_iterator it = this->maturity_models.find(
+
454  maturity_uint); // >maturity_models is specified in
+
455  // information.hpp and used in rcpp
+
456  INFO_LOG << "Input maturity id = " << maturity_uint << "." << std::endl;
+
457  if (it != this->maturity_models.end()) {
+
458  p->maturity = (*it).second; // >maturity defined in population.hpp
+
459  INFO_LOG << "Maturity function successfully set." << std::endl;
+
460  } else {
+
461  valid_model = false;
+
462  ERROR_LOG
+
463  << "Error: Expected maturity function not defined for population "
+
464  << p->id << ", maturity function " << maturity_uint << std::endl;
+
465  exit(1);
+
466  }
+
467 
+
468  } else {
+
469  valid_model = false;
+
470  ERROR_LOG << "Error: No maturity function defined for population "
+
471  << p->id
+
472  << ". FIMS requires maturity functions be defined for all "
+
473  "populations."
+
474  << std::endl;
+
475  exit(1);
+
476  }
+
477  INFO_LOG << "Completed initialization for population " << p->id << "."
+
478  << std::endl;
+
479  }
+
480  INFO_LOG << "Completed initialization of all populations." << std::endl;
+
481  INFO_LOG << "Completed FIMS model creation." << std::endl;
+
482  return valid_model;
+
483  }
+
484 
+
490  size_t GetNages() const { return nages; }
+
491 
+
497  void SetNages(size_t nages) { this->nages = nages; }
+
498 
+
504  size_t GetNseasons() const { return nseasons; }
+
505 
+
511  void SetNseasons(size_t nseasons) { this->nseasons = nseasons; }
+
512 
+
518  size_t GetNyears() const { return nyears; }
+
519 
+
525  void SetNyears(size_t nyears) { this->nyears = nyears; }
+
526 
+
532  std::vector<Type*>& GetParameters() { return parameters; }
+
533 
+
539  std::vector<Type*>& GetFixedEffectsParameters() {
+
540  return fixed_effects_parameters;
+
541  }
+
542 
+
548  std::vector<Type*>& GetRandomEffectsParameters() {
+
549  return random_effects_parameters;
+
550  }
+
551 };
+
552 
+
553 template <typename Type>
+
554 std::shared_ptr<Information<Type> > Information<Type>::fims_information =
+
555  nullptr; // singleton instance
+
556 
+
557 } // namespace fims_info
+
558 
+
559 #endif /* FIMS_COMMON_INFORMATION_HPP */
fims_info::Information
Stores FIMS model information and creates model. Contains all objects and data pre-model construction...
Definition: information.hpp:32
fims_info::Information::populations
std::map< uint32_t, std::shared_ptr< fims_popdy::Population< Type > > > populations
Definition: information.hpp:98
fims_info::Information::random_effects_parameters
std::vector< Type * > random_effects_parameters
Definition: information.hpp:42
@@ -508,31 +541,31 @@
fims_info::Information::distribution_models
std::map< uint32_t, std::shared_ptr< fims_distributions::DistributionsBase< Type > > > distribution_models
Definition: information.hpp:108
fims_info::Information::RegisterParameter
void RegisterParameter(Type &p)
Definition: information.hpp:138
fims_info::Information::RegisterRandomEffect
void RegisterRandomEffect(Type &re)
Definition: information.hpp:147
-
fims_info::Information::SetNyears
void SetNyears(size_t nyears)
Set the Nyears object.
Definition: information.hpp:491
-
fims_info::Information::GetNages
size_t GetNages() const
Get the Nages object.
Definition: information.hpp:456
+
fims_info::Information::SetNyears
void SetNyears(size_t nyears)
Set the Nyears object.
Definition: information.hpp:525
+
fims_info::Information::GetNages
size_t GetNages() const
Get the Nages object.
Definition: information.hpp:490
fims_info::Information::fleet_iterator
std::map< uint32_t, std::shared_ptr< fims_popdy::Fleet< Type > > >::iterator fleet_iterator
Definition: information.hpp:93
fims_info::Information::population_iterator
std::map< uint32_t, std::shared_ptr< fims_popdy::Population< Type > > >::iterator population_iterator
Definition: information.hpp:102
fims_info::Information::nseasons
size_t nseasons
Definition: information.hpp:35
fims_info::Information::data_iterator
std::map< uint32_t, std::shared_ptr< fims_data_object::DataObject< Type > > >::iterator data_iterator
Definition: information.hpp:51
fims_info::Information::selectivity_models
std::map< uint32_t, std::shared_ptr< fims_popdy::SelectivityBase< Type > > > selectivity_models
Definition: information.hpp:63
-
fims_info::Information::CreateModel
bool CreateModel()
Definition: information.hpp:160
-
fims_info::Information::GetNseasons
size_t GetNseasons() const
Get the Nseasons object.
Definition: information.hpp:470
+
fims_info::Information::CreateModel
bool CreateModel()
Definition: information.hpp:161
+
fims_info::Information::GetNseasons
size_t GetNseasons() const
Get the Nseasons object.
Definition: information.hpp:504
fims_info::Information::distribution_models_iterator
std::map< uint32_t, std::shared_ptr< fims_distributions::DistributionsBase< Type > > >::iterator distribution_models_iterator
Definition: information.hpp:113
-
fims_info::Information::GetFixedEffectsParameters
std::vector< Type * > & GetFixedEffectsParameters()
Get the Fixed Effects Parameters object.
Definition: information.hpp:505
+
fims_info::Information::GetFixedEffectsParameters
std::vector< Type * > & GetFixedEffectsParameters()
Get the Fixed Effects Parameters object.
Definition: information.hpp:539
fims_info::Information::maturity_models_iterator
std::map< uint32_t, std::shared_ptr< fims_popdy::MaturityBase< Type > > >::iterator maturity_models_iterator
Definition: information.hpp:83
fims_info::Information::parameters
std::vector< Type * > parameters
Definition: information.hpp:40
fims_info::Information::nyears
size_t nyears
Definition: information.hpp:34
fims_info::Information::maturity_models
std::map< uint32_t, std::shared_ptr< fims_popdy::MaturityBase< Type > > > maturity_models
Definition: information.hpp:79
-
fims_info::Information::GetParameters
std::vector< Type * > & GetParameters()
Get the Parameters object.
Definition: information.hpp:498
-
fims_info::Information::GetRandomEffectsParameters
std::vector< Type * > & GetRandomEffectsParameters()
Get the Random Effects Parameters object.
Definition: information.hpp:514
-
fims_info::Information::GetNyears
size_t GetNyears() const
Get the Nyears object.
Definition: information.hpp:484
+
fims_info::Information::GetParameters
std::vector< Type * > & GetParameters()
Get the Parameters object.
Definition: information.hpp:532
+
fims_info::Information::GetRandomEffectsParameters
std::vector< Type * > & GetRandomEffectsParameters()
Get the Random Effects Parameters object.
Definition: information.hpp:548
+
fims_info::Information::GetNyears
size_t GetNyears() const
Get the Nyears object.
Definition: information.hpp:518
fims_info::Information::growth_models_iterator
std::map< uint32_t, std::shared_ptr< fims_popdy::GrowthBase< Type > > >::iterator growth_models_iterator
Definition: information.hpp:75
fims_info::Information::GetInstance
static std::shared_ptr< Information< Type > > GetInstance()
Definition: information.hpp:125
fims_info::Information::fims_information
static std::shared_ptr< Information< Type > > fims_information
Definition: information.hpp:39
fims_info::Information::recruitment_models
std::map< uint32_t, std::shared_ptr< fims_popdy::RecruitmentBase< Type > > > recruitment_models
Definition: information.hpp:55
fims_info::Information::fixed_effects_parameters
std::vector< Type * > fixed_effects_parameters
Definition: information.hpp:44
-
fims_info::Information::SetNseasons
void SetNseasons(size_t nseasons)
Set the Nseasons object.
Definition: information.hpp:477
-
fims_info::Information::SetNages
void SetNages(size_t nages)
Set the Nages object.
Definition: information.hpp:463
+
fims_info::Information::SetNseasons
void SetNseasons(size_t nseasons)
Set the Nseasons object.
Definition: information.hpp:511
+
fims_info::Information::SetNages
void SetNages(size_t nages)
Set the Nages object.
Definition: information.hpp:497
fims_info::Information::data_objects
std::map< uint32_t, std::shared_ptr< fims_data_object::DataObject< Type > > > data_objects
Definition: information.hpp:48
def.hpp
ERROR_LOG
std::ofstream ERROR_LOG("logs/error.log")
diff --git a/docs/maturity_2functors_2logistic_8hpp_source.html b/docs/maturity_2functors_2logistic_8hpp_source.html index 83db093..73655bb 100644 --- a/docs/maturity_2functors_2logistic_8hpp_source.html +++ b/docs/maturity_2functors_2logistic_8hpp_source.html @@ -96,10 +96,10 @@
22 template <typename Type>
23 struct LogisticMaturity : public MaturityBase<Type> {
24  Type inflection_point;
-
26  Type slope;
+
26  Type slope;
29  LogisticMaturity() : MaturityBase<Type>() {}
30 
-
41  virtual const Type evaluate(const Type & x) {
+
41  virtual const Type evaluate(const Type& x) {
42  return fims_math::logistic<Type>(inflection_point, slope, x);
43  }
44 };
diff --git a/docs/model_8hpp_source.html b/docs/model_8hpp_source.html index f71b833..11c00a2 100644 --- a/docs/model_8hpp_source.html +++ b/docs/model_8hpp_source.html @@ -156,131 +156,138 @@
91  // Loop over populations, evaluate, and sum up the recruitment likelihood
92  // component
93 
-
94 
-
95  typename fims_info::Information<Type>::population_iterator it;
-
96  MODEL_LOG << "Evaluating expected values and summing recruitment nlls for " << this->fims_information->populations.size() << " populations." << std::endl;
-
97 
-
98  for (it = this->fims_information->populations.begin();
-
99  it != this->fims_information->populations.end(); ++it) {
-
100  //(*it).second points to the Population module
-
101  MODEL_LOG << "Setting up pointer to population " << (*it).second->id << "." << std::endl;
-
102  // Prepare recruitment
-
103  (*it).second->recruitment->Prepare();
-
104  MODEL_LOG << "Recruitment for population successfully prepared" << std::endl;
-
105 // link to TMB objective function
-
106 #ifdef TMB_MODEL
-
107  (*it).second->of = this->of;
-
108 #endif
-
109  // Evaluate population
-
110  (*it).second->Evaluate();
-
111  // Recrtuiment negative log-likelihood
-
112  rec_nll += (*it).second->recruitment->evaluate_nll();
-
113  MODEL_LOG << "Recruitment negative log-likelihood is: " << rec_nll << std::endl;
-
114  }
-
115  MODEL_LOG << "All populations successfully evaluated." << std::endl;
-
116 
-
117  // Loop over fleets/surveys, and sum up age comp and index nlls
-
118 
-
119  typename fims_info::Information<Type>::fleet_iterator jt;
-
120  MODEL_LOG << "Evaluating expected values and summing nlls for " << this->fims_information->fleets.size() << " fleets." << std::endl;
-
121 
-
122  for (jt = this->fims_information->fleets.begin();
-
123  jt != this->fims_information->fleets.end(); ++jt) {
-
124  //(*jt).second points to each individual Fleet module
-
125 #ifdef TMB_MODEL
-
126  (*jt).second->of = this->of;
-
127 #endif
-
128  MODEL_LOG << "Setting up pointer to fleet " << (*jt).second->id << "." << std::endl;
-
129  age_comp_nll += (*jt).second->evaluate_age_comp_nll();
-
130  MODEL_LOG << "Sum of survey and age comp negative log-likelihood is: " << age_comp_nll
-
131  << std::endl;
-
132  index_nll += (*jt).second->evaluate_index_nll();
-
133  }
-
134  MODEL_LOG << "All fleets successfully evaluated." << std::endl;
-
135  // Loop over populations and fleets/surveys and fill in reporting
-
136 
-
137  // initiate population index for structuring report out objects
-
138  int pop_idx = 0;
-
139  for (it = this->fims_information->populations.begin();
-
140  it != this->fims_information->populations.end(); ++it) {
-
141 #ifdef TMB_MODEL
-
142  naa(pop_idx) = vector<Type>((*it).second->numbers_at_age);
-
143  ssb(pop_idx) = vector<Type>((*it).second->spawning_biomass);
-
144  rec_dev(pop_idx) =
-
145  vector<Type>((*it).second->recruitment->recruit_deviations);
-
146  recruitment(pop_idx) = vector<Type>((*it).second->expected_recruitment);
-
147  biomass(pop_idx) = vector<Type>((*it).second->biomass);
-
148  M(pop_idx) = vector<Type>((*it).second->M);
-
149 #endif
-
150  pop_idx += 1;
-
151  }
-
152 
-
153  // initiate fleet index for structuring report out objects
-
154  int fleet_idx = 0;
-
155  for (jt = this->fims_information->fleets.begin();
-
156  jt != this->fims_information->fleets.end(); ++jt) {
-
157 #ifdef TMB_MODEL
-
158  exp_index(fleet_idx) = vector<Type>((*jt).second->expected_index);
-
159  exp_catch(fleet_idx) = vector<Type>((*jt).second->expected_catch);
-
160  F_mort(fleet_idx) = vector<Type>((*jt).second->Fmort);
-
161  cnaa(fleet_idx) = vector<Type>((*jt).second->catch_numbers_at_age);
-
162  cwaa(fleet_idx) = vector<Type>((*jt).second->catch_weight_at_age);
-
163 #endif
-
164  fleet_idx += 1;
-
165  }
-
166 
-
167  jnll = rec_nll + age_comp_nll + index_nll;
-
168 
-
169 // Reporting
-
170 #ifdef TMB_MODEL
-
171  REPORT_F(rec_nll, of);
-
172  REPORT_F(age_comp_nll, of);
-
173  REPORT_F(index_nll, of);
-
174  REPORT_F(jnll, of);
-
175  REPORT_F(naa, of);
-
176  REPORT_F(ssb, of);
-
177  REPORT_F(rec_dev, of);
-
178  REPORT_F(recruitment, of);
-
179  REPORT_F(biomass, of);
-
180  REPORT_F(M, of);
-
181  REPORT_F(exp_index, of);
-
182  REPORT_F(exp_catch, of);
-
183  REPORT_F(F_mort, of);
-
184  REPORT_F(cnaa, of);
-
185  REPORT_F(cwaa, of);
-
186 
-
187  /*ADREPORT using ADREPORTvector defined in
-
188  * inst/include/interface/interface.hpp:
-
189  * function collapses the nested vector into a single vector
-
190  */
-
191  vector<Type> NAA = ADREPORTvector(naa);
-
192  vector<Type> Biomass = ADREPORTvector(biomass);
-
193  vector<Type> SSB = ADREPORTvector(ssb);
-
194  vector<Type> RecDev = ADREPORTvector(rec_dev);
-
195  vector<Type> FMort = ADREPORTvector(F_mort);
-
196  vector<Type> ExpectedIndex = ADREPORTvector(exp_index);
-
197  vector<Type> CNAA = ADREPORTvector(cnaa);
-
198 
-
199  ADREPORT_F(NAA, of);
-
200  ADREPORT_F(Biomass, of);
-
201  ADREPORT_F(SSB, of);
-
202  ADREPORT_F(RecDev, of);
-
203  ADREPORT_F(FMort, of);
-
204  ADREPORT_F(ExpectedIndex, of);
-
205  ADREPORT_F(CNAA, of);
-
206 #endif
-
207 
-
208  return jnll;
-
209  }
-
210 };
-
211 
-
212 // Create singleton instance of Model class
-
213 template <typename Type>
-
214 std::shared_ptr<Model<Type> > Model<Type>::fims_model =
-
215  nullptr; // singleton instance
-
216 } // namespace fims_model
-
217 
-
218 #endif /* FIMS_COMMON_MODEL_HPP */
+
94  typename fims_info::Information<Type>::population_iterator it;
+
95  MODEL_LOG << "Evaluating expected values and summing recruitment nlls for "
+
96  << this->fims_information->populations.size() << " populations."
+
97  << std::endl;
+
98 
+
99  for (it = this->fims_information->populations.begin();
+
100  it != this->fims_information->populations.end(); ++it) {
+
101  //(*it).second points to the Population module
+
102  MODEL_LOG << "Setting up pointer to population " << (*it).second->id
+
103  << "." << std::endl;
+
104  // Prepare recruitment
+
105  (*it).second->recruitment->Prepare();
+
106  MODEL_LOG << "Recruitment for population successfully prepared"
+
107  << std::endl;
+
108 // link to TMB objective function
+
109 #ifdef TMB_MODEL
+
110  (*it).second->of = this->of;
+
111 #endif
+
112  // Evaluate population
+
113  (*it).second->Evaluate();
+
114  // Recrtuiment negative log-likelihood
+
115  rec_nll += (*it).second->recruitment->evaluate_nll();
+
116  MODEL_LOG << "Recruitment negative log-likelihood is: " << rec_nll
+
117  << std::endl;
+
118  }
+
119  MODEL_LOG << "All populations successfully evaluated." << std::endl;
+
120 
+
121  // Loop over fleets/surveys, and sum up age comp and index nlls
+
122 
+
123  typename fims_info::Information<Type>::fleet_iterator jt;
+
124  MODEL_LOG << "Evaluating expected values and summing nlls for "
+
125  << this->fims_information->fleets.size() << " fleets."
+
126  << std::endl;
+
127 
+
128  for (jt = this->fims_information->fleets.begin();
+
129  jt != this->fims_information->fleets.end(); ++jt) {
+
130  //(*jt).second points to each individual Fleet module
+
131 #ifdef TMB_MODEL
+
132  (*jt).second->of = this->of;
+
133 #endif
+
134  MODEL_LOG << "Setting up pointer to fleet " << (*jt).second->id << "."
+
135  << std::endl;
+
136  age_comp_nll += (*jt).second->evaluate_age_comp_nll();
+
137  MODEL_LOG << "Sum of survey and age comp negative log-likelihood is: "
+
138  << age_comp_nll << std::endl;
+
139  index_nll += (*jt).second->evaluate_index_nll();
+
140  }
+
141  MODEL_LOG << "All fleets successfully evaluated." << std::endl;
+
142  // Loop over populations and fleets/surveys and fill in reporting
+
143 
+
144  // initiate population index for structuring report out objects
+
145  int pop_idx = 0;
+
146  for (it = this->fims_information->populations.begin();
+
147  it != this->fims_information->populations.end(); ++it) {
+
148 #ifdef TMB_MODEL
+
149  naa(pop_idx) = vector<Type>((*it).second->numbers_at_age);
+
150  ssb(pop_idx) = vector<Type>((*it).second->spawning_biomass);
+
151  rec_dev(pop_idx) =
+
152  vector<Type>((*it).second->recruitment->recruit_deviations);
+
153  recruitment(pop_idx) = vector<Type>((*it).second->expected_recruitment);
+
154  biomass(pop_idx) = vector<Type>((*it).second->biomass);
+
155  M(pop_idx) = vector<Type>((*it).second->M);
+
156 #endif
+
157  pop_idx += 1;
+
158  }
+
159 
+
160  // initiate fleet index for structuring report out objects
+
161  int fleet_idx = 0;
+
162  for (jt = this->fims_information->fleets.begin();
+
163  jt != this->fims_information->fleets.end(); ++jt) {
+
164 #ifdef TMB_MODEL
+
165  exp_index(fleet_idx) = vector<Type>((*jt).second->expected_index);
+
166  exp_catch(fleet_idx) = vector<Type>((*jt).second->expected_catch);
+
167  F_mort(fleet_idx) = vector<Type>((*jt).second->Fmort);
+
168  cnaa(fleet_idx) = vector<Type>((*jt).second->catch_numbers_at_age);
+
169  cwaa(fleet_idx) = vector<Type>((*jt).second->catch_weight_at_age);
+
170 #endif
+
171  fleet_idx += 1;
+
172  }
+
173 
+
174  jnll = rec_nll + age_comp_nll + index_nll;
+
175 
+
176 // Reporting
+
177 #ifdef TMB_MODEL
+
178  REPORT_F(rec_nll, of);
+
179  REPORT_F(age_comp_nll, of);
+
180  REPORT_F(index_nll, of);
+
181  REPORT_F(jnll, of);
+
182  REPORT_F(naa, of);
+
183  REPORT_F(ssb, of);
+
184  REPORT_F(rec_dev, of);
+
185  REPORT_F(recruitment, of);
+
186  REPORT_F(biomass, of);
+
187  REPORT_F(M, of);
+
188  REPORT_F(exp_index, of);
+
189  REPORT_F(exp_catch, of);
+
190  REPORT_F(F_mort, of);
+
191  REPORT_F(cnaa, of);
+
192  REPORT_F(cwaa, of);
+
193 
+
194  /*ADREPORT using ADREPORTvector defined in
+
195  * inst/include/interface/interface.hpp:
+
196  * function collapses the nested vector into a single vector
+
197  */
+
198  vector<Type> NAA = ADREPORTvector(naa);
+
199  vector<Type> Biomass = ADREPORTvector(biomass);
+
200  vector<Type> SSB = ADREPORTvector(ssb);
+
201  vector<Type> RecDev = ADREPORTvector(rec_dev);
+
202  vector<Type> FMort = ADREPORTvector(F_mort);
+
203  vector<Type> ExpectedIndex = ADREPORTvector(exp_index);
+
204  vector<Type> CNAA = ADREPORTvector(cnaa);
+
205 
+
206  ADREPORT_F(NAA, of);
+
207  ADREPORT_F(Biomass, of);
+
208  ADREPORT_F(SSB, of);
+
209  ADREPORT_F(RecDev, of);
+
210  ADREPORT_F(FMort, of);
+
211  ADREPORT_F(ExpectedIndex, of);
+
212  ADREPORT_F(CNAA, of);
+
213 #endif
+
214 
+
215  return jnll;
+
216  }
+
217 };
+
218 
+
219 // Create singleton instance of Model class
+
220 template <typename Type>
+
221 std::shared_ptr<Model<Type> > Model<Type>::fims_model =
+
222  nullptr; // singleton instance
+
223 } // namespace fims_model
+
224 
+
225 #endif /* FIMS_COMMON_MODEL_HPP */
fims_info::Information::fleet_iterator
std::map< uint32_t, std::shared_ptr< fims_popdy::Fleet< Type > > >::iterator fleet_iterator
Definition: information.hpp:93
fims_info::Information::population_iterator
std::map< uint32_t, std::shared_ptr< fims_popdy::Population< Type > > >::iterator population_iterator
Definition: information.hpp:102
fims_info::Information::GetInstance
static std::shared_ptr< Information< Type > > GetInstance()
Definition: information.hpp:125
diff --git a/docs/population_8hpp_source.html b/docs/population_8hpp_source.html index e52e69d..81cc855 100644 --- a/docs/population_8hpp_source.html +++ b/docs/population_8hpp_source.html @@ -242,398 +242,402 @@
215  this->fleets[fleet_]->Fmort[year] *
216  // evaluate is a member function of the selectivity class
217  this->fleets[fleet_]->selectivity->evaluate(ages[age]);
-
218  POPULATION_LOG << " selectivity at age " << ages[age] << " for fleet " << fleet_ << " is "
-
219  << this->fleets[fleet_]->selectivity->evaluate(ages[age])
-
220  << " apical fishing mortality F for the fleet in year " << year << " is "
-
221  << this->fleets[fleet_]->Fmort[year] << std::endl;
-
222  }
-
223  }
-
224  POPULATION_LOG << "M in calculate mortality is " << this->M[i_age_year]
-
225  << std::endl;
-
226  this->mortality_Z[i_age_year] =
-
227  this->M[i_age_year] + this->mortality_F[i_age_year];
-
228  }
-
229 
-
237  inline void CalculateNumbersAA(size_t i_age_year, size_t i_agem1_yearm1,
-
238  size_t age) {
-
239  // using Z from previous age/year
-
240  this->numbers_at_age[i_age_year] =
-
241  this->numbers_at_age[i_agem1_yearm1] *
-
242 
-
243  (fims_math::exp(-this->mortality_Z[i_agem1_yearm1]));
-
244  POPULATION_LOG << " z at i_agem1_yearm1 = " << i_agem1_yearm1 << " is "
-
245  << this->mortality_Z[i_agem1_yearm1] << std::endl;
-
246  // Plus group calculation
-
247  if (age == (this->nages - 1)) {
-
248  this->numbers_at_age[i_age_year] =
-
249  this->numbers_at_age[i_age_year] +
-
250  this->numbers_at_age[i_agem1_yearm1 + 1] *
-
251  (fims_math::exp(-this->mortality_Z[i_agem1_yearm1 + 1]));
-
252  }
-
253  }
-
254 
-
262  inline void CalculateUnfishedNumbersAA(size_t i_age_year,
-
263  size_t i_agem1_yearm1, size_t age) {
-
264  // using M from previous age/year
-
265  this->unfished_numbers_at_age[i_age_year] =
-
266  this->unfished_numbers_at_age[i_agem1_yearm1] *
-
267 
-
268  (fims_math::exp(-this->M[i_agem1_yearm1]));
-
269  POPULATION_LOG << "survival rate at index " << i_agem1_yearm1 << " is "
-
270  << fims_math::exp(-(this->M[i_agem1_yearm1])) << std::endl;
-
271 
-
272  // Plus group calculation
-
273  if (age == (this->nages - 1)) {
-
274  this->unfished_numbers_at_age[i_age_year] =
-
275  this->unfished_numbers_at_age[i_age_year] +
-
276  this->unfished_numbers_at_age[i_agem1_yearm1 + 1] *
-
277  (fims_math::exp(-this->M[i_agem1_yearm1 + 1]));
-
278  }
-
279  }
-
280 
-
288  void CalculateBiomass(size_t i_age_year, size_t year, size_t age) {
-
289  this->biomass[year] +=
-
290  this->numbers_at_age[i_age_year] * this->weight_at_age[age];
-
291  POPULATION_LOG << " age " << ages[age] << std::endl;
-
292  POPULATION_LOG << "growth evaluate: " << this->weight_at_age[age]
-
293  << " biomass inputs----- +++\n";
-
294  }
-
295 
-
304  void CalculateUnfishedBiomass(size_t i_age_year, size_t year, size_t age) {
-
305  this->unfished_biomass[year] += this->unfished_numbers_at_age[i_age_year] *
-
306  this->weight_at_age[age];
-
307  }
-
308 
-
316  void CalculateSpawningBiomass(size_t i_age_year, size_t year, size_t age) {
-
317  this->spawning_biomass[year] += this->proportion_female *
-
318  this->numbers_at_age[i_age_year] *
-
319  this->proportion_mature_at_age[i_age_year] *
-
320  this->weight_at_age[age];
-
321  POPULATION_LOG << " proportion female " << this->proportion_female << " "
-
322  << " mature age " << age << " is "
-
323  << this->proportion_mature_at_age[i_age_year] << " "
-
324  << " numbers at age " << this->numbers_at_age[i_age_year] << " "
-
325  << " growth " << this->weight_at_age[age] << " "
-
326  << " spawning biomass " << this->spawning_biomass[year] << " "
-
327  << " spawning biomass inputs----- +++\n";
-
328  }
-
329 
-
338  void CalculateUnfishedSpawningBiomass(size_t i_age_year, size_t year,
-
339  size_t age) {
-
340  this->unfished_spawning_biomass[year] +=
-
341  this->proportion_female * this->unfished_numbers_at_age[i_age_year] *
-
342  this->proportion_mature_at_age[i_age_year] *
-
343  this->weight_at_age[age];
-
344  }
-
345 
-
351  Type CalculateSBPR0() {
-
352  std::vector<Type> numbers_spr(this->nages, 1.0);
-
353  Type phi_0 = 0.0;
-
354  phi_0 += numbers_spr[0] * this->proportion_female *
-
355  this->proportion_mature_at_age[0] *
-
356  this->growth->evaluate(ages[0]);
-
357  for (size_t a = 1; a < (this->nages - 1); a++) {
-
358  numbers_spr[a] = numbers_spr[a - 1] * fims_math::exp(-this->M[a]);
-
359  phi_0 += numbers_spr[a] * this->proportion_female *
-
360  this->proportion_mature_at_age[a] *
-
361  this->growth->evaluate(ages[a]);
-
362  }
-
363 
-
364  numbers_spr[this->nages - 1] =
-
365  (numbers_spr[nages - 2] * fims_math::exp(-this->M[nages - 2])) /
-
366  (1 - fims_math::exp(-this->M[this->nages - 1]));
-
367  phi_0 += numbers_spr[this->nages - 1] * this->proportion_female *
-
368  this->proportion_mature_at_age[this->nages - 1] *
-
369  this->growth->evaluate(ages[this->nages - 1]);
-
370  return phi_0;
-
371  }
-
372 
-
379  void CalculateRecruitment(size_t i_age_year, size_t year) {
-
380  POPULATION_LOG << "recruitment 1" << std::endl;
-
381  Type phi0 = CalculateSBPR0();
-
382  POPULATION_LOG << "recruitment 2" << std::endl;
-
383  POPULATION_LOG << "phi0 = " << phi0 << std::endl;
-
384  POPULATION_LOG << "spawning biomass = " << this->spawning_biomass[year]
-
385  << std::endl;
-
386  POPULATION_LOG << "rec devs = " << this->recruitment->recruit_deviations[year - 1]
-
387  << std::endl;
-
388  POPULATION_LOG << "rec eval = "
-
389  << this->recruitment->evaluate(this->spawning_biomass[year - 1],
-
390  phi0)
-
391  << std::endl;
-
392  this->numbers_at_age[i_age_year] =
-
393  this->recruitment->evaluate(this->spawning_biomass[year - 1], phi0) *
-
394  this->recruitment->recruit_deviations[year];
-
395  this->expected_recruitment[year] = this->numbers_at_age[i_age_year];
-
396  POPULATION_LOG << " numbers at age at indexya " << i_age_year << " is "
-
397  << this->numbers_at_age[i_age_year] << std::endl;
-
398  }
-
399 
-
406  void CalculateCatch(size_t year, size_t age) {
-
407  for (size_t fleet_ = 0; fleet_ < this->nfleets; fleet_++) {
-
408  if (this->fleets[fleet_]->is_survey == false) {
-
409  size_t index_yf = year * this->nfleets +
-
410  fleet_; // index by fleet and years to dimension fold
-
411  size_t i_age_year = year * this->nages + age;
-
412 
-
413  POPULATION_LOG << " fleet " << fleet_ << " year " << year << " age " << age
-
414  << std::endl;
-
415  this->expected_catch[index_yf] +=
-
416  this->fleets[fleet_]->catch_weight_at_age[i_age_year];
-
417 
-
418  POPULATION_LOG << "expected catch: " << this->expected_catch[index_yf]
-
419  << std::endl;
-
420  POPULATION_LOG << "----------------------------------------------"
-
421  << std::endl;
-
422 
-
423  fleets[fleet_]->expected_catch[year] +=
-
424  this->fleets[fleet_]->catch_weight_at_age[i_age_year];
-
425  }
-
426  }
-
427  }
-
428 
-
436  void CalculateIndex(size_t i_age_year, size_t year, size_t age) {
-
437  for (size_t fleet_ = 0; fleet_ < this->nfleets; fleet_++) {
-
438  Type index_;
-
439  // I = qN (N is total numbers), I is an index in numbers
-
440  if (this->fleets[fleet_]->is_survey == false) {
-
441  index_ = this->fleets[fleet_]->catch_numbers_at_age[i_age_year] *
-
442  this->weight_at_age[age];
-
443  } else {
-
444  POPULATION_LOG << "fleet " << fleet_ << " is a survey" << std::endl;
-
445  index_ = this->fleets[fleet_]->q *
-
446  this->fleets[fleet_]->selectivity->evaluate(ages[age]) *
-
447  this->numbers_at_age[i_age_year] *
-
448  this->weight_at_age[age]; // this->weight_at_age[age];
-
449  }
-
450  fleets[fleet_]->expected_index[year] += index_;
-
451  POPULATION_LOG << " expected index in year " << year << " is "
-
452  << fleets[fleet_]->expected_index[year] << std::endl;
-
453  }
-
454  }
-
455 
-
465  void CalculateCatchNumbersAA(size_t i_age_year, size_t year, size_t age) {
-
466  for (size_t fleet_ = 0; fleet_ < this->nfleets; fleet_++) {
-
467  // make an intermediate value in order to set multiple members (of
-
468  // current and fleet objects) to that value.
-
469  Type catch_; // catch_ is used to avoid using the c++ keyword catch
-
470  // Baranov Catch Equation
-
471  if (this->fleets[fleet_]->is_survey == false) {
-
472  catch_ = (this->fleets[fleet_]->Fmort[year] *
-
473  this->fleets[fleet_]->selectivity->evaluate(ages[age])) /
-
474  this->mortality_Z[i_age_year] *
-
475  this->numbers_at_age[i_age_year] *
-
476  (1 - fims_math::exp(-(this->mortality_Z[i_age_year])));
-
477  } else {
-
478  catch_ = (this->fleets[fleet_]->selectivity->evaluate(ages[age])) *
-
479  this->numbers_at_age[i_age_year];
-
480  }
-
481  POPULATION_LOG << " F " << fleet_ << " " << this->fleets[fleet_]->Fmort[year]
-
482  << std::endl;
-
483  POPULATION_LOG << " selectivity "
-
484  << this->fleets[fleet_]->selectivity->evaluate(ages[age])
-
485  << std::endl;
-
486  POPULATION_LOG << " catch " << catch_ << std::endl;
-
487  // this->catch_numbers_at_age[i_age_yearf] += catch_;
-
488  // catch_numbers_at_age for the fleet module has different
-
489  // dimensions (year/age, not year/fleet/age)
-
490  this->fleets[fleet_]->catch_numbers_at_age[i_age_year] += catch_;
-
491  }
-
492  }
-
493 
-
501  void CalculateCatchWeightAA(size_t year, size_t age) {
-
502  int i_age_year = year * this->nages + age;
-
503  for (size_t fleet_ = 0; fleet_ < this->nfleets; fleet_++) {
-
504  POPULATION_LOG << " fleet " << fleet_ << std::endl;
-
505  POPULATION_LOG << " catchnaa "
-
506  << this->fleets[fleet_]->catch_numbers_at_age[year] << std::endl;
-
507  POPULATION_LOG << " weight " << this->weight_at_age[age] << std::endl;
-
508  this->fleets[fleet_]->catch_weight_at_age[i_age_year] =
-
509  this->fleets[fleet_]->catch_numbers_at_age[i_age_year] *
-
510  this->weight_at_age[age];
-
511  POPULATION_LOG << " catch_waa "
-
512  << this->fleets[fleet_]->catch_weight_at_age[i_age_year]
-
513  << std::endl;
-
514  }
-
515  }
-
516 
-
524  void CalculateMaturityAA(size_t i_age_year, size_t age) {
-
525  // this->maturity is pointing to the maturity module, which has
-
526  // an evaluate function. -> can be nested.
-
527  POPULATION_LOG << " age " << age << std::endl;
-
528  POPULATION_LOG << " ages size " << this->ages.size() << std::endl;
-
529  POPULATION_LOG << " i_age_year " << i_age_year << std::endl;
-
530  POPULATION_LOG << "p mature" << this->proportion_mature_at_age[i_age_year]
-
531  << std::endl;
-
532  POPULATION_LOG << this->ages[age] << std::endl;
-
533  this->proportion_mature_at_age[i_age_year] =
-
534  this->maturity->evaluate(ages[age]);
-
535 
-
536  POPULATION_LOG << "p mature set to " << this->proportion_mature_at_age[i_age_year]
-
537  << std::endl;
-
538  }
+
218  POPULATION_LOG << " selectivity at age " << ages[age] << " for fleet "
+
219  << fleet_ << " is "
+
220  << this->fleets[fleet_]->selectivity->evaluate(ages[age])
+
221  << " apical fishing mortality F for the fleet in year "
+
222  << year << " is " << this->fleets[fleet_]->Fmort[year]
+
223  << std::endl;
+
224  }
+
225  }
+
226  POPULATION_LOG << "M in calculate mortality is " << this->M[i_age_year]
+
227  << std::endl;
+
228  this->mortality_Z[i_age_year] =
+
229  this->M[i_age_year] + this->mortality_F[i_age_year];
+
230  }
+
231 
+
239  inline void CalculateNumbersAA(size_t i_age_year, size_t i_agem1_yearm1,
+
240  size_t age) {
+
241  // using Z from previous age/year
+
242  this->numbers_at_age[i_age_year] =
+
243  this->numbers_at_age[i_agem1_yearm1] *
+
244 
+
245  (fims_math::exp(-this->mortality_Z[i_agem1_yearm1]));
+
246  POPULATION_LOG << " z at i_agem1_yearm1 = " << i_agem1_yearm1 << " is "
+
247  << this->mortality_Z[i_agem1_yearm1] << std::endl;
+
248  // Plus group calculation
+
249  if (age == (this->nages - 1)) {
+
250  this->numbers_at_age[i_age_year] =
+
251  this->numbers_at_age[i_age_year] +
+
252  this->numbers_at_age[i_agem1_yearm1 + 1] *
+
253  (fims_math::exp(-this->mortality_Z[i_agem1_yearm1 + 1]));
+
254  }
+
255  }
+
256 
+
264  inline void CalculateUnfishedNumbersAA(size_t i_age_year,
+
265  size_t i_agem1_yearm1, size_t age) {
+
266  // using M from previous age/year
+
267  this->unfished_numbers_at_age[i_age_year] =
+
268  this->unfished_numbers_at_age[i_agem1_yearm1] *
+
269 
+
270  (fims_math::exp(-this->M[i_agem1_yearm1]));
+
271  POPULATION_LOG << "survival rate at index " << i_agem1_yearm1 << " is "
+
272  << fims_math::exp(-(this->M[i_agem1_yearm1])) << std::endl;
+
273 
+
274  // Plus group calculation
+
275  if (age == (this->nages - 1)) {
+
276  this->unfished_numbers_at_age[i_age_year] =
+
277  this->unfished_numbers_at_age[i_age_year] +
+
278  this->unfished_numbers_at_age[i_agem1_yearm1 + 1] *
+
279  (fims_math::exp(-this->M[i_agem1_yearm1 + 1]));
+
280  }
+
281  }
+
282 
+
290  void CalculateBiomass(size_t i_age_year, size_t year, size_t age) {
+
291  this->biomass[year] +=
+
292  this->numbers_at_age[i_age_year] * this->weight_at_age[age];
+
293  POPULATION_LOG << " age " << ages[age] << std::endl;
+
294  POPULATION_LOG << "growth evaluate: " << this->weight_at_age[age]
+
295  << " biomass inputs----- +++\n";
+
296  }
+
297 
+
306  void CalculateUnfishedBiomass(size_t i_age_year, size_t year, size_t age) {
+
307  this->unfished_biomass[year] +=
+
308  this->unfished_numbers_at_age[i_age_year] * this->weight_at_age[age];
+
309  }
+
310 
+
318  void CalculateSpawningBiomass(size_t i_age_year, size_t year, size_t age) {
+
319  this->spawning_biomass[year] +=
+
320  this->proportion_female * this->numbers_at_age[i_age_year] *
+
321  this->proportion_mature_at_age[i_age_year] * this->weight_at_age[age];
+
322  POPULATION_LOG << " proportion female " << this->proportion_female << " "
+
323  << " mature age " << age << " is "
+
324  << this->proportion_mature_at_age[i_age_year] << " "
+
325  << " numbers at age " << this->numbers_at_age[i_age_year]
+
326  << " "
+
327  << " growth " << this->weight_at_age[age] << " "
+
328  << " spawning biomass " << this->spawning_biomass[year]
+
329  << " "
+
330  << " spawning biomass inputs----- +++\n";
+
331  }
+
332 
+
341  void CalculateUnfishedSpawningBiomass(size_t i_age_year, size_t year,
+
342  size_t age) {
+
343  this->unfished_spawning_biomass[year] +=
+
344  this->proportion_female * this->unfished_numbers_at_age[i_age_year] *
+
345  this->proportion_mature_at_age[i_age_year] * this->weight_at_age[age];
+
346  }
+
347 
+
353  Type CalculateSBPR0() {
+
354  std::vector<Type> numbers_spr(this->nages, 1.0);
+
355  Type phi_0 = 0.0;
+
356  phi_0 += numbers_spr[0] * this->proportion_female *
+
357  this->proportion_mature_at_age[0] *
+
358  this->growth->evaluate(ages[0]);
+
359  for (size_t a = 1; a < (this->nages - 1); a++) {
+
360  numbers_spr[a] = numbers_spr[a - 1] * fims_math::exp(-this->M[a]);
+
361  phi_0 += numbers_spr[a] * this->proportion_female *
+
362  this->proportion_mature_at_age[a] *
+
363  this->growth->evaluate(ages[a]);
+
364  }
+
365 
+
366  numbers_spr[this->nages - 1] =
+
367  (numbers_spr[nages - 2] * fims_math::exp(-this->M[nages - 2])) /
+
368  (1 - fims_math::exp(-this->M[this->nages - 1]));
+
369  phi_0 += numbers_spr[this->nages - 1] * this->proportion_female *
+
370  this->proportion_mature_at_age[this->nages - 1] *
+
371  this->growth->evaluate(ages[this->nages - 1]);
+
372  return phi_0;
+
373  }
+
374 
+
381  void CalculateRecruitment(size_t i_age_year, size_t year) {
+
382  POPULATION_LOG << "recruitment 1" << std::endl;
+
383  Type phi0 = CalculateSBPR0();
+
384  POPULATION_LOG << "recruitment 2" << std::endl;
+
385  POPULATION_LOG << "phi0 = " << phi0 << std::endl;
+
386  POPULATION_LOG << "spawning biomass = " << this->spawning_biomass[year]
+
387  << std::endl;
+
388  POPULATION_LOG << "rec devs = "
+
389  << this->recruitment->recruit_deviations[year - 1]
+
390  << std::endl;
+
391  POPULATION_LOG << "rec eval = "
+
392  << this->recruitment->evaluate(
+
393  this->spawning_biomass[year - 1], phi0)
+
394  << std::endl;
+
395  this->numbers_at_age[i_age_year] =
+
396  this->recruitment->evaluate(this->spawning_biomass[year - 1], phi0) *
+
397  this->recruitment->recruit_deviations[year];
+
398  this->expected_recruitment[year] = this->numbers_at_age[i_age_year];
+
399  POPULATION_LOG << " numbers at age at indexya " << i_age_year << " is "
+
400  << this->numbers_at_age[i_age_year] << std::endl;
+
401  }
+
402 
+
409  void CalculateCatch(size_t year, size_t age) {
+
410  for (size_t fleet_ = 0; fleet_ < this->nfleets; fleet_++) {
+
411  if (this->fleets[fleet_]->is_survey == false) {
+
412  size_t index_yf = year * this->nfleets +
+
413  fleet_; // index by fleet and years to dimension fold
+
414  size_t i_age_year = year * this->nages + age;
+
415 
+
416  POPULATION_LOG << " fleet " << fleet_ << " year " << year << " age "
+
417  << age << std::endl;
+
418  this->expected_catch[index_yf] +=
+
419  this->fleets[fleet_]->catch_weight_at_age[i_age_year];
+
420 
+
421  POPULATION_LOG << "expected catch: " << this->expected_catch[index_yf]
+
422  << std::endl;
+
423  POPULATION_LOG << "----------------------------------------------"
+
424  << std::endl;
+
425 
+
426  fleets[fleet_]->expected_catch[year] +=
+
427  this->fleets[fleet_]->catch_weight_at_age[i_age_year];
+
428  }
+
429  }
+
430  }
+
431 
+
439  void CalculateIndex(size_t i_age_year, size_t year, size_t age) {
+
440  for (size_t fleet_ = 0; fleet_ < this->nfleets; fleet_++) {
+
441  Type index_;
+
442  // I = qN (N is total numbers), I is an index in numbers
+
443  if (this->fleets[fleet_]->is_survey == false) {
+
444  index_ = this->fleets[fleet_]->catch_numbers_at_age[i_age_year] *
+
445  this->weight_at_age[age];
+
446  } else {
+
447  POPULATION_LOG << "fleet " << fleet_ << " is a survey" << std::endl;
+
448  index_ = this->fleets[fleet_]->q *
+
449  this->fleets[fleet_]->selectivity->evaluate(ages[age]) *
+
450  this->numbers_at_age[i_age_year] *
+
451  this->weight_at_age[age]; // this->weight_at_age[age];
+
452  }
+
453  fleets[fleet_]->expected_index[year] += index_;
+
454  POPULATION_LOG << " expected index in year " << year << " is "
+
455  << fleets[fleet_]->expected_index[year] << std::endl;
+
456  }
+
457  }
+
458 
+
468  void CalculateCatchNumbersAA(size_t i_age_year, size_t year, size_t age) {
+
469  for (size_t fleet_ = 0; fleet_ < this->nfleets; fleet_++) {
+
470  // make an intermediate value in order to set multiple members (of
+
471  // current and fleet objects) to that value.
+
472  Type catch_; // catch_ is used to avoid using the c++ keyword catch
+
473  // Baranov Catch Equation
+
474  if (this->fleets[fleet_]->is_survey == false) {
+
475  catch_ = (this->fleets[fleet_]->Fmort[year] *
+
476  this->fleets[fleet_]->selectivity->evaluate(ages[age])) /
+
477  this->mortality_Z[i_age_year] *
+
478  this->numbers_at_age[i_age_year] *
+
479  (1 - fims_math::exp(-(this->mortality_Z[i_age_year])));
+
480  } else {
+
481  catch_ = (this->fleets[fleet_]->selectivity->evaluate(ages[age])) *
+
482  this->numbers_at_age[i_age_year];
+
483  }
+
484  POPULATION_LOG << " F " << fleet_ << " "
+
485  << this->fleets[fleet_]->Fmort[year] << std::endl;
+
486  POPULATION_LOG << " selectivity "
+
487  << this->fleets[fleet_]->selectivity->evaluate(ages[age])
+
488  << std::endl;
+
489  POPULATION_LOG << " catch " << catch_ << std::endl;
+
490  // this->catch_numbers_at_age[i_age_yearf] += catch_;
+
491  // catch_numbers_at_age for the fleet module has different
+
492  // dimensions (year/age, not year/fleet/age)
+
493  this->fleets[fleet_]->catch_numbers_at_age[i_age_year] += catch_;
+
494  }
+
495  }
+
496 
+
504  void CalculateCatchWeightAA(size_t year, size_t age) {
+
505  int i_age_year = year * this->nages + age;
+
506  for (size_t fleet_ = 0; fleet_ < this->nfleets; fleet_++) {
+
507  POPULATION_LOG << " fleet " << fleet_ << std::endl;
+
508  POPULATION_LOG << " catchnaa "
+
509  << this->fleets[fleet_]->catch_numbers_at_age[year]
+
510  << std::endl;
+
511  POPULATION_LOG << " weight " << this->weight_at_age[age] << std::endl;
+
512  this->fleets[fleet_]->catch_weight_at_age[i_age_year] =
+
513  this->fleets[fleet_]->catch_numbers_at_age[i_age_year] *
+
514  this->weight_at_age[age];
+
515  POPULATION_LOG << " catch_waa "
+
516  << this->fleets[fleet_]->catch_weight_at_age[i_age_year]
+
517  << std::endl;
+
518  }
+
519  }
+
520 
+
528  void CalculateMaturityAA(size_t i_age_year, size_t age) {
+
529  // this->maturity is pointing to the maturity module, which has
+
530  // an evaluate function. -> can be nested.
+
531  POPULATION_LOG << " age " << age << std::endl;
+
532  POPULATION_LOG << " ages size " << this->ages.size() << std::endl;
+
533  POPULATION_LOG << " i_age_year " << i_age_year << std::endl;
+
534  POPULATION_LOG << "p mature" << this->proportion_mature_at_age[i_age_year]
+
535  << std::endl;
+
536  POPULATION_LOG << this->ages[age] << std::endl;
+
537  this->proportion_mature_at_age[i_age_year] =
+
538  this->maturity->evaluate(ages[age]);
539 
-
544  void Evaluate() {
-
545  /*
-
546  Sets derived vectors to zero
-
547  Performs parameters transformations
-
548  Sets recruitment deviations to mean 0.
-
549  */
-
550  Prepare();
-
551  /*
-
552  start at year=0, age=0;
-
553  here year 0 is the estimated initial stock structure and age 0 are recruits
-
554  loops start at zero with if statements inside to specify unique code for
-
555  initial structure and recruitment 0 loops. Could also have started loops at
-
556  1 with initial structure and recruitment setup outside the loops.
-
557 
-
558  year loop is extended to <= nyears because SSB is calculted as the start of
-
559  the year value and by extending one extra year we get estimates of the
-
560  population structure at the end of the final year. An alternative approach
-
561  would be to keep initial numbers at age in it's own vector and each year to
-
562  include the population structure at the end of the year. This is likely a
-
563  null point given that we are planning to modify to an event/stanza based
-
564  structure in later milestones which will elimitate this confusion by
-
565  explicity referencing the exact date (or period of averaging) at which any
-
566  calculation or output is being made.
-
567  */
-
568  for (size_t y = 0; y <= this->nyears; y++) {
-
569  for (size_t a = 0; a < this->nages; a++) {
-
570  /*
-
571  index naming defines the dimensional folding structure
-
572  i.e. i_age_year is referencing folding over years and ages.
-
573  */
-
574  size_t i_age_year = y * this->nages + a;
-
575  /*
-
576  Mortality rates are not estimated in the final year which is
-
577  used to show expected stock structure at the end of the model period.
-
578  This is because biomass in year i represents biomass at the start of
-
579  the year.
-
580  Should we add complexity to track more values such as start,
-
581  mid, and end biomass in all years where, start biomass=end biomass of
-
582  the previous year? Referenced above, this is probably not worth
-
583  exploring as later milestone changes will eliminate this confusion.
-
584  */
-
585  if (y < this->nyears) {
-
586  /*
-
587  First thing we need is total mortality aggregated across all fleets
-
588  to inform the subsequent catch and change in numbers at age
-
589  calculations. This is only calculated for years < nyears as these are
-
590  the model estimated years with data. The year loop extends to
-
591  y=nyears so that population numbers at age and SSB can be calculated
-
592  at the end of the last year of the model
-
593  */
-
594  CalculateMortality(i_age_year, y, a);
-
595  }
-
596  CalculateMaturityAA(i_age_year, a);
-
597  /* if statements needed because some quantities are only needed
-
598  for the first year and/or age, so these steps are included here.
-
599  */
-
600  if (y == 0) {
-
601  // Initial numbers at age is a user input or estimated parameter
-
602  // vector.
-
603  CalculateInitialNumbersAA(i_age_year, a);
-
604 
-
605  if (a == 0) {
-
606  // this->numbers_at_age[i_age_year] = this->recruitment->rzero;
-
607  this->unfished_numbers_at_age[i_age_year] =
-
608  fims_math::exp(this->recruitment->log_rzero);
-
609  } else {
-
610  CalculateUnfishedNumbersAA(i_age_year, a - 1, a);
-
611  }
-
612 
-
613  /*
-
614  Fished and unfished biomass vectors are summing biomass at
-
615  age across ages.
-
616  */
-
617 
-
618  CalculateBiomass(i_age_year, y, a);
-
619 
-
620  CalculateUnfishedBiomass(i_age_year, y, a);
+
540  POPULATION_LOG << "p mature set to "
+
541  << this->proportion_mature_at_age[i_age_year] << std::endl;
+
542  }
+
543 
+
548  void Evaluate() {
+
549  /*
+
550  Sets derived vectors to zero
+
551  Performs parameters transformations
+
552  Sets recruitment deviations to mean 0.
+
553  */
+
554  Prepare();
+
555  /*
+
556  start at year=0, age=0;
+
557  here year 0 is the estimated initial stock structure and age 0 are recruits
+
558  loops start at zero with if statements inside to specify unique code for
+
559  initial structure and recruitment 0 loops. Could also have started loops at
+
560  1 with initial structure and recruitment setup outside the loops.
+
561 
+
562  year loop is extended to <= nyears because SSB is calculted as the start of
+
563  the year value and by extending one extra year we get estimates of the
+
564  population structure at the end of the final year. An alternative approach
+
565  would be to keep initial numbers at age in it's own vector and each year to
+
566  include the population structure at the end of the year. This is likely a
+
567  null point given that we are planning to modify to an event/stanza based
+
568  structure in later milestones which will elimitate this confusion by
+
569  explicity referencing the exact date (or period of averaging) at which any
+
570  calculation or output is being made.
+
571  */
+
572  for (size_t y = 0; y <= this->nyears; y++) {
+
573  for (size_t a = 0; a < this->nages; a++) {
+
574  /*
+
575  index naming defines the dimensional folding structure
+
576  i.e. i_age_year is referencing folding over years and ages.
+
577  */
+
578  size_t i_age_year = y * this->nages + a;
+
579  /*
+
580  Mortality rates are not estimated in the final year which is
+
581  used to show expected stock structure at the end of the model period.
+
582  This is because biomass in year i represents biomass at the start of
+
583  the year.
+
584  Should we add complexity to track more values such as start,
+
585  mid, and end biomass in all years where, start biomass=end biomass of
+
586  the previous year? Referenced above, this is probably not worth
+
587  exploring as later milestone changes will eliminate this confusion.
+
588  */
+
589  if (y < this->nyears) {
+
590  /*
+
591  First thing we need is total mortality aggregated across all fleets
+
592  to inform the subsequent catch and change in numbers at age
+
593  calculations. This is only calculated for years < nyears as these are
+
594  the model estimated years with data. The year loop extends to
+
595  y=nyears so that population numbers at age and SSB can be calculated
+
596  at the end of the last year of the model
+
597  */
+
598  CalculateMortality(i_age_year, y, a);
+
599  }
+
600  CalculateMaturityAA(i_age_year, a);
+
601  /* if statements needed because some quantities are only needed
+
602  for the first year and/or age, so these steps are included here.
+
603  */
+
604  if (y == 0) {
+
605  // Initial numbers at age is a user input or estimated parameter
+
606  // vector.
+
607  CalculateInitialNumbersAA(i_age_year, a);
+
608 
+
609  if (a == 0) {
+
610  // this->numbers_at_age[i_age_year] = this->recruitment->rzero;
+
611  this->unfished_numbers_at_age[i_age_year] =
+
612  fims_math::exp(this->recruitment->log_rzero);
+
613  } else {
+
614  CalculateUnfishedNumbersAA(i_age_year, a - 1, a);
+
615  }
+
616 
+
617  /*
+
618  Fished and unfished biomass vectors are summing biomass at
+
619  age across ages.
+
620  */
621 
-
622  /*
-
623  Fished and unfished spawning biomass vectors are summing biomass at
-
624  age across ages to allow calculation of recruitment in the next year.
-
625  */
-
626 
-
627  CalculateSpawningBiomass(i_age_year, y, a);
-
628 
-
629  CalculateUnfishedSpawningBiomass(i_age_year, y, a);
+
622  CalculateBiomass(i_age_year, y, a);
+
623 
+
624  CalculateUnfishedBiomass(i_age_year, y, a);
+
625 
+
626  /*
+
627  Fished and unfished spawning biomass vectors are summing biomass at
+
628  age across ages to allow calculation of recruitment in the next year.
+
629  */
630 
-
631  /*
-
632  Expected recruitment in year 0 is numbers at age 0 in year 0.
-
633  */
+
631  CalculateSpawningBiomass(i_age_year, y, a);
+
632 
+
633  CalculateUnfishedSpawningBiomass(i_age_year, y, a);
634 
-
635  this->expected_recruitment[i_age_year] =
-
636  this->numbers_at_age[i_age_year];
-
637 
-
638  } else {
-
639  if (a == 0) {
-
640  // Set the nrecruits for age a=0 year y (use pointers instead of
-
641  // functional returns) assuming fecundity = 1 and 50:50 sex ratio
-
642  POPULATION_LOG << "Recruitment: " << std::endl;
-
643  CalculateRecruitment(i_age_year, y);
-
644  this->unfished_numbers_at_age[i_age_year] =
-
645  fims_math::exp(this->recruitment->log_rzero);
-
646 
-
647  } else {
-
648  size_t i_agem1_yearm1 = (y - 1) * nages + (a - 1);
-
649  CalculateNumbersAA(i_age_year, i_agem1_yearm1, a);
-
650  CalculateUnfishedNumbersAA(i_age_year, i_agem1_yearm1, a);
-
651  }
-
652  CalculateBiomass(i_age_year, y, a);
-
653  CalculateSpawningBiomass(i_age_year, y, a);
-
654 
-
655  POPULATION_LOG << "index age year: " << i_age_year << std::endl;
-
656  CalculateUnfishedBiomass(i_age_year, y, a);
-
657  CalculateUnfishedSpawningBiomass(i_age_year, y, a);
-
658  }
-
659 
-
660  /*
-
661  Here composition, total catch, and index values are calculated for all
-
662  years with reference data. They are not calculated for y=nyears as there
-
663  is this is just to get final population structure at the end of the
-
664  terminal year.
-
665  */
-
666  if (y < this->nyears) {
-
667  POPULATION_LOG << i_age_year << std::endl;
-
668  CalculateCatchNumbersAA(i_age_year, y, a);
-
669 
-
670  CalculateCatchWeightAA(y, a);
-
671  POPULATION_LOG << "year " << y << " and age " << a << std::endl;
-
672  CalculateCatch(y, a);
-
673  CalculateIndex(i_age_year, y, a);
-
674  }
-
675  }
-
676  }
-
677 
-
678  POPULATION_LOG << "NAA\n";
-
679  for (size_t i = 0; i < nyears; i++) {
-
680  for (size_t j = 0; j < nages; j++) {
-
681  POPULATION_LOG << numbers_at_age[i * nages + j] << "\t";
-
682  }
-
683  POPULATION_LOG << "\n";
-
684  }
-
685 
-
686  POPULATION_LOG << "CAA\n";
-
687  for (size_t fleet_ = 0; fleet_ < this->nfleets; fleet_++) {
-
688  for (size_t i = 0; i < nyears; i++) {
-
689  for (size_t j = 0; j < nages; j++) {
-
690  POPULATION_LOG << "Fleet " << fleet_ + 1 << "\n";
-
691  POPULATION_LOG << fleets[fleet_]->catch_numbers_at_age[i * nages + j]
-
692  << "\t";
-
693  }
-
694  POPULATION_LOG << "\n";
-
695  }
-
696  }
-
697  }
-
698 };
-
699 template <class Type>
-
700 uint32_t Population<Type>::id_g = 0;
-
701 
-
702 } // namespace fims_popdy
-
703 
-
704 #endif /* FIMS_POPULATION_DYNAMICS_POPULATION_HPP */
+
635  /*
+
636  Expected recruitment in year 0 is numbers at age 0 in year 0.
+
637  */
+
638 
+
639  this->expected_recruitment[i_age_year] =
+
640  this->numbers_at_age[i_age_year];
+
641 
+
642  } else {
+
643  if (a == 0) {
+
644  // Set the nrecruits for age a=0 year y (use pointers instead of
+
645  // functional returns) assuming fecundity = 1 and 50:50 sex ratio
+
646  POPULATION_LOG << "Recruitment: " << std::endl;
+
647  CalculateRecruitment(i_age_year, y);
+
648  this->unfished_numbers_at_age[i_age_year] =
+
649  fims_math::exp(this->recruitment->log_rzero);
+
650 
+
651  } else {
+
652  size_t i_agem1_yearm1 = (y - 1) * nages + (a - 1);
+
653  CalculateNumbersAA(i_age_year, i_agem1_yearm1, a);
+
654  CalculateUnfishedNumbersAA(i_age_year, i_agem1_yearm1, a);
+
655  }
+
656  CalculateBiomass(i_age_year, y, a);
+
657  CalculateSpawningBiomass(i_age_year, y, a);
+
658 
+
659  POPULATION_LOG << "index age year: " << i_age_year << std::endl;
+
660  CalculateUnfishedBiomass(i_age_year, y, a);
+
661  CalculateUnfishedSpawningBiomass(i_age_year, y, a);
+
662  }
+
663 
+
664  /*
+
665  Here composition, total catch, and index values are calculated for all
+
666  years with reference data. They are not calculated for y=nyears as there
+
667  is this is just to get final population structure at the end of the
+
668  terminal year.
+
669  */
+
670  if (y < this->nyears) {
+
671  POPULATION_LOG << i_age_year << std::endl;
+
672  CalculateCatchNumbersAA(i_age_year, y, a);
+
673 
+
674  CalculateCatchWeightAA(y, a);
+
675  POPULATION_LOG << "year " << y << " and age " << a << std::endl;
+
676  CalculateCatch(y, a);
+
677  CalculateIndex(i_age_year, y, a);
+
678  }
+
679  }
+
680  }
+
681 
+
682  POPULATION_LOG << "NAA\n";
+
683  for (size_t i = 0; i < nyears; i++) {
+
684  for (size_t j = 0; j < nages; j++) {
+
685  POPULATION_LOG << numbers_at_age[i * nages + j] << "\t";
+
686  }
+
687  POPULATION_LOG << "\n";
+
688  }
+
689 
+
690  POPULATION_LOG << "CAA\n";
+
691  for (size_t fleet_ = 0; fleet_ < this->nfleets; fleet_++) {
+
692  for (size_t i = 0; i < nyears; i++) {
+
693  for (size_t j = 0; j < nages; j++) {
+
694  POPULATION_LOG << "Fleet " << fleet_ + 1 << "\n";
+
695  POPULATION_LOG << fleets[fleet_]->catch_numbers_at_age[i * nages + j]
+
696  << "\t";
+
697  }
+
698  POPULATION_LOG << "\n";
+
699  }
+
700  }
+
701  }
+
702 };
+
703 template <class Type>
+
704 uint32_t Population<Type>::id_g = 0;
+
705 
+
706 } // namespace fims_popdy
+
707 
+
708 #endif /* FIMS_POPULATION_DYNAMICS_POPULATION_HPP */
POPULATION_LOG
std::ofstream POPULATION_LOG("logs/population.log")
fims_model_object::FIMSObject
FIMSObject struct that defines member types and returns the unique id.
Definition: model_object.hpp:25
fims_popdy::Population
Population class. Contains subpopulations that are divided into generic partitions (eg....
Definition: population.hpp:36
@@ -649,42 +653,42 @@
fims_popdy::Population::growth_id
int growth_id
Definition: population.hpp:93
fims_popdy::Population::nyears
size_t nyears
Definition: population.hpp:41
fims_popdy::Population::nfleets
size_t nfleets
Definition: population.hpp:44
-
fims_popdy::Population::CalculateUnfishedSpawningBiomass
void CalculateUnfishedSpawningBiomass(size_t i_age_year, size_t year, size_t age)
Adds to existing yearly unfished spawning biomass estimates the biomass for a specified year and age.
Definition: population.hpp:338
-
fims_popdy::Population::CalculateNumbersAA
void CalculateNumbersAA(size_t i_age_year, size_t i_agem1_yearm1, size_t age)
Calculates numbers at age at year and age specific indices.
Definition: population.hpp:237
-
fims_popdy::Population::CalculateSpawningBiomass
void CalculateSpawningBiomass(size_t i_age_year, size_t year, size_t age)
Calculates spawning biomass.
Definition: population.hpp:316
+
fims_popdy::Population::CalculateUnfishedSpawningBiomass
void CalculateUnfishedSpawningBiomass(size_t i_age_year, size_t year, size_t age)
Adds to existing yearly unfished spawning biomass estimates the biomass for a specified year and age.
Definition: population.hpp:341
+
fims_popdy::Population::CalculateNumbersAA
void CalculateNumbersAA(size_t i_age_year, size_t i_agem1_yearm1, size_t age)
Calculates numbers at age at year and age specific indices.
Definition: population.hpp:239
+
fims_popdy::Population::CalculateSpawningBiomass
void CalculateSpawningBiomass(size_t i_age_year, size_t year, size_t age)
Calculates spawning biomass.
Definition: population.hpp:318
fims_popdy::Population::ParameterVector
typename fims::ModelTraits< Type >::ParameterVector ParameterVector
Definition: population.hpp:39
-
fims_popdy::Population::Evaluate
void Evaluate()
Executes the population loop.
Definition: population.hpp:544
+
fims_popdy::Population::Evaluate
void Evaluate()
Executes the population loop.
Definition: population.hpp:548
fims_popdy::Population::ages
std::vector< double > ages
Definition: population.hpp:58
fims_popdy::Population::proportion_mature_at_age
std::vector< Type > proportion_mature_at_age
Definition: population.hpp:81
fims_popdy::Population::unfished_spawning_biomass
std::vector< Type > unfished_spawning_biomass
Definition: population.hpp:79
-
fims_popdy::Population::CalculateMaturityAA
void CalculateMaturityAA(size_t i_age_year, size_t age)
Calculates expected proportion of individuals mature at a selected ageage.
Definition: population.hpp:524
+
fims_popdy::Population::CalculateMaturityAA
void CalculateMaturityAA(size_t i_age_year, size_t age)
Calculates expected proportion of individuals mature at a selected ageage.
Definition: population.hpp:528
fims_popdy::Population::biomass
std::vector< Type > biomass
Definition: population.hpp:75
-
fims_popdy::Population::CalculateRecruitment
void CalculateRecruitment(size_t i_age_year, size_t year)
Calculates expected recruitment for a given year.
Definition: population.hpp:379
+
fims_popdy::Population::CalculateRecruitment
void CalculateRecruitment(size_t i_age_year, size_t year)
Calculates expected recruitment for a given year.
Definition: population.hpp:381
fims_popdy::Population::Initialize
void Initialize(int nyears, int nseasons, int nages)
Initialize values. Called once at the start of model run.
Definition: population.hpp:125
-
fims_popdy::Population::CalculateBiomass
void CalculateBiomass(size_t i_age_year, size_t year, size_t age)
Calculates biomass.
Definition: population.hpp:288
+
fims_popdy::Population::CalculateBiomass
void CalculateBiomass(size_t i_age_year, size_t year, size_t age)
Calculates biomass.
Definition: population.hpp:290
fims_popdy::Population::spawning_biomass
std::vector< Type > spawning_biomass
Definition: population.hpp:76
fims_popdy::Population::fleet_id
int fleet_id
Definition: population.hpp:103
fims_popdy::Population::mortality_F
ParameterVector mortality_F
Definition: population.hpp:60
fims_popdy::Population::recruitment_id
int recruitment_id
recruitment
Definition: population.hpp:88
-
fims_popdy::Population::CalculateUnfishedBiomass
void CalculateUnfishedBiomass(size_t i_age_year, size_t year, size_t age)
Adds to existing yearly unfished biomass estimates the biomass for a specified year and age.
Definition: population.hpp:304
+
fims_popdy::Population::CalculateUnfishedBiomass
void CalculateUnfishedBiomass(size_t i_age_year, size_t year, size_t age)
Adds to existing yearly unfished biomass estimates the biomass for a specified year and age.
Definition: population.hpp:306
fims_popdy::Population::recruitment
std::shared_ptr< RecruitmentBase< Type > > recruitment
Definition: population.hpp:90
fims_popdy::Population::log_M
ParameterVector log_M
Definition: population.hpp:53
fims_popdy::Population::id_g
static uint32_t id_g
Definition: population.hpp:40
fims_popdy::Population::maturity_id
int maturity_id
Definition: population.hpp:98
fims_popdy::Population::nages
size_t nages
Definition: population.hpp:43
-
fims_popdy::Population::CalculateCatchWeightAA
void CalculateCatchWeightAA(size_t year, size_t age)
Calculates expected catch weight at age for each fleet for a given year and age.
Definition: population.hpp:501
+
fims_popdy::Population::CalculateCatchWeightAA
void CalculateCatchWeightAA(size_t year, size_t age)
Calculates expected catch weight at age for each fleet for a given year and age.
Definition: population.hpp:504
fims_popdy::Population::unfished_biomass
std::vector< Type > unfished_biomass
Definition: population.hpp:77
-
fims_popdy::Population::CalculateUnfishedNumbersAA
void CalculateUnfishedNumbersAA(size_t i_age_year, size_t i_agem1_yearm1, size_t age)
Calculates unfished numbers at age at year and age specific indices.
Definition: population.hpp:262
+
fims_popdy::Population::CalculateUnfishedNumbersAA
void CalculateUnfishedNumbersAA(size_t i_age_year, size_t i_agem1_yearm1, size_t age)
Calculates unfished numbers at age at year and age specific indices.
Definition: population.hpp:264
fims_popdy::Population::expected_recruitment
std::vector< Type > expected_recruitment
Definition: population.hpp:86
-
fims_popdy::Population::CalculateCatchNumbersAA
void CalculateCatchNumbersAA(size_t i_age_year, size_t year, size_t age)
Calculates catch in numbers at age for each fleet for a given year and age, then adds the value to th...
Definition: population.hpp:465
+
fims_popdy::Population::CalculateCatchNumbersAA
void CalculateCatchNumbersAA(size_t i_age_year, size_t year, size_t age)
Calculates catch in numbers at age for each fleet for a given year and age, then adds the value to th...
Definition: population.hpp:468
fims_popdy::Population::fleets
std::vector< std::shared_ptr< Fleet< Type > > > fleets
Definition: population.hpp:105
-
fims_popdy::Population::CalculateIndex
void CalculateIndex(size_t i_age_year, size_t year, size_t age)
Adds to the expected population indices by fleet.
Definition: population.hpp:436
+
fims_popdy::Population::CalculateIndex
void CalculateIndex(size_t i_age_year, size_t year, size_t age)
Adds to the expected population indices by fleet.
Definition: population.hpp:439
fims_popdy::Population::CalculateMortality
void CalculateMortality(size_t i_age_year, size_t year, size_t age)
Calculates total mortality at an index, year, and age.
Definition: population.hpp:211
-
fims_popdy::Population::CalculateCatch
void CalculateCatch(size_t year, size_t age)
Adds to exiting expected total catch by fleet in weight.
Definition: population.hpp:406
+
fims_popdy::Population::CalculateCatch
void CalculateCatch(size_t year, size_t age)
Adds to exiting expected total catch by fleet in weight.
Definition: population.hpp:409
fims_popdy::Population::years
std::vector< double > years
Definition: population.hpp:59
fims_popdy::Population::mortality_Z
std::vector< Type > mortality_Z
Definition: population.hpp:63
fims_popdy::Population::CalculateInitialNumbersAA
void CalculateInitialNumbersAA(size_t i_age_year, size_t a)
Calculates initial numbers at age for index and age.
Definition: population.hpp:199
-
fims_popdy::Population::CalculateSBPR0
Type CalculateSBPR0()
Calculates equilibrium spawning biomass per recruit.
Definition: population.hpp:351
+
fims_popdy::Population::CalculateSBPR0
Type CalculateSBPR0()
Calculates equilibrium spawning biomass per recruit.
Definition: population.hpp:353
fims_popdy::Population::weight_at_age
std::vector< Type > weight_at_age
Definition: population.hpp:67
fims_popdy::Population::Prepare
void Prepare()
Prepare to run the population loop. Called at each model iteration, and used to zero out derived quan...
Definition: population.hpp:156
fims_popdy::Population::log_init_naa
std::vector< Type > log_init_naa
Definition: population.hpp:52
diff --git a/docs/rcpp__interface_8hpp_source.html b/docs/rcpp__interface_8hpp_source.html index a478955..026935b 100644 --- a/docs/rcpp__interface_8hpp_source.html +++ b/docs/rcpp__interface_8hpp_source.html @@ -157,345 +157,346 @@
82  return p;
83 }
84 
-
85 
-
89 void clear_info_log() {
-
90  //First flush the output stream to make sure nothing
-
91  //is left in the stream memory bufffer.
-
92  INFO_LOG.flush();
-
93 
-
94  //Next an new stream is opened and closed to
-
95  //overwrite the file.
-
96  std::ofstream CLEAR_LOG("logs/info.log");
-
97  CLEAR_LOG.close();
-
98 
-
99  //Finally the stream output location is reset back to the start
-
100  //of the file.
-
101  INFO_LOG.seekp(0);
-
102 }
-
103 
-
107 void clear_fims_log() {
-
108  FIMS_LOG.flush();
-
109  std::ofstream CLEAR_LOG("logs/fims.log");
-
110  CLEAR_LOG.close();
-
111  FIMS_LOG.seekp(0);
-
112 }
-
113 
-
117 void clear_data_log() {
-
118  DATA_LOG.flush();
-
119  std::ofstream CLEAR_LOG("logs/data.log");
-
120  CLEAR_LOG.close();
-
121  DATA_LOG.seekp(0);
-
122 }
-
123 
-
127 void clear_error_log() {
-
128  ERROR_LOG.flush();
-
129  std::ofstream CLEAR_LOG("logs/error.log");
-
130  CLEAR_LOG.close();
-
131  ERROR_LOG.seekp(0);
-
132 }
-
133 
-
137 void clear_model_log() {
-
138  MODEL_LOG.flush();
-
139  std::ofstream CLEAR_LOG("logs/model.log");
-
140  CLEAR_LOG.close();
-
141  MODEL_LOG.seekp(0);
-
142 }
-
143 
-
147 void clear_fleet_log() {
-
148  FLEET_LOG.flush();
-
149  std::ofstream CLEAR_LOG("logs/fleet.log");
-
150  CLEAR_LOG.close();
-
151  FLEET_LOG.seekp(0);
-
152 }
-
153 
-
157 void clear_population_log() {
-
158  POPULATION_LOG.flush();
-
159  std::ofstream CLEAR_LOG("logs/population.log");
-
160  CLEAR_LOG.close();
-
161  POPULATION_LOG.seekp(0);
-
162 }
-
163 
-
167 void clear_maturity_log() {
-
168  MATURITY_LOG.flush();
-
169  std::ofstream CLEAR_LOG("logs/maturity.log");
-
170  CLEAR_LOG.close();
-
171  MATURITY_LOG.seekp(0);
-
172 }
-
173 
-
177 void clear_recruitment_log() {
-
178  RECRUITMENT_LOG.flush();
-
179  std::ofstream CLEAR_LOG("logs/recruitment.log");
-
180  CLEAR_LOG.close();
-
181  RECRUITMENT_LOG.seekp(0);
-
182 }
-
183 
-
187 void clear_growth_log() {
-
188  GROWTH_LOG.flush();
-
189  std::ofstream CLEAR_LOG("logs/growth.log");
-
190  CLEAR_LOG.close();
-
191  GROWTH_LOG.seekp(0);
-
192 }
-
193 
-
197 void clear_selectivity_log() {
-
198  SELECTIVITY_LOG.flush();
-
199  std::ofstream CLEAR_LOG("logs/selectivity.log");
-
200  CLEAR_LOG.close();
-
201  SELECTIVITY_LOG.seekp(0);
-
202 }
-
203 
-
207 void clear_debug_log() {
-
208  DEBUG_LOG.flush();
-
209  std::ofstream CLEAR_LOG("logs/debug/debug.log");
-
210  CLEAR_LOG.close();
-
211  DEBUG_LOG.seekp(0);
-
212 }
-
213 
-
214 
-
218 void clear_logs() {
-
219  clear_fims_log();
-
220  clear_info_log();
-
221  clear_data_log();
-
222  clear_error_log();
-
223  clear_model_log();
-
224  clear_fleet_log();
-
225  clear_population_log();
-
226  clear_recruitment_log();
-
227  clear_growth_log();
-
228  clear_maturity_log();
-
229  clear_selectivity_log();
-
230  clear_debug_log();
-
231 }
-
232 
-
233 template <typename Type>
-
234 void clear_internal() {
-
235  std::shared_ptr<fims_info::Information<Type>> d0 =
-
236  fims_info::Information<Type>::GetInstance();
-
237  d0->fixed_effects_parameters.clear();
-
238  d0->random_effects_parameters.clear();
-
239 }
-
243 void clear() {
-
244  // rcpp_interface_base.hpp
-
245  FIMSRcppInterfaceBase::fims_interface_objects.clear();
-
246 
-
247  // rcpp_data.hpp
-
248  DataInterfaceBase::id_g = 1;
-
249  DataInterfaceBase::live_objects.clear();
-
250 
-
251  AgeCompDataInterface::id_g = 1;
-
252  AgeCompDataInterface::live_objects.clear();
-
253 
-
254  IndexDataInterface::id_g = 1;
-
255  IndexDataInterface::live_objects.clear();
-
256 
-
257  // rcpp_fleets.hpp
-
258  FleetInterfaceBase::id_g = 1;
-
259  FleetInterfaceBase::live_objects.clear();
-
260 
-
261  FleetInterface::id_g = 1;
-
262  FleetInterface::live_objects.clear();
-
263 
-
264  // rcpp_growth.hpp
-
265  GrowthInterfaceBase::id_g = 1;
-
266  GrowthInterfaceBase::live_objects.clear();
-
267 
-
268  EWAAGrowthInterface::id_g = 1;
-
269  EWAAGrowthInterface::live_objects.clear();
-
270 
-
271  // rcpp_maturity.hpp
-
272  MaturityInterfaceBase::id_g = 1;
-
273  MaturityInterfaceBase::live_objects.clear();
-
274 
-
275  LogisticMaturityInterface::id_g = 1;
-
276  LogisticMaturityInterface::live_objects.clear();
-
277 
-
278  // rcpp_population.hpp
-
279  PopulationInterfaceBase::id_g = 1;
-
280  PopulationInterfaceBase::live_objects.clear();
-
281 
-
282  PopulationInterface::id_g = 1;
-
283  PopulationInterface::live_objects.clear();
-
284 
-
285  // rcpp_recruitment.hpp
-
286  RecruitmentInterfaceBase::id_g = 1;
-
287  RecruitmentInterfaceBase::live_objects.clear();
-
288 
-
289  BevertonHoltRecruitmentInterface::id_g = 1;
-
290  BevertonHoltRecruitmentInterface::live_objects.clear();
-
291 
-
292  // rcpp_selectivity.hpp
-
293  SelectivityInterfaceBase::id_g = 1;
-
294  SelectivityInterfaceBase::live_objects.clear();
-
295 
-
296  LogisticSelectivityInterface::id_g = 1;
-
297  LogisticSelectivityInterface::live_objects.clear();
-
298 
-
299  DoubleLogisticSelectivityInterface::id_g = 1;
-
300  DoubleLogisticSelectivityInterface::live_objects.clear();
-
301 
-
302  // rcpp_tmb_distribution.hpp
-
303  DistributionsInterfaceBase::id_g = 1;
-
304  DistributionsInterfaceBase::live_objects.clear();
-
305 
-
306  DnormDistributionsInterface::id_g = 1;
-
307  DnormDistributionsInterface::live_objects.clear();
-
308 
-
309  DlnormDistributionsInterface::id_g = 1;
-
310  DlnormDistributionsInterface::live_objects.clear();
-
311 
-
312  DmultinomDistributionsInterface::id_g = 1;
-
313  DmultinomDistributionsInterface::live_objects.clear();
-
314 
-
315  clear_internal<TMB_FIMS_REAL_TYPE>();
-
316  clear_internal<TMB_FIMS_FIRST_ORDER>();
-
317  clear_internal<TMB_FIMS_SECOND_ORDER>();
-
318  clear_internal<TMB_FIMS_THIRD_ORDER>();
-
319 }
-
320 
-
321 RCPP_EXPOSED_CLASS(Parameter)
-
322 RCPP_MODULE(fims) {
-
323  Rcpp::function("CreateTMBModel", &CreateTMBModel);
-
324  Rcpp::function("get_fixed", &get_fixed_parameters_vector);
-
325  Rcpp::function("get_random", &get_random_parameters_vector);
-
326  Rcpp::function("clear", clear);
-
327  Rcpp::function("clear_logs", clear_logs);
-
328  Rcpp::function("clear_fims_log", clear_fims_log);
-
329  Rcpp::function("clear_info_log", clear_info_log);
-
330  Rcpp::function("clear_error_log", clear_error_log);
-
331  Rcpp::function("clear_data_log", clear_data_log);
-
332  Rcpp::function("clear_population_log", clear_population_log);
-
333  Rcpp::function("clear_model_log", clear_model_log);
-
334  Rcpp::function("clear_recruitment_log", clear_recruitment_log);
-
335  Rcpp::function("clear_fleet_log", clear_fleet_log);
-
336  Rcpp::function("clear_growth_log", clear_growth_log);
-
337  Rcpp::function("clear_maturity_log", clear_maturity_log);
-
338  Rcpp::function("clear_selectivity_log", clear_selectivity_log);
-
339  Rcpp::function("clear_debug_log", clear_debug_log);
-
340 
-
341  Rcpp::class_<Parameter>("Parameter")
-
342  .constructor()
-
343  .constructor<double>()
-
344  .constructor<Parameter>()
-
345  .field("value", &Parameter::value_m)
-
346  .field("min", &Parameter::min_m)
-
347  .field("max", &Parameter::max_m)
-
348  .field("is_random_effect", &Parameter::is_random_effect_m)
-
349  .field("estimated", &Parameter::estimated_m);
-
350 
-
351  Rcpp::class_<BevertonHoltRecruitmentInterface>("BevertonHoltRecruitment")
-
352  .constructor()
-
353  .field("logit_steep", &BevertonHoltRecruitmentInterface::logit_steep)
-
354  .field("log_rzero", &BevertonHoltRecruitmentInterface::log_rzero)
-
355  .field("deviations", &BevertonHoltRecruitmentInterface::deviations)
-
356  .field("estimate_deviations",
-
357  &BevertonHoltRecruitmentInterface::estimate_deviations)
-
358  .method("get_id", &BevertonHoltRecruitmentInterface::get_id)
-
359  .field("log_sigma_recruit",
-
360  &BevertonHoltRecruitmentInterface::log_sigma_recruit)
-
361  .method("evaluate", &BevertonHoltRecruitmentInterface::evaluate)
-
362  .method("evaluate_nll", &BevertonHoltRecruitmentInterface::evaluate_nll);
-
363 
-
364  Rcpp::class_<FleetInterface>("Fleet")
-
365  .constructor()
-
366  .field("is_survey", &FleetInterface::is_survey)
-
367  .field("log_q", &FleetInterface::log_q)
-
368  .field("log_Fmort", &FleetInterface::log_Fmort)
-
369  .field("nages", &FleetInterface::nages)
-
370  .field("nyears", &FleetInterface::nyears)
-
371  .field("estimate_F", &FleetInterface::estimate_F)
-
372  .field("estimate_q", &FleetInterface::estimate_q)
-
373  .field("random_q", &FleetInterface::random_q)
-
374  .field("random_F", &FleetInterface::random_F)
-
375  .field("log_obs_error", &FleetInterface::log_obs_error)
-
376  .method("SetAgeCompLikelihood", &FleetInterface::SetAgeCompLikelihood)
-
377  .method("SetIndexLikelihood", &FleetInterface::SetIndexLikelihood)
-
378  .method("SetObservedAgeCompData", &FleetInterface::SetObservedAgeCompData)
-
379  .method("SetObservedIndexData", &FleetInterface::SetObservedIndexData)
-
380  .method("SetSelectivity", &FleetInterface::SetSelectivity);
-
381 
-
382  Rcpp::class_<AgeCompDataInterface>("AgeComp")
-
383  .constructor<int, int>()
-
384  .field("age_comp_data", &AgeCompDataInterface::age_comp_data)
-
385  .method("get_id", &AgeCompDataInterface::get_id);
-
386 
-
387  Rcpp::class_<IndexDataInterface>("Index")
-
388  .constructor<int>()
-
389  .field("index_data", &IndexDataInterface::index_data)
-
390  .method("get_id", &IndexDataInterface::get_id);
-
391 
-
392  Rcpp::class_<PopulationInterface>("Population")
-
393  .constructor()
-
394  .method("get_id", &PopulationInterface::get_id)
-
395  .field("nages", &PopulationInterface::nages)
-
396  .field("nfleets", &PopulationInterface::nfleets)
-
397  .field("nseasons", &PopulationInterface::nseasons)
-
398  .field("nyears", &PopulationInterface::nyears)
-
399  .field("log_M", &PopulationInterface::log_M)
-
400  .field("log_init_naa", &PopulationInterface::log_init_naa)
-
401  .field("prop_female", &PopulationInterface::prop_female)
-
402  .field("ages", &PopulationInterface::ages)
-
403  .field("estimate_M", &PopulationInterface::estimate_M)
-
404  .field("estimate_init_naa", &PopulationInterface::estimate_initNAA)
-
405  .method("evaluate", &PopulationInterface::evaluate)
-
406  .method("SetMaturity", &PopulationInterface::SetMaturity)
-
407  .method("SetGrowth", &PopulationInterface::SetGrowth)
-
408  .method("SetRecruitment", &PopulationInterface::SetRecruitment)
-
409  .method("evaluate", &PopulationInterface::evaluate);
-
410 
-
411  Rcpp::class_<DnormDistributionsInterface>("TMBDnormDistribution")
-
412  .constructor()
-
413  .method("get_id", &DnormDistributionsInterface::get_id)
-
414  .method("evaluate", &DnormDistributionsInterface::evaluate)
-
415  .field("x", &DnormDistributionsInterface::x)
-
416  .field("mean", &DnormDistributionsInterface::mean)
-
417  .field("sd", &DnormDistributionsInterface::sd);
-
418 
-
419  Rcpp::class_<LogisticMaturityInterface>("LogisticMaturity")
-
420  .constructor()
-
421  .field("inflection_point", &LogisticMaturityInterface::inflection_point)
-
422  .field("slope", &LogisticMaturityInterface::slope)
-
423  .method("get_id", &LogisticMaturityInterface::get_id)
-
424  .method("evaluate", &LogisticMaturityInterface::evaluate);
-
425 
-
426  Rcpp::class_<LogisticSelectivityInterface>("LogisticSelectivity")
-
427  .constructor()
-
428  .field("inflection_point", &LogisticSelectivityInterface::inflection_point)
-
429  .field("slope", &LogisticSelectivityInterface::slope)
-
430  .method("get_id", &LogisticSelectivityInterface::get_id)
-
431  .method("evaluate", &LogisticSelectivityInterface::evaluate);
-
432 
-
433  Rcpp::class_<DoubleLogisticSelectivityInterface>("DoubleLogisticSelectivity")
-
434  .constructor()
-
435  .field("inflection_point_asc", &DoubleLogisticSelectivityInterface::inflection_point_asc)
+
88 void clear_info_log() {
+
89  // First flush the output stream to make sure nothing
+
90  // is left in the stream memory bufffer.
+
91  INFO_LOG.flush();
+
92 
+
93  // Next an new stream is opened and closed to
+
94  // overwrite the file.
+
95  std::ofstream CLEAR_LOG("logs/info.log");
+
96  CLEAR_LOG.close();
+
97 
+
98  // Finally the stream output location is reset back to the start
+
99  // of the file.
+
100  INFO_LOG.seekp(0);
+
101 }
+
102 
+
106 void clear_fims_log() {
+
107  FIMS_LOG.flush();
+
108  std::ofstream CLEAR_LOG("logs/fims.log");
+
109  CLEAR_LOG.close();
+
110  FIMS_LOG.seekp(0);
+
111 }
+
112 
+
116 void clear_data_log() {
+
117  DATA_LOG.flush();
+
118  std::ofstream CLEAR_LOG("logs/data.log");
+
119  CLEAR_LOG.close();
+
120  DATA_LOG.seekp(0);
+
121 }
+
122 
+
126 void clear_error_log() {
+
127  ERROR_LOG.flush();
+
128  std::ofstream CLEAR_LOG("logs/error.log");
+
129  CLEAR_LOG.close();
+
130  ERROR_LOG.seekp(0);
+
131 }
+
132 
+
136 void clear_model_log() {
+
137  MODEL_LOG.flush();
+
138  std::ofstream CLEAR_LOG("logs/model.log");
+
139  CLEAR_LOG.close();
+
140  MODEL_LOG.seekp(0);
+
141 }
+
142 
+
146 void clear_fleet_log() {
+
147  FLEET_LOG.flush();
+
148  std::ofstream CLEAR_LOG("logs/fleet.log");
+
149  CLEAR_LOG.close();
+
150  FLEET_LOG.seekp(0);
+
151 }
+
152 
+
156 void clear_population_log() {
+
157  POPULATION_LOG.flush();
+
158  std::ofstream CLEAR_LOG("logs/population.log");
+
159  CLEAR_LOG.close();
+
160  POPULATION_LOG.seekp(0);
+
161 }
+
162 
+
166 void clear_maturity_log() {
+
167  MATURITY_LOG.flush();
+
168  std::ofstream CLEAR_LOG("logs/maturity.log");
+
169  CLEAR_LOG.close();
+
170  MATURITY_LOG.seekp(0);
+
171 }
+
172 
+
176 void clear_recruitment_log() {
+
177  RECRUITMENT_LOG.flush();
+
178  std::ofstream CLEAR_LOG("logs/recruitment.log");
+
179  CLEAR_LOG.close();
+
180  RECRUITMENT_LOG.seekp(0);
+
181 }
+
182 
+
186 void clear_growth_log() {
+
187  GROWTH_LOG.flush();
+
188  std::ofstream CLEAR_LOG("logs/growth.log");
+
189  CLEAR_LOG.close();
+
190  GROWTH_LOG.seekp(0);
+
191 }
+
192 
+
196 void clear_selectivity_log() {
+
197  SELECTIVITY_LOG.flush();
+
198  std::ofstream CLEAR_LOG("logs/selectivity.log");
+
199  CLEAR_LOG.close();
+
200  SELECTIVITY_LOG.seekp(0);
+
201 }
+
202 
+
206 void clear_debug_log() {
+
207  DEBUG_LOG.flush();
+
208  std::ofstream CLEAR_LOG("logs/debug/debug.log");
+
209  CLEAR_LOG.close();
+
210  DEBUG_LOG.seekp(0);
+
211 }
+
212 
+
216 void clear_logs() {
+
217  clear_fims_log();
+
218  clear_info_log();
+
219  clear_data_log();
+
220  clear_error_log();
+
221  clear_model_log();
+
222  clear_fleet_log();
+
223  clear_population_log();
+
224  clear_recruitment_log();
+
225  clear_growth_log();
+
226  clear_maturity_log();
+
227  clear_selectivity_log();
+
228  clear_debug_log();
+
229 }
+
230 
+
231 template <typename Type>
+
232 void clear_internal() {
+
233  std::shared_ptr<fims_info::Information<Type>> d0 =
+
234  fims_info::Information<Type>::GetInstance();
+
235  d0->fixed_effects_parameters.clear();
+
236  d0->random_effects_parameters.clear();
+
237 }
+
241 void clear() {
+
242  // rcpp_interface_base.hpp
+
243  FIMSRcppInterfaceBase::fims_interface_objects.clear();
+
244 
+
245  // rcpp_data.hpp
+
246  DataInterfaceBase::id_g = 1;
+
247  DataInterfaceBase::live_objects.clear();
+
248 
+
249  AgeCompDataInterface::id_g = 1;
+
250  AgeCompDataInterface::live_objects.clear();
+
251 
+
252  IndexDataInterface::id_g = 1;
+
253  IndexDataInterface::live_objects.clear();
+
254 
+
255  // rcpp_fleets.hpp
+
256  FleetInterfaceBase::id_g = 1;
+
257  FleetInterfaceBase::live_objects.clear();
+
258 
+
259  FleetInterface::id_g = 1;
+
260  FleetInterface::live_objects.clear();
+
261 
+
262  // rcpp_growth.hpp
+
263  GrowthInterfaceBase::id_g = 1;
+
264  GrowthInterfaceBase::live_objects.clear();
+
265 
+
266  EWAAGrowthInterface::id_g = 1;
+
267  EWAAGrowthInterface::live_objects.clear();
+
268 
+
269  // rcpp_maturity.hpp
+
270  MaturityInterfaceBase::id_g = 1;
+
271  MaturityInterfaceBase::live_objects.clear();
+
272 
+
273  LogisticMaturityInterface::id_g = 1;
+
274  LogisticMaturityInterface::live_objects.clear();
+
275 
+
276  // rcpp_population.hpp
+
277  PopulationInterfaceBase::id_g = 1;
+
278  PopulationInterfaceBase::live_objects.clear();
+
279 
+
280  PopulationInterface::id_g = 1;
+
281  PopulationInterface::live_objects.clear();
+
282 
+
283  // rcpp_recruitment.hpp
+
284  RecruitmentInterfaceBase::id_g = 1;
+
285  RecruitmentInterfaceBase::live_objects.clear();
+
286 
+
287  BevertonHoltRecruitmentInterface::id_g = 1;
+
288  BevertonHoltRecruitmentInterface::live_objects.clear();
+
289 
+
290  // rcpp_selectivity.hpp
+
291  SelectivityInterfaceBase::id_g = 1;
+
292  SelectivityInterfaceBase::live_objects.clear();
+
293 
+
294  LogisticSelectivityInterface::id_g = 1;
+
295  LogisticSelectivityInterface::live_objects.clear();
+
296 
+
297  DoubleLogisticSelectivityInterface::id_g = 1;
+
298  DoubleLogisticSelectivityInterface::live_objects.clear();
+
299 
+
300  // rcpp_tmb_distribution.hpp
+
301  DistributionsInterfaceBase::id_g = 1;
+
302  DistributionsInterfaceBase::live_objects.clear();
+
303 
+
304  DnormDistributionsInterface::id_g = 1;
+
305  DnormDistributionsInterface::live_objects.clear();
+
306 
+
307  DlnormDistributionsInterface::id_g = 1;
+
308  DlnormDistributionsInterface::live_objects.clear();
+
309 
+
310  DmultinomDistributionsInterface::id_g = 1;
+
311  DmultinomDistributionsInterface::live_objects.clear();
+
312 
+
313  clear_internal<TMB_FIMS_REAL_TYPE>();
+
314  clear_internal<TMB_FIMS_FIRST_ORDER>();
+
315  clear_internal<TMB_FIMS_SECOND_ORDER>();
+
316  clear_internal<TMB_FIMS_THIRD_ORDER>();
+
317 }
+
318 
+
319 RCPP_EXPOSED_CLASS(Parameter)
+
320 RCPP_MODULE(fims) {
+
321  Rcpp::function("CreateTMBModel", &CreateTMBModel);
+
322  Rcpp::function("get_fixed", &get_fixed_parameters_vector);
+
323  Rcpp::function("get_random", &get_random_parameters_vector);
+
324  Rcpp::function("clear", clear);
+
325  Rcpp::function("clear_logs", clear_logs);
+
326  Rcpp::function("clear_fims_log", clear_fims_log);
+
327  Rcpp::function("clear_info_log", clear_info_log);
+
328  Rcpp::function("clear_error_log", clear_error_log);
+
329  Rcpp::function("clear_data_log", clear_data_log);
+
330  Rcpp::function("clear_population_log", clear_population_log);
+
331  Rcpp::function("clear_model_log", clear_model_log);
+
332  Rcpp::function("clear_recruitment_log", clear_recruitment_log);
+
333  Rcpp::function("clear_fleet_log", clear_fleet_log);
+
334  Rcpp::function("clear_growth_log", clear_growth_log);
+
335  Rcpp::function("clear_maturity_log", clear_maturity_log);
+
336  Rcpp::function("clear_selectivity_log", clear_selectivity_log);
+
337  Rcpp::function("clear_debug_log", clear_debug_log);
+
338 
+
339  Rcpp::class_<Parameter>("Parameter")
+
340  .constructor()
+
341  .constructor<double>()
+
342  .constructor<Parameter>()
+
343  .field("value", &Parameter::value_m)
+
344  .field("min", &Parameter::min_m)
+
345  .field("max", &Parameter::max_m)
+
346  .field("is_random_effect", &Parameter::is_random_effect_m)
+
347  .field("estimated", &Parameter::estimated_m);
+
348 
+
349  Rcpp::class_<BevertonHoltRecruitmentInterface>("BevertonHoltRecruitment")
+
350  .constructor()
+
351  .field("logit_steep", &BevertonHoltRecruitmentInterface::logit_steep)
+
352  .field("log_rzero", &BevertonHoltRecruitmentInterface::log_rzero)
+
353  .field("deviations", &BevertonHoltRecruitmentInterface::deviations)
+
354  .field("estimate_deviations",
+
355  &BevertonHoltRecruitmentInterface::estimate_deviations)
+
356  .method("get_id", &BevertonHoltRecruitmentInterface::get_id)
+
357  .field("log_sigma_recruit",
+
358  &BevertonHoltRecruitmentInterface::log_sigma_recruit)
+
359  .method("evaluate", &BevertonHoltRecruitmentInterface::evaluate)
+
360  .method("evaluate_nll", &BevertonHoltRecruitmentInterface::evaluate_nll);
+
361 
+
362  Rcpp::class_<FleetInterface>("Fleet")
+
363  .constructor()
+
364  .field("is_survey", &FleetInterface::is_survey)
+
365  .field("log_q", &FleetInterface::log_q)
+
366  .field("log_Fmort", &FleetInterface::log_Fmort)
+
367  .field("nages", &FleetInterface::nages)
+
368  .field("nyears", &FleetInterface::nyears)
+
369  .field("estimate_F", &FleetInterface::estimate_F)
+
370  .field("estimate_q", &FleetInterface::estimate_q)
+
371  .field("random_q", &FleetInterface::random_q)
+
372  .field("random_F", &FleetInterface::random_F)
+
373  .field("log_obs_error", &FleetInterface::log_obs_error)
+
374  .method("SetAgeCompLikelihood", &FleetInterface::SetAgeCompLikelihood)
+
375  .method("SetIndexLikelihood", &FleetInterface::SetIndexLikelihood)
+
376  .method("SetObservedAgeCompData", &FleetInterface::SetObservedAgeCompData)
+
377  .method("SetObservedIndexData", &FleetInterface::SetObservedIndexData)
+
378  .method("SetSelectivity", &FleetInterface::SetSelectivity);
+
379 
+
380  Rcpp::class_<AgeCompDataInterface>("AgeComp")
+
381  .constructor<int, int>()
+
382  .field("age_comp_data", &AgeCompDataInterface::age_comp_data)
+
383  .method("get_id", &AgeCompDataInterface::get_id);
+
384 
+
385  Rcpp::class_<IndexDataInterface>("Index")
+
386  .constructor<int>()
+
387  .field("index_data", &IndexDataInterface::index_data)
+
388  .method("get_id", &IndexDataInterface::get_id);
+
389 
+
390  Rcpp::class_<PopulationInterface>("Population")
+
391  .constructor()
+
392  .method("get_id", &PopulationInterface::get_id)
+
393  .field("nages", &PopulationInterface::nages)
+
394  .field("nfleets", &PopulationInterface::nfleets)
+
395  .field("nseasons", &PopulationInterface::nseasons)
+
396  .field("nyears", &PopulationInterface::nyears)
+
397  .field("log_M", &PopulationInterface::log_M)
+
398  .field("log_init_naa", &PopulationInterface::log_init_naa)
+
399  .field("prop_female", &PopulationInterface::prop_female)
+
400  .field("ages", &PopulationInterface::ages)
+
401  .field("estimate_M", &PopulationInterface::estimate_M)
+
402  .field("estimate_init_naa", &PopulationInterface::estimate_initNAA)
+
403  .method("evaluate", &PopulationInterface::evaluate)
+
404  .method("SetMaturity", &PopulationInterface::SetMaturity)
+
405  .method("SetGrowth", &PopulationInterface::SetGrowth)
+
406  .method("SetRecruitment", &PopulationInterface::SetRecruitment)
+
407  .method("evaluate", &PopulationInterface::evaluate);
+
408 
+
409  Rcpp::class_<DnormDistributionsInterface>("TMBDnormDistribution")
+
410  .constructor()
+
411  .method("get_id", &DnormDistributionsInterface::get_id)
+
412  .method("evaluate", &DnormDistributionsInterface::evaluate)
+
413  .field("x", &DnormDistributionsInterface::x)
+
414  .field("mean", &DnormDistributionsInterface::mean)
+
415  .field("sd", &DnormDistributionsInterface::sd);
+
416 
+
417  Rcpp::class_<LogisticMaturityInterface>("LogisticMaturity")
+
418  .constructor()
+
419  .field("inflection_point", &LogisticMaturityInterface::inflection_point)
+
420  .field("slope", &LogisticMaturityInterface::slope)
+
421  .method("get_id", &LogisticMaturityInterface::get_id)
+
422  .method("evaluate", &LogisticMaturityInterface::evaluate);
+
423 
+
424  Rcpp::class_<LogisticSelectivityInterface>("LogisticSelectivity")
+
425  .constructor()
+
426  .field("inflection_point",
+
427  &LogisticSelectivityInterface::inflection_point)
+
428  .field("slope", &LogisticSelectivityInterface::slope)
+
429  .method("get_id", &LogisticSelectivityInterface::get_id)
+
430  .method("evaluate", &LogisticSelectivityInterface::evaluate);
+
431 
+
432  Rcpp::class_<DoubleLogisticSelectivityInterface>("DoubleLogisticSelectivity")
+
433  .constructor()
+
434  .field("inflection_point_asc",
+
435  &DoubleLogisticSelectivityInterface::inflection_point_asc)
436  .field("slope_asc", &DoubleLogisticSelectivityInterface::slope_asc)
-
437  .field("inflection_point_desc", &DoubleLogisticSelectivityInterface::inflection_point_desc)
-
438  .field("slope_desc", &DoubleLogisticSelectivityInterface::slope_desc)
-
439  .method("get_id", &DoubleLogisticSelectivityInterface::get_id)
-
440  .method("evaluate", &DoubleLogisticSelectivityInterface::evaluate);
-
441 
-
442  Rcpp::class_<EWAAGrowthInterface>("EWAAgrowth")
-
443  .constructor()
-
444  .field("ages", &EWAAGrowthInterface::ages)
-
445  .field("weights", &EWAAGrowthInterface::weights)
-
446  .method("get_id", &EWAAGrowthInterface::get_id)
-
447  .method("evaluate", &EWAAGrowthInterface::evaluate);
-
448 
-
449  Rcpp::class_<DlnormDistributionsInterface>("TMBDlnormDistribution")
-
450  .constructor()
-
451  .method("get_id", &DlnormDistributionsInterface::get_id)
-
452  .method("evaluate", &DlnormDistributionsInterface::evaluate)
-
453  .field("x", &DlnormDistributionsInterface::x)
-
454  .field("meanlog", &DlnormDistributionsInterface::meanlog)
-
455  .field("sdlog", &DlnormDistributionsInterface::sdlog);
-
456 
-
457  Rcpp::class_<DmultinomDistributionsInterface>("TMBDmultinomDistribution")
-
458  .constructor()
-
459  .method("evaluate", &DmultinomDistributionsInterface::evaluate)
-
460  .method("get_id", &DmultinomDistributionsInterface::get_id)
-
461  .field("x", &DmultinomDistributionsInterface::x)
-
462  .field("p", &DmultinomDistributionsInterface::p);
-
463 }
-
464 
-
465 #endif /* RCPP_INTERFACE_HPP */
+
437  .field("inflection_point_desc",
+
438  &DoubleLogisticSelectivityInterface::inflection_point_desc)
+
439  .field("slope_desc", &DoubleLogisticSelectivityInterface::slope_desc)
+
440  .method("get_id", &DoubleLogisticSelectivityInterface::get_id)
+
441  .method("evaluate", &DoubleLogisticSelectivityInterface::evaluate);
+
442 
+
443  Rcpp::class_<EWAAGrowthInterface>("EWAAgrowth")
+
444  .constructor()
+
445  .field("ages", &EWAAGrowthInterface::ages)
+
446  .field("weights", &EWAAGrowthInterface::weights)
+
447  .method("get_id", &EWAAGrowthInterface::get_id)
+
448  .method("evaluate", &EWAAGrowthInterface::evaluate);
+
449 
+
450  Rcpp::class_<DlnormDistributionsInterface>("TMBDlnormDistribution")
+
451  .constructor()
+
452  .method("get_id", &DlnormDistributionsInterface::get_id)
+
453  .method("evaluate", &DlnormDistributionsInterface::evaluate)
+
454  .field("x", &DlnormDistributionsInterface::x)
+
455  .field("meanlog", &DlnormDistributionsInterface::meanlog)
+
456  .field("sdlog", &DlnormDistributionsInterface::sdlog);
+
457 
+
458  Rcpp::class_<DmultinomDistributionsInterface>("TMBDmultinomDistribution")
+
459  .constructor()
+
460  .method("evaluate", &DmultinomDistributionsInterface::evaluate)
+
461  .method("get_id", &DmultinomDistributionsInterface::get_id)
+
462  .field("x", &DmultinomDistributionsInterface::x)
+
463  .field("p", &DmultinomDistributionsInterface::p);
+
464 }
+
465 
+
466 #endif /* RCPP_INTERFACE_HPP */
AgeCompDataInterface::age_comp_data
Rcpp::NumericVector age_comp_data
Definition: rcpp_data.hpp:65
AgeCompDataInterface::get_id
virtual uint32_t get_id()
get the ID of the interface base object
Definition: rcpp_data.hpp:82
BevertonHoltRecruitmentInterface::evaluate_nll
virtual double evaluate_nll()
evaluate recruitment nll
Definition: rcpp_recruitment.hpp:101
@@ -524,12 +525,12 @@
DnormDistributionsInterface::x
Parameter x
Definition: rcpp_tmb_distribution.hpp:66
DnormDistributionsInterface::sd
Parameter sd
Definition: rcpp_tmb_distribution.hpp:68
DnormDistributionsInterface::get_id
virtual uint32_t get_id()
get_id method for child distribution interface objects to inherit
Definition: rcpp_tmb_distribution.hpp:72
-
DoubleLogisticSelectivityInterface::evaluate
virtual double evaluate(double x)
evaluate the double logistic selectivity function
Definition: rcpp_selectivity.hpp:156
-
DoubleLogisticSelectivityInterface::get_id
virtual uint32_t get_id()
returns the id for the double logistic selectivity interface
Definition: rcpp_selectivity.hpp:150
-
DoubleLogisticSelectivityInterface::slope_asc
Parameter slope_asc
Definition: rcpp_selectivity.hpp:140
-
DoubleLogisticSelectivityInterface::inflection_point_asc
Parameter inflection_point_asc
Definition: rcpp_selectivity.hpp:139
-
DoubleLogisticSelectivityInterface::slope_desc
Parameter slope_desc
Definition: rcpp_selectivity.hpp:143
-
DoubleLogisticSelectivityInterface::inflection_point_desc
Parameter inflection_point_desc
Definition: rcpp_selectivity.hpp:142
+
DoubleLogisticSelectivityInterface::evaluate
virtual double evaluate(double x)
evaluate the double logistic selectivity function
Definition: rcpp_selectivity.hpp:158
+
DoubleLogisticSelectivityInterface::get_id
virtual uint32_t get_id()
returns the id for the double logistic selectivity interface
Definition: rcpp_selectivity.hpp:152
+
DoubleLogisticSelectivityInterface::slope_asc
Parameter slope_asc
Definition: rcpp_selectivity.hpp:142
+
DoubleLogisticSelectivityInterface::inflection_point_asc
Parameter inflection_point_asc
Definition: rcpp_selectivity.hpp:140
+
DoubleLogisticSelectivityInterface::slope_desc
Parameter slope_desc
Definition: rcpp_selectivity.hpp:145
+
DoubleLogisticSelectivityInterface::inflection_point_desc
Parameter inflection_point_desc
Definition: rcpp_selectivity.hpp:143
EWAAGrowthInterface::get_id
virtual uint32_t get_id()
get the id of the GrowthInterfaceBase object
Definition: rcpp_growth.hpp:73
EWAAGrowthInterface::evaluate
virtual double evaluate(double age)
Rcpp interface to the EWAAgrowth evaluate method you can call from R using ewaagrowth....
Definition: rcpp_growth.hpp:95
EWAAGrowthInterface::weights
std::vector< double > weights
Definition: rcpp_growth.hpp:61
@@ -556,14 +557,14 @@
GrowthInterfaceBase::id_g
static uint32_t id_g
Definition: rcpp_growth.hpp:26
IndexDataInterface::index_data
Rcpp::NumericVector index_data
Definition: rcpp_data.hpp:131
IndexDataInterface::get_id
virtual uint32_t get_id()
get the ID of the interface base object
Definition: rcpp_data.hpp:145
-
LogisticMaturityInterface::inflection_point
Parameter inflection_point
Definition: rcpp_maturity.hpp:63
-
LogisticMaturityInterface::slope
Parameter slope
Definition: rcpp_maturity.hpp:64
-
LogisticMaturityInterface::get_id
virtual uint32_t get_id()
returns the id for the logistic maturity interface
Definition: rcpp_maturity.hpp:71
-
LogisticMaturityInterface::evaluate
virtual double evaluate(double x)
evaluate the logistic maturity function
Definition: rcpp_maturity.hpp:77
-
LogisticSelectivityInterface::slope
Parameter slope
Definition: rcpp_selectivity.hpp:64
-
LogisticSelectivityInterface::inflection_point
Parameter inflection_point
Definition: rcpp_selectivity.hpp:63
-
LogisticSelectivityInterface::get_id
virtual uint32_t get_id()
returns the id for the logistic selectivity interface
Definition: rcpp_selectivity.hpp:71
-
LogisticSelectivityInterface::evaluate
virtual double evaluate(double x)
evaluate the logistic selectivity function
Definition: rcpp_selectivity.hpp:77
+
LogisticMaturityInterface::inflection_point
Parameter inflection_point
Definition: rcpp_maturity.hpp:64
+
LogisticMaturityInterface::slope
Parameter slope
Definition: rcpp_maturity.hpp:65
+
LogisticMaturityInterface::get_id
virtual uint32_t get_id()
returns the id for the logistic maturity interface
Definition: rcpp_maturity.hpp:72
+
LogisticMaturityInterface::evaluate
virtual double evaluate(double x)
evaluate the logistic maturity function
Definition: rcpp_maturity.hpp:78
+
LogisticSelectivityInterface::slope
Parameter slope
Definition: rcpp_selectivity.hpp:65
+
LogisticSelectivityInterface::inflection_point
Parameter inflection_point
Definition: rcpp_selectivity.hpp:64
+
LogisticSelectivityInterface::get_id
virtual uint32_t get_id()
returns the id for the logistic selectivity interface
Definition: rcpp_selectivity.hpp:72
+
LogisticSelectivityInterface::evaluate
virtual double evaluate(double x)
evaluate the logistic selectivity function
Definition: rcpp_selectivity.hpp:78
MaturityInterfaceBase::live_objects
static std::map< uint32_t, MaturityInterfaceBase * > live_objects
Definition: rcpp_maturity.hpp:30
MaturityInterfaceBase::id_g
static uint32_t id_g
Definition: rcpp_maturity.hpp:26
Parameter
RcppInterface class that defines the interface between R and C++ for parameter types.
Definition: rcpp_interface_base.hpp:26
diff --git a/docs/rcpp__maturity_8hpp_source.html b/docs/rcpp__maturity_8hpp_source.html index 28db0f3..30a5a22 100644 --- a/docs/rcpp__maturity_8hpp_source.html +++ b/docs/rcpp__maturity_8hpp_source.html @@ -122,77 +122,78 @@
56 
61 class LogisticMaturityInterface : public MaturityInterfaceBase {
62  public:
-
63  Parameter inflection_point;
-
64  Parameter slope;
-
66  LogisticMaturityInterface() : MaturityInterfaceBase() {}
-
67 
-
68  virtual ~LogisticMaturityInterface() {}
-
69 
-
71  virtual uint32_t get_id() { return this->id; }
-
72 
-
77  virtual double evaluate(double x) {
-
78  fims_popdy::LogisticMaturity<double> LogisticMat;
-
79  LogisticMat.inflection_point = this->inflection_point.value_m;
-
80  LogisticMat.slope = this->slope.value_m;
-
81  return LogisticMat.evaluate(x);
-
82  }
-
83 
-
84 #ifdef TMB_MODEL
-
85 
-
86  template <typename Type>
-
87  bool add_to_fims_tmb_internal() {
-
88  std::shared_ptr<fims_info::Information<Type> > info =
-
89  fims_info::Information<Type>::GetInstance();
-
90 
-
91  std::shared_ptr<fims_popdy::LogisticMaturity<Type> > maturity =
-
92  std::make_shared<fims_popdy::LogisticMaturity<Type> >();
-
93 
-
94  // set relative info
-
95  maturity->id = this->id;
-
96  maturity->inflection_point = this->inflection_point.value_m;
-
97  if (this->inflection_point.estimated_m) {
-
98  if (this->inflection_point.is_random_effect_m) {
-
99  info->RegisterRandomEffect(maturity->inflection_point);
-
100  } else {
-
101  info->RegisterParameter(maturity->inflection_point);
-
102  }
-
103  }
-
104  maturity->slope = this->slope.value_m;
-
105  if (this->slope.estimated_m) {
-
106  if (this->slope.is_random_effect_m) {
-
107  info->RegisterRandomEffect(maturity->slope);
-
108  } else {
-
109  info->RegisterParameter(maturity->slope);
-
110  }
-
111  }
-
112 
-
113  // add to Information
-
114  info->maturity_models[maturity->id] = maturity;
-
115 
-
116  return true;
-
117  }
-
118 
-
121  virtual bool add_to_fims_tmb() {
-
122  this->add_to_fims_tmb_internal<TMB_FIMS_REAL_TYPE>();
-
123  this->add_to_fims_tmb_internal<TMB_FIMS_FIRST_ORDER>();
-
124  this->add_to_fims_tmb_internal<TMB_FIMS_SECOND_ORDER>();
-
125  this->add_to_fims_tmb_internal<TMB_FIMS_THIRD_ORDER>();
-
126 
-
127  return true;
-
128  }
-
129 
-
130 #endif
-
131 };
-
132 
-
133 #endif
+
63  Parameter
+
64  inflection_point;
+
65  Parameter slope;
+
67  LogisticMaturityInterface() : MaturityInterfaceBase() {}
+
68 
+
69  virtual ~LogisticMaturityInterface() {}
+
70 
+
72  virtual uint32_t get_id() { return this->id; }
+
73 
+
78  virtual double evaluate(double x) {
+
79  fims_popdy::LogisticMaturity<double> LogisticMat;
+
80  LogisticMat.inflection_point = this->inflection_point.value_m;
+
81  LogisticMat.slope = this->slope.value_m;
+
82  return LogisticMat.evaluate(x);
+
83  }
+
84 
+
85 #ifdef TMB_MODEL
+
86 
+
87  template <typename Type>
+
88  bool add_to_fims_tmb_internal() {
+
89  std::shared_ptr<fims_info::Information<Type> > info =
+
90  fims_info::Information<Type>::GetInstance();
+
91 
+
92  std::shared_ptr<fims_popdy::LogisticMaturity<Type> > maturity =
+
93  std::make_shared<fims_popdy::LogisticMaturity<Type> >();
+
94 
+
95  // set relative info
+
96  maturity->id = this->id;
+
97  maturity->inflection_point = this->inflection_point.value_m;
+
98  if (this->inflection_point.estimated_m) {
+
99  if (this->inflection_point.is_random_effect_m) {
+
100  info->RegisterRandomEffect(maturity->inflection_point);
+
101  } else {
+
102  info->RegisterParameter(maturity->inflection_point);
+
103  }
+
104  }
+
105  maturity->slope = this->slope.value_m;
+
106  if (this->slope.estimated_m) {
+
107  if (this->slope.is_random_effect_m) {
+
108  info->RegisterRandomEffect(maturity->slope);
+
109  } else {
+
110  info->RegisterParameter(maturity->slope);
+
111  }
+
112  }
+
113 
+
114  // add to Information
+
115  info->maturity_models[maturity->id] = maturity;
+
116 
+
117  return true;
+
118  }
+
119 
+
122  virtual bool add_to_fims_tmb() {
+
123  this->add_to_fims_tmb_internal<TMB_FIMS_REAL_TYPE>();
+
124  this->add_to_fims_tmb_internal<TMB_FIMS_FIRST_ORDER>();
+
125  this->add_to_fims_tmb_internal<TMB_FIMS_SECOND_ORDER>();
+
126  this->add_to_fims_tmb_internal<TMB_FIMS_THIRD_ORDER>();
+
127 
+
128  return true;
+
129  }
+
130 
+
131 #endif
+
132 };
+
133 
+
134 #endif
FIMSRcppInterfaceBase
Base class for all interface objects.
Definition: rcpp_interface_base.hpp:61
FIMSRcppInterfaceBase::fims_interface_objects
static std::vector< FIMSRcppInterfaceBase * > fims_interface_objects
Definition: rcpp_interface_base.hpp:64
FIMSRcppInterfaceBase::add_to_fims_tmb
virtual bool add_to_fims_tmb()
virtual method to inherit to add objects to the TMB model
Definition: rcpp_interface_base.hpp:67
LogisticMaturityInterface
Rcpp interface for logistic maturity as an S4 object. To instantiate from R: logistic_maturity <- new...
Definition: rcpp_maturity.hpp:61
-
LogisticMaturityInterface::inflection_point
Parameter inflection_point
Definition: rcpp_maturity.hpp:63
-
LogisticMaturityInterface::slope
Parameter slope
Definition: rcpp_maturity.hpp:64
-
LogisticMaturityInterface::get_id
virtual uint32_t get_id()
returns the id for the logistic maturity interface
Definition: rcpp_maturity.hpp:71
-
LogisticMaturityInterface::evaluate
virtual double evaluate(double x)
evaluate the logistic maturity function
Definition: rcpp_maturity.hpp:77
+
LogisticMaturityInterface::inflection_point
Parameter inflection_point
Definition: rcpp_maturity.hpp:64
+
LogisticMaturityInterface::slope
Parameter slope
Definition: rcpp_maturity.hpp:65
+
LogisticMaturityInterface::get_id
virtual uint32_t get_id()
returns the id for the logistic maturity interface
Definition: rcpp_maturity.hpp:72
+
LogisticMaturityInterface::evaluate
virtual double evaluate(double x)
evaluate the logistic maturity function
Definition: rcpp_maturity.hpp:78
MaturityInterfaceBase
MaturityInterfaceBase class should be inherited to define different Rcpp interfaces for each possible...
Definition: rcpp_maturity.hpp:24
MaturityInterfaceBase::evaluate
virtual double evaluate(double x)=0
evaluate the function
MaturityInterfaceBase::live_objects
static std::map< uint32_t, MaturityInterfaceBase * > live_objects
Definition: rcpp_maturity.hpp:30
diff --git a/docs/rcpp__population_8hpp_source.html b/docs/rcpp__population_8hpp_source.html index 5298004..4deb0df 100644 --- a/docs/rcpp__population_8hpp_source.html +++ b/docs/rcpp__population_8hpp_source.html @@ -243,7 +243,7 @@
PopulationInterface::log_M
Rcpp::NumericVector log_M
Definition: rcpp_population.hpp:63
fims_info::Information::GetInstance
static std::shared_ptr< Information< Type > > GetInstance()
Definition: information.hpp:125
fims_popdy::Population
Population class. Contains subpopulations that are divided into generic partitions (eg....
Definition: population.hpp:36
-
fims_popdy::Population::Evaluate
void Evaluate()
Executes the population loop.
Definition: population.hpp:544
+
fims_popdy::Population::Evaluate
void Evaluate()
Executes the population loop.
Definition: population.hpp:548