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

191 spawner recruitment with a b formulation #442

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1fb37cd
first commit for B-H with ab
Rick-Methot-NOAA Feb 9, 2023
8981777
revise to use WHAM syntax
Rick-Methot-NOAA Feb 14, 2023
5351bb6
Update .gitignore
Rick-Methot-NOAA Feb 14, 2023
cc71b49
Srr=10 now matching SRR=3
Rick-Methot-NOAA May 19, 2023
03b1420
adding reporting for timevary growth
Rick-Methot-NOAA May 20, 2023
63c8681
WIP
Rick-Methot-NOAA May 31, 2023
9201cee
working version with a,b
Rick-Methot-NOAA May 22, 2024
2bb4301
Update .gitignore
May 28, 2024
d01422e
augment spawn_recr report and use to test time-vary SR_parm approach
Rick-Methot-NOAA Jun 12, 2024
92208d4
adding benchmark change
Rick-Methot-NOAA Jun 26, 2024
93eb385
format changes for spawn_recr report
Rick-Methot-NOAA Jul 3, 2024
38ae9ee
fixes to ss_warn
Rick-Methot-NOAA Jul 9, 2024
f034223
WIP-more work needed on benchmark calcs
Rick-Methot-NOAA Aug 14, 2024
0d6d3b6
WIP2-need-to-fix-SPR-passing_to_benchmark
Rick-Methot-NOAA Aug 16, 2024
b4ee3f6
WIP: add switch in benchmark to use correct SPR0
Rick-Methot-NOAA Sep 13, 2024
18fcf7d
refactor SPR to SSBpR; clean-up reference to timevary biology
Rick-Methot-NOAA Sep 17, 2024
f674498
create new switch to control updating of SSBpR0
Rick-Methot-NOAA Sep 20, 2024
e9b838d
too many changes
Rick-Methot-NOAA Oct 4, 2024
33738c4
add HCR_anchor in forecast.ss
Rick-Methot-NOAA Oct 4, 2024
424f3c6
revert change in capitalization of Recr_Virgin
iantaylor-NOAA Oct 18, 2024
27d4095
latest update
Rick-Methot-NOAA Oct 17, 2024
f0bfa6f
go back to g++12.a
e-perl-NOAA Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
*.htp
*.obj
*.log
ss.tpl
ss3.tpl
ss_opt.tpl
ss_trans.tpl
Compile/ss.tpl
Compile/ss_opt.tpl
Compile/ss_trans.tpl
Compile/ss3.tpl
Compile/Make_SS_warn.bat
~$*.*
Compile/ss.log
Compile/ss3.log
Expand Down
227 changes: 137 additions & 90 deletions SS_benchfore.tpl

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions SS_global.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1270,10 +1270,10 @@ REPORT_SECTION
if (Do_TG > 0)
report << " TG-fleetcomp " << TG_like1 << endl
<< " TG-negbin " << TG_like2 << endl;
report << " -log(L): " << obj_fun << " Spbio: " << value(SSB_yr(styr)) << " " << value(SSB_yr(endyr)) << endl;
report << " -log(L): " << obj_fun << " SSBio: " << value(SSB_yr(styr)) << " " << value(SSB_yr(endyr)) << endl;

