Add growth/maturity actions to a g3 model

g3a_grow_lengthvbsimple(
        linf_f = g3_parameterized('Linf', by_stock = by_stock),
        kappa_f = g3_parameterized('K', by_stock = by_stock),
        by_stock = TRUE)

g3a_grow_weightsimple(
        alpha_f = g3_parameterized('walpha', by_stock = by_stock),
        beta_f = g3_parameterized('wbeta', by_stock = by_stock),
        by_stock = TRUE)

g3a_grow_impl_bbinom(
        delta_len_f = g3a_grow_lengthvbsimple(by_stock = by_stock),
        delta_wgt_f = g3a_grow_weightsimple(by_stock = by_stock),
        beta_f = g3_parameterized('bbin', by_stock = by_stock),
        maxlengthgroupgrowth,
        by_stock = TRUE)

g3a_grow_length_multspec(
        p0 = g3_parameterized('multispec.p0', value = 1, by_stock = by_stock),
        p1 = g3_parameterized('multispec.p1', value = 1, by_stock = by_stock),
        p2 = g3_parameterized('multispec.p2', value = 1, by_stock = by_stock),
        p3 = g3_parameterized('multispec.p3', value = 0, by_stock = by_stock),
        temperature = 0,
        by_stock = TRUE)

g3a_grow_weight_multspec(
        p4 = g3_parameterized('multispec.p4', value = 1, by_stock = by_stock),
        p5 = g3_parameterized('multispec.p5', value = 1, by_stock = by_stock),
        p6 = g3_parameterized('multispec.p6', value = 0, by_stock = by_stock),
        p7 = g3_parameterized('multispec.p7', value = 1, by_stock = by_stock),
        p8 = g3_parameterized('multispec.p8', value = 0, by_stock = by_stock),
        temperature = 0,
        by_stock = TRUE)

g3a_grow_length_weightjones(
        p0 = g3_parameterized('weightjones.p0', value = 0, by_stock = by_stock),
        p1 = g3_parameterized('weightjones.p1', value = 0, by_stock = by_stock),
        p2 = g3_parameterized('weightjones.p2', value = 1, by_stock = by_stock),
        p3 = g3_parameterized('weightjones.p3', value = 0, by_stock = by_stock),
        p4 = g3_parameterized('weightjones.p4', value = 1, by_stock = by_stock),
        p5 = g3_parameterized('weightjones.p5', value = 100, by_stock = by_stock),
        p6 = g3_parameterized('weightjones.p6', value = 1, by_stock = by_stock),
        p7 = g3_parameterized('weightjones.p7', value = 1, by_stock = by_stock),
        reference_weight = 0,
        temperature = 0,
        by_stock = TRUE)

g3a_grow_weight_weightjones(
        q0 = g3_parameterized('weightjones.q0', value = 1, by_stock = by_stock),
        q1 = g3_parameterized('weightjones.q1', value = 1, by_stock = by_stock),
        q2 = g3_parameterized('weightjones.q2', value = 1, by_stock = by_stock),
        q3 = g3_parameterized('weightjones.q3', value = 1, by_stock = by_stock),
        q4 = g3_parameterized('weightjones.q4', value = 1, by_stock = by_stock),
        q5 = g3_parameterized('weightjones.q5', value = 0, by_stock = by_stock),
        max_consumption = g3a_predate_maxconsumption(temperature = temperature),
        temperature = 0,
        by_stock = TRUE)

g3a_growmature(stock, impl_f, maturity_f = ~0, output_stocks = list(), 
    output_ratios = rep(1/length(output_stocks), times = length(output_stocks)), 
    transition_f = ~cur_step_final, run_f = ~TRUE,
    run_at = g3_action_order$grow,
    transition_at = g3_action_order$mature)

Arguments

linf_f

A formula to substitute for \(L_\infty\).

kappa_f

A formula to substitute for \(\kappa\).

alpha_f

A formula to substitute for \(\alpha\).

beta_f

A formula to substitute for \(\beta\).

p0, p1, p2, p3, p4, p5, p6, p7, p8, q0, q1, q2, q3, q4, q5

A formula to substitute for the equivalent value.

max_consumption

Maximum predator consumption, see g3a_predate_maxconsumption.

temperature

A formula providing values for the current temperature, likely implemented with g3_timeareadata.

maxlengthgroupgrowth

An integer with the maximum length groups an individual can jump in one step.

reference_weight

Reference weight. see formula for g3a_grow_length_weightjones.

stock

g3_stock to grow.

delta_len_f

A formula defining a non-negative vector for mean increase in length for stock for each lengthgroup, as defined by g3a_grow_lengthvbsimple.

delta_wgt_f

A formula defining the corresponding weight increase as a matrix of lengthgroup to lengthgroup delta for stock, as defined by g3a_grow_weightsimple.

by_stock

Change the default parameterisation (e.g. to be by 'species'), see g3_parameterized.

impl_f

A pair of formula objects, as defined by g3a_grow_impl_bbinom. Both define a matrix of length groups i to length group deltas j (0..maxlengthgroupgrowth), the values in the first indicate the proportion of individuals moving from i to i + j, the values in the second indicate the corresponding weight increase of individuals moving from i to i + j.

maturity_f

A maturity formula, as defined by g3a_mature_constant.

output_stocks

List of g3_stocks that maturing stock should move into.

output_ratios

Vector of proportions for how to distribute into output_stocks, summing to 1, default evenly spread.

transition_f

formula specifying a contition for running maturation steps as well as growth, default final step of year.

run_f

formula specifying a condition for running this action, default always runs.

run_at

Integer order that actions will be run within model, see g3_action_order.

transition_at

