st <- g3_stock('st', 10:20) |> g3s_age(3, 5)
actions <- list(
g3a_time(2000, 2005, step_lengths = c(3, 3, 3, 3)),
gadget3:::g3a_initialconditions_manual(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
Run the code above in your browser using DataLab