R Under development (unstable) (2025-04-18 r88159 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(unittest) > if (!interactive()) options(warn=2, error = function() { sink(stderr()) ; traceback(3) ; q(status = 1) }) > > library(gadget3) > > actions <- list() > area_names <- g3_areas(c('AA', 'BB', 'CC')) > > st_imm_f <- g3_stock(c(species = "fish", maturity = 'imm', sex = 'f'), seq(5L, 25L, 5)) |> + g3s_livesonareas(area_names["AA"]) |> + g3s_age(1L, 5L) > st_imm_m <- g3_stock(c(species = "fish", maturity = 'imm', sex = 'm'), seq(5L, 25L, 5)) |> + g3s_livesonareas(area_names["AA"]) |> + g3s_age(1L, 5L) > st_mat <- g3_stock(c(species = "fish", maturity = 'mat'), seq(5L, 25L, 5)) |> + g3s_livesonareas(area_names["AA"]) |> + g3s_age(3L, 10L) > > actions <- list( + g3a_time( + 1980, 1995, + step_lengths = c(6L, 6L)), + g3a_initialconditions(st_imm_f, quote( 0 * stock__midlen ), quote( 0 * stock__midlen )), + g3a_initialconditions(st_imm_m, quote( 0 * stock__midlen ), quote( 0 * stock__midlen )), + g3a_initialconditions_normalcv(st_mat), + g3a_spawn( + st_mat, + recruitment_f = g3a_spawn_recruitment_bevertonholt( + mu = g3_parameterized('spawn_mu', value = 5, by_year = TRUE), + lambda = g3_parameterized("spawn_lambda", value = 1, by_stock = TRUE) ), + proportion_f = g3_suitability_exponentiall50(), + weightloss_args = list( + abs_loss = g3_parameterized("spawn.weightabsloss", value = 0), + rel_loss = g3_parameterized("spawn.weightrelloss", value = 0) ), + output_stocks = list(st_imm_f, st_imm_m), + output_ratios = list( + st_imm_f = quote( g3_param('spawn_ratio', value = 0.5) ), + st_imm_m = quote( 1 - g3_param('spawn_ratio', value = 0.5) )), + run_f = quote( cur_step == 1 ) ), + g3a_age(st_imm_f), + g3a_age(st_imm_m), + g3a_age(st_mat) ) > > # Compile model > model_fn <- g3_to_r(c(actions, list( + g3a_report_history(actions, c( + '__offspringnum$', + '__num$', + '__wgt$' ))))) > model_cpp <- g3_to_tmb(c(actions, list( + g3a_report_history(actions, c( + '__offspringnum$', + '__num$', + '__wgt$' ))))) > # model_cpp <- edit(model_cpp) > > estimate_l50 <- g3_stock_def(st_mat, "midlen")[[length(g3_stock_def(st_mat, "midlen")) / 2]] > > for (spawn_ratio in runif(5)) ok_group(paste0("spawn_ratio: ", spawn_ratio), { + attr(model_fn, 'parameter_template') |> + g3_init_val("fish_imm_m.Linf", g3_stock_def(st_mat, "midlen")[[1]]) |> + g3_init_val("fish_imm_f.Linf", g3_stock_def(st_mat, "midlen")[[3]]) |> + g3_init_val("fish_mat.Linf", g3_stock_def(st_mat, "midlen")[[5]]) |> + g3_init_val("*.walpha", 0.01, optimise = FALSE) |> + g3_init_val("*.wbeta", 3, optimise = FALSE) |> + + g3_init_val("*.*.l50", estimate_l50, spread = 0.25) |> + g3_init_val("spawn_ratio", spawn_ratio) |> + + identity() -> params + + r <- attributes(model_fn(params)) + num_spawn <- colSums(r$hist_fish_mat__offspringnum, dims = 3) + num_m <- colSums(r$hist_fish_imm_m__num, dims = 3) + num_f <- colSums(r$hist_fish_imm_f__num, dims = 3) + + # Make sure lengthgroup structure varies between m & f (i.e. used appropriate Linfs) + for (t in dimnames(r$hist_fish_imm_m__num)$time) { + ok(ut_cmp_identical( + names(which.max(r$hist_fish_imm_m__num[,1,1,time = t])), + "5:10"), paste0("r$hist_fish_imm_m__num[,1,1,time = ", t, "]: Shortest lengthgroup most populated")) + ok(ut_cmp_identical( + names(which.max(r$hist_fish_imm_f__num[,1,1,time = t])), + "10:15"), paste0("r$hist_fish_imm_f__num[,1,1,time = ", t, "]: Second lengthgroup most populated")) + } + + ok(ut_cmp_equal( + cumsum(num_spawn * (1 - spawn_ratio)), + num_m, + tolerance = 1e-8), "hist_fish_imm_m__num: Cumulative proportion of __offspringnum") + ok(ut_cmp_equal( + cumsum(num_spawn * spawn_ratio), + num_f, + tolerance = 1e-8), "hist_fish_imm_f__num: Cumulatve proportion of __offspringnum") + + gadget3:::ut_tmb_r_compare2(model_fn, model_cpp, params) + }) # spawn_ratio: 0.107349306577817 ok - r$hist_fish_imm_m__num[,1,1,time = 1980-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1980-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1980-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1980-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1981-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1981-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1981-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1981-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1982-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1982-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1982-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1982-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1983-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1983-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1983-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1983-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1984-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1984-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1984-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1984-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1985-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1985-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1985-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1985-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1986-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1986-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1986-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1986-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1987-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1987-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1987-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1987-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1988-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1988-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1988-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1988-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1989-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1989-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1989-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1989-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1990-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1990-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1990-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1990-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1991-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1991-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1991-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1991-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1992-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1992-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1992-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1992-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1993-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1993-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1993-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1993-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1994-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1994-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1994-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1994-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1995-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1995-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1995-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1995-02]: Second lengthgroup most populated ok - hist_fish_imm_m__num: Cumulative proportion of __offspringnum ok - hist_fish_imm_f__num: Cumulatve proportion of __offspringnum # skip: not running TMB tests # spawn_ratio: 0.146614625817165 ok - r$hist_fish_imm_m__num[,1,1,time = 1980-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1980-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1980-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1980-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1981-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1981-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1981-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1981-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1982-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1982-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1982-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1982-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1983-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1983-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1983-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1983-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1984-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1984-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1984-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1984-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1985-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1985-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1985-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1985-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1986-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1986-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1986-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1986-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1987-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1987-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1987-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1987-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1988-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1988-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1988-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1988-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1989-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1989-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1989-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1989-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1990-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1990-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1990-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1990-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1991-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1991-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1991-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1991-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1992-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1992-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1992-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1992-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1993-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1993-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1993-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1993-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1994-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1994-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1994-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1994-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1995-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1995-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1995-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1995-02]: Second lengthgroup most populated ok - hist_fish_imm_m__num: Cumulative proportion of __offspringnum ok - hist_fish_imm_f__num: Cumulatve proportion of __offspringnum # skip: not running TMB tests # spawn_ratio: 0.251677061663941 ok - r$hist_fish_imm_m__num[,1,1,time = 1980-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1980-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1980-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1980-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1981-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1981-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1981-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1981-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1982-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1982-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1982-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1982-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1983-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1983-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1983-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1983-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1984-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1984-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1984-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1984-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1985-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1985-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1985-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1985-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1986-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1986-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1986-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1986-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1987-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1987-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1987-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1987-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1988-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1988-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1988-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1988-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1989-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1989-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1989-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1989-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1990-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1990-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1990-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1990-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1991-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1991-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1991-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1991-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1992-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1992-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1992-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1992-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1993-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1993-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1993-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1993-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1994-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1994-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1994-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1994-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1995-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1995-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1995-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1995-02]: Second lengthgroup most populated ok - hist_fish_imm_m__num: Cumulative proportion of __offspringnum ok - hist_fish_imm_f__num: Cumulatve proportion of __offspringnum # skip: not running TMB tests # spawn_ratio: 0.578015878098086 ok - r$hist_fish_imm_m__num[,1,1,time = 1980-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1980-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1980-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1980-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1981-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1981-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1981-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1981-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1982-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1982-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1982-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1982-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1983-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1983-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1983-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1983-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1984-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1984-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1984-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1984-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1985-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1985-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1985-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1985-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1986-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1986-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1986-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1986-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1987-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1987-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1987-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1987-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1988-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1988-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1988-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1988-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1989-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1989-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1989-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1989-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1990-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1990-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1990-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1990-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1991-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1991-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1991-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1991-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1992-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1992-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1992-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1992-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1993-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1993-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1993-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1993-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1994-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1994-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1994-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1994-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1995-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1995-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1995-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1995-02]: Second lengthgroup most populated ok - hist_fish_imm_m__num: Cumulative proportion of __offspringnum ok - hist_fish_imm_f__num: Cumulatve proportion of __offspringnum # skip: not running TMB tests # spawn_ratio: 0.692307691788301 ok - r$hist_fish_imm_m__num[,1,1,time = 1980-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1980-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1980-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1980-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1981-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1981-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1981-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1981-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1982-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1982-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1982-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1982-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1983-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1983-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1983-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1983-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1984-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1984-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1984-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1984-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1985-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1985-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1985-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1985-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1986-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1986-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1986-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1986-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1987-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1987-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1987-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1987-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1988-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1988-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1988-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1988-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1989-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1989-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1989-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1989-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1990-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1990-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1990-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1990-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1991-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1991-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1991-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1991-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1992-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1992-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1992-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1992-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1993-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1993-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1993-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1993-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1994-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1994-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1994-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1994-02]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1995-01]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1995-01]: Second lengthgroup most populated ok - r$hist_fish_imm_m__num[,1,1,time = 1995-02]: Shortest lengthgroup most populated ok - r$hist_fish_imm_f__num[,1,1,time = 1995-02]: Second lengthgroup most populated ok - hist_fish_imm_m__num: Cumulative proportion of __offspringnum ok - hist_fish_imm_f__num: Cumulatve proportion of __offspringnum # skip: not running TMB tests > > ok_group("weightloss") ################ # weightloss > attr(model_fn, 'parameter_template') |> + g3_init_val("fish_imm_m.Linf", g3_stock_def(st_mat, "midlen")[[1]]) |> + g3_init_val("fish_imm_f.Linf", g3_stock_def(st_mat, "midlen")[[3]]) |> + g3_init_val("fish_mat.Linf", g3_stock_def(st_mat, "midlen")[[5]]) |> + g3_init_val("*.walpha", 1, optimise = FALSE) |> + g3_init_val("*.wbeta", 1, optimise = FALSE) |> + + g3_init_val("*.*.l50", estimate_l50, spread = 0.25) |> + g3_init_val("spawn_ratio", spawn_ratio) |> + g3_init_val('spawn.weightabsloss', 0.2) |> + + identity() -> params > r <- sapply(attributes(model_fn(params)), drop) > > # NB: We can't check spawn.weightabsloss = 0, since inaccuracy in ratio_log_vec() makes a mess > > ok(ut_cmp_equal(round(diff(colSums(r$hist_fish_mat__wgt[,8,])), 1)[seq(1, 31, by = 2)], c( + "1980-02" = 0, + "1981-02" = 0, + "1982-02" = 0, + "1983-02" = 0, + "1984-02" = 0, + "1985-02" = 0, + "1986-02" = 0, + "1987-02" = 0, + "1988-02" = 0, + "1989-02" = 0, + "1990-02" = 0, + "1991-02" = 0, + "1992-02" = 0, + "1993-02" = 0, + "1994-02" = 0, + "1995-02" = 0 )), "r$hist_fish_mat__wgt[,8,]: No weightloss outside spawning steps") ok - r$hist_fish_mat__wgt[,8,]: No weightloss outside spawning steps > ok(ut_cmp_equal(round(diff(colSums(r$hist_fish_mat__wgt[,8,])), 1)[seq(2, 30, by = 2)], c( + "1981-01" = -0.4, + "1982-01" = -0.5, + "1983-01" = -0.5, + "1984-01" = -0.5, + "1985-01" = -0.4, + "1986-01" = -0.3, + "1987-01" = -0.2, + "1988-01" = -0.4, + "1989-01" = -0.4, + "1990-01" = -0.4, + "1991-01" = -0.4, + "1992-01" = -0.4, + "1993-01" = -0.4, + "1994-01" = -0.4, + "1995-01" = -0.4 )), "r$hist_fish_mat__wgt[,8,]: Total weight loss roughly 0.4 (first lengthgroup not spawning, half of remaining 4 spawning)") ok - r$hist_fish_mat__wgt[,8,]: Total weight loss roughly 0.4 (first lengthgroup not spawning, half of remaining 4 spawning) > > gadget3:::ut_tmb_r_compare2(model_fn, model_cpp, params) # skip: not running TMB tests NULL > > proc.time() user system elapsed 3.60 0.15 3.75 1..332 # Looks like you passed all 332 tests.