stocks <- list(
st = g3_stock("st", 1:10 * 10) |> g3s_age(1, 5) )
actions <- list(
g3a_time(1990, 1995, c(3,3,3,3)),
g3a_initialconditions_normalcv(stocks$st),
g3a_growmature(stocks$st, impl_f = gadget3::g3a_grow_impl_bbinom(
maxlengthgroupgrowth = 2L) ),
NULL )
model_fn <- g3_to_r(c(actions, list(
g3a_trace_var(actions),
g3a_trace_timings(actions),
g3a_report_detail(actions) )))
# Configure set of working parameters
attr(model_fn, "parameter_template") |>
g3_init_val("*.K", 0.3) |>
g3_init_val("*.t0", 0.2) |>
g3_init_val("*.Linf", 80) |>
g3_init_val("*.lencv", 0.1) |>
g3_init_val("*.walpha", 0.01) |>
g3_init_val("*.wbeta", 3) |>
g3_init_val("*.M.#", 0.01) |>
identity() -> params.in
nll <- model_fn(params.in) ; r <- attributes(nll) ; nll <- as.vector(nll)
# Show timings of each step of model
r$trace_timings
# Find more informative names with g3_to_desc
as.list(g3_to_desc(actions))
# Try setting parameters to NaN and see what fails:
r <- model_fn(params.in |> g3_init_val("*.t0", NaN))
r <- model_fn(params.in |> g3_init_val("*.bbin", NaN))
Run the code above in your browser using DataLab