-
Notifications
You must be signed in to change notification settings - Fork 1
History of code updates
The following repeats the update notes in the gamcsbase.tpl file (some changes may be on development branches not yet merged into main):
// =========================================================================================
// 2020-01-16; Added index to survey data
// 2020-01-17; Added checks for missing length data
// 2020-01-17; Added ability to specify maturity state for indices
// 2020-01-17; Moved specification of length-class numbers by sex to the DAT file
// 2020-01-17; Deleted the custom M option
// 2020-01-17; Added (partially) double normal - completed ???
// 2020-01-17; Added mirroring of selectivity
// 2020-01-17; CTL labeling initiated.
// 2020-01-17; Recruitment sex-ratio can be specified
// 2020-01-18; Bug file for Selex type 1 (generalized to nclass lengths)
// 2020-01-18; Check that transition matrix in growth data is correct
// 2020-01-20; Added declining logistc (NSRKC)
// 2020-01-20; Added jittering
// 2020-01-21; Added ppSLX to reduce overhead with Selex class objects
// 2020-01-22; Added output to terminal when model quits after StopAfterFnCall function calls
// 2020-01-25; Added a jitter option
// 2020-01-2x; Added cubic spline selex + retention
// 2020-01-28; Added SelectivitySpline class to selex.hpp and new file gsm_splines.hpp
// 2020-01-27; Added mean and CV to recruitment
// Merging Nov-Dec 2021
// 2021-01-14; Bug-fix mirrored parameters
// 2021-01-14; Fixed parameter count for uniform selex
// 2021-01-16; Updated penalty for rec_devs when you select the unfished option
// 2021-01-24; Bug-fix - included first rec_dev in the penalty
// 2021-03-09; Added SurveyType (1=total selectivity; 2=retention*selectivity)
// 2021-03-09; Indices can be any time during a time-step
// 2021-11-22; Add ability to mirror additional variance parameters (new inputs)
// 2021-11-22; fixed analytical Q estimation
// 2021-11-26; Included catch-based comp predictions (new inputs)
// 2021-11-29; New penalty on Fdevs and Fdovs
// 2021-11-29; Tidied up the output
// 2021-11-29; Corrected tagging likelihood
// 2021-12-01; Ability to switch of reference point calculation added
// 2021-12-01; Ability to number of years when computing equilibria added
// 2021-12-02; Ability to weight penalties by fleet added
// 2021-12-02; Ability to select only some derived variables to compute added
// 2021-12-03; Added the derived outputs (and SDs) to gmacsall,out
// 2021-12-03; Added projection-related inputs
// 2021-12-16; Checked the _in files (and corrected a minor error)
// 2021-12-18; Worked on retrospective analysis
// 2022-01-10; Corrected bug that impacted surveys
// 2022-01-12; Improved output of data
// 2022-01-13; Started Hamachan version of dynamics
// 2022-01-14; (Version 2.01.B); Fixed bug with OFL and ABC calculation; added headers ti output files
// 2022-01-14; (Version 2.01.B); Dump file for projections
// 2022-01-15; (Version 2.01.C); Hamachan's one-parameter logistic selectivity curve
// 2022-01-24; (Version 2.01.D); Added new dnorm function
// 2022-02-18; (Version 2.01.E); Fixed selectivity to allow for fixing (or not) the maximum selex to 1
// 2022-04-15; (Version 2.01.F); Corrected the Gmacs_in.Ctl AND protected MLAState
// 2022-04-21; (Version 2.01.F); update of the calc_predicted_composition function to properly include catch-based comp prediction
// 2022-05-06; (Version 2.01.G); Incorporate tiime varying natural mortality and work on the calc_predicted_composition function
// 2022-05-19; (Version 2.01.H); Corrected calculation of FOFL and output for dynamic B0
// 2022-05-24; (Version 2.01.I); Bug-fix - Correct the phase for selectivity parameter when slx_type(k) <0
// 2022-06-05; (Version 2.01.I); Bug-fix - Correct the condition on fhit in calc_brute_equilibrium() and the tempZ1 used in calc_predicted_project()
// 2022-06-06; (Version 2.01.J); Option to consider terminal molting added (new input in .CTL file => cf OTHER CONTROLS)
// 2022-06-06; (Version 2.01.K); Option to calculate the average recruitment used for reference points added (new input in .CTL file => cf OTHER CONTROLS)
// 2022-06-27; (Version 2.01.L); Update catch likelihood function to use dnorm(). Clean a bit the code and fix a small // bug in the calc_predicted_project function (inverse season_type in the computation of tempZ1)
// 2022-10-31 ** WTS ** (Version to 2.01.WTS) - 1. Added commandline input flag "testingflag" to turn on sandbox - 2. Added alternative data file reader (TCSAM02 format)
// 2022-11-16 ** WTS ** (Version to 2.01.WTS) - 1. Added lots of diagnostic output when reading input files - 2. Added ECHOSTR, WriteCtlStr, WriteProjStr macros for 1 // - 3. Reformatted calc_relative_abundance in preparation for adding ability to handle immature data
// 2022-12-22 ** MV ** (Version to 2.01.L02) - 1. Fix a small bug in calc_natural_mortality() - 2. Rename WTS's version - 3. Modify the DatFileReader.cpp to make it // compatible with different OS - Fix a small bug in the control file section (MrelFem)
// 2022-12-31 ** MV ** (Version to 2.01.L03) - 1. Add the simulation approach developped by AE- AE modified the code so initial values for selex is not re-set in the PARAMETER_SECTION
// 2023-01-17 ** AEP ** (Version to 2.01.L04) - 1. Corrected the override of the initialization of selectivity
// 2023-02-4 ** MV ** (Version to 2.01.L04) - 1. Small changes in the Format of the gmacsAll.out // ================================================ //
// 2023-03-20 ** MV ** (Upgrade GMACS to version 2.01.M) - 1. Add the developed code by ** AEP ** to read in environmental data and modify his // version of the code to make it working with all stocks (bug in the loop while counting the // number of selectivity parameters). // - 2. Add the developped code by ** AEP ** to incorporate potential random walk in the selectivity parameters. Modify the initial code to // make it more flexible. Need to be updated to allow environmental impacts not being dependent upon time period of random walk. // ================================================ //
// 2023-03-23 ** MV ** (Upgrade GMACS to version 2.01.M.01) - 1. Fixed a bug in the checking section of the inputs for the growth maxtrix and growth increment model
// 2023-05-30 ** AEP. (Upgrade GMACS to version 2.01.M.02) Added labels for model output and GMACSALL.STD, mature abundance (SSBA) and fixed some bugs in the calculaton of Francis weights.
// 2024-01-08 ** AEP. (Updated GMACS to version 2.01.M.03) (a) Corrected a bug with labels for selectivity; (b) Tag emphasis can be real; (c) merged Cody changes wrt time-varying molt probability and functional maturity;
// 2024-01-09 ** AEP. (Updated GMACS to version 2.01.M.04) (a) added output for the weight units, (b) moved where last functional call, last phase and calculate reference points occurs
// 2024-01-09 ** AEP. (Updated GMACS to version 2.01.M.05) (a) fixed indexing for matrix-based weight-at-length; (b) maturity-specific length-weight, (c) formatted output for gmacsall.out, (d) added OFLs by fleet to gmacsall.out
// 2024-01-10 ** AEP. (Updated GMACS to version 2.01.M.06) (a) modified to output projected catches, (b) calculated historical mortality for projections
// 2024-01-11 ** AEP. (Updated GMACS to version 2.01.M.07) (a) updated the _in files to match the latest version of GMACS. (b) producted inputs files with estimated parameters and expected data
// 2024-01-29 ** AEP. (Updated GMACS to version 2.01.M.08) Fixed time-varying growth increment and added a trap for negative growth increments in fn calls 0 and 1
// 2024-02-01 ** WTS. (Updated GMACS to version 2.01.M.09) Added alternative format for inputting size comps data.
// 2024-02-02 ** WTS. Renamed BOTHSEX, BOTHMATURE to UNDET_SEX, UNDET_MATURE. Added MALES(=1) macro. Need to refactor MALESANDCOMBINED functionality. // Removed MALESANDCOMBINED (duplicated MALES). Refactored selectivity assignments and recruitment (no need to loop over h, so cleaner not to). // Reformatted some code to add parentheses, replace tabs with spaces, and correctly indent blocks. // Replaced o == 1/2 with o == NEW_SHELL/OLD_SHELL, similar for m.
// 2024-02-05 ** WTS. Reverted selectivity assignaments--needed to loop over h if slx_isex(k) was 0. Added alternative input format for fishery catch data.
// 2024-02-29 ** AEP. (Updated GMACS to version 2.01.M.10) (a) corrected error wrt retrospective patterns and catch re-in, (d) adding units to read-in, and (c) output selex andgradient output.
// 2024-03-03 ** AEP. (Updated GMACS to versions 2.10) (Corrected the terminal molt)
// 2024-03-04 ** AEP. (Updated GMACS to versions 2.10.01) (Added immature N matrices)
// 2024-03-06 ** AEP. (Updated GMACS to versions 2.10.02) (Change projections and OFL sections to use the genetic season update code and fixed a projection error for the propotional F case)
// 2024-03-07 ** AEP. (Updated GMACS to versions 2.10.03) (a) Moved the read-in of the general controls to the start of the CTL file, and (b) replaced the read-in of ntheta by its calculation
// 2024-03-08 ** AEP. (Updated GMACS to versions 2.10.04) (a) Improved speed for the Hessian inversion stage by making loops more efficient, and (b) corrected the projection component of the code
// 2024-03-12 ** AEP. (Updated GMACS to versions 2.10.05) Changed read-in for q and add_cv to allow for generic parameter structure
// 2024-03-26 ** AEP. Fixed stock-recruitment bug for two sex models and models with terminal molt
// 2024-03-28 ** WTS. Added PWRLAW_GROWTHMODEL as alternative to LINEAR_GROWTHMODEL
// 2024-03-29 ** AEP. (Updated GMACS to version 2.20.00) Updated read-in for selectivity, M, growth, additional variance, Q and overdispersion
// 2024-03-29 ** AEP. (Updated GMACS to version 2.20.01) Standardized how priors are handled
// 2024-03-31 ** WTS. (Updated GMACS to version 2.20.02) Added extra info to error messages when using alternative dat file format.
// 2024-04-01 ** WTS. For the PWRLAW_GROWTHMODEL, the input definition for the parameter corresponding to gscale is on the ln-scale, // so it is exponentiated when assigning G_pars(3) to gscale. // Changed format of output of block_limits to gmacs_ctl to column form.
// 2024-04-01 ** AEP. (Updated GMACS to version 2.20.03) Tidied up output labels (GMACS_IN and GMACS_OUT).
// 2024-04-02 ** AEP. (Updated GMACS to version 2.20.04) Tidied up penalties (added back one that was commented out)
// 2024-04-02 ** AEP. (Updated GMACS to version 2.20.05) Added new pre-specified selectivity option (11)
// 2024-04-03 ** AEP. (Updated GMACS to version 2.20.06) Added a smoothness penalty to spline selectivity and now output Fs and recruitent to gmacs_out.ctl
// 2024-04-03 ** WTS. Growth transition matrix scale parameter is on l-scale when molt bUseGrowthIncrementModel2==PWRLAW_GROWTHMODEL
// 2024-04-04 ** AEP. Added exit(1) condition when M_relative(ig==1)!=0 after flagging error condition (M specification for first group can't be relative).
// 2024-04-04 ** WTS. Fixed issues with parameter specification when mirroring survey catchability and/or additional survey cv. // Cleaned up compiler warnings by changing " & " and " | " to "&& " and " || ", respectively. // Added missing immature crab use case for survey abundance/biomass calculations. // Fixed issues with prior density calculations when mirroring q's or additional cv's. // Added additional diagnostics for verbose>10. // (Updated GMACS to version 2.20.07).
// 2024-04-05 ** WTS. Revised Gmacsall.out formats to play nice with R. Also developed R code to read and create a list object from the .out file.
// 2024-05-08 ** WTS. Changed leading dimension of log_vn_pars, log_vn_lb, log_vn_ub, log_vn_phz, prior_log_vn_type, prior_log_vn_p1, and // prior_log_vn_p2 from nSizeComps_in (the number of input size comps) to nSizeComps (the number of size comps // after "aggregation") to better match the number of effective sample size parameters. nAgeCompType_in and // nAgeCompType were renamed iSizeCompType_in and iSizeCompType, respectively. // (Updated GMACS to version 2.20.08). // Added N for females by maturity state and shell condition to Gmacsall.out as dataframe with males.
// 2024-05-08 ** WTS. Defined RepFile1 as outstream to "gmacs.rep1". Changed REPORT and REPORT2 macros to REPVEC and REPVEC2 macros for // vector (or scalar) quantities and added output to RepFile1. Added REPMAT and REPMAT2 mamcros to output matrices // to OutFile1 (Gmacsall.out), OutFile2 (gmacs.rep), and RepFile1. Added FUNCTIONs to_str and strg to create an adstring // representation of a space-separated vector (simplifies code to write a vector to a file).
// 2024-05-10 ** WTS. Added more output to RepFile1. Added explicit "Status" column to Summary section of Gmacsall.out to indicate whether // parameter estimate was close to lower bound ("-"), upper bound ("+"), or neither ("ok"). // Changed "pen_fbar", "log_pen_fbar", and "log_pen_fbar_off" to "init_fbar", "log_init_fbar", and "log_init_fbar_foff" // to better clarify their purpose. // TODO: "log_init_fbar_foff" (column 2 of F controls) is never used anywhere. It should be removed from the ctl file.
// 2024-05-11 ** WTS. Revised size fit summary to RepFile1 (gmacs.rep1), added mapInpToAggSizeComps matrix which provides mapping from input size comps to // aggregated size comps (and is used in then revised size fit summary). // (Updated GMACS version to 2.20.09.)
// 2024-05-12 ** WTS. Added commandline option ("-jitter rseed") to override gmacs.dat setting. If rseed is 0, rseed is set based on the model start time. // The value of rseed used to initialize the random number generator is written to "jitter.txt" to allow repeating a jittered model run. // (Updated GMACS version to 2.20.10.)
// 2024-04-13 ** WTS. Added initialization of log_foff to log_init_fbar_foff in INIATIALIZATION section (otherwise it initialized to 0).
// Added likelihood penalty for ln-scale mean female offset to nlogPenalty(2) similar to ln-scale mean for males (search on '20240413').
// Added fishing mortality parameters output to Rep1File.
// Updated GMACS version to 2.20.11.
// 2024-04-22 ** AEP. Added bias-ramp for recruitment deviations.
// 2024-05-10 ** WTS. Added alternative format for environmental time series data in the dat file.
// 2024-05-14 ** AEP. (Updated GMACS to version 2.20.12) Extended initial conditions to allow reference length to pre-specified.
// 2024-05-16 ** AEP. (Updated GMACS to version 2.20.13) F-penalty applies to all seasons (not just season 2)
// 2024-05-20 ** WTS. Added commandline option to make a retrospective run using "-retro XX", where XX is the number of years to peel off.
// 2024-06-26 ** AEP. Added the ability to set Q for size-composition data
// 2024-06-27 ** AEP. (Updated GMACS to version 2.20.15) Corrected the way tail compression is implemented and added a pmin input
// 2024-07-02 ** WTS. Corrected scaling of input size comps so relative proportions of appended size comps always agree with // relative proportions of input sample sizes. Added ECHOs when verbose >=3 for d3_pre_size_comps_in and d3_pre_size_comps.
// 2024-07-23 ** WTS. (Updated GMACS to version 2.20.16) Added Dirichlet-Multinomial alternative calculation using iSizeCompType_in=6. Added // comparison of input/output sample sizes to Gmacsall.out file.
// 2024-07-24 ** WTS. Resolved issue in FINAL_SECTION with deleting ppSLX. nsel_use is the size of ppSLX (the number of selectivity defined),
// not nsel_patterns.
// 2024-10-22 ** WTS. (GMACS Version 2.20.17) Explicitly set n_deviations = 0 after declaration. // Added ECHOs for n_deviations at various stages of counting as diagnostics.
// 2024-11-07 ** WTS. (GMACS Version 2.20.17) Add a lot of verbose>3 cout's to calc_predicted_composition to diagnose ctl file problem specifiying aggregations.
// 2025-01-14 ** AEP. (GMACS Version 2.20.18) Split the Fmsy for Tier 4 between fleets
// 2025-01-15 ** AEP. (GMACS Version 2.20.18) Added the floor spline selectivity pattern and the stacked logistic selectivity pattern
// 2025-01-30 ** AEP. (GMACS Version 2.20.20) Updated the weight aggregated comps are computed.
// 2025-02-15 ** MV. (GMACS Version 2.20.21) Corrected indexing error for the random walk sigma.
// 2025-03-31 ** WTS. (GMACS Version 2.20.22) Added gamma distribution likelihood type (GROWTHINC_DATA_GAMMA) for non-tagging molt increment // data so likelihood is consistent with size transition matrices. Previous normal likelihood based on data CVs is still available. // Corrected logic error going back to 2.20.06 that prevented likelihood for non-tagging molt increment data from being calculated. // Reformated some code sections for better readability and to replace tabs with spaces. Added option and function to replicate // Tanner crab mean molt increment calculations.
// 2025-04-01 ** WTS. (GMACS Version 2.20.23) Added function CreateOutput_OldFormat() to write output to "Gmacsall.out-old", "gmacs.rep-old", // "personal.rep-old", "simdata.out-old", and "Gmacsall.std-old" in the 2.20.06 format (before the output was niceified for R). Was // supposed to help Cody by providing "old"-style output, but he was working with a really old (2.01.M.02 CSS 2023-04-12) // version of GMACS. However, this may benefit users who work with the gmr R package or other code based on the older format.
// 2025-04-01 ** WTS. (GMACS Version 2.20.24) Added macro var ZEROPOP (=5)option to initialize numbers-at-size in start year at 0. The // logN0 is set to -1.0e3.
// 2025-04-07 ** WTS. Fixed incorrectly listed sex in gmacs_in.ctl and gmacs_out.ctl files for probability of maturing when two sex are specified. // Fixed problem in get_all_sdnr_MAR when d3_res_size_comps(k) was missing (nSizeComps(k=0) because size comps were "extended"). // Distinguished between tagging-related (nloglike(5)) and non-tagging-related growth data likelihoods (now nloglike(6)) in code and // Gmacsall.out file. Non-tagging growth likelihoods are now output by indivdual observation in Gamcsall.out as a dataframe ("growth_data"). // Added grwthPosFun to objective function to penalize negative growth (estimated r's [shape factors] in growth-related gamma distribution). // Input size comps in "new" format now respect sex-specific numbers of columns: all input columns are repeated to gmacs_data (file "gmacs_in.dat"), // but only the sex-specific number of columns is kept in the internal arrays.
// 2025-04-07 ** WTS. Added writeToRepFile1 flag to signal whether or not to write results in CheckBounds to RepFile1 (yes from CreateOutput, no from CreateOutput_OldFormat).
// 2025-04-15 ** WTS. Added lines to OutInpFile noting where EXTRA PARS would be defined if they were needed (not obvious starting from a ctl file w/out EXTRA PARS).
// 2025-04-16 ** WTS. Added commandline input option "-StopAfterFnCall xx" to override StopAfterFnCall setting in gmacs.dat file with value of "xx". // Converted "Double normal" as output label to "Double_normal" to be consistent w/ other output labels and facilitate parsing. // Added ascending normal selectivity function code to selex.hpp, SELEX_ASCNORM flag (14) to select it, and associated in/out ctl code .
// 2025-04-17 ** WTS. Incremented version number to 2.20.25. Reformatted some code related to ctl-file q input specification, added survey info to // gmacs_in.ctl and OutInpFile1 file output for q specification.
// 2025-04-21 ** WTS. Incremented version number to 2.20.26. Found issue with RW parameters for selectivity when RW block group has multiple blocks. Fixed // for selectivity but may be an issue for other processes when RW parameters are specified. // Also tracked down what turned out to be an uninitialized array problem (nSizeCompRows) that sent Windows runs off into NeverNeverLand. // Also added logic to skip calculating length likelihoods for the size comps that are the "extended" part of other comps.
// 2025-04-24 ** WTS. Lot of revision to enable blocks to work with catchability (q) parameters--many bits of code were based on assumption that q's // not blocked or time-varying. Refer to "Relative Abundance Indices" (RAI's) and id's for // such rather than "surveys" because the latter was confused between survey indices and catchability parameters. Rows for RAI's in the data // file need to be appended with the RAI id in order to match changes in q id with RAI id (might not be strictly necessary as q id is given // and qToSurv(iq) gives the id of the associated non-mirrored RAI; however, doesn't give RAI's for mirrored q's). // Required removing CreateOutput_OldFormat. Incremented to version 2.20.27.
// 2025-04-24 ** WTS. Added foffdevs_phz vector to set phases for female offset F devs (log_fdovs. phases had been set by foff_phz, // but needed to be turned "off" when no female F devs were defined.) Changed logN0 to -100 when ZEROPOP option is selected (had been -1000). // Incremented version to 2.20.28.
// 2025-05-27 ** WTS. Added input for 'recZ_flag' to CTL file as model_controls(18). Flag determines parameterization for recruitment size distribution in // calc_recruitment_size_distribution (0=standard approach; 1=Tanner approach). Incremented version to 2.20.29.
2025-05-28 ** WTS. Reassigned SELEX_UNIFORM0 and SELX_UNIFORM1 values from (6,5) to (5,6) to agree with ctl file comments. Kept version at 2.20.29 since this has not been pushed to "main" yet. Changed useage of RW parameter definition value FOR SELECTIVITY PARAMETERS ONLY. Was 0: RW devs off; >0: RW devs on. Now, for selectivity parameters only,:
- 0: RW devs off;
- 1: RW devs on w/ newpar = refpar*exp(dev) [as previously];
- 2: newpar = refpar + dev [new option--way to go for many parametric selectivity]. Changed description for selectivity sections of output ctl files. For other parameter types, the behavior is the same as previously (TODO: check if this behavior should be changed, as well).
2025-05-29 ** WTS. Added a check on the size of dataframe read in as dSurveyData when using original format to assure RAI_id column has been added. After dSurveyData is read in, an integer 'chk' is read from the input data file. If this is not equal to 999, then an error is printed and the program exits. Also, revised some information output to various files to clarify things a bit more. Finally, corrected an error reading parameter information for time-blocked "extra" growth parameters (did not affect non-time-blocked growth parameters).
2025-06-04 ** WTS. Cleaned up code in update_population_numbers_at_length related to recruitment, with note for further changes. Added note in calc_initial_numbers_at_length with reminder to change code if logR0, etc are redefined to apply to totrecruits rather than recruits(h).
2025-06-09 ** WTS. Renamed gmacs.rep1 output matrix from "Fully-selected_FM_by_season_sex_and_fishery" to "Fully-selected_capture_rate_by_season_sex_and_fishery" to better describe the content (ft). Note that F(h,i,j)=ft(h,i,j)*vul is the size-specific rate of fishing mortality (vul incorporates both retention mortality and discard mortality) while F2(h,i,j) = ft(h,i,j)*sel is the size-specific fishery capture rate.
2025-06-10 ** WTS. Added pre_capbio array and calc_predicted_capture_biomass function to facilitate export of predicted capture biomass by fishery in CreateOutput as Predicted_capture_biomass-at-size. Fixed inconsistency in how Z and Z2 were assigned as tempZ1 in calc_predicted_catch. Lots of reformatting. Added output to gmacs.rep1 for predicted fishery capture abundance and biomass (pre_capabd, pre_capbio) by year, fleet, sex, and size from (new function) calc_predicted_capture_abdbio. Updated version to 2.20.30.
2025-06-10 ** WTS. Cosmetic changes (added some info).
2025-06-16 ** WTS. Revised calculation of log_q_catch in calc_predicted_catch slightly, added some error checks to help debug.
Incremented version to 2.20.31.