Skip to content

Commit

Permalink
Merge pull request #184 from nmfs-stock-synthesis/fix_DM_index
Browse files Browse the repository at this point in the history
fix for erroroneous limit on D-M parameters
  • Loading branch information
Rick-Methot-NOAA authored Jun 15, 2021
2 parents f881019 + 3c2af89 commit 92c69ca
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 17 deletions.
23 changes: 18 additions & 5 deletions SS_readcontrol_330.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3106,13 +3106,27 @@

// SS_Label_Info_4.097 #Read parameters needed for estimating variance of composition data
{
echoinput<<"#Now count parameters for variance of composition data; CANNOT be time-varying"<<endl;
echoinput<<"#Now count parameters for D-M variance of composition data; CANNOT be time-varying"<<endl;
if(Comp_Err_ParmCount>0)
{
echoinput<<Comp_Err_ParmCount<<" #_parameters are needed"<<endl;
echoinput<<Comp_Err_ParmCount<<" #_parameters are needed: "<<DM_parmlist<<endl;
Comp_Err_Parm_Start=N_selparm;
// create a D-M parameter only for the first fleet that references that parm number

for(f=1;f<=Comp_Err_ParmCount;f++)
{N_selparm++; ParCount++; ParmLabel+="ln(DM_theta)_"+NumLbl(f);}
/*
for (f=1;f<=Nfleet;f++) {
if(Comp_Err_L2(f)>0){
if (DM_parmlist(f)==1) {
N_selparm++; ParCount++; ParmLabel+="ln(DM_theta)_Len_P"+NumLbl(Comp_Err_L2(f))+"("+NumLbl(f)+")";}}
}
for (f=1;f<=Nfleet;f++) {
if(Comp_Err_A2(f)>0){
if (DM_parmlist(f+Nfleet)==1) {
N_selparm++; ParCount++; ParmLabel+="ln(DM_theta)_Age_P"+NumLbl(Comp_Err_A2(f))+"("+NumLbl(f)+")";}}
}
*/
}
}

Expand Down Expand Up @@ -3159,13 +3173,12 @@
for (f = 1; f <= Nfleet; f++)
{
// if Dirichlet was indicated, set fleet for this parameter
if (Comp_Err_L(f) >0 && Comp_Err_L2(f) > 0)
if (Comp_Err_L2(f) > 0)
{
j = Comp_Err_Parm_Start + Comp_Err_L2(f);
selparm_fleet(j)=f;
}

if (Comp_Err_A(f) >0 && Comp_Err_A2(f) > 0)
if (Comp_Err_A2(f) > 0)
{
j = Comp_Err_Parm_Start + Comp_Err_A2(f);
selparm_fleet(j)=f;
Expand Down
41 changes: 32 additions & 9 deletions SS_readdata_330.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@
ivector Comp_Err_L2(1,Nfleet) // composition error type parameter location
vector min_sample_size_L(1,Nfleet) // minimum sample size
int Comp_Err_ParmCount; // counts number of fleets that need a parameter for the error estimation
ivector DM_parmlist(1,2*Nfleet);
LOCAL_CALCS
Comp_Err_ParmCount=0;
min_tail_L.initialize();
Expand All @@ -1064,6 +1065,7 @@
Comp_Err_L.initialize();
Comp_Err_L2.initialize();
min_sample_size_L.initialize();
DM_parmlist.initialize();
if(use_length_data>0)
{
Expand Down Expand Up @@ -1092,16 +1094,28 @@
N_warn++; warning<<N_warn<<" minimum sample size for length comps must be > 0; minimum sample size set to 0.001 "<<endl;
min_sample_size_L(f) = 0.001;
}
if (Comp_Err_L2(f) >Nfleet)
if (Comp_Err_L2(f) >2*Nfleet)
{
N_warn++; cout<<"fatal input error, see warning "<<endl; warning<<N_warn<<"; length D-M index for fleet: "<<f<<" is: "<<Comp_Err_L2(f)<<" but must be an integer <=2*Nfleet "<<endl;
exit(1);
}
else if(Comp_Err_L2(f)>Comp_Err_ParmCount+1)
{
N_warn++; cout<<"fatal input error, see warning "<<endl; warning<<N_warn<<"; length D-M index for fleet: "<<f<<" is: "<<Comp_Err_L2(f)<<" but must be an integer <=Nfleet "<<endl;
N_warn++; cout<<"fatal input error, see warning "<<endl;
warning<<N_warn<<"; length D-M must refer to existing parm num, or increment by 1: "<<Comp_Err_L2(f)<<endl;
exit(1);
}
else if(Comp_Err_L2(f)>Comp_Err_ParmCount)
{
Comp_Err_ParmCount++;
DM_parmlist(f)=1;
}
// else OK because refers to existing parameter
}
// get count of needed dirichlet composition parameters
// the count for age data will be added after reading the age data setup
Comp_Err_ParmCount=max(Comp_Err_L2);
echoinput<<"number of D-M parameters needed for length comp data: "<<Comp_Err_ParmCount<<endl<<endl;
*(ad_comm::global_datafile) >> nlen_bin;
echoinput<<nlen_bin<<" nlen_bin_for_data "<<endl;
}
Expand Down Expand Up @@ -1746,15 +1760,24 @@
N_warn++; warning<<N_warn<<" minimum sample size for age comps must be > 0; minimum sample size set to 0.001 "<<endl;
min_sample_size_A(f) = 0.001;
}
if (Comp_Err_A2(f) >Nfleet)
if (Comp_Err_A2(f) >2*Nfleet)
{
N_warn++; cout<<"fatal input error, see warning "<<endl; warning<<N_warn<<"; Age D-M index for fleet: "<<f<<" is: "<<Comp_Err_A2(f)<<" but must be an integer <=2*Nfleet "<<endl;
exit(1);
}
else if(Comp_Err_A2(f)>Comp_Err_ParmCount+1)
{
N_warn++; cout<<"fatal input error, see warning "<<endl; warning<<N_warn<<"; Age D-M index for fleet: "<<f<<" is: "<<Comp_Err_A2(f)<<" but must be an integer <=Nfleet "<<endl;
N_warn++; cout<<"fatal input error, see warning "<<endl;
warning<<N_warn<<"; Age D-M must refer to existing parm num, or increment by 1: "<<Comp_Err_A2(f)<<endl;
exit(1);
}
else if(Comp_Err_A2(f)>Comp_Err_ParmCount)
{
Comp_Err_ParmCount++;
DM_parmlist(f+Nfleet)=1;
}
// else OK because refers to existing parameter
}
// get count of needed dirichlet composition parameters
j=max(Comp_Err_A2);
Comp_Err_ParmCount=max(Comp_Err_ParmCount,j); // get the maximum parameter number referred to
echoinput<<"number of D-M parameters needed for length and age comp data: "<<Comp_Err_ParmCount<<endl;