report << endl
<< "Year Spbio Recruitment" << endl;
<< "Year SSBio Recruitment" << endl;
report << "Virg " << SSB_yr(styr - 2) << " " << exp_rec(styr - 2, 4) << endl;
report << "Init " << SSB_yr(styr - 1) << " " << exp_rec(styr - 1, 4) << endl;
for (y = styr; y <= endyr; y++)
Expand Down
257 changes: 128 additions & 129 deletions SS_param.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,52 @@ INITIALIZATION_SECTION
PARAMETER_SECTION
// {
// SS_Label_Info_5.0.1 #Setup convergence critera and max func evaluations
LOCAL_CALCS
// clang-format on
// set the filename to all ADMB output files to "base_modelname.[ext]"
// where base_modelname can be read from command line with command modelname followed by text
// e.g. ss3_win.exe -nohess -stopph 3 modelname ss4you
// if requested modelname.par is not found, then will attempt to read from ss3.par then ss.par
// whatever name is read, the write will be to modelname.par. Which has default of ss3.par
ad_comm::adprogram_name = base_modelname;
echoinput << "Begin setting up parameters" << endl;
cout << "Begin setting up parameters ... ";
if (readparfile >= 1)
{
anystring = base_modelname + ".par";
cout << " read parm file: " << anystring << endl;

LOCAL_CALCS
// clang-format on
// set the filename to all ADMB output files to "base_modelname.[ext]"
// where base_modelname can be read from command line with command modelname followed by text
// e.g. ss3_win.exe -nohess -stopph 3 modelname ss4you
// if requested modelname.par is not found, then will attempt to read from ss3.par then ss.par
// whatever name is read, the write will be to modelname.par. Which has default of ss3.par
ad_comm::adprogram_name = base_modelname;
echoinput << "Begin setting up parameters" << endl;
cout << "Begin setting up parameters ... ";
if (readparfile >= 1) {
anystring = base_modelname + ".par";
cout << " read parm file: " << anystring << endl;

ifstream fin(anystring);
if (fin.fail()) {
cout << " no find, try ss3.par" << endl;
anystring = "ss3.par";
ifstream fin(anystring);
if(fin.fail() ) {
cout << " no find, try ss3.par" << endl;
anystring = "ss3.par";
ifstream fin(anystring);
if(fin.fail() ) {
if (fin.fail()) {
cout << " no find, try ss.par" << endl;
anystring = "ss.par";
ifstream fin(anystring);
if(fin.fail() ) {
warnstream << "could not find ss3.par, ss.par, or requested parfile " << base_modelname << ".par";
write_message(FATAL, 0);
if (fin.fail()) {
warnstream << "could not find ss3.par, ss.par, or requested parfile " << base_modelname << ".par";
write_message(FATAL, 0);
}
}}
cout << " found "<<anystring<<endl;

ad_comm::change_pinfile_name(anystring);
}
}

maximum_function_evaluations.allocate(func_eval.indexmin(), func_eval.indexmax());
maximum_function_evaluations = func_eval;
convergence_criteria.allocate(func_conv.indexmin(), func_conv.indexmax());
convergence_criteria = func_conv;
if (do_ageK == 1) // need for age-specific K
{
k = nages;
} // use for dimension of VBK()
else
{
k = 0;
}
// clang-format off
cout << " found " << anystring << endl;

ad_comm::change_pinfile_name(anystring);
}

maximum_function_evaluations.allocate(func_eval.indexmin(), func_eval.indexmax());
maximum_function_evaluations = func_eval;
convergence_criteria.allocate(func_conv.indexmin(), func_conv.indexmax());
convergence_criteria = func_conv;
if (do_ageK == 1) // need for age-specific K
{
k = nages;
} // use for dimension of VBK()
else {
k = 0;
}
// clang-format off
END_CALCS

!! // SS_Label_Info_5.0.2 #Create dummy_parm that will be estimated even if turn_off_phase is set to 0
Expand Down Expand Up @@ -112,23 +111,25 @@ PARAMETER_SECTION
4darray Save_PopBio(styr-3*nseas,TimeMax_Fcast_std+nseas,1,2*pop,1,gmorph,0,nages)

LOCAL_CALCS
// clang-format on
// If empirical wt-at-age is used, maturity and fecundity vectors are set to a distinctive value of 0.5
// If parameters are used, then the calcs could be age-based or length-based or both, so start with default value of 1.0
// These calculations happen in function get_mat_fec() in file SS_biofxn.tpl
if (WTage_rd == 1 || Maturity_Option == 4 || Maturity_Option == 5 ) {
mat_len = 0.5;
mat_age = 0.5;
mat_fec_len = 0.5;
fec_len = 0.5;
}
else {
mat_len = 1.0;
mat_age = 1.0;
mat_fec_len = 1.0;
fec_len = 1.0;
}
// clang-format off
// clang-format on
// If empirical wt-at-age is used, maturity and fecundity vectors are set to a distinctive value of 0.5
// If parameters are used, then the calcs could be age-based or length-based or both, so start with default value of 1.0
// These calculations happen in function get_mat_fec() in file SS_biofxn.tpl
if (WTage_rd == 1 || Maturity_Option == 4 || Maturity_Option == 5)
{
mat_len = 0.5;
mat_age = 0.5;
mat_fec_len = 0.5;
fec_len = 0.5;
}
else
{
mat_len = 1.0;
mat_age = 1.0;
mat_fec_len = 1.0;
fec_len = 1.0;
}
// clang-format off
END_CALCS

3darray age_age(0,N_ageerr+store_agekey_add,1,n_abins2,0,gender*nages+gender-1)
Expand Down Expand Up @@ -159,42 +160,40 @@ PARAMETER_SECTION
3darray recr_dist_endyr(1,N_GP*gender,1,N_settle_timings,1,pop);
!!// SS_Label_Info_5.1.2 #Create SR_parm vector, recruitment vectors
init_bounded_number_vector SR_parm(1,N_SRparm3,SR_parm_LO,SR_parm_HI,SR_parm_PH)
matrix SR_parm_byyr(styr-3,YrMax,1,N_SRparm2+1) // R0, steepness, parm3, sigmar, rec_dev_offset, R1, rho, SPB Time_vary implementation of spawner-recruitment
matrix SR_parm_byyr(styr-3,YrMax,1,N_SRparm2+1) // R0, steepness, parm3, sigmar, rec_dev_offset, R1, rho, SSB Time_vary implementation of spawner-recruitment
vector SR_parm_virg(1,N_SRparm2+1)
vector SR_parm_work(1,N_SRparm2+1)
number two_sigmaRsq;
number half_sigmaRsq;
number sigmaR;
number SPR_virgin;
number SSBpR_virgin;
number SSBpR_virgin_adj;
number regime_change;
number rho;
number dirichlet_Parm;
LOCAL_CALCS
// clang-format on
Ave_Size.initialize();
// if(SR_parm(N_SRparm2)!=0.0 || SR_parm_PH(N_SRparm2)>0) {SR_autocorr=1;} else {SR_autocorr=0;} // flag for recruitment autocorrelation
if (do_recdev == 1)
{
k = recdev_start;
j = recdev_end;
s = 1;
p = -1;
}
else if (do_recdev >= 2)
{
s = recdev_start;
p = recdev_end;
k = 1;
j = -1;
}
else
{
s = 1;
p = -1;
k = 1;
j = -1;
}
// clang-format off
// clang-format on
Ave_Size.initialize();
// if(SR_parm(N_SRparm2)!=0.0 || SR_parm_PH(N_SRparm2)>0) {SR_autocorr=1;} else {SR_autocorr=0;} // flag for recruitment autocorrelation
if (do_recdev == 1) {
k = recdev_start;
j = recdev_end;
s = 1;
p = -1;
}
else if (do_recdev >= 2) {
s = recdev_start;
p = recdev_end;
k = 1;
j = -1;
}
else {
s = 1;
p = -1;
k = 1;
j = -1;
}
// clang-format off
END_CALCS

// vector biasadj(styr-nages,YrMax) // biasadj as used; depends on whether a recdev is estimated or not
Expand All @@ -210,45 +209,45 @@ PARAMETER_SECTION
vector recdev(recdev_first,YrMax);

LOCAL_CALCS
// clang-format on
if (do_recdev == 0)
{
s = -1;
}
else
{
s = YrMax;
}
if (Do_Impl_Error > 0)
{
k = Fcast_recr_PH2;
j = YrMax;
}
else
{
k = -1;
j = -1;
}
// clang-format off
// clang-format on
if (do_recdev == 0) {
s = -1;
}
else {
s = YrMax;
}
if (Do_Impl_Error > 0) {
k = Fcast_recr_PH2;
j = YrMax;
}
else {
k = -1;
j = -1;
}
// clang-format off
END_CALCS
init_bounded_vector Fcast_recruitments(recdev_end+1,s,recdev_LO,recdev_HI,Fcast_recr_PH2)
init_bounded_vector Fcast_impl_error(endyr+1,j,-1,1,k)
vector ABC_buffer(endyr+1,YrMax);
number HCR_anchor // basis (denominator) for inflection in control rule. Select virgin SSB or benchmark SSB

// SPAWN-RECR: define some spawning biomass and recruitment entities
number SSB_virgin
number Recr_virgin
number SSB_vir_LH

number SSB_unf
number SSB_unf // SSB unfished, based on benchmark biology
number Recr_unf
number SSB_use
number R0_use; // annually updated value if SR_update_SSBpR0_timeseries == 1

number SSB_deplete // SSB that will be used as denominator for depletion calculations and as basis for control rule inflection
number SSB_current; // Spawning biomass
number SSB_equil;

number SPR_trial
number SPR_actual;
number SPR_temp; // used to pass quantity into Equil_SpawnRecr
number SSBpR_temp; // SSB per Recruit; used to pass quantity into Equil_SpawnRecr
number Recruits; // Age0 Recruits
number equ_mat_bio
number equ_mat_num
Expand Down Expand Up @@ -321,7 +320,7 @@ PARAMETER_SECTION
!!k=0;
!!if(Hermaphro_Option!=0) k=1;

3darray MaleSPB(styr-3,YrMax*k,1,pop,1,N_GP) //Male Spawning biomass
3darray MaleSSB(styr-3,YrMax*k,1,pop,1,N_GP) //Male Spawning biomass

matrix SSB_equil_pop_gp(1,pop,1,N_GP);
matrix MaleSSB_equil_pop_gp(1,pop,1,N_GP);
Expand Down Expand Up @@ -387,16 +386,15 @@ PARAMETER_SECTION


LOCAL_CALCS
// clang-format on
if (N_Fparm > 0) // continuous F
{
k = N_Fparm;
}
else
{
k = -1;
}
// clang-format off
// clang-format on
if (N_Fparm > 0) // continuous F
{
k = N_Fparm;
}
else {
k = -1;
}
// clang-format off
END_CALCS
// defining F_rate as number_vector allows for Fparm_PH to be element specific
init_bounded_number_vector F_rate(1,k,0.,max_harvest_rate,Fparm_PH_dim)
Expand All @@ -416,6 +414,7 @@ PARAMETER_SECTION
// note that bycatch_F(1,Nfleet,1,nseas) has similar role
number alpha;
number beta;
number steepness;
number GenTime;
number Yield;
number Adj4010;
Expand Down Expand Up @@ -491,9 +490,9 @@ PARAMETER_SECTION
number overdisp // overdispersion

LOCAL_CALCS
// clang-format on
k = Do_TG * (3 * N_TG + 2 * Nfleet1);
// clang-format off
// clang-format on
k = Do_TG * (3 * N_TG + 2 * Nfleet1);
// clang-format off
END_CALCS

init_bounded_number_vector TG_parm(1,k,TG_parm_LO,TG_parm_HI,TG_parm_PH);
Expand All @@ -506,12 +505,12 @@ PARAMETER_SECTION
matrix parm_timevary(1,timevary_cnt,styr-1,YrMax); // time series of adjusted parm values for block and trend

LOCAL_CALCS
// clang-format on
if (Do_Forecast > 0)
k = TimeMax_Fcast_std + nseas;
else
k = TimeMax + nseas;
// clang-format off
// clang-format on
if (Do_Forecast > 0)
k = TimeMax_Fcast_std + nseas;
else
k = TimeMax + nseas;
// clang-format off
END_CALCS

!!// SS_Label_Info_5.1.7 #Create arrays for storing derived selectivity quantities for use in mortality calculations
Expand Down Expand Up @@ -597,8 +596,8 @@ PARAMETER_SECTION
number equ_M_std

!!// SS_Label_Info_5.1.8 #Create matrix called smry to store derived quantities of interest
matrix Smry_Table(styr-3,YrMax,1,17);
// 1=totbio, 2=smrybio, 3=smrynum, 4=enc_catch, 5=dead_catch, 6=ret_catch, 7=spbio, 8=recruit,
matrix Smry_Table(styr-3,YrMax,1,20+2*gmorph);
// 1=totbio, 2=smrybio, 3=smrynum, 4=enc_catch, 5=dead_catch, 6=ret_catch, 7=SSBio, 8=recruit,
// 9=equ_totbio, 10=equ_smrybio, 11=equ_SSB_virgin, 12=equ_S1, 13=Gentime, 14=YPR, 15=meanage_spawners, 16=meanage_smrynums, 17=meanage_catch


Expand Down
Loading
Loading