-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRecruitment.hpp
116 lines (86 loc) · 2.48 KB
/
Recruitment.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Recruitment.hpp
// Age Structured Assessment Modeling System (ASAMS)
#ifndef Recruitment_h
#define Recruitment_h
namespace asams{
/**
*Recruitment base class. Inherits from modelbase.
*/
template <class T>
class recruitment_base:public model_base<T>{
protected: //when class inherits from recruitment, can see
T R0_m;
T h_m;
public:
virtual T evaluate(const T& SB0, const T& SB)=0;
};
/**
*Beverton-Holt implementation. Inherits from recruitment base.
*/
template <class T>
class beverton_holt:public recruitment_base<T>{
public:
beverton_holt(){
}
/**
*Constructor that takes arguments
*@param R0 \f$ R_0\f$ Recruitment at t=0
*@param h Steepness
*/
beverton_holt(T R0, T h){ // constructor
this->R0_m=R0;
this->h_m=h;
}
/**
*Deconstructor
*/
~ beverton_holt(){ //destructor
std::cout <<"I just deleted"<<std::endl;
}
/**
*@brief Beverton-Holt implementation of the virtual evaluate function. Required to be overloaded.
*
*The Beverton-Holt stock-recruit implementation \f$ \frac{0.8*R_0*h*SB}{0.2*SB_0*(1-h) + SB*(h-0.2)}\f$
*@param SB0 \f$ SB_0\f$ Spawning stock biomass at t=0
*@param SB Spawning stock biomass
*/
virtual T evaluate(const T& SB0, const T& SB){
return (0.8*this->R0_m*this->h_m*SB)/(0.2*SB0*(1-this->h_m) + SB*(this->h_m-0.2));
}
};
/**
*Ricker implementation. Inherits from recruitment base.
*/
template <class T>
class ricker:public recruitment_base<T>{
public:
ricker(){
}
/**
*Constructor that takes arguments
*@param R0 \f$ R_0\f$ Recruitment at t=0
*@param h Steepness
*/
ricker(T R0, T h){ // constructor
this->R0_m=R0;
this->h_m=h;
}
/**
*Deconstructor
*/
~ ricker(){ //destructor
std::cout <<"I just deleted"<<std::endl;
}
/**
*@brief Ricker implementation of the virtual evaluate function. Required to be overloaded.
*
*The Ricker stock-recruit implementation \f$ \frac{SB}{\frac{SB_0}{R_0}}*exp(h*\frac{1-SB}{R_0*\frac{SB_0}{R_0}})\f$
*@param SB0 \f$ SB_0\f$ Spawning stock biomass at t=0
*@param SB Spawning stock biomass
*/
virtual T evaluate(const T& SB0, const T& SB){
return SB/(SB0/this->R0_m)*exp(this->h_m*(1-SB/(this->R0_m*(SB0/this->R0_m))));
}
};
}
#endif /* Recruitment_h */