Skip to content

Commit 7b8801b

Browse files
Rick-Methot-NOAAe-perl-NOAA
authored andcommitted
add S-R option 10 for a,b formulation
revise to use WHAM syntax Srr=10 now matching SRR=3 adding reporting for timevary growth WIP augment spawn_recr report and use to test time-vary SR_parm approach adding benchmark change format changes for spawn_recr report refactor SPR to SSBpR; clean-up reference to timevary biology create new switch to control updating of SSBpR0 add HCR_anchor in forecast.ss revert change in capitalization of Recr_Virgin
1 parent d11d414 commit 7b8801b

14 files changed

+1584
-1901
lines changed

.gitignore

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
*.htp
88
*.obj
99
*.log
10-
ss.tpl
11-
ss3.tpl
12-
ss_opt.tpl
13-
ss_trans.tpl
10+
Compile/ss.tpl
11+
Compile/ss_opt.tpl
12+
Compile/ss_trans.tpl
13+
Compile/ss3.tpl
14+
Compile/Make_SS_warn.bat
1415
~$*.*
1516
Compile/ss.log
1617
Compile/ss3.log

Compile/Make_SS_warn.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ tpl2cpp ss3
2828

2929
g++ -c -std=c++17 -O2 -D_FILE_OFFSET_BITS=64 -DUSE_ADMB_CONTRIBS -D_USE_MATH_DEFINES -I. -I"C:\ADMB-13.2\include" -I"C:\ADMB-13.2\include\contrib" -Wall -Wextra -o ss3.obj ss3.cpp
3030

31-
g++ -static -o ss3.exe ss3.obj "C:\ADMB-13.2\lib\libadmb-contrib-mingw64-g++12.a"
31+
g++ -static -o ss3.exe ss3.obj "C:\ADMB-13.2\lib\libadmb-contrib-mingw64-g++13.a"
3232

3333
dir *.exe

SS_benchfore.tpl

+137-90
Large diffs are not rendered by default.

SS_global.tpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1270,10 +1270,10 @@ REPORT_SECTION
12701270
if (Do_TG > 0)
12711271
report << " TG-fleetcomp " << TG_like1 << endl
12721272
<< " TG-negbin " << TG_like2 << endl;
1273-
report << " -log(L): " << obj_fun << " Spbio: " << value(SSB_yr(styr)) << " " << value(SSB_yr(endyr)) << endl;
1273+
report << " -log(L): " << obj_fun << " SSBio: " << value(SSB_yr(styr)) << " " << value(SSB_yr(endyr)) << endl;
12741274

12751275
report << endl
1276-
<< "Year Spbio Recruitment" << endl;
1276+
<< "Year SSBio Recruitment" << endl;
12771277
report << "Virg " << SSB_yr(styr - 2) << " " << exp_rec(styr - 2, 4) << endl;
12781278
report << "Init " << SSB_yr(styr - 1) << " " << exp_rec(styr - 1, 4) << endl;
12791279
for (y = styr; y <= endyr; y++)

SS_param.tpl

