|
Rceattle C++ template
The CEATTLE likelihood: src/TMB/ceattle.cpp and its headers
|
Go to the source code of this file.
Functions | |
| template<class Type> | |
| void | calculate_vulnerability (matrix< Type > &vulnerability, vector< Type > &vulnerability_other, int nspp, const vector< int > &suitMode, matrix< Type > &log_phi) |
| Transforms predator-prey preference parameters into vulnerability. | |
| template<class Type> | |
| void | calculate_parametric_suitability (array< Type > &suitability, array< Type > &suit_other, int nspp, int nyrs, const vector< int > &nsex, const vector< int > &nages, const vector< int > &suitMode, array< Type > &length_hat, array< Type > &weight_hat, matrix< Type > &vulnerability, const vector< Type > &vulnerability_other, const vector< Type > &gam_a, const vector< Type > &gam_b) |
| Parametric suitability (Gamma, Lognormal, Normal) from size ratios. | |
| template<class Type> | |
| void | calculate_msvpa_suitability (array< Type > &stom_div_bio, array< Type > &suitability, array< Type > &suit_other, int nspp, int nyrs, const vector< int > &suit_styr, const vector< int > &suit_endyr, const vector< int > &nyrs_suit, int msmMode, const vector< int > &nsex, const vector< int > &nages, const vector< int > &suitMode, array< Type > &diet_prop, array< Type > &avgN_at_age, array< Type > &weight_hat, array< Type > &other_food_diet_prop) |
| MSVPA/empirical suitability, from stomach content and prey biomass. | |
| template<class Type> | |
| void | calculate_msvpa_predation (array< Type > &avail_food, array< Type > &avail_food_dB0, array< Type > &avail_food_dBF, array< Type > &M2_at_age, array< Type > &M2_at_age_dB0, array< Type > &M2_at_age_dBF, array< Type > &M2_prop, array< Type > &B_eaten, array< Type > &B_eaten_as_prey, array< Type > &diet_prop_hat, array< Type > &other_diet_prop_hat, int nspp, int nyrs, const vector< int > &nsex, const vector< int > &nages, int msmMode, array< Type > &avgN_at_age, array< Type > &avgN_at_age_dB0, array< Type > &avgN_at_age_dBF, array< Type > &suitability, array< Type > &suit_other, array< Type > &weight_hat, array< Type > &ration, const vector< Type > &other_food) |
| Available food, predation mortality (M2), and consumed biomass (MSVPA). | |
| void calculate_msvpa_predation | ( | array< Type > & | avail_food, |
| array< Type > & | avail_food_dB0, | ||
| array< Type > & | avail_food_dBF, | ||
| array< Type > & | M2_at_age, | ||
| array< Type > & | M2_at_age_dB0, | ||
| array< Type > & | M2_at_age_dBF, | ||
| array< Type > & | M2_prop, | ||
| array< Type > & | B_eaten, | ||
| array< Type > & | B_eaten_as_prey, | ||
| array< Type > & | diet_prop_hat, | ||
| array< Type > & | other_diet_prop_hat, | ||
| int | nspp, | ||
| int | nyrs, | ||
| const vector< int > & | nsex, | ||
| const vector< int > & | nages, | ||
| int | msmMode, | ||
| array< Type > & | avgN_at_age, | ||
| array< Type > & | avgN_at_age_dB0, | ||
| array< Type > & | avgN_at_age_dBF, | ||
| array< Type > & | suitability, | ||
| array< Type > & | suit_other, | ||
| array< Type > & | weight_hat, | ||
| array< Type > & | ration, | ||
| const vector< Type > & | other_food ) |
Available food, predation mortality (M2), and consumed biomass (MSVPA).
Available food is suitability-weighted prey biomass plus "other food": prey numbers (thousands of fish) x weight (kg) = mt, and other_food is mt. Under msmMode = 2 (Type III) the prey term is squared, so the denominator is not a biomass there. M2 divides each predator's consumption (avgN x ration) by that denominator, so a LARGER available-food denominator gives LESS predation mortality. The dB0 (F = 0) and dBF (F = Ftarget) arrays repeat the calculation for the dynamic reference points. Prey biomass and the predator scalars are each computed once outside the deepest loop.
| avail_food | Available food (mt) [nspp, max_sex, max_age, nyrs], updated. |
| avail_food_dB0 | Available food at F=0, updated. |
| avail_food_dBF | Available food at F=Ftarget, updated. |
| M2_at_age | Predation mortality (yr^-1), updated; [nspp, max_sex, max_age, nyrs]. |
| M2_at_age_dB0 | Predation mortality at F=0, updated. |
| M2_at_age_dBF | Predation mortality at F=Ftarget, updated. |
| M2_prop | A predator age's contribution to prey M2, not a share of it. |
| B_eaten | Prey biomass eaten by a specific predator age (mt), updated. |
| B_eaten_as_prey | Prey biomass eaten by all predators (mt), updated. |
| diet_prop_hat | Predicted diet proportions, updated. |
| other_diet_prop_hat | Predicted proportion of "other food" in diet, updated. |
| nspp | Number of species. |
| nyrs | Years, hindcast plus projection. |
| nsex | Sexes modelled per species: 1 = combined, 2 = both. |
| nages | Age bins per species. |
| msmMode | Predation mode (1 = Type II MSVPA, Holsman et al. 2015; 2 = Type III MSVPA, which squares the prey term). |
| avgN_at_age | Average numbers-at-age (thousands of fish). |
| avgN_at_age_dB0 | Average numbers-at-age at F=0. |
| avgN_at_age_dBF | Average numbers-at-age at F=Ftarget. |
| suitability | Calculated suitability. |
| suit_other | Suitability for "other food". |
| weight_hat | Estimated weights-at-age (kg). |
| ration | Individual consumption (kg/predator/yr); consumption_at_age. |
| other_food | "Other food" biomass by predator (mt). |
Definition at line 349 of file predation.hpp.
| void calculate_msvpa_suitability | ( | array< Type > & | stom_div_bio, |
| array< Type > & | suitability, | ||
| array< Type > & | suit_other, | ||
| int | nspp, | ||
| int | nyrs, | ||
| const vector< int > & | suit_styr, | ||
| const vector< int > & | suit_endyr, | ||
| const vector< int > & | nyrs_suit, | ||
| int | msmMode, | ||
| const vector< int > & | nsex, | ||
| const vector< int > & | nages, | ||
| const vector< int > & | suitMode, | ||
| array< Type > & | diet_prop, | ||
| array< Type > & | avgN_at_age, | ||
| array< Type > & | weight_hat, | ||
| array< Type > & | other_food_diet_prop ) |
MSVPA/empirical suitability, from stomach content and prey biomass.
For predators with suitMode = 0. stom_div_bio is the observed diet proportion divided by prey biomass (numbers in thousands x weight in kg = mt; the prey term is squared under msmMode = 2, Type III). That ratio is normalized over the modeled prey and "other food", averaged over suit_styr..suit_endyr, and held constant across all years.
A prey age whose average numbers approach zero with a positive diet proportion sends stom_div_bio, and so the prey term, to infinity: that one cell takes the whole normalized share, "other food" vanishes, available food collapses with it, so M2 diverges. The other-food term is floored at a fixed fraction of the prey term, bounding suit_other below at floor/(1 + floor), leaving sum(suitability) + suit_other = 1 exact. .warn_suitability_floor() reports when it binds.
| stom_div_bio | Ratio of diet proportion to biomass, updated; [nspp*max_sex, nspp*max_sex, max_age, max_age, nyrs]. |
| suitability | Final calculated suitability, updated. |
| suit_other | Remaining suitability for "other food", updated. |
| nspp | Number of species. |
| nyrs | Years, hindcast plus projection. |
| suit_styr | Start year index of the suitability window, per predator. |
| suit_endyr | End year index of the suitability window, per predator. |
| nyrs_suit | Years in the suitability window, per predator. |
| msmMode | Predation mode; 2 (Type III) squares the prey numbers. |
| nsex | Sexes modelled per species: 1 = combined, 2 = both. |
| nages | Age bins per species. |
| suitMode | Suitability mode per predator species. |
| diet_prop | Observed diet proportions from organize_diet_obs(). |
| avgN_at_age | Average numbers-at-age (thousands of fish). |
| weight_hat | Estimated weights-at-age (kg). |
| other_food_diet_prop | Residual diet proportion for "other food", per mt of it. |
Definition at line 180 of file predation.hpp.
| void calculate_parametric_suitability | ( | array< Type > & | suitability, |
| array< Type > & | suit_other, | ||
| int | nspp, | ||
| int | nyrs, | ||
| const vector< int > & | nsex, | ||
| const vector< int > & | nages, | ||
| const vector< int > & | suitMode, | ||
| array< Type > & | length_hat, | ||
| array< Type > & | weight_hat, | ||
| matrix< Type > & | vulnerability, | ||
| const vector< Type > & | vulnerability_other, | ||
| const vector< Type > & | gam_a, | ||
| const vector< Type > & | gam_b ) |
Parametric suitability (Gamma, Lognormal, Normal) from size ratios.
Evaluates the predator-to-prey size ratio against a density scaled to a peak of 1. suitMode sets both the density and the size metric:
| suitability | Size-based suitability, updated [nspp*max_sex, nspp*max_sex, max_age, max_age, nyrs]. |
| suit_other | Baseline vulnerability to "other food", updated; [nspp, max_sex, max_age, nyrs] – species NOT collapsed, unlike suitability. |
| nspp | Number of species. |
| nyrs | Years, hindcast plus projection. |
| nsex | Sexes modelled per species: 1 = combined, 2 = both. |
| nages | Age bins per species. |
| suitMode | Parametric suitability mode per predator species. |
| length_hat | Lengths-at-age [nspp*2+n_flt, max_sex, max_age, nyrs]. |
| weight_hat | Weights-at-age [nspp*2+n_flt, max_sex, max_age, nyrs]. |
| vulnerability | Bounded predator-prey vulnerability [nspp, nspp]. |
| vulnerability_other | Vulnerability preference for "other food" [nspp]. |
| gam_a | Shape/mean parameter for predator size-selectivity [nspp]. |
| gam_b | Scale/sd parameter for predator size-selectivity [nspp]. |
Definition at line 76 of file predation.hpp.
| void calculate_vulnerability | ( | matrix< Type > & | vulnerability, |
| vector< Type > & | vulnerability_other, | ||
| int | nspp, | ||
| const vector< int > & | suitMode, | ||
| matrix< Type > & | log_phi ) |
Transforms predator-prey preference parameters into vulnerability.
Multinomial logistic transform: each predator's prey preferences and its vulnerability to "other food" sum to 1. Parametric suitability only (suitMode > 0). Adopted from Trijoulet et al. 2020 (https://github.com/vtrijoulet/Multisp_model_JAE/blob/master/MS_SSM.cpp).
| vulnerability | Bounded predator-prey vulnerability [nspp, nspp], updated. |
| vulnerability_other | Remaining vulnerability for "other food" [nspp], updated. |
| nspp | Number of species. |
| suitMode | Suitability/preference mode per species. |
| log_phi | Estimated log-preference parameters [nspp, nspp]. |
Definition at line 20 of file predation.hpp.