FIMS  v0.9.3
Loading...
Searching...
No Matches
recruitment_base.hpp
Go to the documentation of this file.
1
10#ifndef FIMS_POPULATION_DYNAMICS_RECRUITMENT_BASE_HPP
11#define FIMS_POPULATION_DYNAMICS_RECRUITMENT_BASE_HPP
12
13#include <cmath> // for using std::pow and M_PI
14
15#include "common/fims_math.hpp" // for using fims_math::log()
18
19namespace fims_popdy {
20
26template <class Type>
28 static uint32_t id_g;
32 bool constrain_deviations = false;
44 int process_id = -999;
45 std::shared_ptr<fims_popdy::RecruitmentBase<Type>>
47 std::shared_ptr<fims_popdy::RecruitmentBase<Type>>
53
54 virtual ~RecruitmentBase() {}
55
60 void Prepare() {
61 // this->PrepareConstrainedDeviations();
63 0.0);
64 }
65
86 virtual const Type evaluate_mean(const Type &spawners, const Type &phi_0) = 0;
87
92 virtual const Type evaluate_process(size_t pos) = 0;
93
101 if (!this->constrain_deviations) {
102 return;
103 }
104
105 Type sum = static_cast<Type>(0.0);
106
107 for (size_t i = 0; i < this->log_recruit_devs.size(); i++) {
108 sum += this->log_recruit_devs[i];
109 }
110
111 for (size_t i = 0; i < this->log_recruit_devs.size(); i++) {
112 this->log_recruit_devs[i] -= sum / (this->log_recruit_devs.size());
113 }
114 }
115};
116
117template <class Type>
119} // namespace fims_popdy
120
121#endif /* FIMS_POPULATION_DYNAMICS_RECRUITMENT_BASE_HPP */
Definition fims_vector.hpp:27
size_type size() const
Returns the number of elements.
Definition fims_vector.hpp:273
A collection of mathematical functions used in FIMS.
Establishes the FIMS Vector class.
Definition of the FIMSObject structure.
The population dynamics of FIMS.
Definition catch_at_age.hpp:41
void clear_internal()
Clears the internal objects.
Definition rcpp_interface.hpp:235
FIMSObject struct that defines member types and returns the unique id.
Definition model_object.hpp:24
Base class for all recruitment functors.
Definition recruitment_base.hpp:27
virtual const Type evaluate_process(size_t pos)=0
Handle error in recruitment.
fims::Vector< Type > log_rzero
Definition recruitment_base.hpp:35
static uint32_t id_g
Definition recruitment_base.hpp:28
void PrepareConstrainedDeviations()
Prepare constrained recruitment deviations. Based on ADMB sum-to-zero constraint implementation....
Definition recruitment_base.hpp:100
void Prepare()
Prepares the recruitment deviations vector.
Definition recruitment_base.hpp:60
bool estimate_log_recruit_devs
Definition recruitment_base.hpp:41
bool constrain_deviations
Definition recruitment_base.hpp:32
fims::Vector< Type > log_r
Definition recruitment_base.hpp:37
fims::Vector< Type > log_expected_recruitment
Definition recruitment_base.hpp:39
int process_id
Definition recruitment_base.hpp:44
std::shared_ptr< fims_popdy::RecruitmentBase< Type > > process
Definition recruitment_base.hpp:46
virtual const Type evaluate_mean(const Type &spawners, const Type &phi_0)=0
Evaluates expected recruitment from the stock–recruitment relationship before recruitment-process dev...
std::shared_ptr< fims_popdy::RecruitmentBase< Type > > recruitment
Definition recruitment_base.hpp:48
RecruitmentBase()
Constructor.
Definition recruitment_base.hpp:52
fims::Vector< Type > log_recruit_devs
Definition recruitment_base.hpp:30