action_weightloss.Rd
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 )
The g3_stock
that will lose weight in this action.
Fractional weight loss, 0.1
will result in the stock having 90
NULL
means no fractional weight loss will be applied.
Absolute weight loss, applied after rel_loss.
NULL
means no absolute weight loss will be applied.
Minimum weight below which weight cannot fall further. Should be more than zero to avoid models returning NaN.
Stock instance weightloss applies to, by default applies to whole stock.
Used by g3a_spawn
to apply to subset that spawned.
Which step to perform renewal in, or NULL
for continuous spawning.
Adds cur_step == (run_step)
into default run_f.
formula specifying a condition for running this action, default always runs.
Integer order that spawning actions will be run within model, see g3_action_order
.
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"))
#> time
#> age 2000-01 2000-02 2000-03 2000-04 2001-01 2001-02 2001-03 2001-04 2002-01
#> age3 33000 32890 32780 32670 27149.1 27039.1 26929.1 26819.1 22468.38
#> age4 44000 43890 43780 43670 27149.1 27039.1 26929.1 26819.1 22468.38
#> age5 55000 54890 54780 54670 40349.1 40239.1 40129.1 40019.1 29508.38
#> time
#> age 2002-02 2002-03 2002-04 2003-01 2003-02 2003-03 2003-04 2004-01
#> age3 22358.38 22248.38 22138.38 18723.8 18613.8 18503.8 18393.8 15728.14
#> age4 22358.38 22248.38 22138.38 18723.8 18613.8 18503.8 18393.8 15728.14
#> age5 29398.38 29288.38 29178.38 24355.8 24245.8 24135.8 24025.8 20233.74
#> time
#> age 2004-02 2004-03 2004-04 2005-01 2005-02 2005-03 2005-04
#> age3 15618.14 15508.14 15398.14 13331.61 13221.61 13111.61 13001.61
#> age4 15618.14 15508.14 15398.14 13331.61 13221.61 13111.61 13001.61
#> age5 20123.74 20013.74 19903.74 16936.09 16826.09 16716.09 16606.09
## See g3a_spawn for an example of weightloss in spawning