Running ‘test-aab_env.R’ [1s/1s]
  Running ‘test-action_age.R’ [3s/4s]
  Running ‘test-action_grow-methods.R’ [5s/6s]
  Running ‘test-action_grow.R’ [2s/3s]
  Running ‘test-action_mature.R’ [2s/3s]
  Running ‘test-action_migrate.R’ [2s/2s]
  Running ‘test-action_naturalmortality.R’ [1s/2s]
  Running ‘test-action_predate-catchability.R’ [6s/7s]
  Running ‘test-action_predate-numberfleet.R’ [2s/3s]
  Running ‘test-action_predate-predator.R’ [15s/19s]
  Running ‘test-action_predate-timebasedsuitability.R’ [3s/4s]
  Running ‘test-action_predate.R’ [7s/8s]
  Running ‘test-action_renewal-otherfood.R’ [8s/9s]
  Running ‘test-action_renewal.R’ [4s/5s]
  Running ‘test-action_report.R’ [1s/2s]
  Running ‘test-action_spawn-multipleoutputs.R’ [4s/5s]
  Running ‘test-action_spawn.R’ [5s/7s]
  Running ‘test-action_spmodel.R’ [2s/2s]
  Running ‘test-action_tagging.R’ [2s/3s]
  Running ‘test-action_time.R’ [1s/2s]
  Running ‘test-action_weightloss.R’ [2s/3s]
  Running ‘test-array_utils.R’ [2s/2s]
  Running ‘test-env_dif.R’ [1s/1s]
  Running ‘test-eval.R’ [1s/1s]
  Running ‘test-formula_utils.R’ [1s/1s]
  Running ‘test-init_val.R’ [1s/2s]
  Running ‘test-likelihood_bounds.R’ [3s/3s]
  Running ‘test-likelihood_data.R’ [4s/5s]
  Running ‘test-likelihood_distribution-surveyindices.R’ [2s/3s]
  Running ‘test-likelihood_distribution.R’ [14s/19s]
  Running ‘test-likelihood_random.R’ [1s/2s]
  Running ‘test-likelihood_sparsesample.R’ [4s/5s]
  Running ‘test-likelihood_tagging_ckmr.R’ [4s/4s]
  Running ‘test-likelihood_understocking.R’ [0s/0s]
  Running ‘test-param_project-ar1.R’ [4s/5s]
  Running ‘test-param_project-logar1.R’ [4s/4s]
  Running ‘test-param_project.R’ [2s/3s]
  Running ‘test-params.R’ [3s/3s]
  Running ‘test-quota-assess.R’ [6s/8s]
  Running ‘test-quota-hockeyfleet.R’ [4s/5s]
  Running ‘test-quota.R’ [2s/2s]
  Running ‘test-regression.R’ [1s/2s]
  Running ‘test-run.R’ [1s/1s]
  Running ‘test-run_r.R’ [2s/3s]
  Running ‘test-run_tmb-reporting_enabled.R’ [1s/1s]
  Running ‘test-run_tmb.R’ [4s/5s]
  Running ‘test-step.R’ [2s/3s]
  Running ‘test-stock.R’ [1s/1s]
  Running ‘test-stock_age.R’ [2s/3s]
  Running ‘test-stock_areas.R’ [2s/2s]
  Running ‘test-stock_product.R’ [0s/0s]
  Running ‘test-stock_tag.R’ [1s/2s]
  Running ‘test-stock_time-fishingyear.R’ [2s/2s]
  Running ‘test-stock_time.R’ [1s/1s]
  Running ‘test-suitability-report.R’ [7s/10s]
  Running ‘test-suitability.R’ [3s/3s]
  Running ‘test-timedata.R’ [1s/2s]
  Running ‘test-timevariable.R’ [1s/1s]
