Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"replicate" option in future_om_list does not replicate rec_devs when scenarios run in tandem #144

Open
rwildermuth opened this issue Dec 16, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@rwildermuth
Copy link

rwildermuth commented Dec 16, 2022

After some digging, I figured out that running multiple scenarios in a single run_SSMSE() call with scen = c("replicate", "all") in the future_om_list doesn't actually make the recruitment deviations in the OM the same across scenarios. If I provide a seed to the run_SSMSE() call and run it separately for each scenario, then I do get the same rec_dev time series.

I've saved an example of this while implementing autocorrelated recruitment to our SardineMSE github here.

I discovered this because I need to call run_SSMSE() separately for our project in order to use multiple different custom HCR functions and that function won't allow you to specify more than one 'custom_MS_source'.

Note: this isn't a problem for situations where all recruitment deviations are provided outside of SSMSE as is done here. In this case, tandem scenarios all have rec_dev time series in common.

@k-doering-NOAA k-doering-NOAA added the bug Something isn't working label Dec 16, 2022
@k-doering-NOAA k-doering-NOAA self-assigned this Dec 16, 2022
@k-doering-NOAA
Copy link
Collaborator

Thanks for reporting this @rwildermuth! Am I right in that you have a work around for this issue for now?

@rwildermuth
Copy link
Author

rwildermuth commented Dec 16, 2022 via email

@k-doering-NOAA
Copy link
Collaborator

k-doering-NOAA commented Dec 27, 2022

Replicated the bug by running the following code and looking at the Fcast_recdevs section of the ss.par file for each OM output. The Fcast_recdevs were all different, even though they should have been identical across scenarios and iterations given the rec_dev_specify$scen <- c("replicate", "all") line.

devtools::load_all() # or library(SSMSE)
new_temp_path <- file.path("mult_scenarios")
nyrs <- 6
datfile <- system.file("extdata", "models", "cod", "ss3.dat", package = "SSMSE")
# create the sample_structure
sample_struct <- create_sample_struct(dat = datfile, nyrs = nyrs)
sample_struct[["lencomp"]] <- NULL
sample_struct[["meanbodywt"]] <- NULL
sample_struct[["MeanSize_at_Age_obs"]] <- NULL

# add recruitment deviations (core issue)
template_mod_change <- create_future_om_list(list_length = 1)
rec_dev_specify <- template_mod_change[[1]]
rec_dev_specify$pars <- "rec_devs"
rec_dev_specify$scen <- c("replicate", "all")
rec_dev_specify$input$first_yr_averaging <- 1 # use same sd as from the orig model.
rec_dev_specify$input$last_yr_averaging <- 100
rec_dev_specify$input$last_yr_orig_val <- 100
rec_dev_specify$input$first_yr_final_val <- 101
rec_dev_specify$input$ts_param <- "sd"
rec_dev_specify$input$value <- NA
my_future_om_list <- list(rec_dev_specify)

# run SSMSE

  result <- run_SSMSE(
    scen_name_vec = c("scen1", "scen2"), # name of the scenario
    out_dir_scen_vec = new_temp_path, # directory in which to run the scenario
    iter_vec = c(2, 2), # run with 3 iterations each
    OM_name_vec = "cod",
    EM_name_vec = "cod", # cod is included in package data
    MS_vec = "EM", # The management strategy is specified in the EM
    custom_MS_source = NULL,
    use_SS_boot_vec = TRUE, # use the SS bootstrap module for sampling
    nyrs_vec = nyrs, # Years to project OM forward
    nyrs_assess_vec = 3, # Years between assessments
    future_om_list = my_future_om_list,
    run_EM_last_yr = FALSE,
    run_parallel = FALSE,
    sample_struct_list = list(sample_struct, sample_struct), # How to sample data for running the EM.
    seed = 12345
  )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants