This repository contains an R/RTMB scaffold for porting GMACS stock assessment logic, with the current implementation focused on the BBRKC model.
The detailed porting notes, parity checks, and next implementation steps live in
bbrkc_rtmb_port_steps.qmd.
R/read_gmacs_bbrkc.R: parsers for BBRKC GMACS input files and ADMB reference outputs.R/gmacs_rtmb_nll.R: RTMB data/parameter construction, parameter mapping, deterministic model blocks, comparison helpers, and the RTMB objective factory.run_bbrkc.R: parser, RTMB tape, and component-comparison smoke run.optimize_bbrkc.R: shortnlminb()optimization smoke test.run_tanner.R: Tanner input parser and fitted-parameter summary for the files inexamples/tanners; it also discovers Tanner ADMB report outputs whenGmacsall.outandgmacs.repor recognized equivalent names are added.run_snow.R: Snow crab input parser and ADMB report-summary smoke run for the files inexamples/snow.gmacs.tpl: GMACS ADMB template reference.examples/tanners/: Tanner crab GMACS input files retained as local reference material.GMACS_InputFiles.zip: original archive for the Tanner crab input files. This is ignored for future commits; the extractedtanners/files are the useful repository copy.
The BBRKC scripts require these files in one directory:
gmacs.datgmacs.pinGmacsall.outgmacs.rep
By default the scripts look in examples/BBRKC, which contains the committed
BBRKC parity example. To use another location, set GMACS_BBRKC_ROOT:
GMACS_BBRKC_ROOT=/path/to/BBRKC Rscript run_bbrkc.R
GMACS_BBRKC_ROOT=/path/to/BBRKC Rscript optimize_bbrkc.RFrom R:
Sys.setenv(GMACS_BBRKC_ROOT = "/path/to/BBRKC")
source("run_bbrkc.R")- Reads BBRKC data sections for dimensions, M proportions, fleets, catch, survey indices, size compositions, growth, and environment.
- Reads fitted parameter vectors from
gmacs.pin. - Builds an RTMB
mapfrom BBRKC control phases, mapping the 560 full.pinentries down to the 366 active ADMB parameters. - Reads ADMB likelihood, selectivity, fishing mortality, natural mortality,
total mortality, growth, numbers-at-size, catch-fit, index-fit, size-fit, and
summary reference blocks from
Gmacsall.outandgmacs.rep. - Ports deterministic BBRKC selectivity, fishing mortality, natural mortality, total mortality, survival setup, molt probability, growth transition matrices, recruitment, FREEPARSSCALED initial numbers, seasonal population updates, catch predictions, survey index predictions, and size-composition predictions.
- Computes gamma growth transitions and recruitment size distributions with
RTMB::pgamma()so active growth and recruitment-distribution parameters remain on the AD tape. - Builds an RTMB objective with named likelihood slots matching
gmacs.tpl. - Audits the active likelihood components, raw
nlogPenalty, andpriorDensityagainst ADMB reference blocks inrun_bbrkc.R.
The Quarto notes are rendered for GitHub Pages under docs/:
quarto render bbrkc_rtmb_port_steps.qmd --output-dir docs --output bbrkc.html --no-clean
quarto render tanner_rtmb_port_steps.qmd --output-dir docs --output tanner.html --no-clean
quarto render snow_rtmb_port_steps.qmd --output-dir docs --output snow.html --no-cleanConfigure GitHub Pages to serve the docs/ directory from the main branch.
- Run
Rscript run_bbrkc.Rafter every deterministic prediction change and inspect the printed ADMB likelihood/penalty/prior audit. - Add active growth likelihood terms if future GMACS inputs include growth observations.
- Broaden validation against additional GMACS model configurations.