Running the tests in ‘tests/test-param_project-logar1.R’ failed.
Complete output:
  > if (!interactive()) options(warn=2, error = function() { sink(stderr()) ; traceback(3) ; q(status = 1) })
  > library(unittest)
  > 
  > library(gadget3)
  > 
  > st_imm <- g3_stock(c("stst", maturity = "imm"), c(10, 20, 30)) |> g3s_age(0, 5)
  > st_mat <- g3_stock(c("stst", maturity = "mat"), c(10, 20, 30)) |> g3s_age(3, 15)
  > stocks_st <- list(st_imm, st_mat)
  > fl <- g3_fleet(c("fl", "surv"))
  > 
  > actions <- list(
  +     g3a_time(1990, 1994, c(6,6)),
  +     g3a_initialconditions(st_imm,
  +         quote( 100 + stock__minlen ),
  +         quote( 1e4 + 0 * stock__minlen ) ),
  +     g3a_initialconditions(st_mat,
  +         quote( 100 + stock__minlen ),
  +         quote( 1e4 + 0 * stock__minlen ) ),
  +     g3a_age(st_imm),
  +     g3a_age(st_mat),
  + 
  +     g3a_spawn(
  +         st_mat,
  +         g3a_spawn_recruitment_hockeystick(
  +             r0 = g3_param_project(
  +                 "rec",
  +                 g3_param_project_logar1(),
  +                 random = FALSE,
  +                 scale = "rec.scalar",
  +                 by_stock = stocks_st,
  +                 by_step = FALSE )),
  +             output_stocks = list(st_imm),
  +             run_step = 1 ),
  + 
  +     # NB: Dummy parameter so model will compile in TMB
  +     quote( nll <- nll + g3_param("x", value = 0) ) )
  > full_actions <- c(actions, list(
  +     g3a_report_detail(actions),
  +     g3a_report_history(actions, 'proj_.*', out_prefix = NULL),
  +     NULL))
  > model_fn <- g3_to_r(full_actions)
  > model_cpp <- g3_to_tmb(full_actions)
  > 
  > ok_group("No noise") ##########################################################
  # No noise
  > 
  > attr(model_fn, 'parameter_template') |>
  +     g3_init_val("stst.rec.#", rnorm(5, 1e5, 500)) |>
  +     g3_init_val("stst.rec.proj.logar1.lstddev", -1e6) |>  # i.e. no noise
  +     g3_init_val("stst.rec.proj.logar1.logphi", 0.8) |>
  +     g3_init_val("stst_mat.spawn.blim", 1e2) |>  # blim too low to trigger
  + 
  +     g3_init_val("*.K", 0.3, lower = 0.04, upper = 1.2) |>
  +     g3_init_val("*.Linf", max(g3_stock_def(st_imm, "midlen")), spread = 0.2) |>
  +     g3_init_val("*.t0", g3_stock_def(st_imm, "minage") - 0.8, spread = 2) |>
  +     g3_init_val("*.walpha", 0.01, optimise = FALSE) |>
  +     g3_init_val("*.wbeta", 3, optimise = FALSE) |>
  + 
  +     g3_init_val("project_years", 100) |>
  +     identity() -> params.in
  > nll <- model_fn(params.in) ; r <- attributes(nll) ; nll <- as.vector(nll)
  > 
  > ok(ut_cmp_equal(
  +     as.vector(tail(r$proj_logar1_stst_rec__var, -4)),
  +     as.vector(rep(r$proj_logar1_stst_rec__var["1994"], 101)),
  +     end = NULL), "r$proj_logar1_stst_rec__var: Projected values just repeat final non-projected value")
  ok - r$proj_logar1_stst_rec__var: Projected values just repeat final non-projected value
  > ok(ut_cmp_equal(
  +     as.vector( g3_array_agg(r$detail_stst_imm__spawnednum, c("year"), step = 1, age = 0) ),
  +     as.vector( r$proj_logar1_stst_rec__var ),
  +     end = NULL), "r$detail_stst_imm__spawnednum: projection variable used for recruitment")
  ok - r$detail_stst_imm__spawnednum: projection variable used for recruitment
  > 
  > gadget3:::ut_tmb_r_compare2(model_fn, model_cpp, params.in)
  # skip: not running TMB tests
  NULL
  > 
  > ok_group("No noise, fixed loglevel") ##########################################
  # No noise, fixed loglevel
  > 
  > attr(model_fn, 'parameter_template') |>
  +     g3_init_val("stst.rec.#", rnorm(5, 1e5, 500)) |>
  +     g3_init_val("stst.rec.proj.logar1.lstddev", -1e6) |>  # i.e. no noise
  +     g3_init_val("stst.rec.proj.logar1.logphi", 0.8) |>
  +     g3_init_val("stst.rec.proj.logar1.loglevel", log(round(runif(1, 10, 20)))) |>
  +     g3_init_val("stst_mat.spawn.blim", 1e2) |>  # blim too low to trigger
  + 
  +     g3_init_val("*.K", 0.3, lower = 0.04, upper = 1.2) |>
  +     g3_init_val("*.Linf", max(g3_stock_def(st_imm, "midlen")), spread = 0.2) |>
  +     g3_init_val("*.t0", g3_stock_def(st_imm, "minage") - 0.8, spread = 2) |>
  +     g3_init_val("*.walpha", 0.01, optimise = FALSE) |>
  +     g3_init_val("*.wbeta", 3, optimise = FALSE) |>
  + 
  +     g3_init_val("project_years", 100) |>
  +     identity() -> params.in
  > nll <- model_fn(params.in) ; r <- attributes(nll) ; nll <- as.vector(nll)
  > 
  > ok(ut_cmp_equal(
  +     as.vector(tail(r$proj_logar1_stst_rec__var, 10)),
  +     rep(exp(params.in$stst.rec.proj.logar1.loglevel), 10),
  +     end = NULL ), "proj_logar1_stst_rec__var: Settles to loglevel in projection, regardless of initial value")
  ok - proj_logar1_stst_rec__var: Settles to loglevel in projection, regardless of initial value
  > 
  > gadget3:::ut_tmb_r_compare2(model_fn, model_cpp, params.in)
  # skip: not running TMB tests
  NULL
  > 
  > ok_group("No noise, last 3 values as loglevel") ###############################
  # No noise, last 3 values as loglevel
  > 
  > attr(model_fn, 'parameter_template') |>
  +     g3_init_val("stst.rec.#", rnorm(5, 1e5, 500)) |>
  +     g3_init_val("stst.rec.proj.logar1.lstddev", -1e6) |>  # i.e. no noise
  +     g3_init_val("stst.rec.proj.logar1.logphi", 0.8) |>
  +     g3_init_val("stst.rec.proj.logar1.loglevel", -3) |>
  +     g3_init_val("stst_mat.spawn.blim", 1e2) |>  # blim too low to trigger
  + 
  +     g3_init_val("*.K", 0.3, lower = 0.04, upper = 1.2) |>
  +     g3_init_val("*.Linf", max(g3_stock_def(st_imm, "midlen")), spread = 0.2) |>
  +     g3_init_val("*.t0", g3_stock_def(st_imm, "minage") - 0.8, spread = 2) |>
  +     g3_init_val("*.walpha", 0.01, optimise = FALSE) |>
  +     g3_init_val("*.wbeta", 3, optimise = FALSE) |>
  + 
  +     g3_init_val("project_years", 100) |>
  +     identity() -> params.in
  > nll <- model_fn(params.in) ; r <- attributes(nll) ; nll <- as.vector(nll)
  > 
  > ok(ut_cmp_equal(
  +     as.vector(tail(r$proj_logar1_stst_rec__var, 10)),
  +     rep( mean(r$proj_logar1_stst_rec__var[c("1992", "1993", "1994")]), 10),
  +     tolerance = 5e-5 ), "proj_logar1_stst_rec__var: Settles to loglevel matching mean of last 3 values")
  not ok - proj_logar1_stst_rec__var: Settles to loglevel matching mean of last 3 values
  # Test returned non-TRUE value:
  # Mean relative difference: 5.062598e-05
  # --- as.vector(tail(r$proj_logar1_stst_rec__var, 10))
  # +++ rep(mean(r$proj_logar1_stst_rec__var[c("1992", "1993", "1994")]), 10)
  #  [1] [-99883.9 99883.9 99883.9 99883.9 99883.9 99883.9 99883.9 99883.9 99883.9-]
  # [-[10] 99883.9-]{+99888.96 99888.96 99888.96 99888.96 99888.96 99888.96 99888.96 99888.96+}
  # {+ [9] 99888.96 99888.96+}
  > 
  > gadget3:::ut_tmb_r_compare2(model_fn, model_cpp, params.in)
  # skip: not running TMB tests
  NULL
  > 
  > ok_group("With noise, no projection") #########################################
  # With noise, no projection
  > 
  > old_seed <- .Random.seed
  > set.seed(1234)  # Fix seed so we always choose the same stst.rec.#
  > attr(model_fn, 'parameter_template') |>
  +     g3_init_val("stst.rec.#", rnorm(5, 1e5, 500)) |>
  +     g3_init_val("stst.rec.proj.logar1.lstddev", -8) |>
  +     g3_init_val("stst.rec.proj.logar1.logphi", 0.8) |>
  +     g3_init_val("stst_mat.spawn.blim", 1e2) |>  # blim too low to trigger
  + 
  +     g3_init_val("*.K", 0.3, lower = 0.04, upper = 1.2) |>
  +     g3_init_val("*.Linf", max(g3_stock_def(st_imm, "midlen")), spread = 0.2) |>
  +     g3_init_val("*.t0", g3_stock_def(st_imm, "minage") - 0.8, spread = 2) |>
  +     g3_init_val("*.walpha", 0.01, optimise = FALSE) |>
  +     g3_init_val("*.wbeta", 3, optimise = FALSE) |>
  + 
  +     g3_init_val("project_years", 0) |>
  +     identity() -> params.in
  > .Random.seed <- old_seed
  > nll <- model_fn(params.in) ; r <- attributes(nll) ; nll <- as.vector(nll)
  > 
  > ok(ut_cmp_equal(nll, 682647457), "nll: Matches baseline (stst.rec.# always the same values)")
  ok - nll: Matches baseline (stst.rec.# always the same values)
  > ok(ut_cmp_equal(
  +     as.vector(r$proj_logar1_stst_rec__nll),
  +     c(588296503, 23684246, 23644656, 23227865, 23794187) ), "r$proj_logar1_stst_rec__nll: Matches baseline")
  ok - r$proj_logar1_stst_rec__nll: Matches baseline
  > 
  > gadget3:::ut_tmb_r_compare2(model_fn, model_cpp, params.in)
  # skip: not running TMB tests
  NULL
  > 
  > ok_group("With noise") ########################################################
  # With noise
  > 
  > attr(model_fn, 'parameter_template') |>
  +     g3_init_val("stst.rec.#", rnorm(5, 1e5, 500)) |>
  +     g3_init_val("stst.rec.proj.logar1.lstddev", -8) |>
  +     g3_init_val("stst.rec.proj.logar1.logphi", 0.8) |>
  +     g3_init_val("stst_mat.spawn.blim", 1e2) |>  # blim too low to trigger
  + 
  +     g3_init_val("*.K", 0.3, lower = 0.04, upper = 1.2) |>
  +     g3_init_val("*.Linf", max(g3_stock_def(st_imm, "midlen")), spread = 0.2) |>
  +     g3_init_val("*.t0", g3_stock_def(st_imm, "minage") - 0.8, spread = 2) |>
  +     g3_init_val("*.walpha", 0.01, optimise = FALSE) |>
  +     g3_init_val("*.wbeta", 3, optimise = FALSE) |>
  + 
  +     g3_init_val("project_years", 100) |>
  +     identity() -> params.in
  > nll <- model_fn(params.in) ; r <- attributes(nll) ; nll <- as.vector(nll)
  > 
  > ok(ut_cmp_equal(
  +     as.vector( g3_array_agg(r$detail_stst_imm__spawnednum, c("year"), step = 1, age = 0) ),
  +     as.vector( r$proj_logar1_stst_rec__var ),
  +     end = NULL), "r$detail_stst_imm__spawnednum: projection variable used for recruitment")
  ok - r$detail_stst_imm__spawnednum: projection variable used for recruitment
  > 
  > ok(all(r$proj_logar1_stst_rec__var > 1e4), "r$proj_logar1_stst_rec__var: Noise not high enough for value to drop below 1e4")
  ok - r$proj_logar1_stst_rec__var: Noise not high enough for value to drop below 1e4
  > 
  > # plot(r$proj_logar1_stst_rec__var)
  > 
  > proc.time()
     user  system elapsed 
    3.410   0.080   4.338 
  1..8
  # Looks like you failed 1 of 8 tests.
  # 4: proj_logar1_stst_rec__var: Settles to loglevel matching mean of last 3 values