library(magrittr)
stocks <- list(
imm = g3_stock(c('ling', maturity = "imm"), seq(10, 100, 10)) %>% g3s_age(3, 7),
mat = g3_stock(c('ling', maturity = "mat"), seq(10, 100, 10)) %>% g3s_age(5, 10) )
actions <- list(
g3a_time(2000, 2000),
g3a_initialconditions_normalcv(stocks$imm),
g3a_initialconditions_normalcv(stocks$mat),
NULL)
model_fn <- g3_to_r(c(actions, list(
g3a_report_detail(actions) )))
attr(model_fn, 'parameter_template') |>
g3_init_val("init.F", 0.4) |>
g3_init_val("ling_imm.Linf", 80) |>
g3_init_val("ling_mat.Linf", 160) |>
g3_init_val("ling_*.K", 90) |>
g3_init_val("ling_*.t0", 0) |>
g3_init_val("ling_*.lencv", 0.1) |>
g3_init_val("ling_imm.init.#", 3:7 * 100) |>
g3_init_val("ling_mat.init.#", 5:10 * 200) |>
g3_init_val("ling_*.init.scalar", 200) |>
g3_init_val("ling_*.walpha", 2.275e-06) |>
g3_init_val("ling_*.wbeta", 3.2020) |>
g3_init_val("ling_*.M.#", 0.15) |>
identity() -> params.in
r <- model_fn(params.in)
g3_array_plot(attr(r, "dstart_ling_imm__num")[,,time=1])
g3_array_plot(attr(r, "dstart_ling_mat__num")[,,time=1])
## Plots
par(mar = c(4,2,2,1), cex.main = 1)
curve(g3_eval(g3a_renewal_vonb_t0(Linf = 20, K = 0.8, t0 = 0), age = x),
0, 10, col = 2, xlab = "age", main = "g3a_renewal_vonb_t0(Linf = 20, K = 0.8..1.4, t0 = 0)")
curve(g3_eval(g3a_renewal_vonb_t0(Linf = 20, K = 1.0, t0 = 0), age = x),
0, 10, col = 1, add = TRUE)
curve(g3_eval(g3a_renewal_vonb_t0(Linf = 20, K = 1.2, t0 = 0), age = x),
0, 10, col = 3, add = TRUE)
curve(g3_eval(g3a_renewal_vonb_t0(Linf = 20, K = 1.4, t0 = 0), age = x),
0, 10, col = 4, add = TRUE)
## Otherfood
# "Otherfood" stocks are defined in a similar manner to any other stock
# Note that _normalparam & _normalcv need both length & age dimensions
other_wgt <- g3_stock('other_wgt', 0)
other_cv <- g3_stock('other_cv', seq(50, 100, by = 10)) %>% g3s_age(5,10)
actions <- list(
g3a_time(2000, 2010),
# Will get other_wgt.of_abund.1998.1, other_wgt.of_meanwgt parameters
g3a_otherfood(other_wgt),
# Use standard vonB parameters (Linf/K/t0) to define abundance
g3a_otherfood_normalcv(other_cv),
NULL)
model_fn <- g3_to_r(c(actions, list(
g3a_report_detail(actions) )))
attr(model_fn, 'parameter_template') |>
g3_init_val("other_cv.Linf", 80) |>
g3_init_val("other_cv.K", 90) |>
g3_init_val("other_cv.t0", 0) |>
g3_init_val("other_cv.of_abund.#", 100:110) |>
g3_init_val("other_wgt.of_abund.#", 100:110) |>
g3_init_val("other_wgt.of_abund.step.#", 1) |>
g3_init_val("other_cv.of_abund.proj", 80) |>
g3_init_val("other_wgt.of_abund.proj", 70) |>
g3_init_val("project_years", 5) |>
identity() -> params.in
r <- model_fn(params.in)
g3_array_plot(t(attr(r, "dstart_other_wgt__num")))
g3_array_plot(t(attr(r, "dstart_other_cv__num")[,age="age7",]))
Run the code above in your browser using DataLab