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'))
attr(r, "detail_st__wgt")[1,,]
#> time
#> age 2000-01 2000-02 2000-03 2000-04 2001-01 2001-02 2001-03 2001-04 2002-01
#> age3 3000 2990 2980 2970 2412.1 2402.1 2392.1 2382.1 1941.78
#> age4 4000 3990 3980 3970 2412.1 2402.1 2392.1 2382.1 1941.78
#> age5 5000 4990 4980 4970 3612.1 3602.1 3592.1 3582.1 2581.78
#> time
#> age 2002-02 2002-03 2002-04 2003-01 2003-02 2003-03 2003-04 2004-01
#> age3 1931.78 1921.78 1911.78 1565.524 1555.524 1545.524 1535.524 1264.519
#> age4 1931.78 1921.78 1911.78 1565.524 1555.524 1545.524 1535.524 1264.519
#> age5 2571.78 2561.78 2551.78 2077.524 2067.524 2057.524 2047.524 1674.119
#> time
#> age 2004-02 2004-03 2004-04 2005-01 2005-02 2005-03 2005-04
#> age3 1254.519 1244.519 1234.519 1023.715 1013.715 1003.715 993.7154
#> age4 1254.519 1244.519 1234.519 1023.715 1013.715 1003.715 993.7154
#> age5 1664.119 1654.119 1644.119 1351.395 1341.395 1331.395 1321.3954
## See g3a_spawn for an example of weightloss in spawning