+126-127
Original file line numberDiff line numberDiff line change
@@ -13,53 +13,52 @@ INITIALIZATION_SECTION
1313
PARAMETER_SECTION
1414
// {
1515
// SS_Label_Info_5.0.1 #Setup convergence critera and max func evaluations
16-
LOCAL_CALCS
17-
// clang-format on
18-
// set the filename to all ADMB output files to "base_modelname.[ext]"
19-
// where base_modelname can be read from command line with command modelname followed by text
20-
// e.g. ss3_win.exe -nohess -stopph 3 modelname ss4you
21-
// if requested modelname.par is not found, then will attempt to read from ss3.par then ss.par
22-
// whatever name is read, the write will be to modelname.par. Which has default of ss3.par
23-
ad_comm::adprogram_name = base_modelname;
24-
echoinput << "Begin setting up parameters" << endl;
25-
cout << "Begin setting up parameters ... ";
26-
if (readparfile >= 1)
27-
{
28-
anystring = base_modelname + ".par";
29-
cout << " read parm file: " << anystring << endl;
30-
16+
LOCAL_CALCS
17+
// clang-format on
18+
// set the filename to all ADMB output files to "base_modelname.[ext]"
19+
// where base_modelname can be read from command line with command modelname followed by text
20+
// e.g. ss3_win.exe -nohess -stopph 3 modelname ss4you
21+
// if requested modelname.par is not found, then will attempt to read from ss3.par then ss.par
22+
// whatever name is read, the write will be to modelname.par. Which has default of ss3.par
23+
ad_comm::adprogram_name = base_modelname;
24+
echoinput << "Begin setting up parameters" << endl;
25+
cout << "Begin setting up parameters ... ";
26+
if (readparfile >= 1) {
27+
anystring = base_modelname + ".par";
28+
cout << " read parm file: " << anystring << endl;
29+
30+
ifstream fin(anystring);
31+
if (fin.fail()) {
32+
cout << " no find, try ss3.par" << endl;
33+
anystring = "ss3.par";
3134
ifstream fin(anystring);
32-
if(fin.fail() ) {
33-
cout << " no find, try ss3.par" << endl;
34-
anystring = "ss3.par";
35-
ifstream fin(anystring);
36-
if(fin.fail() ) {
35+
if (fin.fail()) {
3736
cout << " no find, try ss.par" << endl;
3837
anystring = "ss.par";
3938
ifstream fin(anystring);
40-
if(fin.fail() ) {
41-
warnstream << "could not find ss3.par, ss.par, or requested parfile " << base_modelname << ".par";
42-
write_message(FATAL, 0);
39+
if (fin.fail()) {
40+
warnstream << "could not find ss3.par, ss.par, or requested parfile " << base_modelname << ".par";
41+
write_message(FATAL, 0);
4342
}
44-
}}
45-
cout << " found "<<anystring<<endl;
46-
47-
ad_comm::change_pinfile_name(anystring);
43+
}
4844
}
49-
50-
maximum_function_evaluations.allocate(func_eval.indexmin(), func_eval.indexmax());
51-
maximum_function_evaluations = func_eval;
52-
convergence_criteria.allocate(func_conv.indexmin(), func_conv.indexmax());
53-
convergence_criteria = func_conv;
54-
if (do_ageK == 1) // need for age-specific K
55-
{
56-
k = nages;
57-
} // use for dimension of VBK()
58-
else
59-
{
60-
k = 0;
61-
}
62-
// clang-format off
45+
cout << " found " << anystring << endl;
46+
47+
ad_comm::change_pinfile_name(anystring);
48+
}
49+
50+
maximum_function_evaluations.allocate(func_eval.indexmin(), func_eval.indexmax());
51+
maximum_function_evaluations = func_eval;
52+
convergence_criteria.allocate(func_conv.indexmin(), func_conv.indexmax());
53+
convergence_criteria = func_conv;
54+
if (do_ageK == 1) // need for age-specific K
55+
{
56+
k = nages;
57+
} // use for dimension of VBK()
58+
else {
59+
k = 0;
60+
}
61+
// clang-format off
6362
END_CALCS
6463

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

114113
LOCAL_CALCS
115-
// clang-format on
116-
// If empirical wt-at-age is used, maturity and fecundity vectors are set to a distinctive value of 0.5
117-
// If parameters are used, then the calcs could be age-based or length-based or both, so start with default value of 1.0
118-
// These calculations happen in function get_mat_fec() in file SS_biofxn.tpl
119-
if (WTage_rd == 1 || Maturity_Option == 4 || Maturity_Option == 5 ) {
120-
mat_len = 0.5;
121-
mat_age = 0.5;
122-
mat_fec_len = 0.5;
123-
fec_len = 0.5;
124-
}
125-
else {
126-
mat_len = 1.0;
127-
mat_age = 1.0;
128-
mat_fec_len = 1.0;
129-
fec_len = 1.0;
130-
}
131-
// clang-format off
114+
// clang-format on
115+
// If empirical wt-at-age is used, maturity and fecundity vectors are set to a distinctive value of 0.5
116+
// If parameters are used, then the calcs could be age-based or length-based or both, so start with default value of 1.0
117+
// These calculations happen in function get_mat_fec() in file SS_biofxn.tpl
118+
if (WTage_rd == 1 || Maturity_Option == 4 || Maturity_Option == 5)
119+
{
120+
mat_len = 0.5;
121+
mat_age = 0.5;
122+
mat_fec_len = 0.5;
123+
fec_len = 0.5;
124+
}
125+
else
126+
{
127+
mat_len = 1.0;
128+
mat_age = 1.0;
129+
mat_fec_len = 1.0;
130+
fec_len = 1.0;
131+
}
132+
// clang-format off
132133
END_CALCS
133134

134135
3darray age_age(0,N_ageerr+store_agekey_add,1,n_abins2,0,gender*nages+gender-1)
@@ -159,42 +160,40 @@ PARAMETER_SECTION
159160
3darray recr_dist_endyr(1,N_GP*gender,1,N_settle_timings,1,pop);
160161
!!// SS_Label_Info_5.1.2 #Create SR_parm vector, recruitment vectors
161162
init_bounded_number_vector SR_parm(1,N_SRparm3,SR_parm_LO,SR_parm_HI,SR_parm_PH)
162-
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
163+
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
163164
vector SR_parm_virg(1,N_SRparm2+1)
164165
vector SR_parm_work(1,N_SRparm2+1)
165166
number two_sigmaRsq;
166167
number half_sigmaRsq;
167168
number sigmaR;
168-
number SPR_virgin;
169+
number SSBpR_virgin;
170+
number SSBpR_virgin_adj;
169171
number regime_change;
170172
number rho;
171173
number dirichlet_Parm;
172174
LOCAL_CALCS
173-
// clang-format on
174-
Ave_Size.initialize();
175-
// if(SR_parm(N_SRparm2)!=0.0 || SR_parm_PH(N_SRparm2)>0) {SR_autocorr=1;} else {SR_autocorr=0;} // flag for recruitment autocorrelation
176-
if (do_recdev == 1)
177-
{
178-
k = recdev_start;
179-
j = recdev_end;
180-
s = 1;
181-
p = -1;
182-
}
183-
else if (do_recdev >= 2)
184-
{
185-
s = recdev_start;
186-
p = recdev_end;
187-
k = 1;
188-
j = -1;
189-
}
190-
else
191-
{
192-
s = 1;
193-
p = -1;
194-
k = 1;
195-
j = -1;
196-
}
197-
// clang-format off
175+
// clang-format on
176+
Ave_Size.initialize();
177+
// if(SR_parm(N_SRparm2)!=0.0 || SR_parm_PH(N_SRparm2)>0) {SR_autocorr=1;} else {SR_autocorr=0;} // flag for recruitment autocorrelation
178+
if (do_recdev == 1) {
179+
k = recdev_start;
180+
j = recdev_end;
181+
s = 1;
182+
p = -1;
183+
}
184+
else if (do_recdev >= 2) {
185+
s = recdev_start;
186+
p = recdev_end;
187+
k = 1;
188+
j = -1;
189+
}
190+
else {
191+
s = 1;
192+
p = -1;
193+
k = 1;
194+
j = -1;
195+
}
196+
// clang-format off
198197
END_CALCS
199198

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

212211
LOCAL_CALCS
213-
// clang-format on
214-
if (do_recdev == 0)
215-
{
216-
s = -1;
217-
}
218-
else
219-
{
220-
s = YrMax;
221-
}
222-
if (Do_Impl_Error > 0)
223-
{
224-
k = Fcast_recr_PH2;
225-
j = YrMax;
226-
}
227-
else
228-
{
229-
k = -1;
230-
j = -1;
231-
}
232-
// clang-format off
212+
// clang-format on
213+
if (do_recdev == 0) {
214+
s = -1;
215+
}
216+
else {
217+
s = YrMax;
218+
}
219+
if (Do_Impl_Error > 0) {
220+
k = Fcast_recr_PH2;
221+
j = YrMax;
222+
}
223+
else {
224+
k = -1;
225+
j = -1;
226+
}
227+
// clang-format off
233228
END_CALCS
234229
init_bounded_vector Fcast_recruitments(recdev_end+1,s,recdev_LO,recdev_HI,Fcast_recr_PH2)
235230
init_bounded_vector Fcast_impl_error(endyr+1,j,-1,1,k)
236231
vector ABC_buffer(endyr+1,YrMax);
232+
number HCR_anchor // basis (denominator) for inflection in control rule. Select virgin SSB or benchmark SSB
237233

238234
// SPAWN-RECR: define some spawning biomass and recruitment entities
239235
number SSB_virgin
240236
number Recr_virgin
241237
number SSB_vir_LH
242238

243-
number SSB_unf
239+
number SSB_unf // SSB unfished, based on benchmark biology
244240
number Recr_unf
241+
number SSB_use
242+
number R0_use; // annually updated value if SR_update_SSBpR0_timeseries == 1
245243

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

249248
number SPR_trial
250249
number SPR_actual;
251-
number SPR_temp; // used to pass quantity into Equil_SpawnRecr
250+
number SSBpR_temp; // SSB per Recruit; used to pass quantity into Equil_SpawnRecr
252251
number Recruits; // Age0 Recruits
253252
number equ_mat_bio
254253
number equ_mat_num
@@ -321,7 +320,7 @@ PARAMETER_SECTION
321320
!!k=0;
322321
!!if(Hermaphro_Option!=0) k=1;
323322

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

326325
matrix SSB_equil_pop_gp(1,pop,1,N_GP);
327326
matrix MaleSSB_equil_pop_gp(1,pop,1,N_GP);
@@ -387,16 +386,15 @@ PARAMETER_SECTION
387386

388387

389388
LOCAL_CALCS
390-
// clang-format on
391-
if (N_Fparm > 0) // continuous F
392-
{
393-
k = N_Fparm;
394-
}
395-
else
396-
{
397-
k = -1;
398-
}
399-
// clang-format off
389+
// clang-format on
390+
if (N_Fparm > 0) // continuous F
391+
{
392+
k = N_Fparm;
393+
}
394+
else {
395+
k = -1;
396+
}
397+
// clang-format off
400398
END_CALCS
401399
// defining F_rate as number_vector allows for Fparm_PH to be element specific
402400
init_bounded_number_vector F_rate(1,k,0.,max_harvest_rate,Fparm_PH_dim)
@@ -416,6 +414,7 @@ PARAMETER_SECTION
416414
// note that bycatch_F(1,Nfleet,1,nseas) has similar role
417415
number alpha;
418416
number beta;
417+
number steepness;
419418
number GenTime;
420419
number Yield;
421420
number Adj4010;
@@ -491,9 +490,9 @@ PARAMETER_SECTION
491490
number overdisp // overdispersion
492491

493492
LOCAL_CALCS
494-
// clang-format on
495-
k = Do_TG * (3 * N_TG + 2 * Nfleet1);
496-
// clang-format off
493+
// clang-format on
494+
k = Do_TG * (3 * N_TG + 2 * Nfleet1);
495+
// clang-format off
497496
END_CALCS
498497

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

508507
LOCAL_CALCS
509-
// clang-format on
510-
if (Do_Forecast > 0)
511-
k = TimeMax_Fcast_std + nseas;
512-
else
513-
k = TimeMax + nseas;
514-
// clang-format off
508+
// clang-format on
509+
if (Do_Forecast > 0)
510+
k = TimeMax_Fcast_std + nseas;
511+
else
512+
k = TimeMax + nseas;
513+
// clang-format off
515514
END_CALCS
516515

517516
!!// SS_Label_Info_5.1.7 #Create arrays for storing derived selectivity quantities for use in mortality calculations

0 commit comments

Comments
 (0)