Closed iantaylor-NOAA closed 3 years ago
starting work on this new feature.
[x] re-work of the input for M parameters and setup. DONE
[x] move get_wtlen(), which includes maturity, ahead of get_natmort() because Maunder's M depends on maturity
[x] create algorithm for the needed number of parameters
get code working currently calculating age-maturity from length maturity parameters in the natM code section but using mean length-at-age rather than integrating over the length distribution. This caused need to make array age-maturity dimensioned with Gpat*sex, rather than just by Gpat. This also prevents the new code from using the length-maturity vector directly, which is a shortcoming. Also prevents using direct calculation of age maturity. Code for fecundity could be a prototype for improvement. Doing a prelim commit of the branch now.
revised the order of operations for growth, maturity and M to be as below. Realize this causes an order of operations problem that may require M to be first, as it was before. The issue is:
1) mean length-at-age in the plus group depends upon M in the start year because fish keep growing in the plus group. 2) maturity at age depends upon length-at-age 3) M depends upon maturity at age 4) oops - that's circular
So, I think that implementing your M will require restricting it to model configurations that do not link maturity to length and growth.
Pushing this version of the new natmort branch, but further work on this OOO problem is needed. Tested the current revised OOO using Steve Barbeaux's cod model with env links for M and growth, so a strong test.
ALK_subseas_update=1; // this is a vector by ALK_IDX; fill with "1" indicates that all ALKs will need re-estimation
get_growth2(y); // does all seasons
get_wtlen(); // does all seasons
// do spawnseas, spawn_subseas update // s=spawn_seas; // subseas=spawn_subseas; t=t_base+spawn_seas; get_growth3(y,t,spawn_seas,spawn_subseas); Make_AgeLength_Key(spawn_seas,spawn_subseas); // spawn subseas get_mat_fec(); // does only spawn_seas if(Hermaphro_Option!=0) get_Hermaphro(); }
if(timevary_MG(y,1)>0) get_natmort();
The changes to maturity-fecundity calculations appear to be working. The code was already doing M after growth so perhaps my concerns about OOO are unfounded. The current test code has M after maturity-fecundity and appears to run fine for old examples and not have any problem with variance of biology parameters. Some more bigger changes are: change 4darray save_sel_fec(styr-3*nseas,TimeMax_Fcast_std+nseas,0,Nfleet,1,gmorph,0,nages) // save sel_al_3 (Asel_2) and save fecundity for output; +nseas covers no forecast setups
to 4darray save_sel_fec(0,Nfleet,styr-3*nseas,TimeMax_Fcast_std+nseas,1,gmorph,0,nages) // save sel_al_3 (Asel_2) and save fecundity for output; +nseas covers no forecast setups
to make referencing the last 2 dimensions easier. More changes like this will come later.
Also, in get_mat_fec, start using a shallow copy for similar improve in efficiency: dvar_matrix ALK_w=ALK(ALK_idx,g); // shallow copy so the matrix ALK_w is easier to address than the full 4Darray ALK()
Just realized another fringe case to deal with. If growth or maturity is time-varying and Maunder's M links to maturity, then the time-varying flag for M needs to be turned on. The way to do this is when the timevary flags are created. I will deal with this after the merge as a tune-up to the new M code
Just realized another fringe case to deal with. If growth or maturity is time-varying and Maunder's M links to maturity, then the time-varying flag for M needs to be turned on. The way to do this is when the timevary flags are created. I will deal with this after the merge as a tune-up to the new M code
@Rick-Methot-NOAA , good catch. could an error msg with informative msg be provided for the fringe case in the meantime? Hopefully this could be quickly added until there is time available to work on the fringe case.
Not yet. We really need to lean on Mark and his team to document and test. This is a Beta feature at best right now.
On Thu, Apr 29, 2021 at 9:12 AM Kathryn Doering @.***> wrote:
Just realized another fringe case to deal with. If growth or maturity is time-varying and Maunder's M links to maturity, then the time-varying flag for M needs to be turned on. The way to do this is when the timevary flags are created. I will deal with this after the merge as a tune-up to the new M code
@Rick-Methot-NOAA https://github.com/Rick-Methot-NOAA , good catch. could an error msg with informative msg be provided for the fringe case in the meantime? Hopefully this could be quickly added until there is time available to work on the fringe case.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nmfs-stock-synthesis/stock-synthesis/issues/102#issuecomment-829372817, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPV4IHTU3ODIGR5FZC4F6LTLGANNANCNFSM4T2WJQBA .
Email from Mark Maunder (part of larger conversation with Rick with the same subject line as this issue):
Attached file includes Mark's changes (renamed to .txt because github doesn't support .tpl attachments): natmort.tpl.txt