Integer order that transition actions will be run within model, see g3_action_order.

Details

A model can have any number of g3a_growmature actions, so long as the calling arguments are different. For instance, run_f = ~age == 5 and run_f = ~age == 7.

impl_f's dependent variables are analysed to see what will affect growth. If nothing but cur_step_size will affect growth, then growth will only be recalculated when the step size changes.

Value

g3a_grow_lengthvbsimple

Returns a formula for use as delta_len_f:

$$ {{\Delta}L}_i = ( L_\infty - L_i )(1 - e^{-\kappa {\Delta t}}) $$

\(\Delta t\)

Length of current step as a proportion of the year, e.g. 0.25. See cur_step_size in g3a_time

g3a_grow_weightsimple

Returns a formula for use as delta_wgt_f:

$$ {{\Delta}W}_{i,j} = \alpha ( (L_i + {{\Delta}L}_j)^\beta - {L_i}^\beta ) $$

\({\Delta}L\)

Vector of all possible length group increases i.e 0..maxlengthgroupgrowth

g3a_grow_length_multspec

Returns a formula for use as delta_len_f: $$ {{\Delta}L}_i = {\Delta t} p_0 L_i^{p_1} \psi_i (p_2 T + p_3) $$

\(p_x\)

Supplied parameters

\(\Delta t\)

Length of current step as a proportion of the year, e.g. 0.25. See cur_step_size in g3a_time

\(L_i\)

Current length

\(\psi_i\)

Feeding level of stock. See g3a_predate_catchability_predator

\(T\)

Temperature of current region

g3a_grow_weight_multspec

Returns a formula for use as delta_wgt_f: $$ {{\Delta}W}_{i,j} = {\Delta t} p_4 {W_i}^{p_5} (\psi_i - p_6) (p_7 T + p_8) $$

\(p_x\)

Supplied parameters

\(\Delta t\)

Length of current step as a proportion of the year, e.g. 0.25. See cur_step_size in g3a_time

\(W_i\)

Current mean weight

\(\psi_i\)

Feeding level of stock. See g3a_predate_catchability_predator

\(T\)

Temperature of current region

Note that the equation is not dependent on the change in length, the value will be the same for each \(j\).

g3a_grow_length_weightjones

Returns a formula for use as delta_len_f: $$ r = \frac{ W_i - (p_0 + \psi_i (p_1 + p_2 \psi_i)) W_{ref} }{ W_i } $$ $$ {{\Delta}L}_i = {minmax}(p_3 + p_4 r, 0, p_5) \frac{ {{\Delta}W}_{i,j} }{ p_6 p_7 {L_i}^{(p_7 - 1)} } $$

\(W_i\)

Current mean weight

\(p_x\)

Supplied parameters

\(\psi_i\)

Feeding level of stock. See g3a_predate_catchability_predator

\(W_{ref}\)

Reference weight, from the reference_weight parameter

\({{\Delta}W}_{i,j}\)

Change in weight, i.e. the output from the delta_wgt_f formula, probably g3a_grow_weight_weightjones.

g3a_grow_weight_weightjones

Returns a formula for use as delta_wgt_f: $$ {{\Delta}W}_{i,j} = {\Delta t} ( \frac{ M \psi_i }{ q_0 {W_i}^{q_1} } - q_2 {W_i}^{q_3} e^{(q_4 T + q_5)} ) $$

\(q_x\)

Supplied parameters

\(\Delta t\)

Length of current step as a proportion of the year, e.g. 0.25. See cur_step_size in g3a_time

\(M\)

Maximum theoretical consumption, as defined by g3a_predate_maxconsumption

\(\psi_i\)

Feeding level of stock. See g3a_predate_catchability_predator

\(W_i\)

Current mean weight

\(T\)

Temperature of current region

Note that the equation is not dependent on the change in length, the value will be the same for each \(j\).

g3a_grow_impl_bbinom

formula object converting mean growths using beta-binomia distribution. See https://gadget-framework.github.io/gadget2/userguide/chap-stock.html#beta-binomial

g3a_growmature

An action (i.e. list of formula objects) that will, for the given stock...

  1. Move any maturing individuals into temporary storage, stock__transitioning_num / stock__transitioning_wgt

  2. Calculate increase in length/weight using growth_f and impl_f

  3. Move the contents of the temporary storage into output_stocks

Examples

ling_imm <- g3_stock(c(species = 'ling', 'imm'), seq(20, 156, 4))
ling_mat <- g3_stock(c(species = 'ling', 'mat'), seq(20, 156, 4))

# Growth / maturity for immature ling
growth_action <- g3a_growmature(ling_imm,
    impl_f = g3a_grow_impl_bbinom(
        # Parameters will be ling.Linf, ling.K
        g3a_grow_lengthvbsimple(by_stock = 'species'),
        # Parameters will be ling_imm.walpha, ling_imm.wbeta
        g3a_grow_weightsimple(),
        maxlengthgroupgrowth = 15),
    maturity_f = g3a_mature_constant(
        alpha = g3_parameterized('ling.mat1', scale = 0.001),
        l50 = g3_parameterized('ling.mat2')),
        output_stocks = list(ling_mat))

# Multspec growth - define a data frame with temperature
temperature <- g3_timeareadata(
    'temp',
    data.frame(year = 2000, step=c(1,2), temp=c(10, 14)),
    value_field = "temp" )

ms_growth_actions <- list(
  g3a_growmature(ling_imm, g3a_grow_impl_bbinom(
    g3a_grow_length_multspec(temperature = temperature),
    g3a_grow_weight_multspec(temperature = temperature),
    maxlengthgroupgrowth = 8 )),
  NULL)