action_weightloss: Gadget3 weightloss action

action_weightlossR Documentation

Gadget3 weightloss action

Description

Add weight loss events to a g3 model

Usage

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 )

Arguments

stock

The g3_stock that will lose weight in this action.

rel_loss

Fractional weight loss, 0.1 will result in the stock having 90 NULL means no fractional weight loss will be applied.

abs_loss

Absolute weight loss, applied after rel_loss. NULL means no absolute weight loss will be applied.

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 g3a_spawn to apply to subset that spawned.

run_step

Which step to perform renewal in, or NULL for continuous spawning. Adds cur_step == (run_step) into default run_f.

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 g3_action_order.

Value

g3a_weightloss

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

  1. Apply rel_loss and abs_loss to the parent stock

See Also

g3a_naturalmortality, g3a_spawn, g3_stock

Examples

  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

lentinj/gadget3 documentation built on June 12, 2025, 5:46 a.m.