9#ifndef POPULATION_DYNAMICS_GROWTH_VONB_SCHNUTE_HPP
10#define POPULATION_DYNAMICS_GROWTH_VONB_SCHNUTE_HPP
31template <
typename Type>
32struct VonBertalanffySchnuteGrowth :
public GrowthBase<Type> {
49 VonBertalanffySchnuteGrowth() :
GrowthBase<Type>() {}
64 const Type age_nonnegative = age <= Type(0.0) ? Type(0.0) : age;
74 const Type denom_safe =
91 return fims_math::log(length_safe);
106 Type& d_log_laa_d_length_young,
107 Type& d_log_laa_d_length_old,
108 Type& d_log_laa_d_k)
const {
111 const Type age_nonnegative = age <= Type(0.0) ? Type(0.0) : age;
114 const Type mean_length_safe =
117 d_log_laa_d_length_young = ratio / mean_length_safe;
118 d_log_laa_d_length_old = Type(0.0);
119 d_log_laa_d_k = Type(0.0);
124 const Type age_delta_2 =
130 const Type numer = Type(1.0) - exp_num;
131 const Type denom = Type(1.0) - exp_den;
132 const Type denom_safe =
135 const Type ratio = numer / denom_safe;
138 const Type mean_length_safe =
141 const Type d_length_d_l1 = Type(1.0) - ratio;
142 const Type d_length_d_l2 = ratio;
144 const Type d_numer_d_k = age_delta_1 * exp_num;
145 const Type d_denom_d_k = age_delta_2 * exp_den;
146 const Type d_ratio_d_k = (d_numer_d_k * denom_safe - numer * d_denom_d_k) /
147 (denom_safe * denom_safe);
148 const Type d_length_d_k = delta_length * d_ratio_d_k;
150 d_log_laa_d_length_young = d_length_d_l1 / mean_length_safe;
151 d_log_laa_d_length_old = d_length_d_l2 / mean_length_safe;
152 d_log_laa_d_k = d_length_d_k / mean_length_safe;
169 Type& d_log_laa_d_log_length_young,
170 Type& d_log_laa_d_log_length_old,
171 Type& d_log_laa_d_log_k)
const {
172 Type d_log_laa_d_length_young = Type(0.0);
173 Type d_log_laa_d_length_old = Type(0.0);
174 Type d_log_laa_d_k = Type(0.0);
177 d_log_laa_d_length_old, d_log_laa_d_k);
194 virtual const Type
evaluate(
int year,
const double& a)
override {
A collection of mathematical functions used in FIMS.
const Type ad_max(const Type &a, const Type &b, Type C=1e-5)
Definition fims_math.hpp:380
const Type ad_fabs(const Type &x, Type C=1e-5)
Definition fims_math.hpp:333
Declares the GrowthBase class which is the base class for all growth functors.
The population dynamics of FIMS.
Definition catch_at_age.hpp:45
GrowthBase()
Constructor.
Definition growth_base.hpp:34
VonBertalanffySchnute growth functor for length-at-age and weight-at-age.
Definition vonb_schnute.hpp:32
Type mean_length_young
Expected length at the first reference age.
Definition vonb_schnute.hpp:34
Type length_at_age(const Type &age) const
Evaluate mean length at age.
Definition vonb_schnute.hpp:57
Type reference_age_for_length_old
Second reference age for the length parameterization.
Definition vonb_schnute.hpp:42
Type growth_coefficient
Growth coefficient.
Definition vonb_schnute.hpp:38
Type weight_at_age(const Type &age) const
Evaluate mean weight at age via the length-weight relationship.
Definition vonb_schnute.hpp:189
void log_length_at_age_logscale_gradient(const Type &age, Type &d_log_laa_d_log_length_young, Type &d_log_laa_d_log_length_old, Type &d_log_laa_d_log_k) const
Evaluate the gradient of log mean length at age with respect to the log-scale FIMS VonBertalanffySchn...
Definition vonb_schnute.hpp:168
Type length_weight_b
Exponent in the length-weight relationship, W = a * L^b.
Definition vonb_schnute.hpp:47
Type log_length_at_age(const Type &age) const
Evaluate log mean length at age.
Definition vonb_schnute.hpp:88
void log_length_at_age_gradient(const Type &age, Type &d_log_laa_d_length_young, Type &d_log_laa_d_length_old, Type &d_log_laa_d_k) const
Evaluate the gradient of log mean length at age with respect to the current natural-scale FIMS VonBer...
Definition vonb_schnute.hpp:105
Type reference_age_for_length_young
First reference age for the length parameterization.
Definition vonb_schnute.hpp:40
Type length_weight_a
Coefficient in the length-weight relationship, W = a * L^b.
Definition vonb_schnute.hpp:45
virtual const Type evaluate(int year, const double &a) override
Calculates the growth at the independent variable value.
Definition vonb_schnute.hpp:194
Type mean_length_old
Expected length at the second reference age.
Definition vonb_schnute.hpp:36