*(ad_comm::global_datafile) >> Lbin_method;
Expand Down
2 changes: 1 addition & 1 deletion SS_versioninfo_330opt.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DATA_SECTION
!!// SS_Label_Section_1.0 #DATA_SECTION

!!// SS_Label_Info_1.1.1 #Create string with version info
!!version_info+="#V3.30.17.00;_2021_06_11;_fast;_Stock_Synthesis_by_Richard_Methot_(NOAA)_using_ADMB_12.3";
!!version_info+="#V3.30.17.01;_2021_06_15;_fast;_Stock_Synthesis_by_Richard_Methot_(NOAA)_using_ADMB_12.3";
!!version_info+="#Stock Synthesis (SS) is a work of the U.S. Government and is not subject to copyright protection in the United States.";
!!version_info+="#Foreign copyrights may apply. See copyright.txt for more information.";
!!version_info2+="#_user_support_available_at:NMFS.Stock.Synthesis@noaa.gov";
Expand Down
2 changes: 1 addition & 1 deletion SS_versioninfo_330safe.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DATA_SECTION
!!// SS_Label_Section_1.0 #DATA_SECTION

!!// SS_Label_Info_1.1.1 #Create string with version info
!!version_info+="#V3.30.17.00;_2021_06_11;_safe;_Stock_Synthesis_by_Richard_Methot_(NOAA)_using_ADMB_12.3";
!!version_info+="#V3.30.17.01;_2021_06_15;_safe;_Stock_Synthesis_by_Richard_Methot_(NOAA)_using_ADMB_12.3";
!!version_info+="#Stock Synthesis (SS) is a work of the U.S. Government and is not subject to copyright protection in the United States.";
!!version_info+="#Foreign copyrights may apply. See copyright.txt for more information.";
!!version_info2+="#_user_support_available_at:NMFS.Stock.Synthesis@noaa.gov";
Expand Down
2 changes: 1 addition & 1 deletion SS_versioninfo_330trans.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DATA_SECTION
!!// SS_Label_Section_1.0 #DATA_SECTION

!!// SS_Label_Info_1.1.1 #Create string with version info
!!version_info+="#V3.30.17.00;_2021_06_11;_trans;_Stock_Synthesis_by_Richard_Methot_(NOAA)_using_ADMB_12.3";
!!version_info+="#V3.30.17.01;_2021_06_15;_trans;_Stock_Synthesis_by_Richard_Methot_(NOAA)_using_ADMB_12.3";
!!version_info+="#Stock Synthesis (SS) is a work of the U.S. Government and is not subject to copyright protection in the United States.";
!!version_info+="#Foreign copyrights may apply. See copyright.txt for more information.";
!!version_info2+="#_user_support_available_at:NMFS.Stock.Synthesis@noaa.gov";
Expand Down
2 changes: 2 additions & 0 deletions SS_write_ssnew.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,7 @@ FUNCTION void write_nucontrol()
if(Comp_Err_ParmCount>0)
{
report4<<"#_Dirichlet parameters"<<endl;
report4<<"#_multiple_fleets_can_refer_to_same_parm;_but_list_cannot_have_gaps"<<endl;
k=Comp_Err_Parm_Start;
for(f=1;f<=Comp_Err_ParmCount;f++)
{
Expand All @@ -1921,6 +1922,7 @@ FUNCTION void write_nucontrol()
report4<<" # "<<ParmLabel(NP)<<endl;
}
}
else
{
report4<<"#_No_Dirichlet parameters"<<endl;
}
Expand Down

0 comments on commit 92c69ca

Please sign in to comment.