action_weightloss | R Documentation |
Add weight loss events to a g3 model
g3a_weightloss(
stock,
rel_loss = NULL,
abs_loss = NULL,
min_weight = 1e-7,
apply_to_pop = quote( stock__num ),
run_f = TRUE,
run_step = NULL,
run_at = g3_action_order$naturalmortality )
stock |
The |
rel_loss |
Fractional weight loss, |
abs_loss |
Absolute weight loss, applied after rel_loss.
|
min_weight |
Minimum weight below which weight cannot fall further. Should be more than zero to avoid models returning NaN. |
apply_to_pop |
Stock instance weightloss applies to, by default applies to whole stock.
Used by |
run_step |
Which step to perform renewal in, or |
run_f |
formula specifying a condition for running this action, default always runs. |
run_at |
Integer order that spawning actions will be run within model, see |
An action (i.e. list of formula objects) that will, for the given stock...
Apply rel_loss and abs_loss to the parent stock
g3a_naturalmortality
,
g3a_spawn
,
g3_stock
st <- g3_stock('st', 10:20) |> g3s_age(3, 5)
actions <- list(
g3a_time(2000, 2005, step_lengths = c(3, 3, 3, 3)),
g3a_initialconditions(st,
# Set initial abundance & weight based on age
~1e5 + 0 * st__midlen,
~1000 * age + 0 * st__midlen ),
g3a_age(st),
g3a_weightloss(st,
# 20% of body weight should be shed in autumn
rel_loss = g3_parameterized("rel_loss_autumn", by_stock = TRUE, value = 0.2),
run_step = 4 ),
g3a_weightloss(st,
# Remove "10" from body weight, with a minimum based on length
abs_loss = g3_parameterized("absloss_length_mw", by_stock = TRUE, value = 10),
min_weight = g3_formula(
wmin.a * st__midlen^wmin.b,
wmin.a = g3_parameterized("wmin.a", by_stock = TRUE, value = 10),
wmin.b = g3_parameterized("wmin.a", by_stock = TRUE, value = 2) )),
NULL)
model_fn <- g3_to_r(c(actions, g3a_report_detail(actions)))
r <- model_fn(attr(model_fn, 'parameter_template'))
g3_array_agg(attr(r, "dstart_st__wgt"), c("age", "time"))
## See g3a_spawn for an example of weightloss in spawning
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.