Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/userguide.tex
[mareframe] / trunk / gadget / userguide.tex Repository:
ViewVC logotype

Annotation of /trunk/gadget/userguide.tex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download) (as text)

1 : agomez 1 \documentclass[10pt,twoside]{book}
2 :     \usepackage{a4wide}
3 :     \usepackage{amsmath}
4 :     \usepackage[T1]{fontenc}
5 :     \usepackage{palatino}
6 :     \usepackage{fancyhdr}
7 :    
8 :     \begin{document}
9 :    
10 :     \title{\Huge{Gadget User Guide}}
11 :     \author{Edited by James Begley}
12 :     \date{\today} % show the date on the title page
13 :     %\date{} % don't show the date on the title page
14 :     \maketitle
15 :    
16 :     \setlength{\parindent}{0mm}
17 :    
18 :     % run dvips -f -t a4 -Pcmz -Pamz -o userguide.ps userguide.dvi
19 :    
20 :     % set the header and footer styles
21 :     \pagestyle{fancy}
22 :     \fancyhf{}
23 :     \renewcommand{\chaptermark}[1]{\markboth{\textbf{\thechapter}\ \emph{#1}}{}}
24 :     \fancyhead[LO,RE]{}
25 :     \fancyhead[LE,RO]{\nouppercase{\leftmark}}
26 :     \fancyfoot[LE,RO]{\textbf{\thepage}}
27 :     \fancyfoot[LO,RE]{}
28 :    
29 :     % set the header and footer styles for the first page of the chapters
30 :     \fancypagestyle{plain}{\fancyhf{}\fancyfoot[LE,RO]{\textbf{\thepage}}\renewcommand{\headrulewidth}{0pt}}
31 :    
32 :     \thispagestyle{empty}
33 :    
34 :     \frontmatter
35 :     \pagenumbering{roman}
36 :     \tableofcontents
37 :    
38 :     \mainmatter
39 :     \pagenumbering{arabic}
40 :    
41 :     \chapter{Introduction to Gadget}\label{chap:intro}
42 :     Gadget is the {\bf G}lobally applicable {\bf A}rea {\bf D}isaggregated {\bf G}eneral {\bf E}cosystem {\bf T}oolbox. Gadget is a flexible and powerful software tool that has been developed to model marine ecosystems, including both the impact of the interactions between species and the impact of fisheries harvesting the species. Gadget simulates these processes in a biologically realistic manner, and uses a framework to test the development of the modelled ecosystem in a statistically rigorous manner. Gadget has successfully been used to investigate the population dynamics of stock complexes in Icelandic waters, the Barents Sea, the North Sea and the Irish and Celtic Seas.
43 :    
44 :     \section{What is Gadget?}\label{sec:whatisgadget}
45 :     Gadget can run complicated statistical models which take many features of the ecosystem into account. Gadget works by running an internal forward projection model based on many parameters describing the ecosystem, and then comparing the output from this model to observed measurements to get a likelihood score. The model ecosystem parameters can then be adjusted, and the model re-run, until an optimum is found, which corresponds to the model with the lowest likelihood score. This iterative, computationally intensive process is handled within Gadget, using a robust minimisation algorithm. The Gadget software framework consists of three parts:
46 :    
47 :     \begin{itemize}
48 :     \item a parametric model to {\bf simulate} the ecosystem
49 :     \item statistical functions to {\bf compare} the model output to data
50 :     \item search algorithms to {\bf optimise} the model parameters
51 :     \end{itemize}
52 :    
53 :     Gadget allows the user to include a number of features of the ecosystem into the model: One or more species, each of which may be split into multiple components; multiple areas with migration between areas; predation between and within species; growth; maturation; reproduction and recruitment; multiple commercial and survey fleets taking catches from the populations.
54 :    
55 :     \bigskip
56 :     Like any large piece of code, Gadget is based on previous ideas by several authors. Conceptually the modelling framework extends earlier multi species programming work such as MSVPA and MULTSPEC into a more generic statistical framework. Alternatively, Gadget is a conceptual extension of the Stock Synthesis statistical assessment single-species framework into a multi species setting.
57 :    
58 :     \bigskip
59 :     The initial BORMICON code was developed as part of a multi species programme implemented at the Marine Research Institute in Reykjavik, Iceland, starting in 1992 with \'{O}lafur K P\'{a}lsson as project coordinator and Gunnar Stef\'{a}nsson coordinating the modelling work. Subsequently the code became the basis for Fleksibest at the Institute of Marine Research in Bergen, Norway. Further development work in 1999-2003 was partly funded by EU grant QLK5-CT1999-01609 (''Development of Structurally Detailed Statistically Testable Models of Marine Populations''). Development work for 2004-2006 is currently being partly funded by EU grant 502482 (''Critical Interactions Between Species and their Implications for a Precautionary Fisheries Management in a Variable Environment - a Modelling Approach'').
60 :    
61 :     \bigskip
62 :     The Gadget code is derived from the original BORMICON code of Halld\'{o}r Narfi Stef\'{a}nsson, H\"{o}skuldur Bj\"{o}rnsson and Hersir Sigurgeirsson. Subsequent contributions include program additions by Morten Nygaard {\AA}snes and Kristin Fr{\o}ysa to include the Fleksibest model. The ability to run in parallel across a network of computers using PVM was implemented primarily by Au{\dh}bj\"{o}rg Jakobsd\'{o}ttir with input from several other people, including J\'{o}n Gu{\dh}mundsson who worked on a variant based on Condor. Several mathematical additions and changes to allow for parallel minimisation on a network were implemented by {\TH}\'{o}rd\'{i}s Linda {\TH}\'{o}rarinsd\'{o}ttir and Kristjana \'{Y}r J\'{o}nsd\'{o}ttir.
63 :    
64 :     \bigskip
65 :     More recent changes include the work to use information from tagging experiments, which was implemented primarily by Sigur{\dh}ur Hannesson. The work on multivariate distributions was implemented by Bjarki {\TH}\'{o}r Elvarsson. Recent additions including major code cleanups, modifications to the input formats and debugging operations have been led by James Begley, who is the current maintainer of the code and coordinator of all programming efforts.
66 :    
67 :     \section{Getting Gadget}\label{sec:gettinggadget}
68 :     Gadget is distributed via anonymous ftp from the MRI ftp site, and the address of the top level directory of the Gadget distributions is:
69 :    
70 :     {\small\begin{verbatim}
71 :     ftp://ftp.hafro.is/pub/reiknid/dst2/gadget/
72 :     \end{verbatim}}
73 :    
74 :     The most recent version of Gadget will be available as a gzipped tarfile from this directory. This file will be called gadget$<$version$>$.tar.gz, where $<$version$>$ represents the version number of Gadget. As a guide, the current version of Gadget is 2.1.06, so the file to be downloaded is gadget2.1.06.tar.gz.
75 :    
76 :     \bigskip
77 :     Gadget is a program that runs on a Unix computing platform, and is regularly tested on machines running versions of Solaris, Linux, Mac OSX and Cygwin (a Unix emulator for Microsoft Windows machines). It should also run on other versions of Unix, but this may require modifications to the makefile in order to do so. Gadget is distributed as a set of source code files, which need to be compiled into an executable program before it can be run. To allow for various different versions, the makefile has a list of supported computing platforms, so the makefile should be checked (and if necessary changed) to ensure that the required options are available before the source code is compiled. The default options in the makefile will compile Gadget for a Linux machine, using the GNU C++ compiler. A summary of the commands required to compile Gadget, using the default options for a Linux machine from the downloaded file are:
78 :    
79 :     {\small\begin{verbatim}
80 :     gunzip gadget<version>.tar.gz
81 :     tar -xvf gadget<version>.tar
82 :     cd source
83 :     make
84 :     \end{verbatim}}
85 :    
86 :     The most recent copy of this document will also be placed on the MRI ftp site, along with copies of any example datasets that are available. These datasets will be checked so that they run without any problems, and will also contain some comments to help the user understand the format of the data files. It is recommended that this user guide is read in conjunction with an example dataset.
87 :    
88 :     \bigskip
89 :     A web site has been set up that contains details of the recent changes to Gadget, documentation updates and other news. This is also a good place to look for more information about Gadget. The address of the Gadget web site is {\tt http://www.hafro.is/gadget}
90 :    
91 :     \bigskip
92 :     Throughout this document any text in $<$angled brackets$>$ should be adjusted by the user to make it relevant to the current situation, so for example the text above should be altered to the following to compile Gadget version 2.1.06 on a Linux machine:
93 :    
94 :     {\small\begin{verbatim}
95 :     gunzip gadget2.1.06.tar.gz
96 :     tar -xvf gadget2.1.06.tar
97 :     cd source
98 :     make
99 :     \end{verbatim}}
100 :    
101 :     \section{Running Gadget}\label{sec:runninggadget}
102 :     Gadget is a command line program that runs on a Linux computing platform. To start Gadget, simply type the following at a standard Linux prompt:
103 :    
104 :     {\small\begin{verbatim}
105 :     gadget <options>
106 :     \end{verbatim}}
107 :    
108 :     where $<$options$>$ are a combination of the starting switches described in the next section. Note that this assumes that the Gadget executable has been placed in a directory that is included in the \$PATH, which might not be the case for some Linux distributions. If this is the case, Gadget should be started by including the path to the Gadget executable, for example by typing {\small{\tt ./gadget}} if the Gadget executable is in the current directory.
109 :    
110 :     \bigskip
111 :     Gadget is not an interactive program, so once it has started there is no need for any further input from the user. However, if Gadget was started incorrectly (for example, using the wrong input files) then Gadget can be stopped by pressing $<$CTRL$><$C$>$, which will interrupt the calculations, displaying a menu from which it is possible to either store the current calculations to a text file, or to exit (by pressing $<$Q$>$).
112 :    
113 :     \bigskip
114 :     When Gadget starts, it will look for a file called ''main'', which contains a list of all the other data files required. Gadget will search for this file in the following 2 locations:
115 :    
116 :     \begin{enumerate}
117 :     \item the directory specified by the Linux environment variable called ''GADGET\_WORKING\_DIR'', optionally taking data from the directory specified by the Linux environment variable called ''GADGET\_DATA\_DIR''
118 :     \item the current directory (ie. from where Gadget has been started) if these environment variables have not been set (note that this is the default location)
119 :     \end{enumerate}
120 :    
121 :     When Gadget is reading in the input data files, these files will be checked to ensure that they are in the correct format, and if there is an error in the format Gadget will print an error message and stop. Note that when Gadget is checking the format of a data file containing a number of columns (eg. the ''area'' file) it will only check the first data line in the file (so, for the case of the ''area'' file it will check that there are 4 entries on the first row and then assume that all the other rows also have 4 entries). Hopefully, there should be enough information in these error messages to lead the user to the input file that is causing the error.
122 :    
123 :     \bigskip
124 :     If all else fails, and the error messages do not lead the user to the source of the error, then there is an email address set up for any difficulties or questions that may arise, or reporting any bugs that get found. In addition to sorting out any problems that the user may be getting, we can also try to help with interpreting the output. This email address is {\tt gadgethelp@hafro.is}
125 :    
126 :     \bigskip
127 :     Sending an email to this address should get a response within a couple of working days. This email address can also be used to give us any feedback on the usefulness (or otherwise) of Gadget, so let us know what you think!
128 :    
129 :     \section{Starting Switches}\label{sec:starting}
130 :     The following is a list of the command line switches that Gadget will recognise, together with a brief description of what the switch means to the running of the Gadget model.
131 :    
132 :     {\small\begin{verbatim}
133 :     gadget -s
134 :     \end{verbatim}}
135 :     Starting Gadget with the -s switch will start a simulation run, where a single run of the model will take place. This option is useful since it will give the model output (see Print Files, chapter~\ref{chap:print}), and it is used when running large Gadget models, using the paramin parallel processing optimiser to find the optimum.
136 :    
137 :     {\small\begin{verbatim}
138 :     gadget -l
139 :     \end{verbatim}}
140 :     Starting Gadget with the -l switch will start a optimising run, where the overall likelihood score will be reduced to an optimum, depending on the optimising information given (see the -opt switch).
141 :    
142 :     {\small\begin{verbatim}
143 :     gadget -n
144 :     \end{verbatim}}
145 :     Starting Gadget with the -n switch will start a network run, used in conjunction with the paramin optimiser to find an optimal solution for large models.
146 :    
147 :     {\small\begin{verbatim}
148 :     gadget -v
149 :     gadget --version
150 :     \end{verbatim}}
151 :     Starting Gadget with the -v (or -\hspace{0pt}-version) switch will display the version of Gadget that is being run.
152 :    
153 :     {\small\begin{verbatim}
154 :     gadget -h
155 :     gadget --help
156 :     \end{verbatim}}
157 :     Starting Gadget with the -h (or -\hspace{0pt}-help) switch will display a help screen, giving information about the various starting switches that can be used.
158 :    
159 :     {\small\begin{verbatim}
160 :     gadget -i <filename>
161 :     \end{verbatim}}
162 :     Starting Gadget with the -i switch will give Gadget an inputfile file from which the initial values and bounds of any variables can be read (see Parameter Files, chapter~\ref{chap:param}, for more information on the format of this file).
163 :    
164 :     {\small\begin{verbatim}
165 :     gadget -opt <filename>
166 :     \end{verbatim}}
167 :     Starting Gadget with the -opt switch will give Gadget an optimisation input file, from which the information about the optimisation routines will be read. This will specify the type of optimisation to perform, and also parameters for that optimisation routine (see Optimisation Files, chapter~\ref{chap:optim}, for more information on the format of this file).
168 :    
169 :     {\small\begin{verbatim}
170 :     gadget -main <filename>
171 :     \end{verbatim}}
172 :     Starting Gadget with the -main switch will specify a filename for the main Gadget model input file, which contains links to all the other data files that are to be used by Gadget (see Main File, section~\ref{sec:mainfile}, for more information on the format of this file). If Gadget is started without the -main switch, Gadget will use the default filename ''main'' as the name for the main file.
173 :    
174 :     \newpage %JMB insert page break
175 :     {\small\begin{verbatim}
176 :     gadget -p <filename>
177 :     \end{verbatim}}
178 :     Starting Gadget with the -p switch specifies the file that Gadget will use to print the final values and bounds of the variables, in the same format as for the inputfile. This file can then be used as the starting point for a subsequent Gadget run, if required. This file will always be generated, and if Gadget is started without the -p switch the default filename is ''params.out'' which will be created in the current directory (see Output Files, chapter~\ref{chap:output}, for more information on the format of this file).
179 :    
180 :     {\small\begin{verbatim}
181 :     gadget -o <filename>
182 :     \end{verbatim}}
183 :     Starting Gadget with the -o switch specifies the file that Gadget will use to print the score from the likelihood calculations. This file will give details on the parameters that have been used, the likelihood components that have been used, and the values for these parameters and likelihood components. This can be a large file if Gadget is performing an optimising run (see Output Files, chapter~\ref{chap:output}, for more information on the format of this file).
184 :    
185 :     {\small\begin{verbatim}
186 :     gadget -print <number>
187 :     \end{verbatim}}
188 :     Starting Gadget with the -print switch will specify the frequency with which information is written to the likelihood output file (specified with the -o switch). The default value for this is 1, meaning that the likelihood information is written for every iteration.
189 :    
190 :     {\small\begin{verbatim}
191 :     gadget -precision <number>
192 :     \end{verbatim}}
193 :     Starting Gadget with the -precision switch will specify the number of digits to be used when printing the output from the likelihood calculations to files specified with the -o switch.
194 :    
195 :     {\small\begin{verbatim}
196 :     gadget -log <filename>
197 :     \end{verbatim}}
198 :     Starting Gadget with the -log switch will specify a file to which Gadget will write logging messages to keep a record of internal Gadget actions. This can be a large file if Gadget is performing an optimising run (see Log Output, section~\ref{sec:logoutput}, for more information on the format of this file).
199 :    
200 :     {\small\begin{verbatim}
201 :     gadget -loglevel <number>
202 :     \end{verbatim}}
203 :     Starting Gadget with the -loglevel switch will specify the level of detail that is to be used by Gadget when logging messages (both to the screen and to a log file if one has been specified with the -log switch). If Gadget is started without the -loglevel switch then the default is for warning messages and error messages to be shown during a simulation run (when Gadget is started with the -s switch) and only error messages are shown during an optimising run (when Gadget is started with the -l switch).
204 :    
205 :     {\small\begin{verbatim}
206 :     gadget -seed <number>
207 :     \end{verbatim}}
208 :     Starting Gadget with the -seed switch will specify the value that is used to initialise the random number generator used within Gadget (see Repeatability, section~\ref{sec:repeat} for more information on the use of the random number generator within Gadget runs).
209 :    
210 :     {\small\begin{verbatim}
211 :     gadget -m <filename>
212 :     \end{verbatim}}
213 :     Starting Gadget with the -m switch will specify a file from which Gadget can read the other command line options. This file should contain a simple list of the switches and their values, as they would be entered from the command line.
214 :    
215 :     \newpage %JMB insert page break
216 :     {\small\begin{verbatim}
217 :     gadget -printinitial <filename>
218 :     \end{verbatim}}
219 :     Starting Gadget with the -printinitial switch will specify a file to which Gadget will write all internal information for the model at the start of the run (ie. the stock populations, likelihood calculations and other information from before the first timestep). This file will be large for moderately complicated models, and it is of most use for debugging purposes.
220 :    
221 :     {\small\begin{verbatim}
222 :     gadget -printfinal <filename>
223 :     \end{verbatim}}
224 :     Starting Gadget with the -printfinal switch will specify a file to which Gadget will write all internal information for the model at the end of the run (ie. the stock populations, likelihood calculations and other information from after the last timestep). This file will be large for moderately complicated models, and it is of most use for debugging purposes.
225 :    
226 :     {\small\begin{verbatim}
227 :     gadget -maxratio <ratio>
228 :     \end{verbatim}}
229 :     Starting Gadget with the -maxratio switch will specify the maximum ratio of prey that is allowed to be ''consumed'' on any one timestep. This consumption includes both the consumption by other stocks and the catch by any fleets. The default value is 0.95, which ensures that no mare than 95\% of the available stock biomass is consumed on a single timestep.
230 :    
231 :     %gadget -noprint
232 :     %gadget -forceprint
233 :    
234 :     \bigskip
235 :     Most of these switches can be combined to specify more information about the Gadget run that will be performed. For instance:
236 :    
237 :     {\small\begin{verbatim}
238 :     gadget -l -i inputfile.txt -o likelihood.txt -opt optinfo.txt -print 10
239 :     \end{verbatim}}
240 :    
241 :     will start Gadget for a likelihood run, taking the initial values and information about the parameters from the file inputfile.txt, with the optimisation being done in accordance with the information in optinfo.txt, and printing likelihood information (every 10 iterations) to the file likelihood.txt.
242 :    
243 :     \bigskip
244 :     Note that it is not possible to do both a simulation run and a likelihood run at the same time, and starting Gadget with both the -l and -s switches will result in a warning, after which Gadget will perform a simulation run, with the -l switch being ignored.
245 :    
246 :     \chapter{Input Files}\label{chap:input}
247 :     All the input files for Gadget are plain ASCII text files, so they can be viewed in any plain-text text editor. Any whitespace or blank lines in the data files are ignored, so the layout of the files can be adjusted into a easily viewable form to check the content of the files. The case of any text in an input file is ignored by Gadget, so for example, ''Stock'' and ''stock'' would be interpreted by Gadget as being the same.
248 :    
249 :     \bigskip
250 :     Unless stated otherwise, all the input and output files use the following measurement units:
251 :    
252 :     \begin{itemize}
253 :     \item length - all measurements are in centimetres
254 :     \item weight - all measurements are in kilogrammes
255 :     \item age - all measurements are in years
256 :     \end{itemize}
257 :    
258 :     Gadget is a program that runs on a Linux computing platform, so the input data files must use a Linux style end-of-line character ($<$linefeed$>$) and not a Windows style end-of-line character ($<$carriage return$><$linefeed$>$). All the lines of the input files containing data should end with an end-of-line character.
259 :    
260 :     \section{Comments in Input Files}\label{sec:comments}
261 :     Any of the input files used by Gadget can contain comments that are not used by Gadget. The start of the comment is denoted by a semi-colon '';''. Once Gadget has read as far as the semi-colon, the rest of the line will be ignored.
262 :    
263 :     \section{What Does The \# Mean?}\label{sec:whatdoeshash}
264 :     When Gadget is performing an optimising run, a number of the parameters can be adjusted to try to find a better fit between the modelled output and the data. The parameters that are to be adjusted are termed ''switches'' and are marked in the input files by the '\#' character. There are two valid formats for switches in the data file - either directly, or as part of a function.
265 :    
266 :     \subsection{Switches}
267 :     The format for the switches is given by:
268 :    
269 :     {\small\begin{verbatim}
270 :     <numerical part>#<name>
271 :     \end{verbatim}}
272 :    
273 :     where the $<$numerical part$>$ consists of the (optional) initial value for the switch, and the $<$name$>$ is a alpha-numerical text string used to identify the switch in the parameter file. Note that there is no whitespace either before or after the '\#' character. Also note that the name of the switch cannot contain a hyphen, since this will be interpreted by Gadget as the mathematical subtraction symbol.
274 :    
275 :     \bigskip
276 :     Any initial value specified in the data files will be overwritten by the initial value given in the parameter file (see chapter~\ref{chap:param}). If the initial value is not given, then a value of 1 with be assumed by Gadget. A switch can appear in more than one place in the data files, but needs to be defined with the same initial value each time.
277 :    
278 :     \bigskip
279 :     Examples of valid switches in the data files can include:
280 :    
281 :     \begin{enumerate}
282 :     \item defining a simple switch (called ''age2'') without an initial value
283 :     {\small\begin{verbatim}
284 :     #age2
285 :     \end{verbatim}}
286 :     \item defining a switch with an initial value
287 :     {\small\begin{verbatim}
288 :     10#age2
289 :     \end{verbatim}}
290 :     \end{enumerate}
291 :    
292 :     \subsection{Functions}
293 :     The format for the functions is given by:
294 :    
295 :     {\small\begin{verbatim}
296 :     (<function> <parameters>)
297 :     \end{verbatim}}
298 :    
299 :     where the $<$function$>$ defines the name of the function, and the $<$parameters$>$ is a vectors of the parameters to be used - either numbers or the names of switches denoted by the '\#' character. Note that the function is contained within (round brackets). Valid function names include the 4 mathematical operators ('*', '+', '-' and '/'), trigonometric functions ('sin' and 'cos', with the argument in radians), logarithmic functions ('log', 'log10' and 'exp'), square root ('sqrt') and a function to generate a random number between 0 and 1 ('rand').
300 :    
301 :     \bigskip
302 :     Examples of valid functions for the switches in the data files can include:
303 :    
304 :     \begin{enumerate}
305 :     \item defining a function based on a switch
306 :     {\small\begin{verbatim}
307 :     (* 10 #age2)
308 :     \end{verbatim}}
309 :     note that in this case, Gadget will use 10 times the value of parameter ''age2''.
310 :     \item defining a function based on more than one switch
311 :     {\small\begin{verbatim}
312 :     (* #area1 #age2)
313 :     \end{verbatim}}
314 :     note that in this case, Gadget will use the value of parameter ''area1'' multiplied by the value of parameter ''age2''.
315 :     \item nesting functions
316 :     {\small\begin{verbatim}
317 :     (log (+ #area1 #age2))
318 :     \end{verbatim}}
319 :     note that in this case, Gadget will use the value of the natural logarithm of parameter ''area1'' plus parameter ''age2''.
320 :     \end{enumerate}
321 :    
322 :     \chapter{Model Files}\label{chap:model}
323 :     Gadget requires a number of data files to define a Gadget model. The number of data files required depends on the complexity of the Gadget model, and there is no limit on the number, or name, of these data files. The main input file gives links to all the other data files required, and must be specified with the ''-main $<$filename$>$'' command line option, or be called ''main''.
324 :    
325 :     \section{Main File}\label{sec:mainfile}
326 :     The main Gadget input file is usually called ''main'', unless it is specified with the ''-main $<$filename$>$'' command line option. This file only contains links to other files which will make up the Gadget model. The format for this file is:
327 :    
328 :     {\small\begin{verbatim}
329 :     <typeoffile> <filename>
330 :     \end{verbatim}}
331 :    
332 :     where $<$typeoffile$>$ is a keyword to tell Gadget what sort of information the file will contain, and the name of the file is given by $<$filename$>$, relative to the directory in which the main file resides. Where zero or more files of a certain type could be used, the main file is divided into sections that are separated by a keyword in [square brackets]. The format for the main file is shown below:
333 :    
334 :     {\small\begin{verbatim}
335 :     timefile <name of the time file>
336 :     areafile <name of the area file>
337 :     printfiles <names of the print files>
338 :     [stock]
339 :     stockfiles <names of the stock files>
340 :     [tagging]
341 :     tagfiles <names of the tag files>
342 :     [otherfood]
343 :     otherfoodfiles <names of the otherfood files>
344 :     [fleet]
345 :     fleetfiles <names of the fleet files>
346 :     [likelihood]
347 :     likelihoodfiles <names of the likelihood files>
348 :     \end{verbatim}}
349 :    
350 :     The printfile element of the main file is optional, and can be commented out if no model output is required. It should be noted that the keyword ''printfiles'' must be present, so to comment out the printfile section, a semi colon should be placed before the name of the printfile, as shown in the line below:
351 :    
352 :     {\small\begin{verbatim}
353 :     printfiles ; <filename> commented out so no printing will take place
354 :     \end{verbatim}}
355 :    
356 :     \section{Time File}\label{sec:timefile}
357 :     This specifies the start and end times for the model run, and the number of timesteps per year. Note that the model can run into the future, and that datasets covering only part of the overall run can be used. Gadget splits each year up into a number of time steps, but these time steps need not all be the same length.
358 :    
359 :     \bigskip
360 :     The format for this file is a list of the first year and timestep, and the last year and timestep, and how each year is to be divided into timesteps. This is done by specifying first the number of timesteps in a year, and then the length of each timestep (in months), and Gadget will check that the number of timesteps in a year sums up to 12. This is shown below:
361 :    
362 :     {\small\begin{verbatim}
363 :     firstyear <first year>
364 :     firststep <first step>
365 :     lastyear <last year>
366 :     laststep <last step>
367 :     notimesteps <how the year is split up>
368 :     \end{verbatim}}
369 :    
370 :     Examples for how the year can be split up include:
371 :    
372 :     \begin{enumerate}
373 :     \item 4 equal timesteps, splitting the year into quarters
374 :     {\small\begin{verbatim}
375 :     notimesteps 4 3 3 3 3
376 :     \end{verbatim}}
377 :     \item 12 equal timesteps, splitting the year into months
378 :     {\small\begin{verbatim}
379 :     notimesteps 12 1 1 1 1 1 1 1 1 1 1 1 1
380 :     \end{verbatim}}
381 :     \item 6 unequal timesteps, splitting the year into the following periods, $<$January - February$>$, $<$March$>$, $<$April - June$>$, $<$July - September$>$, $<$October$>$ and $<$November - December$>$
382 :     {\small\begin{verbatim}
383 :     notimesteps 6 2 1 3 3 1 2
384 :     \end{verbatim}}
385 :     \end{enumerate}
386 :    
387 :     \section{Area File}\label{sec:areafile}
388 :     This file specifies which areas the model will be run on, and gives a time dependent temperature for each area. Note that although the temperature data must be provided it need not actually be used, depending on the growth and feeding options chosen for the stock file.
389 :    
390 :     \bigskip
391 :     The format for this file is a list of the areas that are to be used (by specifying a numeric identifier for each area), followed by the size of each area (in square kilometres) and then a listing of the temperature for each timestep and area combination. An example of this format is given below:
392 :    
393 :     {\small\begin{verbatim}
394 :     areas <vector of area identifiers>
395 :     size <vector of sizes>
396 :     temperature
397 :     <year> <step> <area> <temperature>
398 :     \end{verbatim}}
399 :    
400 :     \section{Other Input Data Files}\label{sec:otherinputfile}
401 :     There are three other types of input that are important since they are used in other data files to denote a grouping of data. These are Aggregation files, which are files used to gather data into convenient groups, TimeVariable files, which are files used to denote variables that can vary over time, and ActionAtTime, which is used to define the timesteps that an action takes place within a data file.
402 :    
403 :     \subsection{Aggregation Files}
404 :     Aggregation files are important since they are used to group the data in convenient groups. They consist of a text label (used to identify the group in the data) followed by a list of the data that the label represents. This data will then be read in from an associated data file. There are aggregation files to group areas, ages, lengths or preys together. Aggregation files can contain comments and blank lines, to make the format easier to view in a text editor.
405 :    
406 :     \subsubsection{Area Aggregation}
407 :     Area aggregation files contain one or more identifying labels and then a list of one or more areas that the label refers to. The format for this is:
408 :    
409 :     {\small\begin{verbatim}
410 :     <label> <areas>
411 :     \end{verbatim}}
412 :    
413 :     An example of this is:
414 :    
415 :     {\small\begin{verbatim}
416 :     north 1 2 6
417 :     south 3 4 5 7
418 :     \end{verbatim}}
419 :    
420 :     This example shows that for the associated data file, the label ''north'' will be interpreted as applying to areas 1, 2 and 6 and the label ''south'' will be interpreted as applying to areas 3, 4, 5 and 7.
421 :    
422 :     \subsubsection{Age Aggregation}
423 :     Age aggregation files contain one or more identifying labels and then a list of one or more ages that the label refers to. The format for this is:
424 :    
425 :     {\small\begin{verbatim}
426 :     <label> <ages>
427 :     \end{verbatim}}
428 :    
429 :     An example of this is:
430 :    
431 :     {\small\begin{verbatim}
432 :     young 1 2 3 4
433 :     old 5 6 7
434 :     \end{verbatim}}
435 :    
436 :     This example shows that for the associated data file, the label ''young'' will be interpreted as applying to ages 1 - 4 and the label ''old'' will be interpreted as applying to ages 5 to 7.
437 :    
438 :     \subsubsection{Length Aggregation}
439 :     Length aggregation files contain one or more identifying labels and then the minimum and maximum length that the label refers to. The format for this is:
440 :    
441 :     {\small\begin{verbatim}
442 :     <label> <minimum> <maximum>
443 :     \end{verbatim}}
444 :    
445 :     When more than one length group label is defined, then the labels should be ordered so that the smallest length group is first in the file. The data is checked, so that the maximum length associated with label $<$i$>$ is the same as the minimum length for label $<$i+1$>$. An example of this is:
446 :    
447 :     {\small\begin{verbatim}
448 :     small 5 25
449 :     medium 25 55
450 :     large 55 80
451 :     \end{verbatim}}
452 :    
453 :     This example shows that for the associated data file, the label ''small'' will be interpreted as applying to lengths 5-25cm, the label ''medium'' will be interpreted as applying to the lengths 25-55cm and the label ''large'' will be interpreted as applying to lengths 55-80cm.
454 :    
455 :     \subsubsection{Prey Aggregation}
456 :     Prey aggregation files contain one or more identifying labels, and then the names of the preys, the minimum and maximum lengths for the preys and the digestion coefficients for the consumption of the preys. The format for this is:
457 :    
458 :     {\small\begin{verbatim}
459 :     <label>
460 :     <prey names>
461 :     lengths <minimum> <maximum>
462 :     digestioncoefficients d0 d1 d2
463 :     \end{verbatim}}
464 :    
465 :     The digestion coefficients define a multiplier used when calculating the consumption of the prey. This multiplier is length dependant, and is calculated according to the digestion equation given below:
466 :    
467 :     \begin{equation}\label{eq:digestion}
468 :     D = d_{0} + d_{1}l^{d_{2}}
469 :     \end{equation}
470 :    
471 :     \bigskip
472 :     An example of a prey aggregation file is:
473 :    
474 :     {\small\begin{verbatim}
475 :     ; for the first prey
476 :     smallcapelin
477 :     immature.capelin
478 :     lengths 5 10
479 :     digestioncoefficients 1 0 0
480 :     ;
481 :     ; for the second prey
482 :     mediumcapelin
483 :     immature.capelin mature.capelin
484 :     lengths 10 15
485 :     digestioncoefficients 1 0 0
486 :     ;
487 :     ; for the third prey
488 :     largecapelin
489 :     mature.capelin
490 :     lengths 15 20
491 :     digestioncoefficients 1 0 0
492 :     \end{verbatim}}
493 :    
494 :     This example shows that for the associated data file, the label ''smallcapelin'' will be interpreted as applying to immature capelin (a stock called immature.capelin) of lengths 5-10cm, the label ''mediumcapelin'' will be interpreted as applying to immature and mature capelin (stocks immature.capelin and mature.capelin) of lengths 10-15cm, and the label ''largecapelin'' will be interpreted as applying to mature capelin (a stock called mature.capelin) of lengths 15-20cm.
495 :    
496 :     \subsection{TimeVariable Files}
497 :     TimeVariable files are used in place of a single variable in the input files, to define variables in the Gadget model that can vary over time. They are used by specifying the name of the TimeVariable file in place of the value or parameter in the input file. TimeVariable files can contain comments and blank lines, to make the format easier to view in a text editor.
498 :    
499 :     \bigskip
500 :     TimeVariable files consist of a one word description of the data, followed by the keyword ''data'', and then a list of the timesteps when the value of TimeVariable changes, along with the new value for the TimeVariable. The values can either be numerical values or a parameter to be optimised. The first timestep in the TimeVariable file must correspond to the first timestep in the model. The basic format for this file is shown below:
501 :    
502 :     {\small\begin{verbatim}
503 :     <description> ; one word description of the data
504 :     data
505 :     <year> <step> <value>
506 :     \end{verbatim}}
507 :    
508 :     An example of a TimeVariable file is:
509 :    
510 :     {\small\begin{verbatim}
511 :     annualgrowth
512 :     data
513 :     ; year step value
514 :     1995 1 #grow1995
515 :     1996 1 #grow1996
516 :     1997 1 #grow1997
517 :     1998 1 #grow1998
518 :     1999 1 #grow1999
519 :     2000 1 #grow2000
520 :     \end{verbatim}}
521 :    
522 :     This example shows that the the parameter ''grow1995'' is to be used for growth in 1995, ''grow1996'' is to be used in 1996 and so on through to ''grow2000'' which is to be used from 2000 through to the end of the simulation. Note that this example assumes that the first timestep of the simulation is the first timestep in 1995.
523 :    
524 :     \subsection{ActionAtTime}
525 :     ActionAtTime is a simple list of timesteps within a data file that define when a specified action (for example printing) will take place. The format for this is:
526 :    
527 :     {\small\begin{verbatim}
528 :     <year> <step>
529 :     \end{verbatim}}
530 :    
531 :     where year and step are either a valid timestep or the keyword ''all''. These can be grouped together to specify a more complex time period.
532 :    
533 :     \bigskip
534 :     Examples of valid ActionAtTime entries in the data files include:
535 :    
536 :     \begin{enumerate}
537 :     \item the action taking place on the first timestep of 2002
538 :     {\small\begin{verbatim}
539 :     2002 1
540 :     \end{verbatim}}
541 :     \item the action taking place on all timesteps of 2000
542 :     {\small\begin{verbatim}
543 :     2000 all
544 :     \end{verbatim}}
545 :     \item the action taking place on the second timestep of each year
546 :     {\small\begin{verbatim}
547 :     all 2
548 :     \end{verbatim}}
549 :     \item the action taking place on all timesteps of each year
550 :     {\small\begin{verbatim}
551 :     all all
552 :     \end{verbatim}}
553 :     \item the action taking place on the first and second timesteps of each year
554 :     {\small\begin{verbatim}
555 :     all 1
556 :     all 2
557 :     \end{verbatim}}
558 :     \end{enumerate}
559 :    
560 :     \chapter{Stock Files}\label{chap:stock}
561 :     The stock files contain all the information that Gadget requires for each stock in the model. To define the stock files in the Gadget model, the following lines are required in the ''main'' Gadget file:
562 :    
563 :     {\small\begin{verbatim}
564 :     [stock]
565 :     stockfiles <names of the stock files>
566 :     \end{verbatim}}
567 :    
568 :     The ''main'' file needs to list the files that define the stocks to be used in the model. Each stock requires a separate stock file. The information for the stocks are very detailed, and so these stock files are quite large and can be complicated to look at. The basic format for this file is:
569 :    
570 :     {\small\begin{verbatim}
571 :     stockname <name of the stock>
572 :     livesonareas <areas that the stock lives on>
573 :     minage <minimum age for the stock>
574 :     maxage <maximum age for the stock>
575 :     minlength <minimum length for the stock>
576 :     maxlength <maximum length for the stock>
577 :     dl <step size for the length groups>
578 :     refweightfile <see Reference Weight>
579 :     growthandeatlengths <see Growth and Eat Lengths>
580 :     doesgrow <see Growth>
581 :     naturalmortality <see Natural Mortality>
582 :     iseaten <see Stock Prey>
583 :     doeseat <see Stock Predator>
584 :     initialconditions <see Initial Conditions>
585 :     doesmigrate <see Migration>
586 :     doesmature <see Maturation>
587 :     doesmove <see Movement>
588 :     doesrenew <see Renewal>
589 :     doesspawn <see Spawning>
590 :     doesstray <see Straying>
591 :     \end{verbatim}}
592 :    
593 :     The first seven lines of this file give the basic details of the stock, and are fairly self explanatory. It should be noted that the oldest age group and the longest length group are interpreted in Gadget as plus groups for the stock. The remaining lines give more detail about the stock, and are covered in the sub sections below.
594 :    
595 :     \section{Reference Weight}\label{sec:stockrefweight}
596 :     The reference weight section lists the weight of the stock for various length groups. This is the reference weight that can be used in the initial conditions to set up the stock, and can also be used by the growth functions when calculating the increase in length of the stock due to the growth. In the stock file, the format for the reference weight is given by:
597 :    
598 :     {\small\begin{verbatim}
599 :     refweightfile <name of the reference weight file>
600 :     \end{verbatim}}
601 :    
602 :     The format of the reference weight file is simply a two column list of the length and the corresponding weight for the stock. This file is ordered so that the smallest length group is given first, up to the longest length group which is given last. The format for this file is shown below:
603 :    
604 :     {\small\begin{verbatim}
605 :     <length> <weight>
606 :     \end{verbatim}}
607 :    
608 :     When this data is read into Gadget it is aggregated so that the weight is calculated for each length group defined in the stock file.
609 :    
610 :     \section{Growth and Eat Lengths}\label{sec:stockgrowthlength}
611 :     The calculations for the growth and consumption parts of the Gadget model can be done on a coarser scale than that defined in the stock file. The growth and eat lengths section of the stock file gives the name of a length aggregation file that defines this length grouping. In the stock file, the format for the growth and eat lengths is:
612 :    
613 :     {\small\begin{verbatim}
614 :     growthandeatlengths <name of the length aggregation file>
615 :     \end{verbatim}}
616 :    
617 :     \section{Growth}\label{sec:stockgrowth}
618 :     The growth section of the stock file determines if, and how, the stock will grow in the Gadget model. The format for the first part of the growth section is given below:
619 :    
620 :     {\small\begin{verbatim}
621 :     doesgrow <0 or 1> ; 0 for no growth, 1 for growth
622 :     \end{verbatim}}
623 :    
624 :     If there is no growth, then the following sections don't apply, and the next section of the input file is the natural mortality, given in section~\ref{sec:stocknatmort} below. If the stock does grow, there are various different functions that determine the mean growth of the stock, so there are a number of different formats that the growth data can take. Once the mean growth has been calculated, the growth then needs to be statistically distributed to give the overall growth of the stock. Thus, after the growth function data has been read in, there is then data for the growth implementation. The full format for the growth of the stock is therefore given by:
625 :    
626 :     {\small\begin{verbatim}
627 :     doesgrow 1
628 :     growthfunction <growth function>
629 :     <format for the growth function data>
630 :     <format for the growth implementation>
631 :     \end{verbatim}}
632 :    
633 :     The $<$growth function$>$ defines what growth function is to be used to calculate the growth of the stock. Currently, there are 7 growth functions defined, so valid function names are:
634 :    
635 :     \bigskip
636 :     multspec - use the MULTSPEC growth function\newline
637 :     weightvb - use the WeightVB growth function\newline
638 :     weightjones - use the WeightJones growth function\newline
639 :     weightvbexpanded - use the WeightVBExpanded growth function\newline
640 :     lengthvb - use the LengthVB growth function\newline
641 :     lengthpower - use the LengthPower growth function\newline
642 :     lengthvbsimple - use the LengthVBSimple growth function
643 :    
644 :     \subsection{MULTSPEC Growth Function}\label{subsec:growth1}
645 :     This growth function is a simplified ''MULTSPEC'' growth equation, with the increase in length for each length group of the stock given by equation~\ref{eq:growth1l}, and the corresponding increase in weight of the stock given by equation~\ref{eq:growth1w} below:
646 :    
647 :     \begin{equation}\label{eq:growth1l}
648 :     \Delta L_{i} = \Delta t p_{0} {L_{i}}^{p_{1}} \psi (p_{2} T + p_{3})
649 :     \end{equation}
650 :    
651 :     \begin{equation}\label{eq:growth1w}
652 :     \Delta W_{i} = \Delta t p_{4} {W_{i}}^{p_{5}} (\psi - p_{6}) (p_{7} T + p_{8})
653 :     \end{equation}
654 :    
655 :     where:\newline
656 :     $<\Delta t>$ is the length of the timestep\newline
657 :     $<$ T $>$ is the temperature\newline
658 :     $<\psi>$ is the feeding level (see section~\ref{sec:consumption})
659 :    
660 :     \bigskip
661 :     There are 4 parameters in the length equation, and 5 in the weight equation, giving a total of 9 parameters to be declared to define this growth function. This is given in the main stock file by declaring a single vector with 9 components, consisting of the 4 length parameters followed by the 5 weight parameters. This is shown below:
662 :    
663 :     {\small\begin{verbatim}
664 :     growthparameters <growth parameters vector>
665 :     \end{verbatim}}
666 :    
667 :     %JMB removed this from the documentation
668 :     %\subsection{FromFile Growth Function}\label{subsec:growth2}
669 :     %This growth function is the growth function that is used to read the growth from a file, rather than calculating it in the Gadget model. This is declared in the main stock file by listing the files containing the increase in length and weight. Since it is possible for the growth to be different in different areas, it is necessary to list a lengthfile and weightfile for each area. This is shown below:
670 :     %
671 :     %{\small\begin{verbatim}
672 :     %growthfiles <lengthfile> <weightfile>
673 :     %\end{verbatim}}
674 :     %
675 :     %The formats for the lengthfiles and the weightfiles are the same. They consist of a list of the year, timesteps, area and length label, followed by the growth for that timestep/area/length combination. The length group label used must match those specified in the growthandeatlengths length aggregation file. For the lengthfiles, the growth represents the mean length increase for that length group. For the weightfiles, the growth represents the mean increase in weight for that length group. The format of these files is shown below:
676 :     %
677 :     %{\small\begin{verbatim}
678 :     %<year> <step> <area> <length group> <number>
679 :     %\end{verbatim}}
680 :    
681 :     \subsection{WeightVB Growth Function}\label{subsec:growth3}
682 :     This growth function is a form of the Von Bertalanffy growth equation, extended to introduce the concept of starvation to the growth function. The increase in the weight for each length group the stock is given by equation~\ref{eq:growth3w}, and the corresponding increase in the length of the stock is given by equation~\ref{eq:growth3lc} below:
683 :    
684 :     \begin{equation}\label{eq:growth3w}
685 :     \Delta W_{i} = \Delta t q_{0} e^{q_{1} T} \left( \left( \frac{W_{i}}{q_{2}} \right)^{q_{4}} - \left( \frac{W_{i}}{q_{3}} \right)^{q_{5}} \right)
686 :     \end{equation}
687 :    
688 :     \begin{equation}\label{eq:growth3la}
689 :     r = \frac{W - \left( p_{0} + p_{8} \left( p_{1} + p_{2}p_{8} \right) \right) W_{ref}}{W}
690 :     \end{equation}
691 :    
692 :     \begin{equation}\label{eq:growth3lb}
693 :     f(x) =
694 :     \begin{cases}
695 :     0 & \textrm{if $p_{3} + p_{4}x \leq 0$} \\
696 :     p_{5} & \textrm{if $p_{3} + p_{4}x \geq p_{5}$} \\
697 :     p_{3} + p_{4}x & \textrm{otherwise}
698 :     \end{cases}
699 :     \end{equation}
700 :    
701 :     \begin{equation}\label{eq:growth3lc}
702 :     \Delta L_{i} = \frac{\Delta W_{i}} {p_{6} p_{7} l^{p_{7} - 1}} f(r)
703 :     \end{equation}
704 :    
705 :     where:\newline
706 :     $<\Delta t>$ is the length of the timestep\newline
707 :     $<$ T $>$ is the temperature\newline
708 :     $<W_{ref}>$ is the reference weight
709 :    
710 :     \bigskip
711 :     Comparing the weight to the reference weight (by using equations~\ref{eq:growth3la} and \ref{eq:growth3lb}) introduces the concept of starvation to the Gadget model. When the weight of the population is less than a function of the reference weight, there is no length increase (ensuring that the growth only has an effect on the weight).
712 :    
713 :     \bigskip
714 :     There are 6 parameters for the equation for increase of the weight, and a further 9 parameters for the increase in length. These are declared in 2 vectors, as shown below:
715 :    
716 :     {\small\begin{verbatim}
717 :     wgrowthparameters <weight parameters vector>
718 :     lgrowthparameters <length parameters vector>
719 :     \end{verbatim}}
720 :    
721 :     \subsection{WeightJones Growth Function}\label{subsec:growth4}
722 :     This growth function is a form of the Jones growth equation, extended to introduce the concept of starvation to the growth function. The increase in the weight for each length group the stock is given by equation~\ref{eq:growth4w}, and the corresponding increase in the length of the stock is given by equation~\ref{eq:growth4lc} below:
723 :    
724 :     \begin{equation}\label{eq:growth4w}
725 :     \Delta W_{i} = \Delta t \left( \frac{C}{q_{0} W_{i}^{q_{1}}} - q_{2} W_{i}^{q_{3}} e^{(q_{4} T + q_{5})} \right)
726 :     \end{equation}
727 :    
728 :     \begin{equation}\label{eq:growth4la}
729 :     r = \frac{W - \left( p_{0} + \psi \left( p_{1} + p_{2}\psi \right) \right) W_{ref}}{W}
730 :     \end{equation}
731 :    
732 :     \begin{equation}\label{eq:growth4lb}
733 :     f(x) =
734 :     \begin{cases}
735 :     0 & \textrm{if $p_{3} + p_{4}x \leq 0$} \\
736 :     p_{5} & \textrm{if $p_{3} + p_{4}x \geq p_{5}$} \\
737 :     p_{3} + p_{4}x & \textrm{otherwise}
738 :     \end{cases}
739 :     \end{equation}
740 :    
741 :     \begin{equation}\label{eq:growth4lc}
742 :     \Delta L_{i} = \frac{\Delta W_{i}} {p_{6} p_{7} l^{p_{7} - 1}} f(r)
743 :     \end{equation}
744 :    
745 :     where:\newline
746 :     $<\Delta t>$ is the length of the timestep\newline
747 :     $<$ C $>$ is the consumption (see section~\ref{sec:consumption})\newline
748 :     $<$ T $>$ is the temperature\newline
749 :     $<\psi>$ is the feeding level (see section~\ref{sec:consumption})\newline
750 :     $<W_{ref}>$ is the reference weight
751 :    
752 :     \bigskip
753 :     There are 6 parameters for the equation for increase of the weight, and a further 8 parameters for the increase in length. These are declared in 2 vectors, as shown below:
754 :    
755 :     {\small\begin{verbatim}
756 :     wgrowthparameters <weight parameters vector>
757 :     lgrowthparameters <length parameters vector>
758 :     \end{verbatim}}
759 :    
760 :     \subsection{WeightVBExpanded Growth Function}\label{subsec:growth5}
761 :     This growth function is an expanded form of the Von Bertalanffy growth equation, with additional information to allow for differing growth depending on the year, timestep and area. The increase in the weight of the stock is given by equation~\ref{eq:growth5w} below, and the corresponding increase in the length of the stock is identical to that for WeightVB growth function (see section~\ref{subsec:growth3}) given by equation~\ref{eq:growth3lc}:
762 :    
763 :     \begin{equation}\label{eq:growth5w}
764 :     \Delta W_{i} = \Delta t Y_{y} S_{s} A_{a} q_{0} e^{q_{1}T} \left( \left( \frac{W_{i}}{q_{2}} \right)^{q_{4}} - \left( \frac{W_{i}}{q_{3}} \right)^{q_{5}} \right)
765 :     \end{equation}
766 :    
767 :     where:\newline
768 :     $<\Delta t>$ is the length of the timestep\newline
769 :     $<$ T $>$ is the temperature\newline
770 :     $<Y_{y}>$ is a multiplier for year y\newline
771 :     $<S_{s}>$ is a multiplier for step s\newline
772 :     $<A_{a}>$ is a multiplier for area a
773 :    
774 :     \bigskip
775 :     There are 6 parameters for the equation for increase of the weight, and a further 9 parameters for the increase in length and these are declared in 2 vectors. Additionally there are vectors for the year, step and area multipliers, as is shown below:
776 :    
777 :     {\small\begin{verbatim}
778 :     wgrowthparameters <weight parameters vector>
779 :     lgrowthparameters <length parameters vector>
780 :     yeareffect <year effect vector>
781 :     stepeffect <step effect vector>
782 :     areaeffect <area effect vector>
783 :     \end{verbatim}}
784 :    
785 :     Note that the $<$year effect$>$ vector requires one entry for each year, the $<$step effect$>$ vector requires one entry for each step and the $<$area effect$>$ vector requires one entry for each area.
786 :    
787 :     \subsection{LengthVB Growth Function}\label{subsec:growth6}
788 :     This growth function is a simplified form of the Von Bertalanffy growth equation. The increase in the length for each length group the stock is given by equation~\ref{eq:growth6}, with the corresponding increase in the weight of the stock read in from a data file:
789 :    
790 :     \begin{equation}\label{eq:growth6}
791 :     \Delta L_{i} = \left( q_{0} - L_{i} \right) \left( 1 - e^{-q_{1} \Delta t} \right)
792 :     \end{equation}
793 :    
794 :     where:\newline
795 :     $<\Delta t>$ is the length of the timestep
796 :    
797 :     \bigskip
798 :     There are a total of 2 parameters for the equation for increase in length. These are declared in a single vector, as shown below:
799 :    
800 :     {\small\begin{verbatim}
801 :     growthparameters <growth parameters vector>
802 :     weightgrowthfile <weight data file>
803 :     \end{verbatim}}
804 :    
805 :     The weight data file consists of a list of the year, timestep, area and length group label, followed by the mean increase in weight for that timestep/area/length combination. The length group label used must match those specified in the growthandeatlengths length aggregation file. The format of this file is shown below:
806 :    
807 :     {\small\begin{verbatim}
808 :     <year> <step> <area> <length group> <number>
809 :     \end{verbatim}}
810 :    
811 :     \subsection{LengthPower Growth Function}\label{subsec:growth7}
812 :     This growth function uses a simple power-based growth equation to calculate the increase in length. The increase in the length for each length group the stock is given by equation~\ref{eq:growth7}, with the corresponding increase in the weight of the stock read in from a data file:
813 :    
814 :     \begin{equation}\label{eq:growth7}
815 :     \Delta L_{i} = L_{i}^{q_{0}} e^{q_{1} \Delta t}
816 :     \end{equation}
817 :    
818 :     where:\newline
819 :     $<\Delta t>$ is the length of the timestep
820 :    
821 :     \bigskip
822 :     There are a total of 2 parameters for the equation for increase in length. These are declared in a single vector, as shown below:
823 :    
824 :     {\small\begin{verbatim}
825 :     growthparameters <growth parameters vector>
826 :     weightgrowthfile <weight data file>
827 :     \end{verbatim}}
828 :    
829 :     The weight data file consists of a list of the year, timestep, area and length group label, followed by the mean increase in weight for that timestep/area/length combination. The length group label used must match those specified in the growthandeatlengths length aggregation file. The format of this file is shown below:
830 :    
831 :     {\small\begin{verbatim}
832 :     <year> <step> <area> <length group> <number>
833 :     \end{verbatim}}
834 :    
835 :     \subsection{LengthVBSimple Growth Function}\label{subsec:growth8}
836 :     This growth function is a simplified form of the Von Bertalanffy growth equation. The increase in the length for each length group the stock is given by equation~\ref{eq:growth8l}, and the corresponding increase in the weight of the stock is given by equation~\ref{eq:growth8w} below:
837 :    
838 :     \begin{equation}\label{eq:growth8l}
839 :     \Delta L_{i} = \left( L_{\infty} - L_{i} \right) \left( 1 - e^{-\kappa \Delta t} \right)
840 :     \end{equation}
841 :    
842 :     \begin{equation}\label{eq:growth8w}
843 :     \Delta W_{i} = \alpha \left( \left( L_{i} + \Delta L_{i} \right) ^{\beta} - {L_{i}}^{\beta} \right)
844 :     \end{equation}
845 :    
846 :     where:\newline
847 :     $<\Delta t>$ is the length of the timestep
848 :    
849 :     \bigskip
850 :     There are a total of 4 parameters for the equation for increase in length and weight. These are declared in a single vector, as shown below:
851 :    
852 :     {\small\begin{verbatim}
853 :     growthparameters <linf> <kappa> <alpha> <beta>
854 :     \end{verbatim}}
855 :    
856 :     It is important to note that if the value of $L_{\infty}$ is less than the mean length of a length group, then the length increase calculated by equation~\ref{eq:growth8l} would be negative for that length group, which will result in Gadget printing a warning message. To avoid this, the user should ensure that the value of $L_{\infty}$ is always greater than the mean length of the largest length group.
857 :    
858 :     \section{Growth Implementation}\label{sec:stockgrowthimplement}
859 :     The growth functions described above calculate the mean growth for the stock within the model. This must then be translated into a statistical distribution of actual growths around that mean. Currently there is only one statistical distribution implemented with Gadget, the beta-binomial, which is described below.
860 :    
861 :     \bigskip
862 :     Note that regardless of the results of the implementation function there is a minimum width to the possible distribution implemented in Gadget - where growth is allocated between two adjacent length categories. This is a result of the discretisation within Gadget. To avoid this the user should select a length category size small enough for some fish to grow by at least 3 or 4 categories in one time step.
863 :    
864 :     \subsection{Beta-Binomial}
865 :     This method uses a statistical distribution to govern the implementation of fish growth. The statistical distribution chosen is the beta-binomial, an extension of the binomial distribution with the flexibility to produce non-symmetrical distributions, which is defined for integers, x = 0, \ldots, n as:
866 :    
867 :     \begin{equation}\label{eq:betabin1}
868 :     {n \choose x} p^x (1 - p)^{n - x} = \frac{\Gamma(n + 1)}{\Gamma(x + 1)\Gamma(n - x + 1)} p^x (1 - p)^{n - x}
869 :     \end{equation}
870 :    
871 :     For more flexibility, this can be re-arranged by calculating the parameter $<$p$>$ from a second beta-binomial distribution, leading to equation~\ref{eq:betabin2} shown below, which is defined for 0 $\le$ p $\le$ 1:
872 :    
873 :     \begin{equation}\label{eq:betabin2}
874 :     f(p) = \frac{\Gamma(\alpha + \beta)}{\Gamma(\alpha) \Gamma(\beta)}p^{\alpha - 1}(1 - p)^{\beta - 1}
875 :     \end{equation}
876 :     \begin{equation}\label{eq:betabin3}
877 :     \alpha = \frac{\beta \Delta L}{n - \Delta L}
878 :     \end{equation}
879 :    
880 :     The distribution is governed by three parameters; the mean length growth computed by the growth function scaled by dividing by the width of the length groups ($<\Delta$L $>$), a fixed limit on the number of length groups ($<$ n $>$), and a value for beta. This distribution was chosen because it provides a high degree of flexibility resulting from changing a single estimated parameter, beta. To define the distribution data using a beta-binomial distribution the following data is required in the main stock file:
881 :    
882 :     {\small\begin{verbatim}
883 :     beta <beta>
884 :     maxlengthgroupgrowth <max length group growth>
885 :     \end{verbatim}}
886 :    
887 :     The parameter $<$beta$>$ is the parameter that Gadget can estimate in the optimisation routines, in order to tune the distribution to best fit the data. High values of beta produce a narrow distribution, whilst lower values produce a more dispersed distribution with a larger right-hand tail. Note that very low values of beta (which lead to $\alpha$ < 1 in equation~\ref{eq:betabin3}) can lead to unexpected results and should be avoided.
888 :    
889 :     \bigskip
890 :     The $<$max length group growth$>$ value is the maximum number of length categories a fish is permitted to grow in a single timestep within the model. This should be set to be several length groups larger than any fish can be reasonably expected to grow in a time step, in order to provide the beta-binomial distribution with sufficient flexibility to produce a distribution around the mean.
891 :    
892 :     \section{Natural Mortality}\label{sec:stocknatmort}
893 :     The natural mortality is a measure of how much of the stock will be removed from the model due to additional natural causes that are not modelled as part of other processes (for example predation). In Gadget, this is simply modelled as the proportion of the stock that is removed due to these additional causes (the residual mortality) from each age group, on each timestep, as shown in equation~\ref{eq:natmort} below:
894 :    
895 :     \begin{equation}\label{eq:natmort}
896 :     N_{a} = e^{-m_{a} \Delta t}
897 :     \end{equation}
898 :    
899 :     where:\newline
900 :     $<\Delta t>$ is the length of the timestep
901 :    
902 :     \bigskip
903 :     The natural mortality parameters $<m_{a}>$ are specified in the stock file as a vector, with one parameter per age group, as shown below:
904 :    
905 :     {\small\begin{verbatim}
906 :     naturalmortality <natural mortality vector>
907 :     \end{verbatim}}
908 :    
909 :     \section{Stock Prey}\label{sec:stockprey}
910 :     The stock prey section of the stock file determines if, and how, the stock will be treated as a prey in the Gadget model. The format for the first part of the prey section of the main stock file is given below:
911 :    
912 :     {\small\begin{verbatim}
913 :     iseaten <0 or 1> ; 0 for not eaten, 1 for eaten
914 :     \end{verbatim}}
915 :    
916 :     Note that the fleets are treated as a predator by Gadget, so for the stock to be caught by the fleets, the stock needs to be declared as a prey. If the stock is not eaten, then the following section doesn't apply, and the next section of the input file is the stock predator, given in section~\ref{sec:stockpredator} below. If the stock is eaten, then for Gadget to treat it as a prey the length groups for that prey, and the energy content of the prey, must be defined. The length groups need not be to the same scale as for the stock as a whole. This is done by listing a length aggregation file that is to be used, as well as the energy content (in kilojoules per kilogram), as shown for the full example below:
917 :    
918 :     {\small\begin{verbatim}
919 :     iseaten 1
920 :     preylengths <length aggregation file>
921 :     energycontent <energy value>
922 :     \end{verbatim}}
923 :    
924 :     \section{Stock Predator}\label{sec:stockpredator}
925 :     The stock predator section of the stock file determines if, and how, the stock will be treated as a predator in the Gadget model. The format for the first part of the predator section is given below:
926 :    
927 :     {\small\begin{verbatim}
928 :     doeseat <0 or 1> ; 0 for not a predator, 1 for predator
929 :     \end{verbatim}}
930 :    
931 :     If the stock is not a predator, then the following sections don't apply, and the next section of the input file is the initial conditions, given in section~\ref{sec:stockinitial} below. If the stock is a predator, then it is necessary to specify information about the predation. This is done by defining a suitability function, and then some prey preference, consumption and feeding parameters. The full format for this is shown below:
932 :    
933 :     {\small\begin{verbatim}
934 :     doeseat 1
935 :     suitability <see Suitability>
936 :     preference <prey preference values>
937 :     maxconsumption <maximum consumption vector>
938 :     halffeedingvalue <half feeding value>
939 :     \end{verbatim}}
940 :    
941 :     The $<$suitability$>$ defines the prey that the predator will consume, and is discussed in the Suitability section below (see section~\ref{sec:suitability}). The $<$prey preference$>$ values, $<$maximum consumption$>$ vector and $<$half feeding$>$ value parameters define how the stock consumes any prey that is eaten, and are described in the following section.
942 :    
943 :     \section{Consumption}\label{sec:consumption}
944 :     The consumption determines how much of a given prey is consumed by the predator. This will result in the population of the prey being reduced, and can also affect the growth of the predator, depending on the growth function selected. The consumption of a prey is dependant on the length of both the predator and the prey, and the amount of the prey available, as a proportion of the total amount of food available. The consumption of prey $p$ is given by equation~\ref{eq:totalcons} below:
945 :    
946 :     \begin{equation}\label{eq:totalcons}
947 :     C_{p}(l, L) = \frac{N_{L} M_{L} \psi_{L} F_{p}(l, L)}{\displaystyle \sum_{\it preys} F_{p}(l, L)}
948 :     \end{equation}
949 :    
950 :     \begin{equation}\label{eq:preycons}
951 :     F_{p}(l, L) =\Big( S_{p}(l, L) E_{p} N_{l} W_{l} \Big) ^{d_{p}}
952 :     \end{equation}
953 :    
954 :     \begin{equation}\label{eq:maxcons}
955 :     M_{L} = m_{0} \Delta t e^{(m_{1}T - m_{2}T^3)} L^{m_{3}}
956 :     \end{equation}
957 :    
958 :     \begin{equation}\label{eq:feedlevel}
959 :     \psi_{L} = \frac{\displaystyle \sum_{\it preys} F_{p}(l, L)}{H \Delta t + \displaystyle \sum_{\it preys} F_{p}(l, L)}
960 :     \end{equation}
961 :    
962 :     where:\newline
963 :     $<$ L $>$ is the length of the predator\newline
964 :     $<$ l $>$ is the length of the prey\newline
965 :     $<$ H $>$ is the half feeding value\newline
966 :     $<$ d $>$ is the preference of the predator for the prey\newline
967 :     $<$ E $>$ is the energy content of the prey (see section~\ref{sec:stockprey})\newline
968 :     $<$ N $>$ is the number of prey in the length cell\newline
969 :     $<$ W $>$ is the mean weight of the prey in the length cell\newline
970 :     $<$ S $>$ is the suitability function (see section~\ref{sec:suitability})\newline
971 :     $<\Delta t>$ is the length of the timestep\newline
972 :     $<$ T $>$ is the temperature of the area that the feeding takes place on
973 :    
974 :     \bigskip
975 :     In equation~\ref{eq:totalcons}, the parameter $<$ F $>$ gives the amount of a given prey that is consumed by the predator, given by multiplying the biomass of the prey by the suitability (see section~\ref{sec:suitability}), as shown in equation~\ref{eq:preycons}. The summation over preys is over all preys that the predator consumes, including non-modelled prey, given as ''otherfood'' in section~\ref{chap:other}. The value of $<$ C $>$ can have an affect on the growth of the predator when the growth function has been set to ''WeightJones''.
976 :    
977 :     \bigskip
978 :     In equation~\ref{eq:preycons}, the parameter $<$ d $>$ gives the preference of the predator for the prey, controlling the form of the functional response that is used to model the predation. Setting this parameter to 1 will ensure that a Type II functional response is used (note that this is always used when modelling the predation by the fleets, see section~\ref{chap:fleet}). Any other value will mean that a Type III functional response is used. The prey preference parameter is specified by listing the names of the prey and the associated preference value, as shown in the example below:
979 :    
980 :     {\small\begin{verbatim}
981 :     ...
982 :     preference
983 :     <name of prey 1> <preference for prey 1>
984 :     <name of prey 2> <preference for prey 2>
985 :     maxconsumption <maximum consumption vector>
986 :     ...
987 :     \end{verbatim}}
988 :    
989 :     In equation~\ref{eq:maxcons}, the parameter $<$ M $>$ gives the maximum possible consumption for the predator on the current timestep. This is a function of temperature and the length of the predator, using the 4 parameters specified by the $<$maximum consumption$>$ vector in the input file. Note that the maximum consumption should be specified in kilojoules per month.
990 :    
991 :     \bigskip
992 :     In equation~\ref{eq:feedlevel}, the parameter $<\psi>$ gives the ''feeding level'' which denotes the fraction of the available food that the predator is consuming. This is governed by the total amount of prey available and the $<$half feeding$>$ value which is specified in the input file. The $<$half feeding$>$ value is the biomass of prey required to allow the predator to consume prey at half the maximum consumption level. The value of $<\psi>$ can have an affect on the growth of the predator (ie. when there isn't sufficient food available) when the growth function has been set to ''MULTSPEC'' or ''WeightJones''.
993 :    
994 :     \section{Suitability}\label{sec:suitability}
995 :     The suitability determines how the predators act on the preys. This selectivity relationship between the predator and the prey is based on the lengths of the predator and prey, and are defined by declaring a suitability function and the parameters for that function. The suitability values can be thought of as the proportion of the prey length group that the predator length group can consume, and as such the suitability values should be between 0 and 1.
996 :    
997 :     \bigskip
998 :     To define a suitability relationship based on a suitability function, the stock file (for the predator) needs to contain the following data:
999 :    
1000 :     {\small\begin{verbatim}
1001 :     suitability
1002 :     <preyname> function <functionname> <parameters> ; for each prey
1003 :     \end{verbatim}}
1004 :    
1005 :     The $<$functionname$>$ defines which suitability function is to be used to calculate the suitability for the predator acting on the prey. Currently there are 7 suitability functions defined, and the valid suitability function names are:
1006 :    
1007 :     \bigskip
1008 :     constant - use the Constant suitabilty function\newline
1009 :     straightline - use the StraightLine suitabilty function\newline
1010 :     exponential - use the Exponential suitabilty function\newline
1011 :     exponentiall50 - use the ExponentialL50 suitabilty function\newline
1012 :     richards - use the Richards suitabilty function\newline
1013 :     andersen - use the Andersen suitabilty function\newline
1014 :     gamma - use the Gamma suitabilty function
1015 :    
1016 :     \bigskip
1017 :     For the following suitability functions, the convention used is to represent the length group of the prey by l, and the length group of the predator by L.
1018 :    
1019 :     \subsection{Constant Suitability Function}
1020 :     This is a constant suitability function, where there is no dependence on either the length of the predator or the length of the prey as given by the following equation:
1021 :    
1022 :     \begin{equation}\label{eq:constsuit}
1023 :     S(l, L) = \alpha
1024 :     \end{equation}
1025 :    
1026 :     Hence, to specify a constant suitability function, the file format required is:
1027 :    
1028 :     {\small\begin{verbatim}
1029 :     <preyname> function constant <alpha>
1030 :     \end{verbatim}}
1031 :    
1032 :     \subsection{StraightLine Suitability Function}
1033 :     This is a suitability function that has no dependence on the length of the predator, and a linear dependence on the length of the prey as given by the following equation:
1034 :    
1035 :     \begin{equation}\label{eq:straightsuit}
1036 :     S(l, L) = \alpha l + \beta
1037 :     \end{equation}
1038 :    
1039 :     Hence, to specify a straight line suitability function, the file format required is:
1040 :    
1041 :     {\small\begin{verbatim}
1042 :     <preyname> function straightline <alpha> <beta>
1043 :     \end{verbatim}}
1044 :    
1045 :     \subsection{Exponential Suitability Function}
1046 :     This is a suitability function that has a logarithmic dependence on both the length of the predator and the length of the prey as given by the following equation:
1047 :    
1048 :     \begin{equation}\label{eq:expsuit}
1049 :     S(l, L) = {\frac{\delta}{1 + e^{(- \alpha - \beta l - \gamma L)}}}
1050 :     \end{equation}
1051 :    
1052 :     Hence, to specify this suitability function, the file format required is:
1053 :    
1054 :     {\small\begin{verbatim}
1055 :     <preyname> function exponential <alpha> <beta> <gamma> <delta>
1056 :     \end{verbatim}}
1057 :    
1058 :     \subsection{ExponentialL50 Suitability Function}
1059 :     This is a suitability function that has no dependence on the length of the predator, and a logarithmic dependence on the length of the prey as given by the following equation:
1060 :    
1061 :     \begin{equation}\label{eq:l50suit}
1062 :     S(l, L) = { \frac{1}{1 + e^{ -4 \alpha (l - l_{50})}}}
1063 :     \end{equation}
1064 :    
1065 :     Note that the prey length dependence is actually dependant on the difference between the length of the prey and $l_{50}$, which is the length of the prey with a 50\% probability of predation. Hence, to specify this suitability function, the file format required is:
1066 :    
1067 :     {\small\begin{verbatim}
1068 :     <preyname> function exponentiall50 <alpha> <l50>
1069 :     \end{verbatim}}
1070 :    
1071 :     \subsection{Richards Suitability Function}
1072 :     This is a suitability function that is an extension to the Exponential suitiability function, and has a logarithmic dependence on both the length of the predator and the length of the prey as given by the following equation:
1073 :    
1074 :     \begin{equation}\label{eq:richsuit}
1075 :     S(l, L) = \left({\frac{p_3}{1 + e^{(- p_0 - p_1 l - p_2 L)}}}\right) ^ {\frac{1}{p_4}}
1076 :     \end{equation}
1077 :    
1078 :     Hence, to specify this suitability function, the file format required is:
1079 :    
1080 :     {\small\begin{verbatim}
1081 :     <preyname> function richards <vector of 5 parameters>
1082 :     \end{verbatim}}
1083 :    
1084 :     \subsection{Andersen Suitability Function}
1085 :     This is a more general suitability function that is dependant on the ratio of the predator length to the prey length as given by the following equation:
1086 :    
1087 :     \begin{equation}\label{eq:andersensuit}
1088 :     S(l, L) =
1089 :     \begin{cases}
1090 :     p_0 + p_2e^{-\frac{(\ln\frac{L}{l} - p_1)^2}{p_4}} & \textrm{if $\ln\frac{L}{l} \leq p_1$} \\
1091 :     p_0 + p_2e^{-\frac{(\ln\frac{L}{l} - p_1)^2}{p_3}} & \textrm{if $\ln\frac{L}{l} > p_1$}
1092 :     \end{cases}
1093 :     \end{equation}
1094 :    
1095 :     Note that the log of the ratio of the predator/prey lengths is bounded, to ensure that the suitability function is always well defined. To specify this suitability function, the file format required is:
1096 :    
1097 :     {\small\begin{verbatim}
1098 :     <preyname> function andersen <vector of 5 parameters>
1099 :     \end{verbatim}}
1100 :    
1101 :     \subsection{Gamma Suitability Function}
1102 :     This is a suitability function that is only dependant on the prey length as given by the following equation:
1103 :    
1104 :     \begin{equation}\label{eq:gammasuit}
1105 :     S(l, L) = \left(\frac{l}{(\alpha - 1) \beta\gamma}\right) ^ {(\alpha - 1)}e ^ {(\alpha - 1 - \frac{l}{\beta\gamma})}
1106 :     \end{equation}
1107 :    
1108 :     Hence, to specify this suitability function, the file format required is:
1109 :    
1110 :     {\small\begin{verbatim}
1111 :     <preyname> function gamma <alpha> <beta> <gamma>
1112 :     \end{verbatim}}
1113 :    
1114 :     This is a suitability function that is more suitable for use when considering the predation by a fleet (see section~\ref{sec:fleetsuit}), where the parameter $<\gamma>$ would represent the size of the mesh used by the fleet (specified in centimetres).
1115 :    
1116 :     \section{Initial Conditions}\label{sec:stockinitial}
1117 :     The initial conditions section of stock file specifies the stock population at the start of the simulation (ie. at the beginning of the first timestep specified in the ''time'' file). This includes setting up the population size, the length distribution and the mean weight for each length group. This is done by specifying the minimum and maximum age and length for the stock on this timestep, and either specifying parameters to allow Gadget to create a stock distribution based on a Normal distribution, or the numbers that make up the stock distribution required.
1118 :    
1119 :     \bigskip
1120 :     The format for the initial conditions section of the stock file is given below:
1121 :    
1122 :     {\small\begin{verbatim}
1123 :     initialconditions
1124 :     minage <minimum age for the initial stock>
1125 :     maxage <maximum age for the initial stock>
1126 :     minlength <minimum length for the initial stock>
1127 :     maxlength <maximum length for the initial stock>
1128 :     dl <step size for the initial length groups>
1129 :     sdev <standard deviation multiplier>
1130 :     <initial stock distribution data>
1131 :     \end{verbatim}}
1132 :    
1133 :     The optional $<$sdev$>$ value is used to scale the standard deviation of the length of the initial stock. The standard deviation used in calculating the length distribution will be multiplied by this value. If it is not specified, then it is assumed to have a value of 1 (ie, no scaling will take place). The optional $<$dl$>$ value is used to set the length group divisions for the initial stock population. If this is not specified, then it is assumed that the initial population will have the same value for $<$dl$>$ as for the stock, as specified in the main stock file.
1134 :    
1135 :     \bigskip
1136 :     There are three formats for the initial stock distribution data, as given below:
1137 :    
1138 :     \bigskip
1139 :     Normal Condition - use a Normal function to generate the length distribution, with a relative condition factor to assign a mean weight to the initial population\newline
1140 :     Normal Parametric - use a Normal function to generate the length distribution, with a parametric weight-length relationship to calculate a mean weight for the initial population\newline
1141 :     Numerical - specify the numbers, and the corresponding mean weights, for the initial population
1142 :    
1143 :     \subsection{Normal Condition Distribution}
1144 :     To specify an initial stock with the lengths given by a Normal distribution, and using a relative condition factor to generate the weights, the main stock file needs to specify the name of a datafile containing the information about the Normal distribution, as shown below:
1145 :    
1146 :     {\small\begin{verbatim}
1147 :     normalcondfile <name of the initial stock data file>
1148 :     \end{verbatim}}
1149 :    
1150 :     The initial stock file contains all the information that Gadget requires to construct an initial population of the stock. Gadget will construct a population of 10,000 fish for each age group, with the length groups for these age groups having a Normal distribution about a specified mean length with a specified standard deviation. The mean weight for this initial population is calculated by multiplying the reference weight (specified in the main stock file) by a relative conditioning factor (which is typically set to 1).
1151 :    
1152 :     \bigskip
1153 :     To get from a population with 10,000 fish in each age group (for each area) to the initial population used in the model, each age group is multiplied by an age weighting factor and an area weighting factor.
1154 :    
1155 :     \bigskip
1156 :     Hence, the format for the initial stock file is given below:
1157 :    
1158 :     {\small\begin{verbatim}
1159 :     <age> <area> <age factor> <area factor> <mean> <stddev> <relcond>
1160 :     \end{verbatim}}
1161 :    
1162 :     \subsection{Normal Parametric Distribution}
1163 :     To specify an initial stock with the lengths given by a Normal distribution, and using a weight-length relationship to generate the weights, the main stock file needs to specify the name of a datafile containing the information about the Normal distribution, as shown below:
1164 :    
1165 :     {\small\begin{verbatim}
1166 :     normalparamfile <name of the initial stock data file>
1167 :     \end{verbatim}}
1168 :    
1169 :     The initial stock file contains all the information that Gadget requires to construct an initial population of the stock. Gadget will construct a population of 10,000 fish for each age group, with the length groups for these age groups having a Normal distribution about a specified mean length with a specified standard deviation. The mean weight for this initial population is then calculated from the standard weight-length relationship, as given in equation~\ref{eq:wlen} below:
1170 :    
1171 :     \begin{equation}\label{eq:wlen}
1172 :     W = \alpha L^{\beta}
1173 :     \end{equation}
1174 :    
1175 :     \bigskip
1176 :     To get from a population with 10,000 fish in each age group (for each area) to the initial population used in the model, each age group is multiplied by an age weighting factor and an area weighting factor.
1177 :    
1178 :     \bigskip
1179 :     Hence, the format for the initial stock file is given below:
1180 :    
1181 :     {\small\begin{verbatim}
1182 :     <age> <area> <age factor> <area factor> <mean> <stddev> <alpha> <beta>
1183 :     \end{verbatim}}
1184 :    
1185 :     \subsection{Numerical Distribution}
1186 :     An alternative approach is to define the initial stock population by specifying an age-length table, along with the mean weight, for the initial stock. This approach requires the main stock file to specify a data file to give the age-length table, as shown below:
1187 :    
1188 :     {\small\begin{verbatim}
1189 :     numberfile <name of the initial stock data file>
1190 :     \end{verbatim}}
1191 :    
1192 :     The initial stock file contains the age-length table for the initial population. This file specifies the population, and mean weight, of the stock for each area, age group and length group combination, as shown below:
1193 :    
1194 :     {\small\begin{verbatim}
1195 :     <area> <age> <length> <number> <weight>
1196 :     \end{verbatim}}
1197 :    
1198 :     Note that the $<$length$>$ value refers to the minimum length of the age-length cell that the initial population will be put into.
1199 :    
1200 :     \section{Migration}\label{sec:stockmigrate}
1201 :     The migration section of the stock file determines if, and how, the stock will migrate in the Gadget model. The migration of a stock within a Gadget model is calculated based on migration matrices. The format for the first part of the migration section is given below:
1202 :    
1203 :     {\small\begin{verbatim}
1204 :     doesmigrate <0 or 1> ; 0 for no migration, 1 for migration
1205 :     \end{verbatim}}
1206 :    
1207 :     If the stock does not migrate, then the following section doesn't apply, and the next section of the input file is the maturation, given in section~\ref{sec:stockmature} below. If the stock does migrate, then further information about the migration is required. There are currently 2 formats for the migration data, as given in the list below:
1208 :    
1209 :     \bigskip
1210 :     Migration Matrices - specify the migration matrices to be used\newline
1211 :     Migration Ratios - specify the ratio of the stock that moves between areas, and let Gadget calculate the required matrices based on these ratios
1212 :    
1213 :     \subsection{Migration Matrices}
1214 :     To specify the migration of the stock by defining the migration matrices directly, the main stock file needs to specify the name of a datafile containing information about when the migration will take place, and the name of a datafile containing information about the migration matrices, as shown below:
1215 :    
1216 :     {\small\begin{verbatim}
1217 :     doesmigrate 1
1218 :     yearstepfile <name of the migration timestep data file>
1219 :     definematrices <name of the migration matrix data file>
1220 :     \end{verbatim}}
1221 :    
1222 :     The migration timestep file contains a simple list of the timesteps that the migration will take place on, along with the name of the migration matrix that is to be used on each timestep, as shown below:
1223 :    
1224 :     {\small\begin{verbatim}
1225 :     <year> <step> <migration matrix>
1226 :     \end{verbatim}}
1227 :    
1228 :     The migration matrix file contains the migration matrices to be used to move the stock between the various areas within the Gadget model. Each matrix is listed, starting with the keyword [migrationmatrix], followed by the name of the migration matrix, and then the matrix to be used, as shown below:
1229 :    
1230 :     {\small\begin{verbatim}
1231 :     [migrationmatrix]
1232 :     name <migration matrix>
1233 :     <migration matrix data>
1234 :     \end{verbatim}}
1235 :    
1236 :     The $<$migration matrix$>$ data should be a square $n$ x $n$ matrix, for the $n$ areas that the stock is defined on, with the proportion moving {\bf from} each area given in the columns, and the proportion moving {\bf to} each area given in the rows. Since migration shouldn't change the total number of fish in the model, each column in the matrix should sum to one.
1237 :    
1238 :     \bigskip
1239 :     An example of a migration matrix data for a stock that is defined on two areas is given below:
1240 :    
1241 :     {\small\begin{verbatim}
1242 :     [migrationmatrix]
1243 :     name example
1244 :     0.6 0.3
1245 :     0.4 0.7
1246 :     \end{verbatim}}
1247 :    
1248 :     For the migration of the stock in the example shown above, 60\% of the stock that are on area 1 at the start of the migration will move to area 1 (ie. they will stay there) and the remaining 40\% will move to area 2. For the stock that start the timestep on area 2, 30\% will move to area 1 and the remaining 70\% will stay on area 2.
1249 :    
1250 :     \subsection{Migration Ratios}
1251 :     An alternative approach is to specify the migration of the stock by defining the ratio of the stock that will migrate between given areas, and let Gadget calculate the resulting migration matrices to use within the model. To use this format for the migration data, the main stock file needs to specify the name of a datafile containing information about when the migration will take place, and the name of a datafile containing information about the migration ratios, as shown below:
1252 :    
1253 :     {\small\begin{verbatim}
1254 :     doesmigrate 1
1255 :     yearstepfile <name of the migration timestep data file>
1256 :     defineratios <name of the migration ratio data file>
1257 :     \end{verbatim}}
1258 :    
1259 :     The migration timestep file contains a list of the timesteps that the migration will take place on, along with the name of the migration matrix that is to be used on each timestep, in the same format as for the Migration Matrices, as shown above.
1260 :    
1261 :     \bigskip
1262 :     The migration ratio file contains the ratios to be used by Gadget to construct the migration matrices to move the stock between the various areas within the Gadget model. Each matrix is listed, starting with the keyword [migrationmatrix], followed by the name of the migration matrix, and then a list of the ratios to be used to construct the matrix, as shown below:
1263 :    
1264 :     {\small\begin{verbatim}
1265 :     [migrationmatrix]
1266 :     name <migration matrix>
1267 :     <from> <to> <ratio>
1268 :     \end{verbatim}}
1269 :    
1270 :     The migration ratio data is a list of the ratio of the stock that moves from the $<$from$>$ area to the $<$to$>$ area. Gadget will attempt to construct the migration matrix based on these ratios. Where the data is incomplete, Gadget will assume that there is no migration between areas (ie. fish will stay on the area that they are on at the start of the timestep). If Gadget cannot construct a (unique) migration matrix, then the model will stop the current simulation and display an error message.
1271 :    
1272 :     \bigskip
1273 :     An example of a migration ratio data for a stock that is defined on two areas is given below:
1274 :    
1275 :     {\small\begin{verbatim}
1276 :     [migrationmatrix]
1277 :     name example
1278 :     1 2 0.4
1279 :     2 1 0.3
1280 :     \end{verbatim}}
1281 :    
1282 :     For the migration of the stock in the example shown above, 40\% of the stock that are on area 1 at the start of the migration will move to area 2, and the remaining 60\% will stay on area 1. For the stock that start the timestep on area 2, 30\% will move to area 1 and the remaining 70\% will stay on area 2.
1283 :    
1284 :     \section{Maturation}\label{sec:stockmature}
1285 :     The maturation section of the stock file determines if, and how, the stock will mature in the Gadget model. The format for the first part of the maturation section is given below:
1286 :    
1287 :     {\small\begin{verbatim}
1288 :     doesmature <0 or 1> ; 0 for no maturation, 1 for maturation
1289 :     \end{verbatim}}
1290 :    
1291 :     If the stock does not mature, then the following sections don't apply, and the next section of the input file is the movement, given in section~\ref{sec:stockmove} below. If the stock does mature, then there are various different functions that describe how the stock can mature. The type of maturity function is denoted by a name, as shown below, and then the data required for that maturity function is given in a datafile. Thus the format for the maturity data, in the main stock file, is given below:
1292 :    
1293 :     {\small\begin{verbatim}
1294 :     doesmature 1
1295 :     maturityfunction <maturity function>
1296 :     maturityfile <name of the maturity data file>
1297 :     \end{verbatim}}
1298 :    
1299 :     The $<$maturity function$>$ defines the function that is to be used to calculate how the stock will mature. Currently there are 4 maturity functions defined, and the valid maturity function names are:
1300 :    
1301 :     \bigskip
1302 :     continuous - use the Continuous maturation function\newline
1303 :     constant - use the Constant maturation function\newline
1304 :     constantweight - use the ConstantWeight maturation function\newline
1305 :     fixedlength - use the FixedLength maturation function
1306 :    
1307 :     \bigskip
1308 :     The format for the data in the maturity data file is dependent on the maturity function that is to be used. All the maturity functions require the name of the mature stocks that the immature stock will mature into, and the ratio of the maturing part of the immature stock that is to mature into each mature stock. This allows for part of an immature stock to mature into more than one mature stock, so for example, an immature stock could mature into either a male mature stock or a female mature stock.
1309 :    
1310 :     \bigskip
1311 :     The maturity functions calculate the proportion of the fish in each age-length group that will become mature, and then move these fish from the age-length group for the current stock into the corresponding age-length group for the mature stock. Note that there is a check to ensure that the corresponding age-length group exists for the mature stock, and if it doesn't then the fish don't become mature and will stay in the immature stock.
1312 :    
1313 :     \subsection{Continuous Maturity Function}
1314 :     This maturity function calculates the proportion of an age-length group of an immature stock that becomes mature according to the maturity equations~\ref{eq:mat1a} and \ref{eq:mat1b} given below:
1315 :    
1316 :     \begin{equation}\label{eq:mat1a}
1317 :     P(l, a) = {\frac{1}{1 - M}}{\frac{dM}{dt}}
1318 :     \end{equation}
1319 :    
1320 :     \begin{equation}\label{eq:mat1b}
1321 :     M(l_{t},a_{t}) = \frac{1}{1 + e^{-\alpha(l_{t} - l_{50}) - \beta(a_{t} - a_{50})}}
1322 :     \end{equation}
1323 :    
1324 :     \bigskip
1325 :     The maturity term is a function of $l_{50}$ and $a_{50}$, which are the length and age where 50\% of the stock are mature. This is a continuous process, with the maturity proportion being calculated on every timestep. The file format for this maturity function is given below:
1326 :    
1327 :     {\small\begin{verbatim}
1328 :     maturestocksandratios <stockname i> <ratio i> ; for each stock i
1329 :     coefficients <alpha> <l50> <beta> <a50>
1330 :     \end{verbatim}}
1331 :    
1332 :     \subsection{Constant Maturity Function}
1333 :     This maturity function is similar to the Continuous maturity function, with the maturity proportion being calculated according to the maturity equation~\ref{eq:mat3} given below:
1334 :    
1335 :     \begin{equation}\label{eq:mat3}
1336 :     P(l, a) = \frac{1}{ 1 + e^{-4\alpha(l - l_{50}) -4\beta(a - a_{50})}}
1337 :     \end{equation}
1338 :    
1339 :     For this maturation function, it is assumed that maturation is an annual event, taking place on the same timesteps in each year. The file format for this maturity function is the similar to that for the Continuous maturity function, and is shown below:
1340 :    
1341 :     {\small\begin{verbatim}
1342 :     maturestocksandratios <stockname i> <ratio i> ; for each stock i
1343 :     coefficients <alpha> <l50> <beta> <a50>
1344 :     maturitysteps <vector of timesteps>
1345 :     \end{verbatim}}
1346 :    
1347 :     The $<$maturitysteps$>$ vector is a vector of timesteps that the maturation process will take place on.
1348 :    
1349 :     \subsection{ConstantWeight Maturity Function}
1350 :     This maturity function is an extension to the Constant maturity function, with the maturity proportion being calculated according to the maturity equation~\ref{eq:mat4} given below:
1351 :    
1352 :     \begin{equation}\label{eq:mat4}
1353 :     P(l, a) = \frac{1}{ 1 + e^{-4\alpha(l - l_{50}) -4\beta(a - a_{50}) -4\gamma(k - k_{50})}}
1354 :     \end{equation}
1355 :    
1356 :     The maturity function has been extended to include the relative condition of the stock (calculated by dividing the current weight by the reference weight) and $k_{50}$ which is the relative condition where 50\% of the stock is mature. The file format for this maturity function is the similar to that for the Constant maturity function, and is shown below:
1357 :    
1358 :     {\small\begin{verbatim}
1359 :     maturestocksandratios <stockname i> <ratio i> ; for each stock i
1360 :     coefficients <alpha> <l50> <beta> <a50> <gamma> <k50>
1361 :     maturitysteps <vector of timesteps>
1362 :     \end{verbatim}}
1363 :    
1364 :     \subsection{FixedLength Maturity Function}
1365 :     This maturity function takes a different approach, and bases the proportion of the immature stock that matures on the length of the immature stock, as the length varies through the year. This is approach assumes that the maturation process is the same for each year. The proportion of the immature stock that matures is given by the equation~\ref{eq:mat2} below:
1366 :    
1367 :     \begin{equation}\label{eq:mat2}
1368 :     P(l, a) =
1369 :     \begin{cases}
1370 :     1 & \textrm{if there is an $i$ such that $s_i$ is the current step and $l > l_i$} \\
1371 :     0 & \textrm{otherwise}
1372 :     \end{cases}
1373 :     \end{equation}
1374 :    
1375 :     For each timestep in the year, the stock is assumed to mature when the length of the fish reaches a certain value. This length can change for each timestep. This information is given in a file with the format specified below:
1376 :    
1377 :     {\small\begin{verbatim}
1378 :     maturestocksandratios <stockname i> <ratio i> ; for each stock i
1379 :     maturitysteps <vector of timesteps>
1380 :     maturitylengths <vector of lengths>
1381 :     \end{verbatim}}
1382 :    
1383 :     Note that the $<$maturitysteps$>$ and the $<$maturitylengths$>$ vectors need to be the same size.
1384 :    
1385 :     \section{Movement (''Transition'')}\label{sec:stockmove}
1386 :     The movement section of the stock file determines if, and how, the stock will move (into a different stock) in the Gadget model. This allows for a Gadget model to be set up with different stock files for stock that is the same species, but with differing properties (for instance age or maturity status) and for the entries to move between these stocks when required. For the current version of Gadget, the only movement between stocks that is valid is for the stock in the oldest age group of one stock to move into a different stock. The format for the first part of the movement section is given below:
1387 :    
1388 :     {\small\begin{verbatim}
1389 :     doesmove <0 or 1> ; 0 for no movement, 1 for movement
1390 :     \end{verbatim}}
1391 :    
1392 :     If the stock does not move, then the following section doesn't apply, and the next section of the input file is the renewal, given in section~\ref{sec:stockrenew} below. If the stock does move, then the information required to define the movement is the timestep for the movement to occur (since the movement is assumed to be an annual event) and the names of the stocks to move the oldest age group into, along with the ratio of the oldest age group that will move into that particular stock. Thus the full format for the movement of the stock is given below:
1393 :    
1394 :     {\small\begin{verbatim}
1395 :     doesmove 1
1396 :     transitionstocksandratios <stockname i> <ratio i> ; for each stock i
1397 :     transitionstep <timestep for the stock to move>
1398 :     \end{verbatim}}
1399 :    
1400 :     The movement function simples move the fish from the oldest age-length groups for the current stock into the corresponding age-length group for the stock that the fish will move into (in a similar manner to that used for the maturation, given in section~\ref{sec:stockmature}). Note that there is a check to ensure that the corresponding age-length group exists, and if it doesn't then the fish don't move and will stay in the oldest age group for current stock, which is modelled as a plus group.
1401 :    
1402 :     \section{Renewal (''Recruitment'')}\label{sec:stockrenew}
1403 :     The renewal section of the stock file determines if, and how, the stock will be renewed in the Gadget model. The format for the first part of the renewal section is given below:
1404 :    
1405 :     {\small\begin{verbatim}
1406 :     doesrenew <0 or 1> ; 0 for no renewal, 1 for renewal
1407 :     \end{verbatim}}
1408 :    
1409 :     If the stock does not renew, then the following sections don't apply, and the next section of the input file is the spawning, given in section~\ref{sec:stockspawn} below. If the stock does renew, then further information is required about the renewal data. This is given in a separate file, so the format for the renewal data, in the main stock file, is given below:
1410 :    
1411 :     {\small\begin{verbatim}
1412 :     doesrenew 1
1413 :     minlength <minimum length for the recruits>
1414 :     maxlength <maximum length for the recruits>
1415 :     dl <step size for the recruits>
1416 :     <renewal distribution data>
1417 :     \end{verbatim}}
1418 :    
1419 :     The $<$dl$>$ value is optional, and can be used to specify a different step size for the recruits than for the stock that the recruits will be added to. If this value is not specified here then the recruits will be given the same step length as for the stock they will be added to.
1420 :    
1421 :     \bigskip
1422 :     In a similar manner to the format for the initial population (see section~\ref{sec:stockinitial}) there are three formats for the renewal distribution data, as given below:
1423 :    
1424 :     \bigskip
1425 :     Normal Condition - use a Normal function to generate the length distribution, with a relative condition factor to assign a mean weight to the new recruits\newline
1426 :     Normal Parametric - use a Normal function to generate the length distribution, with a parametric weight-length relationship to calculate a mean weight for the new recruits\newline
1427 :     Numerical - specify the numbers, and the corresponding mean weights, for the new recruits
1428 :    
1429 :     \subsection{Normal Condition Distribution}
1430 :     To specify renewal data with the lengths given by a Normal distribution, and using a relative condition factor to generate the weights, the main stock file needs to specify the name of a datafile containing the information about the Normal distribution, as shown below:
1431 :    
1432 :     {\small\begin{verbatim}
1433 :     normalcondfile <name of the renewal data file>
1434 :     \end{verbatim}}
1435 :    
1436 :     The renewal file contains all the information that Gadget requires to construct the renewal data for the stock. For each timestep and area, this file lists the the age of the recruits (which would typically match the minimum age of the stock that the recruits are to be added to), the number of recruits (in units of 10,000 fish), parameters used to define the Normal distribution for length groups of the recruits, and the relative condition factor, used along with the reference weight to assign a mean weight for the recruits.
1437 :    
1438 :     \bigskip
1439 :     Hence, the format for the renewal file is given below:
1440 :    
1441 :     {\small\begin{verbatim}
1442 :     <year> <step> <area> <age> <number> <mean> <stddev> <relcond>
1443 :     \end{verbatim}}
1444 :    
1445 :     \subsection{Normal Parametric Distribution}
1446 :     To specify renewal data with the lengths given by a Normal distribution, and using a weight-length relationship to generate the weights, the main stock file needs to specify the name of a datafile containing the information about the Normal distribution, as shown below:
1447 :    
1448 :     {\small\begin{verbatim}
1449 :     normalparamfile <name of the renewal data file>
1450 :     \end{verbatim}}
1451 :    
1452 :     The renewal file contains all the information that Gadget requires to construct the renewal data for the stock. For each timestep and area, this file lists the the age of the recruits (which would typically match the minimum age of the stock that the recruits are to be added to), the number of recruits (in units of 10,000 fish), parameters used to define the Normal distribution for length groups of the recruits, and parameters to define the weight-length relationship for these recruits.
1453 :    
1454 :     \bigskip
1455 :     Hence, the format for the renewal file is given below:
1456 :    
1457 :     {\small\begin{verbatim}
1458 :     <year> <step> <area> <age> <number> <mean> <stddev> <alpha> <beta>
1459 :     \end{verbatim}}
1460 :    
1461 :     \subsection{Numerical Distribution}
1462 :     An alternative approach is to define the renewal data by specifying an age-length table, along with the mean weight, for each timestep that will have new fish added to the stock. This approach requires the main stock file to specify a data file to give the age-length table, as shown below:
1463 :    
1464 :     {\small\begin{verbatim}
1465 :     numberfile <name of the renewal data file>
1466 :     \end{verbatim}}
1467 :    
1468 :     The renewal file contains data for an age-length table for each timestep that will have new fish added to the stock. This file specifies the number, and mean weight, of the new fish for each timestep, area, age group and length group combination, as shown below:
1469 :    
1470 :     {\small\begin{verbatim}
1471 :     <year> <step> <area> <age> <length> <number> <weight>
1472 :     \end{verbatim}}
1473 :    
1474 :     Note that the $<$length$>$ value refers to the minimum length of the age-length cell that the new fish will be put into.
1475 :    
1476 :     \section{Spawning}\label{sec:stockspawn}
1477 :     The spawning section of the stock file determines if, and how, the stock will spawn in the Gadget model. This covers the mortality and weight loss from the stock due to the spawning process, and optionally the creation of a new spawned stock. The format for the first part of the spawning section is given below:
1478 :    
1479 :     {\small\begin{verbatim}
1480 :     doesspawn <0 or 1> ; 0 for no spawning, 1 for spawning
1481 :     \end{verbatim}}
1482 :    
1483 :     If the stock does not spawn, then the following sections don't apply, and the next section of the input file is the straying information, given in section~\ref{sec:stockstray} below. If the stock does spawn, then further information is required about the spawning data. This is given in a separate file, so the format for the spawning data, in the main stock file, is given below:
1484 :    
1485 :     {\small\begin{verbatim}
1486 :     doesspawn 1
1487 :     spawnfile <name of the spawning data file>
1488 :     \end{verbatim}}
1489 :    
1490 :     The spawning data file defines what happens to the stock as it spawns. The spawning is length-dependent, and the affect that spawning has on each length group of the mature stock is given by the spawning equations~\ref{eq:spawn1} and \ref{eq:spawn2} below:
1491 :    
1492 :     \newpage %JMB insert page break
1493 :     \begin{equation}\label{eq:spawn1}
1494 :     N = N {\left(1 + P {(e^{-m} - 1)}\right)}
1495 :     \end{equation}
1496 :    
1497 :     \begin{equation}\label{eq:spawn2}
1498 :     W = W \frac{\left(1 + P {((2 - w)e^{-m} - 1)}\right)}{\left(1 + P {(2e^{-m} - 1)}\right)}
1499 :     \end{equation}
1500 :    
1501 :     where:\newline
1502 :     $<$ N $>$ is the population of the age-length group\newline
1503 :     $<$ W $>$ is the mean weight of the population of the age-length group\newline
1504 :     $<$ P $>$ is the proportion of the length group that will spawn\newline
1505 :     $<m>$ is the spawning mortality for that length group\newline
1506 :     $<w>$ is the spawning weight loss for that length group
1507 :    
1508 :     \bigskip
1509 :     In equation~\ref{eq:spawn1}, the population of the age-length cell of the mature stock is reduced due to the spawning mortality of the fish that spawn. In equation~\ref{eq:spawn2}, the mean weight of the population in the age-length cell is adjusted to take the reduction in weight of the fish that spawn, and the change in population, into account.
1510 :    
1511 :     \bigskip
1512 :     Spawning is considered to be an annual event, that takes place on the same timestep and the same area in each year that the spawning occurs. To model the spawning process as it affects the parent (without the creation of a child stock), it is necessary to specify the timestep and area that the spawning will take place on, and the length selection functions to determine proportion of each length group that will spawn, and the spawning mortality and weight loss of those that spawn. This is done in the spawning data file, as shown below:
1513 :    
1514 :     {\small\begin{verbatim}
1515 :     spawnsteps <vector of timesteps>
1516 :     spawnareas <vector of areas>
1517 :     firstspawnyear <first year that the spawning occurs>
1518 :     lastspawnyear <last year that the spawning occurs>
1519 :     onlyparent
1520 :     proportionfunction <see Length Selection>
1521 :     mortalityfunction <see Length Selection>
1522 :     weightlossfunction <see Length Selection>
1523 :     \end{verbatim}}
1524 :    
1525 :     The optional <firstspawnyear> and <lastspawnyear> values define the first and last years on which the spawning process will take place. This means that it is possible to define recruits (see section~\ref{sec:stockrenew} above) for some years in the model and use a spawning process in other years in the model. If these are not specified in the input file, then it assumed that the spawning process will take place on all years in the simulation, and these will default to the first year and last year in the simulation.
1526 :    
1527 :     \bigskip
1528 :     Alternatively, it is possible to consider the spawning process as part of a through life-cycle model, and so the spawning process can create recruits to be added to one or more stocks (in a similar manner to the renewal data, given in section~\ref{sec:stockrenew} above). The total number of recruits given by the spawning process is added to the youngest age group of the spawned stock at the start of the following timestep. The lengths of the spawned stock are distributed with a Normal distribution about a specified mean length $<$mean$>$ with a standard deviation $<$stddev$>$. The mean weight of the fish in these age length cells is given from equation~\ref{eq:wlen}, with $\alpha$ and $\beta$ specified in the spawning data file. Hence, if the spawning process is to calculate a number of recruits to the model, the format for the spawning data file is shown below:
1529 :    
1530 :     {\small\begin{verbatim}
1531 :     spawnsteps <vector of timesteps>
1532 :     spawnareas <vector of areas>
1533 :     firstspawnyear <first year that the spawning occurs>
1534 :     lastspawnyear <last year that the spawning occurs>
1535 :     spawnstocksandratios <stockname i> <ratio i> ; for each stock i
1536 :     proportionfunction <see Length Selection>
1537 :     mortalityfunction <see Length Selection>
1538 :     weightlossfunction <see Length Selection>
1539 :     recruitment <functionname> <parameters>
1540 :     stockparameters <mean> <stddev> <alpha> <beta>
1541 :     \end{verbatim}}
1542 :    
1543 :     The recruitment $<$functionname$>$ defines which recruitment function to use to calculate the number of recruits to be added to the spawned stock. Currently there are 4 recruitment functions defined, and the valid recruitment function names are:
1544 :    
1545 :     \bigskip
1546 :     fecundity - use the Fecundity recruitment function\newline
1547 :     simplessb - use the SimpleSSB recruitment function\newline
1548 :     ricker - use the Ricker recruitment function\newline
1549 :     bevertonholt - use the BevertonHolt recruitment function
1550 :    
1551 :     \subsection{Fecundity Recruitment Function}
1552 :     This recruitment function calculates the number of recruits to be added to the spawned stock as a function of the length, age, number and weight of the spawning stock, given by the following equation:
1553 :    
1554 :     \begin{equation}\label{eq:rec1}
1555 :     R = p_{0} \sum_{\it ages}\sum_{\it lengths} l ^{p_{1}} a ^{p_{2}} N_{al} ^{p_{3}} W_{al} ^{p_{4}}
1556 :     \end{equation}
1557 :    
1558 :     Hence, to specify this recruitment function, the file format required is:
1559 :    
1560 :     {\small\begin{verbatim}
1561 :     recruitment fecundity <vector of 5 parameters>
1562 :     \end{verbatim}}
1563 :    
1564 :     \subsection{SimpleSSB Recruitment Function}
1565 :     This recruitment function calculates the number of recruits to be added to the spawned stock as a simple proportion of the spawning stock biomass, given by the following equations:
1566 :    
1567 :     \begin{equation}\label{eq:ssb}
1568 :     S = \sum_{\it ages}\sum_{\it lengths} N_{al} W_{al}
1569 :     \end{equation}
1570 :    
1571 :     \begin{equation}\label{eq:rec2}
1572 :     R = \mu S
1573 :     \end{equation}
1574 :    
1575 :     Hence, to specify this recruitment function, the file format required is:
1576 :    
1577 :     {\small\begin{verbatim}
1578 :     recruitment simplessb <mu>
1579 :     \end{verbatim}}
1580 :    
1581 :     \subsection{Ricker Recruitment Function}
1582 :     This recruitment function calculates the number of recruits to be added to the spawned stock, as a function of the spawning stock biomass (see equation~\ref{eq:ssb}), based on the Ricker recruitment relationship given by the following equation:
1583 :    
1584 :     \begin{equation}\label{eq:rec3}
1585 :     R = \mu S e ^{-\lambda S}
1586 :     \end{equation}
1587 :    
1588 :     Hence, to specify this recruitment function, the file format required is:
1589 :    
1590 :     {\small\begin{verbatim}
1591 :     recruitment ricker <mu> <lambda>
1592 :     \end{verbatim}}
1593 :    
1594 :     \subsection{BevertonHolt Recruitment Function}
1595 :     This recruitment function calculates the number of recruits to be added to the spawned stock, as a function of the spawning stock biomass (see equation~\ref{eq:ssb}), based on the Beverton Holt recruitment relationship given by the following equation:
1596 :    
1597 :     \begin{equation}\label{eq:rec4}
1598 :     R = \frac{\mu S}{\lambda + S}
1599 :     \end{equation}
1600 :    
1601 :     Hence, to specify this recruitment function, the file format required is:
1602 :    
1603 :     {\small\begin{verbatim}
1604 :     recruitment bevertonholt <mu> <lambda>
1605 :     \end{verbatim}}
1606 :    
1607 :     \section{Length Selection}\label{sec:lselection}
1608 :     The length selection function determines the proportion of the length group that will be selected, in a similar way to the suitability functions (see section~\ref{sec:suitability} above). To define a length selection function, it is necessary to specify the function, the name of the function ans the parameters for the function, as shown below:
1609 :    
1610 :     {\small\begin{verbatim}
1611 :     <function> <functionname> <parameters>
1612 :     \end{verbatim}}
1613 :    
1614 :     The $<$function$>$ defines how the length selection function will be used (for an example, see section~\ref{sec:stockspawn} above). The $<$functionname$>$ defines which selection function is to be used to calculate the selection of the stock. Currently there are three selection functions defined, and the valid length selection function names are:
1615 :    
1616 :     \bigskip
1617 :     constant - use the Constant selection function\newline
1618 :     straightline - use the StraightLine selection function\newline
1619 :     exponential - use the Exponential selection function
1620 :    
1621 :     \subsection{Constant Selection Function}
1622 :     This is a selection function, where there is no dependence on the length of the stock is given by the following equation:
1623 :    
1624 :     \begin{equation}\label{eq:constsel}
1625 :     S(l) = \alpha
1626 :     \end{equation}
1627 :    
1628 :     Hence, to specify a constant selection function, the file format required is:
1629 :    
1630 :     {\small\begin{verbatim}
1631 :     <function> constant <alpha>
1632 :     \end{verbatim}}
1633 :    
1634 :     \subsection{StraightLine Selection Function}
1635 :     This is a selection function that has a linear dependence on the length of the stock is given by the following equation:
1636 :    
1637 :     \begin{equation}\label{eq:straightsel}
1638 :     S(l) = \alpha l + \beta
1639 :     \end{equation}
1640 :    
1641 :     \bigskip
1642 :     Hence, to specify a straight line selection function, the file format required is:
1643 :    
1644 :     {\small\begin{verbatim}
1645 :     <function> straightline <alpha> <beta>
1646 :     \end{verbatim}}
1647 :    
1648 :     \subsection{Exponential Selection Function}
1649 :     This is a selection function that has a logarithmic dependence on the length of the stock is given by the following equation:
1650 :    
1651 :     \begin{equation}\label{eq:expsel}
1652 :     S(l) = \frac{1}{1 + e^{ \alpha (l - l_{50})}}
1653 :     \end{equation}
1654 :    
1655 :     \bigskip
1656 :     Note that the stock length dependence is actually dependant on the difference between the length of the stock and $l_{50}$, which is the length of the stock with a 50\% probability of selection. Hence, to specify this selection function, the file format required is:
1657 :    
1658 :     {\small\begin{verbatim}
1659 :     <function> exponential <alpha> <l50>
1660 :     \end{verbatim}}
1661 :    
1662 :     \section{Straying}\label{sec:stockstray}
1663 :     The straying section of the stock file determines if, and how, the stock will stray from one substock to another substock in the Gadget model. The format for the first part of the straying section of the stock file is given below:
1664 :    
1665 :     {\small\begin{verbatim}
1666 :     doesstray <0 or 1> ; 0 for no straying, 1 for straying
1667 :     \end{verbatim}}
1668 :    
1669 :     If the stock does not stray, then the following section doesn't apply, and the stock file is complete. If the stock does stray, then further information is required about the straying data. This is given in a separate file, so the format for the straying data, in the main stock file, is given below:
1670 :    
1671 :     {\small\begin{verbatim}
1672 :     doesstray 1
1673 :     strayfile <name of the straying data file>
1674 :     \end{verbatim}}
1675 :    
1676 :     The straying data file defines what happens to the stock as it strays from one substock to another. The straying is length-dependent, so that a proportion of each length group (over all age groups) will move to the corresponding length group in a different substock. This process can be thought of as an extension to the transition process (see section~\ref{sec:stockmove}).
1677 :    
1678 :     \bigskip
1679 :     Straying is considered to be an annual event, that takes place on the same timestep and the same area in each year. To model the straying process in Gadget, it is necessary to specify the timestep and the area that the straying will take place on, the the names of the stocks to move the straying fish into, along with the ratio of the fish that will move into that particular stock (in a similar manner to that used for the transition process) and the length selection function to determine the proportion of the length group that will stray. This is done in the straying data file, as shown below:
1680 :    
1681 :     {\small\begin{verbatim}
1682 :     straysteps <vector of timesteps>
1683 :     strayareas <vector of areas>
1684 :     straystocksandratios <stockname i> <ratio i> ; for each stock i
1685 :     proportionfunction <see Length Selection>
1686 :     \end{verbatim}}
1687 :    
1688 :     \chapter{Tag Files}\label{chap:tag}
1689 :     The tag files contain the information about the tagging experiments that are to be included in the Gadget model. Gadget will keep track of the number, and proportion, of fish in an age-length cell that have been tagged for a tagging experiment. This information can then be compared to the recaptures from that tagging experiment when calculating a likelihood score (see Recaptures, section~\ref{sec:recaptures}).
1690 :    
1691 :     \bigskip
1692 :     To define tagged populations in the Gadget model, the ''main'' file must contain a list of the data files that contain the description of the tagging experiments, and the format for this is shown below:
1693 :    
1694 :     {\small\begin{verbatim}
1695 :     [tagging]
1696 :     tagfiles <names of the tag files>
1697 :     \end{verbatim}}
1698 :    
1699 :     The main tag file lists the tagging experiments, along with basic information about the experiments and the name of the datafile that contains information about the number of fish tagged for the tagging experiment. The format for this file shown below, with each new tagging experiment starting with the keyword [component]:
1700 :    
1701 :     {\small\begin{verbatim}
1702 :     [component]
1703 :     tagid <name of the tagging experiment>
1704 :     stock <name of the tagged stock>
1705 :     tagarea <area that the tagging took place>
1706 :     endyear <year of last recapture>
1707 :     tagloss <proportion of tagged fish that are lost>
1708 :     numbers <see Tagging Numbers>
1709 :     \end{verbatim}}
1710 :    
1711 :     Each tagging experiment is defined by specifying the name of the tagging experiment, the stock that is tagged for the tagging experiment, and the area that the tagging took place on. Note that it is currently possible to only tag one stock, on one area, for each tagging experiment.
1712 :    
1713 :     \bigskip
1714 :     The optional $<$endyear$>$ value is used to define the end of a tagging experiment, and should be set to the year of the last expected recapture from the tagging experiment. This can be used to reduce the calculation time. If this is not specified, then it is assumed that the tagging experiment will run until the end of the simulation.
1715 :    
1716 :     \bigskip
1717 :     The $<$tagloss$>$ value is used to remove tagged fish from the model. For each time step, a number of tags can be lost from the tagging experiment. The number of tagged fish that remain in the tagging experiment is given by the equation~\ref{eq:tagloss} below:
1718 :    
1719 :     \begin{equation}\label{eq:tagloss}
1720 :     N = N (e^{-t})
1721 :     \end{equation}
1722 :    
1723 :     where:\newline
1724 :     $<$ N $>$ is the number of tagged fish in an age-length group\newline
1725 :     $<t>$ is the proportion of tagged fish that are lost, as specified in the input file
1726 :    
1727 :     \section{Tagging Numbers}\label{sec:tagnumbers}
1728 :     The numbers section of the tag file gives the number of fish tagged for the tagging experiment. This is given in a column format in a separate file, so the main tag file simply gives the name of this tag data file, as shown in the example below:
1729 :    
1730 :     {\small\begin{verbatim}
1731 :     numbers <name of data file>
1732 :     \end{verbatim}}
1733 :    
1734 :     For the tag datafile, this is a simple list of tag identifier, timestep, length and then the number of fish tagged, for that tag/timestep/length combination. This format is shown below:
1735 :    
1736 :     {\small\begin{verbatim}
1737 :     <tagid> <year> <step> <length> <number>
1738 :     \end{verbatim}}
1739 :    
1740 :     Note that the $<$length$>$ value refers to the minimum length of the length cell that the tagged fish will be put into.
1741 :    
1742 :     \chapter{Otherfood Files}\label{chap:other}
1743 :     The otherfood files contain the information about non-dynamic prey that is available for the predators to consume. The otherfood acts as a prey that is always available, and it is used to avoid the situation where the non-availability of a prey stock prevents the predators from growing as expected.
1744 :    
1745 :     \bigskip
1746 :     To define otherfood in the Gadget model, the ''main'' file must contain a list of the data files that contain the description of the otherfood, and the format for this is shown below:
1747 :    
1748 :     {\small\begin{verbatim}
1749 :     [otherfood]
1750 :     otherfoodfiles <names of the otherfood files>
1751 :     \end{verbatim}}
1752 :    
1753 :     The main otherfood file lists the otherfood, along with basic information about the food and the name of the datafile that contains information about the amount of food that is available for the predators to eat. The format for this file shown below, with each new otherfood starting with the keyword [component]:
1754 :    
1755 :     {\small\begin{verbatim}
1756 :     [component]
1757 :     foodname <food name>
1758 :     livesonareas <areas>
1759 :     lengths <min> <max>
1760 :     energycontent <energy value>
1761 :     amount <see Food Amounts>
1762 :     \end{verbatim}}
1763 :    
1764 :     The otherfood is defined by specifying the otherfood name and areas it is available for consumption on and the minimum and maximum length of food (for compatibility with the dynamic stock predation and printer classes).
1765 :    
1766 :     \section{Food Amounts}\label{sec:foodamounts}
1767 :     The amounts section of the otherfood file gives the biomass of otherfood that is available for the predators to eat. This data is listed in a column format in a separate file, so the main otherfood file simply gives the name of this otherfood data file, as shown in the example below:
1768 :    
1769 :     {\small\begin{verbatim}
1770 :     amount <name of data file>
1771 :     \end{verbatim}}
1772 :    
1773 :     For the otherfood datafile, this is a simple list of year, timestep, area, food name and then the biomass of the food available for the predators to eat, for that timestep/area combination. This format is shown below:
1774 :    
1775 :     {\small\begin{verbatim}
1776 :     <year> <step> <area> <food name> <amount>
1777 :     \end{verbatim}}
1778 :    
1779 :     \chapter{Fleet Files}\label{chap:fleet}
1780 :     The fleet files contain the information about the fleets that are reducing the population of the stocks in the Gadget model. The fleets act as a simple predator in the model, with the landings data treated as the fleets ''consumption'' of the stock that is caught.
1781 :    
1782 :     \bigskip
1783 :     To define fleets in the Gadget model, the ''main'' file must contain a list of the data files that contain the description of the fleets, and the format for this is shown below:
1784 :    
1785 :     {\small\begin{verbatim}
1786 :     [fleet]
1787 :     fleetfiles <names of the fleet files>
1788 :     \end{verbatim}}
1789 :    
1790 :     There are 5 types of fleets implemented in Gadget, and the main fleet file lists the fleets and their type, along with information about the fleet and the name of the datafile that contains information about the landings. The format for this file shown below, with each new fleet starting with the keyword [component]:
1791 :    
1792 :     {\small\begin{verbatim}
1793 :     [component]
1794 :     <type> <fleetname>
1795 :     <fleet data>
1796 :     \end{verbatim}}
1797 :    
1798 :     The fleet data for each fleet type is covered in the sub sections below. The $<$type$>$ defines the type of fleet for the $<$fleetname$>$ fleet, and the 5 valid fleet types that can used in Gadget are:
1799 :    
1800 :     \bigskip
1801 :     TotalFleet\newline
1802 :     NumberFleet\newline
1803 :     LinearFleet\newline
1804 :     EffortFleet\newline
1805 :     QuotaFleet
1806 :    
1807 :     \section{TotalFleet}\label{sec:totalfleet}
1808 :     The fleet type used that creates a predator based on the landings data (by biomass) for the fleet is called ''TotalFleet''. This total amount landed is then split between the various stocks, and length groups of the stocks, according to equation~\ref{eq:tcons} below:
1809 :    
1810 :     \begin{equation}\label{eq:tcons}
1811 :     C_{s}(l) = \frac{E S_{s}(l) N_{sl} W_{sl}}{\displaystyle \sum_{\it stocks} \sum_{\it lengths} S_{s}(l) N_{sl} W_{sl}}
1812 :     \end{equation}
1813 :    
1814 :     where:\newline
1815 :     $<$ E $>$ is the biomass caught by the fleet\newline
1816 :     $<$ N $>$ is the number of stock in the length cell\newline
1817 :     $<$ W $>$ is the mean weight of the stock in the length cell\newline
1818 :     $<$ S $>$ is the suitability function (see section~\ref{sec:fleetsuit})
1819 :    
1820 :     \bigskip
1821 :     This fleet type is defined by specifying the fleet name and areas it operates on, along with a suitability function for each stock that the fleet will catch and a data file listing the biomass that the fleet will catch. The file format for the TotalFleet is given below:
1822 :    
1823 :     {\small\begin{verbatim}
1824 :     [component]
1825 :     totalfleet <fleetname>
1826 :     livesonareas <areas>
1827 :     multiplicative <multi>
1828 :     suitability <see Fleet Suitability>
1829 :     amount <see Fleet Amounts>
1830 :     \end{verbatim}}
1831 :    
1832 :     The optional $<$multi$>$ value is a multiplicative constant used to scale the data if required - the default value for this multiplier is 1 (ie. no scaling).
1833 :    
1834 :     \bigskip
1835 :     The fleets act as a predator, so Gadget also requires a suitability function to be defined for the predation of the stocks in the model. The total amount that has been landed by the fleet is also required - this is taken from the landings data, based on timestep and area, and is specified in a separate file.
1836 :    
1837 :     \section{NumberFleet}\label{sec:numberfleet}
1838 :     The fleet type used that creates a predator based on the number of the stock landed (not the biomass) is called ''NumberFleet''. This total number caught is then split between the various stocks, and length groups of the stocks, according to equation~\ref{eq:ncons} below:
1839 :    
1840 :     \begin{equation}\label{eq:ncons}
1841 :     C_{s}(l) = \frac{E S_{s}(l) N_{sl}}{\displaystyle \sum_{\it stocks} \sum_{\it lengths} S_{s}(l) N_{sl}}
1842 :     \end{equation}
1843 :    
1844 :     where:\newline
1845 :     $<$ E $>$ is the number caught by the fleet\newline
1846 :     $<$ N $>$ is the number of stock in the length cell\newline
1847 :     $<$ S $>$ is the suitability function (see section~\ref{sec:fleetsuit})
1848 :    
1849 :     \bigskip
1850 :     This fleet type is defined by specifying the fleet name and areas it operates on, along with a suitability function for each stock that the fleet will catch and a data file listing the numbers that the fleet will catch. The file format for the NumberFleet is given below:
1851 :    
1852 :     {\small\begin{verbatim}
1853 :     [component]
1854 :     numberfleet <fleetname>
1855 :     livesonareas <areas>
1856 :     multiplicative <multi>
1857 :     suitability <see Fleet Suitability>
1858 :     amount <see Fleet Amounts>
1859 :     \end{verbatim}}
1860 :    
1861 :     The optional $<$multi$>$ value is a multiplicative constant used to scale the data if required - the default value for this multiplier is 1 (ie. no scaling).
1862 :    
1863 :     \bigskip
1864 :     The fleets act as a predator, so Gadget also requires a suitability function to be defined for the predation of the stocks in the model. The total number of fish that has been caught by the fleet is also required - this is taken from the landings data, based on timestep and area, and is specified in a separate file.
1865 :    
1866 :     \section{LinearFleet}\label{sec:linearfleet}
1867 :     The fleet type used that creates a predator that removes the caught fish based on the available biomass of the stock multiplied by a scaling factor is called ''LinearFleet''. The biomass caught is then split between the various stocks, and length groups of the stocks, according to equation~\ref{eq:lcons} below:
1868 :    
1869 :     \begin{equation}\label{eq:lcons}
1870 :     C_{s}(l) = E \Delta t S_{s}(l) N_{sl} W_{sl}
1871 :     \end{equation}
1872 :    
1873 :     where:\newline
1874 :     $<$ E $>$ is the scaling factor for the stock that is to be caught, per month\newline
1875 :     $<\Delta t>$ is the length of the timestep\newline
1876 :     $<$ N $>$ is the number of stock in the length cell\newline
1877 :     $<$ W $>$ is the mean weight of the stock in the length cell\newline
1878 :     $<$ S $>$ is the suitability function (see section~\ref{sec:fleetsuit})
1879 :    
1880 :     \bigskip
1881 :     This fleet type is defined by specifying the fleet name and areas it operates on, along with a suitability function for each stock that the fleet will catch and a data file listing the fishing level for the fleet. The file format for the LinearFleet is given below:
1882 :    
1883 :     {\small\begin{verbatim}
1884 :     [component]
1885 :     linearfleet <fleetname>
1886 :     livesonareas <areas>
1887 :     multiplicative <multi>
1888 :     suitability <see Fleet Suitability>
1889 :     amount <see Fleet Amounts>
1890 :     \end{verbatim}}
1891 :    
1892 :     The optional $<$multi$>$ value is a multiplicative constant used to scale the data if required - the default value for this multiplier is 1 (ie. no scaling).
1893 :    
1894 :     \bigskip
1895 :     The fleets act as a predator, so Gadget also requires a suitability function to be defined for the predation of the stocks in the model. The scaling factor to be used when calculating the amount that the fleet will catch is also required, and this is specified in a separate file.
1896 :    
1897 :     \bigskip
1898 :     The fleet of type LinearFleet acts a simple predator, and can be used for fleets acting in the future, when the landings data is not available.
1899 :    
1900 :     \section{EffortFleet}\label{sec:effortfleet}
1901 :     The fleet type used that creates a predator that removes the caught fish based on the available biomass of the stock multiplied by a scaling factor and a 'catchability' parameter for that stock is called ''EffortFleet''. The biomass caught is then split between the various stocks, and length groups of the stocks, according to equation~\ref{eq:econs} below:
1902 :    
1903 :     \begin{equation}\label{eq:econs}
1904 :     C_{s}(l) = E q_{s} \Delta t S_{s}(l) N_{sl} W_{sl}
1905 :     \end{equation}
1906 :    
1907 :     where:\newline
1908 :     $<$ E $>$ is the scaling factor for the stock that is to be caught, per month\newline
1909 :     $<$ q $>$ is the catchability parameter for that stock\newline
1910 :     $<\Delta t>$ is the length of the timestep\newline
1911 :     $<$ N $>$ is the number of stock in the length cell\newline
1912 :     $<$ W $>$ is the mean weight of the stock in the length cell\newline
1913 :     $<$ S $>$ is the suitability function (see section~\ref{sec:fleetsuit})
1914 :    
1915 :     \bigskip
1916 :     This fleet type is defined by specifying the fleet name and areas it operates on, along with a suitability function and catchability parameter for each stock that the fleet will catch and a data file listing the proportion of each stock that the fleet will catch. The file format for the EffortFleet is given below:
1917 :    
1918 :     {\small\begin{verbatim}
1919 :     [component]
1920 :     effortfleet <fleetname>
1921 :     livesonareas <areas>
1922 :     multiplicative <multi>
1923 :     suitability <see Fleet Suitability>
1924 :     catchability <stock catchability parameters>
1925 :     amount <see Fleet Amounts>
1926 :     \end{verbatim}}
1927 :    
1928 :     The optional $<$multi$>$ value is a multiplicative constant used to scale the data if required - the default value for this multiplier is 1 (ie. no scaling).
1929 :    
1930 :     \bigskip
1931 :     The fleets act as a predator, so Gadget also requires a suitability function to be defined for the predation of the stocks in the model. The scaling factor to be used when calculating the amount that the fleet will catch is also required, and this is specified in a separate file.
1932 :    
1933 :     \bigskip
1934 :     The fleet of type EffortFleet is a multi-species extension to the fleet of type LinearFleet (see section~\ref{sec:linearfleet} above). This means that when a fleet is used to catch more than one species (either directly or as bycatch) the different catchability for these species can be taken into account. This catchability parameter is specified by listing the names of the prey and the associated preference value, as shown in the example below:
1935 :    
1936 :     {\small\begin{verbatim}
1937 :     ...
1938 :     catchability
1939 :     <name of stock 1> <catchability for stock 1>
1940 :     <name of stock 2> <catchability for stock 2>
1941 :     amount
1942 :     ...
1943 :     \end{verbatim}}
1944 :    
1945 :     \section{QuotaFleet}\label{sec:quotafleet}
1946 :     The fleet type used that creates a predator that removes the caught fish based on the available biomass of the stock multiplied by a scaling factor set according to a simple harvest control rule is called ''QuotaFleet''. The biomass caught is then split between the various stocks, and length groups of the stocks, according to equation~\ref{eq:lcons} (see section~\ref{sec:linearfleet} above). The scaling factor (the parameter ''E'' in the equation above) is set according to a simple harvest control rule.
1947 :    
1948 :     \bigskip
1949 :     This fleet type is defined by specifying the fleet name and areas it operates on, along with a suitability function for each stock that the fleet will catch, a simple harvest control rule and a data file listing the proportion of each stock that the fleet will catch. The file format for the QuotaFleet is given below:
1950 :    
1951 :     {\small\begin{verbatim}
1952 :     [component]
1953 :     quotafleet <fleetname>
1954 :     livesonareas <areas>
1955 :     multiplicative <multi>
1956 :     suitability <see Fleet Suitability>
1957 :     quotafunction <function name>
1958 :     biomasslevel <vector of biomass levels>
1959 :     quotalevel <vector of quota levels>
1960 :     amount <see Fleet Amounts>
1961 :     \end{verbatim}}
1962 :    
1963 :     The optional $<$multi$>$ value is a multiplicative constant used to scale the data if required - the default value for this multiplier is 1 (ie. no scaling).
1964 :    
1965 :     \bigskip
1966 :     The fleets act as a predator, so Gadget also requires a suitability function to be defined for the predation of the stocks in the model. A scaling factor that can be used when calculating the amount that the fleet will catch is also required, and this is specified in a separate file (although this is usually set to 1, since the scaling factor to be used is multiplied by that calculated using the simple harvest control rule below).
1967 :    
1968 :     \bigskip
1969 :     The simple harvest control rule that is used to calculate the scaling factor to be used to determine the fishing level is defined by the $<$function name$>$ value, along with the $<$biomasslevel$>$ and $<$quotalevel$>$ vectors. Currently there are 2 quota functions defined, and the valid function names are:
1970 :    
1971 :     \bigskip
1972 :     simple - use a simple harvest control rule, based on the biomass of each stock\newline
1973 :     simplesum - use a simple harvest control rule, based on the biomass of all the stocks
1974 :    
1975 :     \bigskip
1976 :     The $<$biomasslevel$>$ vector is a list of $n$ biomass points at which the fishing level will change, and the $<$quotalevel$>$ vector is the corresponding list of $n+1$ fishing levels. Note that the first quotalevel value corresponds to the fishing level that will be used when the biomass is between 0 and the first biomasslevel value, so the quotalevel vector must have one more entry than the biomasslevel vector.
1977 :    
1978 :     \bigskip
1979 :     An example of valid biomasslevel and quotalevel vectors is given below:
1980 :    
1981 :     {\small\begin{verbatim}
1982 :     biomasslevel 10000 250000
1983 :     quotalevel 0.1 0.4 0.9
1984 :     \end{verbatim}}
1985 :    
1986 :     The fishing level for the stock in the example shown above would be set to 0.1 if the biomass of the stock is less than 10,000 kilogrammes, 0.4 if the biomass is between 10,000 and 250,000 kilogrammes and 0.9 if the biomass is above 250,000 kilogrammes. Note that the biomasslevel vector has 2 entries, and that the quotalevel vector has a third entry.
1987 :    
1988 :     \section{Fleet Suitability}\label{sec:fleetsuit}
1989 :     The suitability determines how the fleets act on the stocks that are caught. Since Gadget treats the fleets as predators of the stocks, the format for the suitability functions for the fleets is the same as the format for the suitability functions of the stock when they are acting as a predator. The format for the suitability functions as discussed in section~\ref{sec:suitability} above. Note that in the equations for the suitability functions, the 'length' of the predator is a meaningless concept when the predator is a fleet.
1990 :    
1991 :     \section{Fleet Amounts}\label{sec:fleetamount}
1992 :     The amounts section of the fleet file gives the landings data for the fleets. This data is listed in a column format in a separate file, so the main fleet file simply gives the name of this fleet data file, as shown in the example below:
1993 :    
1994 :     {\small\begin{verbatim}
1995 :     amount <name of data file>
1996 :     \end{verbatim}}
1997 :    
1998 :     For fleets of type TotalFleet or NumberFleet, the data file is a list of year, timestep, area, fleetname and then the amount of catch landed (either biomass or number), taken from landings data, for that timestep/area/fleet combination:
1999 :    
2000 :     {\small\begin{verbatim}
2001 :     <year> <step> <area> <fleetname> <amount>
2002 :     \end{verbatim}}
2003 :    
2004 :     For fleets of type LinearFleet, EffortFleet or QuotaFleet, the data file is a list of year, timestep, area, fleetname and then the scaling factor to be used when calculating the amount of the catch for that timestep/area/fleet combination:
2005 :    
2006 :     {\small\begin{verbatim}
2007 :     <year> <step> <area> <fleetname> <scaling factor>
2008 :     \end{verbatim}}
2009 :    
2010 :     \chapter{Likelihood Files}\label{chap:like}
2011 :     The likelihood files are used to define the various likelihood components that are used to calculate the ''goodness of fit'' of the Gadget model to the available data. Each likelihood component will calculate a likelihood score for that individual component, and there is then a weighted sum of all the likelihood scores to calculate an overall likelihood score. It is this overall likelihood score that the optimiser attempts to minimise during an optimising run.
2012 :    
2013 :     \bigskip
2014 :     To define likelihood files in the Gadget model, the ''main'' file must contain a list of the data files that contain the description of the likelihood classes required, and the format for this is shown below:
2015 :    
2016 :     {\small\begin{verbatim}
2017 :     [likelihood]
2018 :     likelihoodfiles <names of the likelihood files>
2019 :     \end{verbatim}}
2020 :    
2021 :     The likelihood files contain a list of various type of likelihood classes, separated by the keyword [component] that control the different likelihood components in the model, the name and weight for that likelihood component and various likelihood data, depending in the likelihood component type. The format of the likelihood files is follows:
2022 :    
2023 :     {\small\begin{verbatim}
2024 :     [component]
2025 :     name <name for the likelihood component>
2026 :     weight <weight for the likelihood component>
2027 :     type <likelihood type>
2028 :     <likelihood data>
2029 :     \end{verbatim}}
2030 :    
2031 :     The likelihood data for each likelihood type is covered in the sub sections below. The $<$likelihood type$>$ defines the type of likelihood component that is to be used, and there are currently 12 valid likelihood types defined in Gadget. These are:
2032 :    
2033 :     \bigskip
2034 :     BoundLikelihood\newline
2035 :     Understocking\newline
2036 :     CatchDistribution\newline
2037 :     CatchStatistics\newline
2038 :     StockDistribution\newline
2039 :     SurveyIndices\newline
2040 :     SurveyDistribution\newline
2041 :     StomachContent\newline
2042 :     Recaptures\newline
2043 :     RecStatistics\newline
2044 :     MigrationPenalty\newline
2045 :     CatchInKilos
2046 :    
2047 :     \section{BoundLikelihood (''Penalty'')}\label{sec:boundlike}
2048 :     The BoundLikelihood likelihood component is used to give a penalty weight to parameters that have moved beyond the bounds, as specified in the parameter file, in the optimisation process. This file does not specify the bounds that are to be used, only the penalty that is to be applied when these bounds are exceeded. Since the Simmulated Annealing (see section~\ref{sec:simann}) algorithm will always choose a value for the parameter that is within the bounds, this likelihood component will return a zero likelihood score during an optimisation using that algorithm. However, both the Hooke \& Jeeves (see section~\ref{sec:hooke}) and the BFGS (see section~\ref{sec:bfgs}) algorithms can choose a parameter outside the specified bounds, and so this likelihood component can then return a positive score.
2049 :    
2050 :     \bigskip
2051 :     To specify a BoundLikelihood likelihood component, the format required in the main likelihood file is as follows:
2052 :    
2053 :     {\small\begin{verbatim}
2054 :     [component]
2055 :     name <name for the likelihood component>
2056 :     weight <weight for the likelihood component>
2057 :     type penalty
2058 :     datafile <name for the datafile>
2059 :     \end{verbatim}}
2060 :    
2061 :     The datafile defines the penalty that is to be applied to the parameter when it exceeds the bounds, as given by equation~\ref{eq:bound} below:
2062 :    
2063 :     \begin{equation}\label{eq:bound}
2064 :     \ell_{i} =
2065 :     \begin{cases}
2066 :     lw_{i} (val_{i} - lb_{i})^{p_{i}} & \textrm{if $val_{i} < lb_i$} \\
2067 :     uw_{i} (val_{i} - ub_{i})^{p_{i}} & \textrm{if $val_{i} > ub_i$} \\
2068 :     0 & \textrm{otherwise}
2069 :     \end{cases}
2070 :     \end{equation}
2071 :    
2072 :     where:\newline
2073 :     $<val_i>$ is the value of the parameter\newline
2074 :     $<lw_i>$ is the weight applied when the parameter exceeds the lower bound\newline
2075 :     $<uw_i>$ is the weight applied when the parameter exceeds the upper bound\newline
2076 :     $<lb_i>$ is the lower bound\newline
2077 :     $<ub_i>$ is the upper bound\newline
2078 :     $<p_i>$ is the power coefficient\newline
2079 :    
2080 :     Note that when the value of the parameter is exactly equal to the bound, this equation will give a zero likelihood score.
2081 :    
2082 :     \bigskip
2083 :     The datafile lists these weights and the power that is to be used for each parameter. The format for this file is shown below:
2084 :    
2085 :     {\small\begin{verbatim}
2086 :     <switch> <power> <lower> <upper>
2087 :     \end{verbatim}}
2088 :    
2089 :     where $<$lower$>$ is the weighting used when the parameter hits the lower bound, and $<$upper$>$ is the weighting used when the parameter hits the upper bound, for the parameter with the name $<$switch$>$.
2090 :    
2091 :     \bigskip
2092 :     It is possible to define a default penalty that is used for all switches that are not defined separately. To do this, simply enter a line in the data file with the switch name given as ''default'', and then the power, lower and upper weights that are required. For example:
2093 :    
2094 :     {\small\begin{verbatim}
2095 :     default 2 1000 1000
2096 :     \end{verbatim}}
2097 :    
2098 :     would define a default penalty, where the lower and upper weights were 1000, and the power was 2.
2099 :    
2100 :     \section{Understocking}\label{sec:understocking}
2101 :     The Understocking likelihood component calculates a penalty that is applied if there are an insufficient number of a particular prey to meet the requirements of the predators. In the case of a fleet, this means that the landings data indicates that more fish have been landed than there are fish in the model, for that timetep and area combination. A well defined model will have a zero likelihood score from this component. The likelihood component that is used is the sum of squares of the overconsumption, given by the equation below:
2102 :    
2103 :     \begin{equation}\label{eq:understocking}
2104 :     \ell = \sum_{\it time}\sum_{\it areas} \Big(\sum_{\it preys} U_{trp} \Big)^p
2105 :     \end{equation}
2106 :    
2107 :     where:\newline
2108 :     $<$ U $>$ is the understocking that has occurred in the model\newline
2109 :     $<$ p $>$ is the power coefficient (which should be 2 for sum of squares fit)
2110 :    
2111 :     \bigskip
2112 :     To specify an Understocking likelihood component, the format required in the main likelihood file is as follows:
2113 :    
2114 :     {\small\begin{verbatim}
2115 :     [component]
2116 :     name <name for the likelihood component>
2117 :     weight <weight for the likelihood component>
2118 :     type understocking
2119 :     powercoeff <power>
2120 :     \end{verbatim}}
2121 :    
2122 :     The $<$power$>$ value is optional, and if this is not given, the power coefficient is assumed to be 2, giving a sum of squares equation for this likelihood component.
2123 :    
2124 :     \section{CatchDistribution}\label{sec:catchdist}
2125 :     The CatchDistribution likelihood component is used to compare distribution data sampled from the model with distribution data sampled from landings or surveys. The distribution data can either be aggregated into age groups (giving a distribution of length groups for each age), length groups (giving a distribution of age groups for each length) or into age-length groups. The likelihood score that is calculated gives some measure as to how well the data from the model fit to the data from the sample catches.
2126 :    
2127 :     \bigskip
2128 :     To specify a CatchDistribution likelihood component, the format required in the main likelihood file is as follows:
2129 :    
2130 :     {\small\begin{verbatim}
2131 :     [component]
2132 :     name <name for the likelihood component>
2133 :     weight <weight for the likelihood component>
2134 :     type catchdistribution
2135 :     datafile <name for the datafile>
2136 :     function <function name>
2137 :     <multivariate parameters>
2138 :     aggregationlevel <0 or 1> ; 1 to aggregate data over the whole year
2139 :     overconsumption <0 or 1> ; 1 to take overconsumption into account
2140 :     epsilon <epsilon>
2141 :     areaaggfile <area aggregation file specifying areas>
2142 :     ageaggfile <age aggregation file specifying ages>
2143 :     lenaggfile <length aggregation file specifying lengths>
2144 :     fleetnames <vector of the names of the fleets>
2145 :     stocknames <vector of the names of the stocks>
2146 :     \end{verbatim}}
2147 :    
2148 :     The optional flag $<$aggregationlevel$>$ is used to specify whether the distribution data should be aggregated over the whole year (by setting aggregation level to 1) or not aggregated, and calculated for each timestep (by setting aggregation level to 0). If this line is not specified, then an aggregation level of 0 is assumed, and the distribution data is not aggregated over the whole year. Note that not all of the functions used to compare the data can aggregate the data over the whole year.
2149 :    
2150 :     \bigskip
2151 :     The optional flag $<$overconsumption$>$ is used to specify whether any over consumption of the stock is to be taken into account when calculating the model distribution. If this is set to 1, then the model catch data will be adjusted to ensure that the fleets don't catch more stock than is available, by applying a bound to the catch of the fleets. If this line is not specified, then an overconsumption of 0 is assumed and any understocking that is present in the model is ignored, which can lead to an unrealistic result if the understocking likelihood component is not specified.
2152 :    
2153 :     \bigskip
2154 :     The optional $<$epsilon$>$ value is used whenever the calculated probability is very unlikely, although the exact format of this depends on the function that is to be used when calculating the likelihood score. This means that the likelihood component is not dominated by one or two stray values, since these will be reset back to less unlikely values. The default value for $<$epsilon$>$ is 10, which is used whenever it is not defined in the input file.
2155 :    
2156 :     \bigskip
2157 :     The $<$fleetnames$>$ vector contains a list of all the fleets to be aggregated into a single pseudo fleet for the purposes of the data comparison. Similarly, the $<$stocknames$>$ vector contains a list of all the stocks to be aggregated into a single pseudo stock.
2158 :    
2159 :     \bigskip
2160 :     The $<$function name$>$ defines what likelihood function is to be used to compare the modelled age-length catch distribution to the input age-length catch distribution. Currently, there are 8 likelihood functions defined, and the valid function names are:
2161 :    
2162 :     \bigskip
2163 :     sumofsquares - use a sum of squares function\newline
2164 :     stratified - use a stratified sum of squares function\newline
2165 :     multinomial - use a multinomial function\newline
2166 :     pearson - use a Pearson function\newline
2167 :     gamma - use a gamma function\newline
2168 :     log - use a log function\newline
2169 :     mvn - use a multivariate normal function\newline
2170 :     mvlogistic - use a multivariate logistic function
2171 :    
2172 :     \bigskip
2173 :     The $<$multivariate parameters$>$ are only required for the multivariate functions, and Gadget will generate an error if they are specified when they are not required. These parameters are described in the following sections.
2174 :    
2175 :     \bigskip
2176 :     Finally, the file specified by $<$datafile$>$ contains a list of the age-length catch distribution that Gadget is to use to fit the likelihood function to, aggregated according to the aggregation files specified, for the numbers calculated in the model. The format of this file is given below:
2177 :    
2178 :     {\small\begin{verbatim}
2179 :     <year> <step> <area> <age> <length> <number>
2180 :     \end{verbatim}}
2181 :    
2182 :     where $<$number$>$ is the number of samples for the timestep/area/age/length combination.
2183 :    
2184 :     \subsection{Sum of Squares Function}
2185 :     The sum of squares function calculates the likelihood component from equation~\ref{eq:catchdist4} below:
2186 :    
2187 :     \begin{equation}\label{eq:catchdist4}
2188 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it ages}\sum_{\it lengths} \Big( P_{tral} - \pi_{tral} \Big) ^2
2189 :     \end{equation}
2190 :    
2191 :     where:\newline
2192 :     $<$ P $>$ is the proportion of the data sample for that time/area/age/length combination\newline
2193 :     $<\pi>$ is the proportion of the model sample for that time/area/age/length combination
2194 :    
2195 :     \subsection{Stratified Sum of Squares Function}
2196 :     The stratified function is a variant of the sum of squares function that calculates an age distribution for each length class, and then calculates the likelihood component from equation~\ref{eq:catchdist4} above. The difference between this function and the sum of squares function above is in the way the proportions of the samples are calculated - for this function the proportion is calculated for each length group in turn, whereas for the sum of squares function the proportion is taken over all the length groups. If there is only one length group then these two functions are identical.
2197 :    
2198 :     \subsection{Multinomial Function}
2199 :     The multinomial function calculates the likelihood component from equation~\ref{eq:catchdist1} below:
2200 :    
2201 :     \begin{equation}\label{eq:catchdist1}
2202 :     \ell = 2 \sum_{\it time}\sum_{\it areas}\sum_{\it ages} \Bigg( \log N_{tra}! - \sum_{\it lengths} \log N_{tral}! + \sum_{\it lengths} \Big( N_{tral} \log {\frac{\nu_{tral}}{\sum \nu_{tral}}} \Big) \Bigg)
2203 :     \end{equation}
2204 :    
2205 :     where:\newline
2206 :     $<$ N $>$ is the data sample size for that time/area/age/length combination\newline
2207 :     $<\nu>$ is the model sample size for that time/area/age/length combination
2208 :    
2209 :     \subsection{Pearson Function}
2210 :     The Pearson function calculates the likelihood component from equation~\ref{eq:catchdist2} below:
2211 :    
2212 :     \begin{equation}\label{eq:catchdist2}
2213 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it ages}\sum_{\it lengths} \Big( {\frac{ ( N_{tral} - \nu_{tral} ) ^2} {\nu_{tral} + \epsilon}} \Big)
2214 :     \end{equation}
2215 :    
2216 :     where:\newline
2217 :     $<$ N $>$ is the data sample size for that time/area/age/length combination\newline
2218 :     $<\nu>$ is the model sample size for that time/area/age/length combination
2219 :    
2220 :     \subsection{Gamma Function}
2221 :     The gamma function calculates the likelihood component from equation~\ref{eq:catchdist3} below:
2222 :    
2223 :     \begin{equation}\label{eq:catchdist3}
2224 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it ages}\sum_{\it lengths} \Big( {\frac{ N_{tral}} { (\nu_{tral} + \epsilon )} + \log ({\nu_{tral} + \epsilon}}) \Big)
2225 :     \end{equation}
2226 :    
2227 :     where:\newline
2228 :     $<$ N $>$ is the data sample size for that time/area/age/length combination\newline
2229 :     $<\nu>$ is the model sample size for that time/area/age/length combination
2230 :    
2231 :     \subsection{Log Function}
2232 :     The log function calculates the likelihood component from equation~\ref{eq:catchdist7} below:
2233 :    
2234 :     \begin{equation}\label{eq:catchdist7}
2235 :     \ell = \sum_{\it time}\sum_{\it areas} \Big( \log \Big( {\frac{ \displaystyle \sum_{\it ages}\sum_{\it lengths} \nu_{tral}} { \displaystyle \sum_{\it ages}\sum_{\it lengths} N_{tral}}} \Big) \Big) ^2
2236 :     \end{equation}
2237 :    
2238 :     where:\newline
2239 :     $<$ N $>$ is the data sample size for that time/area/age/length combination\newline
2240 :     $<\nu>$ is the model sample size for that time/area/age/length combination
2241 :    
2242 :     \subsection{Multivariate Normal Function}
2243 :     The multivariate normal function calculates the likelihood component from equation~\ref{eq:catchdist5} below:
2244 :    
2245 :     \begin{equation}\label{eq:catchdist5}
2246 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it ages} \Big( log|\Sigma| + (P_{tra} - \pi_{tra})^T \Sigma^{-1}(P_{tra} - \pi_{tra}) \Big)
2247 :     \end{equation}
2248 :    
2249 :     where:\newline
2250 :     $<\Sigma>$ is the variance-covariance matrix for the multivariate normal distribution\newline
2251 :     $<$ P $>$ is the proportion of the data sample for that time/area/age combination\newline
2252 :     $<\pi>$ is the proportion of the model sample for that time/area/age combination
2253 :    
2254 :     \bigskip
2255 :     For the formulation of the variance-covariance matrix, $<\Sigma>$ is calculated from equations \ref{eq:cdsigma1} and \ref{eq:cdsigma2} below:
2256 :    
2257 :     \begin{equation}\label{eq:cdsigma1}
2258 :     \Sigma = (\sigma_{ij})_{ij}
2259 :     \end{equation}
2260 :    
2261 :     \begin{equation}\label{eq:cdsigma2}
2262 :     \sigma_{ij} =
2263 :     \begin{cases}
2264 :     \displaystyle \sum^{lag}_{l=1} c_l \sigma_{i-l,j} + \delta^i_{j} \sigma^2 & \textrm{if $i \geq j$} \\
2265 :     \displaystyle \sum^{lag}_{l=1} c_l \sigma_{j,i-l} & \textrm{otherwise}
2266 :     \end{cases}
2267 :     \end{equation}
2268 :    
2269 :     In equation \ref{eq:cdsigma2} it is assumed that the number in each length group is autocorrelated with lag $<$ lag $>$. Note that setting the lag to be zero simplifies the multivariate normal distribution to a univariate one.
2270 :    
2271 :     \bigskip
2272 :     To specify this likelihood function, it is necessary to specify the parameters $<\sigma>$ and $<$ lag $>$ and a list of $<$ lag $>$ correlation parameters. This is done in the likelihood file, as shown below:
2273 :    
2274 :     {\small\begin{verbatim}
2275 :     ...
2276 :     function mvn
2277 :     lag <lag>
2278 :     sigma <sigma>
2279 :     param <correlation parameter> ; note that a total of
2280 :     param <correlation parameter> ; <lag> correlation
2281 :     ... ; parameters are required
2282 :     aggregationlevel <0 or 1> ; 1 to aggregate data over the whole year
2283 :     ...
2284 :     \end{verbatim}}
2285 :    
2286 :     \subsection{Multivariate Logistic Function}
2287 :     The multivariate logistic function calculates the likelihood component from equations \ref{eq:catchdist6a} and \ref{eq:catchdist6b} below:
2288 :    
2289 :     \begin{equation}\label{eq:catchdist6a}
2290 :     \ell = \frac{1}{2\sigma^2} \sum_{\it time} \Big((L - 1) log(\sigma)+\sum_{\it areas}\sum_{\it ages}\sum_{\it lengths} \tau_{tral}^2 \Big)
2291 :     \end{equation}
2292 :    
2293 :     \begin{equation}\label{eq:catchdist6b}
2294 :     \tau_{tral} = log(P_{tral}) - log(\pi_{tral}) - \frac{1}{L}\sum_{\it lengths} \Big(log(P_{tral}) - log(\pi_{tral}) \Big)
2295 :     \end{equation}
2296 :    
2297 :     where:\newline
2298 :     $<$ L $>$ is the number of length groups\newline
2299 :     $<$ P $>$ is the proportion of the data sample for that time/area/age/length combination\newline
2300 :     $<\pi>$ is the proportion of the model sample for that time/area/age/length combination
2301 :    
2302 :     \bigskip
2303 :     To specify this likelihood function it is necessary to specify the parameter $<\sigma>$. This is done in the likelihood file as shown below:
2304 :    
2305 :     {\small\begin{verbatim}
2306 :     ...
2307 :     function mvlogistic
2308 :     sigma <sigma>
2309 :     aggregationlevel <0 or 1> ; 1 to aggregate data over the whole year
2310 :     ...
2311 :     \end{verbatim}}
2312 :    
2313 :     \section{CatchStatistics}\label{sec:catchstat}
2314 :     The CatchStatistics likelihood component is used to compare statistical data sampled from the model with statistical data sampled from landings or surveys. This is typically used to compare biological data, such as the mean length at age or mean weight at age. The likelihood score that is calculated gives some measure as to how well the data from the model fits to the data from the landings.
2315 :    
2316 :     \bigskip
2317 :     To specify a CatchStatistics likelihood component, the format required in the main likelihood file is as follows:
2318 :    
2319 :     {\small\begin{verbatim}
2320 :     [component]
2321 :     name <name for the likelihood component>
2322 :     weight <weight for the likelihood component>
2323 :     type catchstatistics
2324 :     datafile <name for the datafile>
2325 :     function <function name>
2326 :     overconsumption <0 or 1> ; 1 to take overconsumption into account
2327 :     areaaggfile <area aggregation file specifying areas>
2328 :     ageaggfile <age aggregation file specifying ages>
2329 :     fleetnames <vector of the names of the fleets>
2330 :     stocknames <vector of the names of the stocks>
2331 :     \end{verbatim}}
2332 :    
2333 :     The optional flag $<$overconsumption$>$ is used to specify whether any over consumption of the stock is to be taken into account when calculating the model statistical data. If this is set to 1, then the model catch data will be adjusted to ensure that the fleets don't catch more stock than is available, by applying a bound to the catch of the fleets. If this line is not specified, then an overconsumption of 0 is assumed and any understocking that is present in the model is ignored, which can lead to an unrealistic result if the understocking likelihood component is not specified.
2334 :    
2335 :     \bigskip
2336 :     The $<$fleetnames$>$ vector contains a list of all the fleets to be aggregated into a single pseudo fleet for the purposes of the data comparison. Similarly, the $<$stocknames$>$ vector contains a list of all the stocks to be aggregated into a single pseudo stock.
2337 :    
2338 :     \bigskip
2339 :     The $<$function name$>$ defines what likelihood function is to be used to compare the modelled statistical data to the input statistical data. Currently, there are 5 likelihood functions defined, and the format of the statistical data given in the file specified by $<$datafile$>$ depends on the likelihood function used. The valid functions are:
2340 :    
2341 :     \bigskip
2342 :     lengthcalcstddev - use a weighted sum of squares of mean length\newline
2343 :     lengthgivenstddev - use a weighted sum of squares of mean length with given standard deviation\newline
2344 :     weightgivenstddev - use a weighted sum of squares of mean weight with given standard deviation\newline
2345 :     weightnostddev - use a unweighted sum of squares of mean weight\newline
2346 :     lengthnostddev - use a unweighted sum of squares of mean length
2347 :    
2348 :     \subsection{Weighted Sum of Squares of Mean Length}
2349 :     This likelihood function calculates the likelihood score based on a weighted sum of squares of the mean length, with the weighting given by calculating the variance of length of the modelled population, as shown in equation~\ref{eq:catchstat1} below:
2350 :    
2351 :     \begin{equation}\label{eq:catchstat1}
2352 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it ages} \Big(\frac{(x_{tra}-\mu_{tra})^2} {\sigma_{tra}^2} N_{tra}\Big)
2353 :     \end{equation}
2354 :    
2355 :     where:\newline
2356 :     $<$ x $>$ is the sample mean length from the data\newline
2357 :     $<\mu>$ is the mean length calculated from the model\newline
2358 :     $<\sigma>$ is the standard deviation of the length, calculated from the model\newline
2359 :     $<$ N $>$ is the sample size
2360 :    
2361 :     \bigskip
2362 :     For this CatchStatistics function, the format of the statistical data required in the file specified by $<$datafile$>$ is given below:
2363 :    
2364 :     {\small\begin{verbatim}
2365 :     <year> <step> <area> <age> <number> <mean>
2366 :     \end{verbatim}}
2367 :    
2368 :     where $<$number$>$ is the number of samples for the timestep/area/age combination, and $<$mean$>$ is the mean length of these samples.
2369 :    
2370 :     \subsection{Weighted Sum of Squares of Mean Length\newline With Given Standard Deviation}
2371 :     This likelihood function calculates the likelihood score based on a weighted sum of squares of the mean length, with the weighting given the variance of length of the input population, as shown in equation~\ref{eq:catchstat2} below:
2372 :    
2373 :     \begin{equation}\label{eq:catchstat2}
2374 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it ages} \Big(\frac{(x_{tra}-\mu_{tra})^2} {s_{tra}^2} N_{tra}\Big)
2375 :     \end{equation}
2376 :    
2377 :     where:\newline
2378 :     $<$ x $>$ is the sample mean length from the data\newline
2379 :     $<\mu>$ is the mean length calculated from the model\newline
2380 :     $<$ s $>$ is the standard deviation of the length from the data\newline
2381 :     $<$ N $>$ is the sample size
2382 :    
2383 :     \bigskip
2384 :     For this CatchStatistics function, the format of the statistical data required in the file specified by $<$datafile$>$ is given below:
2385 :    
2386 :     {\small\begin{verbatim}
2387 :     <year> <step> <area> <age> <number> <mean> <stddev>
2388 :     \end{verbatim}}
2389 :    
2390 :     where $<$number$>$ is the number of samples for the timestep/area/age combination, $<$mean$>$ is the mean length of these samples and $<$stddev$>$ is the standard deviation of the length of these samples.
2391 :    
2392 :     \subsection{Weighted Sum of Squares of Mean Weight\newline With Given Standard Deviation}
2393 :     This likelihood function calculates the likelihood score based on a weighted sum of squares of the mean weight, with the weighting given the variance of weight of the input population, as shown in equation~\ref{eq:catchstat3} below:
2394 :    
2395 :     \begin{equation}\label{eq:catchstat3}
2396 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it ages} \Big(\frac{(x_{tra}-\mu_{tra})^2} {s_{tra}^2} N_{tra}\Big)
2397 :     \end{equation}
2398 :    
2399 :     where:\newline
2400 :     $<$ x $>$ is the sample mean weight from the data\newline
2401 :     $<\mu>$ is the mean weight calculated from the model\newline
2402 :     $<$ s $>$ is the standard deviation of the weight from the data\newline
2403 :     $<$ N $>$ is the sample size
2404 :    
2405 :     \bigskip
2406 :     For this CatchStatistics function, the format of the statistical data required in the file specified by $<$datafile$>$ is given below:
2407 :    
2408 :     {\small\begin{verbatim}
2409 :     <year> <step> <area> <age> <number> <mean> <stddev>
2410 :     \end{verbatim}}
2411 :    
2412 :     where $<$number$>$ is the number of samples for the timestep/area/age combination, $<$mean$>$ is the mean weight of these samples and $<$stddev$>$ is the standard deviation of the weight of these samples.
2413 :    
2414 :     \subsection{Unweighted Sum of Squares of Mean Weight}
2415 :     This likelihood function calculates the likelihood score based on a unweighted sum of squares of the mean weight, with the variance of the weight of the population assumed to be 1, as shown in equation~\ref{eq:catchstat4} below:
2416 :    
2417 :     \begin{equation}\label{eq:catchstat4}
2418 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it ages} \Big((x_{tra}-\mu_{tra})^2 N_{tra}\Big)
2419 :     \end{equation}
2420 :    
2421 :     where:\newline
2422 :     $<$ x $>$ is the sample mean weight from the data\newline
2423 :     $<\mu>$ is the mean weight calculated from the model\newline
2424 :     $<$ N $>$ is the sample size
2425 :    
2426 :     \bigskip
2427 :     For this CatchStatistics function, the format of the statistical data required in the file specified by $<$datafile$>$ is given below:
2428 :    
2429 :     {\small\begin{verbatim}
2430 :     <year> <step> <area> <age> <number> <mean>
2431 :     \end{verbatim}}
2432 :    
2433 :     where $<$number$>$ is the number of samples for the timestep/area/age combination, and $<$mean$>$ is the mean weight of these samples.
2434 :    
2435 :     \subsection{Unweighted Sum of Squares of Mean Length}
2436 :     This likelihood function calculates the likelihood score based on a unweighted sum of squares of the mean length, with the variance of the length of the population assumed to be 1, as shown in equation~\ref{eq:catchstat5} below:
2437 :    
2438 :     \begin{equation}\label{eq:catchstat5}
2439 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it ages} \Big((x_{tra}-\mu_{tra})^2 N_{tra}\Big)
2440 :     \end{equation}
2441 :    
2442 :     where:\newline
2443 :     $<$ x $>$ is the sample mean length from the data\newline
2444 :     $<\mu>$ is the mean length calculated from the model\newline
2445 :     $<$ N $>$ is the sample size
2446 :    
2447 :     \bigskip
2448 :     For this CatchStatistics function, the format of the statistical data required in the file specified by $<$datafile$>$ is given below:
2449 :    
2450 :     {\small\begin{verbatim}
2451 :     <year> <step> <area> <age> <number> <mean>
2452 :     \end{verbatim}}
2453 :    
2454 :     where $<$number$>$ is the number of samples for the timestep/area/age combination, and $<$mean$>$ is the mean length of these samples.
2455 :    
2456 :     \section{StockDistribution}\label{sec:stockdist}
2457 :     The StockDistribution likelihood component is used to compare distribution data sampled from the model with distribution data sampled from landings or surveys for different stocks within the Gadget model. This is typically used to compare Gadget stocks that are based on the same species, but have differing biological properties (eg. immature and mature fish). The distribution data can either be aggregated into age groups (giving a distribution of length groups for each age), length groups (giving a distribution of age groups for each length) or into age-length groups. The likelihood score that is calculated gives some measure as to how well the data from the model fits to the data from the landings.
2458 :    
2459 :     \bigskip
2460 :     To specify a StockDistribution likelihood component, the format required in the main likelihood file is as follows:
2461 :    
2462 :     {\small\begin{verbatim}
2463 :     [component]
2464 :     name <name for the likelihood component>
2465 :     weight <weight for the likelihood component>
2466 :     type stockdistribution
2467 :     datafile <name for the datafile>
2468 :     function <function name>
2469 :     overconsumption <0 or 1> ; 1 to take overconsumption into account
2470 :     epsilon <epsilon>
2471 :     areaaggfile <area aggregation file specifying areas>
2472 :     ageaggfile <age aggregation file specifying ages>
2473 :     lenaggfile <length aggregation file specifying lengths>
2474 :     fleetnames <vector of the names of the fleets>
2475 :     stocknames <vector of the names of the stocks>
2476 :     \end{verbatim}}
2477 :    
2478 :     The optional flag $<$overconsumption$>$ is used to specify whether any over consumption of the stock is to be taken into account when calculating the model distribution. If this is set to 1, then the model catch data will be adjusted to ensure that the fleets don't catch more stock than is available, by applying a bound to the catch of the fleets. If this line is not specified, then an overconsumption of 0 is assumed and any understocking that is present in the model is ignored, which can lead to an unrealistic result if the understocking likelihood component is not specified.
2479 :    
2480 :     \bigskip
2481 :     The optional $<$epsilon$>$ value is used whenever the calculated probability is very unlikely, although the exact format of this depends on the function that is to be used when calculating the likelihood score. This means that the likelihood component is not dominated by one or two stray values, since these will be reset back to less unlikely values. The default value for $<$epsilon$>$ is 10, which is used whenever it is not defined in the input file.
2482 :    
2483 :     \bigskip
2484 :     The $<$fleetnames$>$ vector contains a list of all the fleets to be aggregated into a single pseudo fleet for the purposes of the data comparison. However, the $<$stocknames$>$ vector contains a list of all the stocks to be compared for the data comparison. These stocks are not aggregated into a single pseudo stock.
2485 :    
2486 :     \bigskip
2487 :     The $<$function name$>$ defines what likelihood function is to be used to compare the modelled age-length stock distribution to the input age-length stock distribution. Currently, there are two likelihood functions defined, and the valid functions are:
2488 :    
2489 :     \bigskip
2490 :     sumofsquares - use a sum of squares function\newline
2491 :     multinomial - use a multinomial function
2492 :    
2493 :     \bigskip
2494 :     Finally, the datafile is a list of the age-length catch distribution for each stock, that Gadget is to use to fit the likelihood function to, aggregated according to the aggregation files specified, for the numbers calculated in the model. The format of this file is given below:
2495 :    
2496 :     {\small\begin{verbatim}
2497 :     <year> <step> <area> <stock> <age> <length> <number>
2498 :     \end{verbatim}}
2499 :    
2500 :     where $<$number$>$ is the number of samples for the timestep/area/stock/age/length combination.
2501 :    
2502 :     \subsection{Sum of Squares Function}
2503 :     The sum of squares function calculates the likelihood component from equation~\ref{eq:stockdist2} below:
2504 :    
2505 :     \begin{equation}\label{eq:stockdist2}
2506 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it ages}\sum_{\it lengths}\sum_{\it stocks} ( P_{trals} - \pi_{trals} ) ^2
2507 :     \end{equation}
2508 :    
2509 :     where:\newline
2510 :     $<$ P $>$ is the proportion of the data sample for that time/area/age/length/stock combination\newline
2511 :     $<\pi>$ is the proportion of the model sample for that time/area/age/length/stock combination
2512 :    
2513 :     \subsection{Multinomial Function}
2514 :     The multinomial function calculates the likelihood component from equation~\ref{eq:stockdist1} below:
2515 :    
2516 :     \begin{equation}\label{eq:stockdist1}
2517 :     \ell = 2 \sum_{\it time}\sum_{\it areas}\sum_{\it ages}\sum_{\it lengths} \Bigg( \log N_{tral}! - \sum_{\it stocks} \log N_{trals}! + \sum_{\it stocks} \Big( N_{trals} \log {\frac{\nu_{tral}}{\sum \nu_{trals}}} \Big)\Bigg)
2518 :     \end{equation}
2519 :    
2520 :     where:\newline
2521 :     $<$ N $>$ is the data sample size for that time/area/age/length/stock combination\newline
2522 :     $<\nu>$ is the model sample size for that time/area/age/length/stock combination
2523 :    
2524 :     \section{SurveyIndices}\label{sec:surveyindices}
2525 :     The SurveyIndices likelihood component is used to compare the development of a stock in the Gadget model to indices calculated from a standardized survey for that stock. These indices can be aggregated into length groups or age groups. The likelihood component that is used is the sum of squares of a linear regression fitted to the difference between the modelled data and the specified index, given by equation~\ref{eq:surveyindex} below:
2526 :    
2527 :     \begin{equation}\label{eq:surveyindex}
2528 :     \ell = \sum_{\it time}\Big(I_{t} - (\alpha + \beta N_{t})\Big)^2
2529 :     \end{equation}
2530 :    
2531 :     where:\newline
2532 :     $<$ I $>$ is the observed survey index\newline
2533 :     $<$ N $>$ is the corresponding index calculated in the Gadget model
2534 :    
2535 :     %\begin{equation}\label{eq:weightsurveyindex}
2536 :     %\ell = \sum_{\it time} w_{t} \Big(I_{t} - (\alpha + \beta N_{t})\Big)^2
2537 :     %\end{equation}
2538 :    
2539 :     %where:\newline
2540 :     %$<$ w $>$ is the weight for the survey index\newline
2541 :     %$<$ I $>$ is the observed survey index\newline
2542 :     %$<$ N $>$ is the corresponding index calculated in the Gadget model
2543 :    
2544 :     \bigskip
2545 :     The exact format of this linear regression equation will vary, depending on survey index data available. It is possible to take the log of the indices and the modelled data before fitting the linear regression line. The slope and intercept of the linear regression line are controlled by the parameters alpha and beta, and it is possible to fix these to specified numbers, or let Gadget calculate these to get the best fit to the modelled data.
2546 :    
2547 :     \bigskip
2548 :     To specify a SurveyIndices likelihood component, the format required in the main likelihood file is as follows:
2549 :    
2550 :     {\small\begin{verbatim}
2551 :     [component]
2552 :     name <name for the likelihood component>
2553 :     weight <weight for the likelihood component>
2554 :     type surveyindices
2555 :     datafile <name for the datafile>
2556 :     sitype <survey index type>
2557 :     biomass <0 or 1> ; 1 to base index data on biomass
2558 :     <survey index data>
2559 :     \end{verbatim}}
2560 :    
2561 :     The optional flag $<$biomass$>$ is used to specify whether the index data should be based on the biomass of the stock or on the population numbers for the stock. If this is set to 1, then the index data calculated in the model will be based on the available biomass of the stock. If this line is not specified, then a biomass value of 0 is assumed and the index data calculated in the model will be based on the available population numbers for the stock.
2562 :    
2563 :     \bigskip
2564 :     The format of the survey index data, and the contents of the datafile, depend on the type of survey index that is to be used, which is specified by the value of $<$survey index type$>$. There are currently 5 valid options, which are:
2565 :    
2566 :     \bigskip
2567 :     lengths - defining a length group based survey index\newline
2568 :     ages - defining an age group based survey index\newline
2569 :     fleets - defining a length group based survey index, taking the fleet selectivity into account\newline
2570 :     acoustic - defining an acoustic based survey index\newline
2571 :     effort - defining an fishing effort based survey index
2572 :    
2573 :     \subsection{SurveyIndices by Length}\label{subsec:sibylength}
2574 :     To specify a length group based SurveyIndices likelihood component, the format required in the main likelihood file is as follows:
2575 :    
2576 :     {\small\begin{verbatim}
2577 :     [component]
2578 :     name <name for the likelihood component>
2579 :     weight <weight for the likelihood component>
2580 :     type surveyindices
2581 :     datafile <name for the datafile>
2582 :     sitype lengths
2583 :     biomass <0 or 1> ; 1 to base index data on biomass
2584 :     areaaggfile <area aggregation file specifying areas>
2585 :     lenaggfile <length aggregation file specifying lengths>
2586 :     stocknames <vector of the names of the stocks>
2587 :     fittype <fit type>
2588 :     <fit type parameters>
2589 :     \end{verbatim}}
2590 :    
2591 :     The datafile is a list of the indices that Gadget is to use to fit the linear regression to, aggregated according to the length aggregation file specified, for the population numbers calculated in the model. The format of this file is given below:
2592 :    
2593 :     {\small\begin{verbatim}
2594 :     <year> <step> <area> <length> <number>
2595 :     \end{verbatim}}
2596 :    
2597 :     where $<$number$>$ is the survey index for that timestep/area/length combination.
2598 :    
2599 :     \bigskip
2600 :     The $<$fit type$>$ defines the type of linear regression equation to be used to calculate the likelihood score for this likelihood component. These options specify whether or not the log of the numbers is to be used, and whether the parameters alpha and beta are to be estimated by Gadget, or fixed. If these parameters are to be fixed, then they are specified here. In total, there are 8 valid entries for $<$fit type$>$, and the associated parameters, and these are:
2601 :    
2602 :     \bigskip
2603 :     linearfit\newline
2604 :     loglinearfit\newline
2605 :     fixedslopelinearfit\newline
2606 :     fixedslopeloglinearfit\newline
2607 :     fixedinterceptlinearfit\newline
2608 :     fixedinterceptloglinearfit\newline
2609 :     fixedlinearfit\newline
2610 :     fixedloglinearfit
2611 :    
2612 :     \subsubsection{linear regression, estimating both slope and intercept}
2613 :     This fit type will fit a linear regression line, with the alpha and beta parameter values estimated from the data within the Gadget model. The file format for this fit type is given below:
2614 :     {\small\begin{verbatim}
2615 :     fittype linearfit
2616 :     \end{verbatim}}
2617 :    
2618 :     \subsubsection{log linear regression, estimating both slope and intercept}
2619 :     This fit type will fit a log linear regression line, with the alpha and beta parameter values estimated from the data within the Gadget model. The file format for this fit type is given below:
2620 :    
2621 :     {\small\begin{verbatim}
2622 :     fittype loglinearfit
2623 :     \end{verbatim}}
2624 :    
2625 :     \subsubsection{linear regression, fixing slope and estimating intercept}
2626 :     This fit type will fit a linear regression line, with the alpha parameter value estimated from the data within the Gadget model, and the beta parameter value specified in the input file. The file format for this fit type is given below:
2627 :    
2628 :     {\small\begin{verbatim}
2629 :     fittype fixedslopelinearfit
2630 :     slope <beta>
2631 :     \end{verbatim}}
2632 :    
2633 :     \subsubsection{log linear regression, fixing slope and estimating intercept}
2634 :     This fit type will fit a log linear regression line, with the alpha parameter value estimated from the data within the Gadget model, and the beta parameter value specified in the input file. The file format for this fit type is given below:
2635 :    
2636 :     {\small\begin{verbatim}
2637 :     fittype fixedslopeloglinearfit
2638 :     slope <beta>
2639 :     \end{verbatim}}
2640 :    
2641 :     \subsubsection{linear regression, fixing intercept and estimating slope}
2642 :     This fit type will fit a linear regression line, with the beta parameter value estimated from the data within the Gadget model, and the alpha parameter value specified in the input file. The file format for this fit type is given below:
2643 :    
2644 :     {\small\begin{verbatim}
2645 :     fittype fixedinterceptlinearfit
2646 :     intercept <alpha>
2647 :     \end{verbatim}}
2648 :    
2649 :     \subsubsection{log linear regression, fixing intercept and estimating slope}
2650 :     This fit type will fit a log linear regression line, with the beta parameter value estimated from the data within the Gadget model, and the alpha parameter value specified in the input file. The file format for this fit type is given below:
2651 :    
2652 :     {\small\begin{verbatim}
2653 :     fittype fixedinterceptloglinearfit
2654 :     intercept <alpha>
2655 :     \end{verbatim}}
2656 :    
2657 :     \subsubsection{linear regression, fixing both slope and intercept}
2658 :     This fit type will fit a linear regression line, with the alpha and beta parameter values specified in the input file. The file format for this fit type is given below:
2659 :    
2660 :     {\small\begin{verbatim}
2661 :     fittype fixedlinearfit
2662 :     slope <beta>
2663 :     intercept <alpha>
2664 :     \end{verbatim}}
2665 :    
2666 :     \subsubsection{log linear regression, fixing both slope and intercept}
2667 :     This fit type will fit a log linear regression line, with the alpha and beta parameter values specified in the input file. The file format for this fit type is given below:
2668 :    
2669 :     {\small\begin{verbatim}
2670 :     fittype fixedloglinearfit
2671 :     slope <beta>
2672 :     intercept <alpha>
2673 :     \end{verbatim}}
2674 :    
2675 :     \subsection{SurveyIndices by Age}\label{subsec:sibyage}
2676 :     To specify an age group based SurveyIndices likelihood component, the format required in the main likelihood file is as follows:
2677 :    
2678 :     {\small\begin{verbatim}
2679 :     [component]
2680 :     name <name for the likelihood component>
2681 :     weight <weight for the likelihood component>
2682 :     type surveyindices
2683 :     datafile <name for the datafile>
2684 :     sitype ages
2685 :     biomass <0 or 1> ; 1 to base index data on biomass
2686 :     areaaggfile <area aggregation file specifying areas>
2687 :     ageaggfile <age aggregation file specifying ages>
2688 :     stocknames <vector of the names of the stocks>
2689 :     fittype <fit type>
2690 :     <fit type parameters>
2691 :     \end{verbatim}}
2692 :    
2693 :     The datafile is a list of the indices that Gadget is to use to fit the linear regression to, aggregated according to the age aggregation file specified, for the population numbers calculated in the model. The format of this file is given below:
2694 :    
2695 :     {\small\begin{verbatim}
2696 :     <year> <step> <area> <age> <number>
2697 :     \end{verbatim}}
2698 :    
2699 :     where $<$number$>$ is the survey index for that timestep/area/age combination.
2700 :    
2701 :     \bigskip
2702 :     The $<$fit type$>$ defines the type of linear regression equation to be used to calculate the likelihood score for this likelihood component. The valid fit type options are the same as for the length based survey indices, given in section~\ref{subsec:sibylength} above.
2703 :    
2704 :     \subsection{SurveyIndices by Fleet}\label{subsec:sibyfleet}
2705 :     To specify a length group based SurveyIndices likelihood component taking the fleet selectivity into account, the format required in the main likelihood file is as follows:
2706 :    
2707 :     {\small\begin{verbatim}
2708 :     [component]
2709 :     name <name for the likelihood component>
2710 :     weight <weight for the likelihood component>
2711 :     type surveyindices
2712 :     datafile <name for the datafile>
2713 :     sitype fleets
2714 :     biomass <0 or 1> ; 1 to base index data on biomass
2715 :     areaaggfile <area aggregation file specifying areas>
2716 :     lenaggfile <length aggregation file specifying lengths>
2717 :     fleetnames <vector of the names of the fleets>
2718 :     stocknames <vector of the names of the stocks>
2719 :     fittype <fit type>
2720 :     <fit type parameters>
2721 :     \end{verbatim}}
2722 :    
2723 :     The datafile is a list of the indices that Gadget is to use to fit the linear regression to, aggregated according to the length aggregation file specified, for the population numbers calculated in the model. The format of this file is given below:
2724 :    
2725 :     {\small\begin{verbatim}
2726 :     <year> <step> <area> <length> <number>
2727 :     \end{verbatim}}
2728 :    
2729 :     where $<$number$>$ is the survey index for that timestep/area/length combination.
2730 :    
2731 :     \bigskip
2732 :     The $<$fit type$>$ defines the type of linear regression equation to be used to calculate the likelihood score for this likelihood component. The valid fit type options are the same as for the length based survey indices, given in section~\ref{subsec:sibylength} above.
2733 :    
2734 :     \subsection{SurveyIndices by Acoustic}\label{subsec:sibyacoustic}
2735 :     To specify an acoustic based SurveyIndices likelihood component, the format required in the main likelihood file is as follows:
2736 :    
2737 :     {\small\begin{verbatim}
2738 :     [component]
2739 :     name <name for the likelihood component>
2740 :     weight <weight for the likelihood component>
2741 :     type surveyindices
2742 :     datafile <name for the datafile>
2743 :     sitype acoustic
2744 :     biomass <0 or 1> ; 1 to base index data on biomass
2745 :     areaaggfile <area aggregation file specifying areas>
2746 :     surveynames <vector of the names of the acoustic surveys>
2747 :     stocknames <vector of the names of the stocks>
2748 :     fittype <fit type>
2749 :     <fit type parameters>
2750 :     \end{verbatim}}
2751 :    
2752 :     The datafile is a list of the acoustic indices that Gadget is to use to fit the linear regression to, for the population calculated in the model. The format of this file is given below:
2753 :    
2754 :     {\small\begin{verbatim}
2755 :     <year> <step> <area> <survey> <acoustic>
2756 :     \end{verbatim}}
2757 :    
2758 :     where $<$acoustic$>$ is the acoustic index for that timestep/area/survey combination.
2759 :    
2760 :     \bigskip
2761 :     The $<$fit type$>$ defines the type of linear regression equation to be used to calculate the likelihood score for this likelihood component. The valid fit type options are the same as for the length based survey indices, given in section~\ref{subsec:sibylength} above.
2762 :    
2763 :     \subsection{SurveyIndices by Effort}\label{subsec:sibyeffort}
2764 :     To specify an effort based SurveyIndices likelihood component, the format required in the main likelihood file is as follows:
2765 :    
2766 :     {\small\begin{verbatim}
2767 :     [component]
2768 :     name <name for the likelihood component>
2769 :     weight <weight for the likelihood component>
2770 :     type surveyindices
2771 :     datafile <name for the datafile>
2772 :     sitype effort
2773 :     biomass <0 or 1> ; 1 to base index data on biomass
2774 :     areaaggfile <area aggregation file specifying areas>
2775 :     fleetnames <vector of the names of the fleets>
2776 :     stocknames <vector of the names of the stocks>
2777 :     fittype <fit type>
2778 :     <fit type parameters>
2779 :     \end{verbatim}}
2780 :    
2781 :     The datafile is a list of the fleet effort indices that Gadget is to use to fit the linear regression to, for the fishing effort calculated in the model. The format of this file is given below:
2782 :    
2783 :     {\small\begin{verbatim}
2784 :     <year> <step> <area> <fleet> <effort>
2785 :     \end{verbatim}}
2786 :    
2787 :     where $<$effort$>$ is the effort index for that timestep/area/fleet combination.
2788 :    
2789 :     \bigskip
2790 :     The $<$fit type$>$ defines the type of linear regression equation to be used to calculate the likelihood score for this likelihood component. The valid fit type options are the same as for the length based survey indices, given in section~\ref{subsec:sibylength} above.
2791 :    
2792 :     \section{SurveyDistribution}\label{sec:surveydistribution}
2793 :     The SurveyDistribution likelihood component is used to compare the development of a stock in the Gadget model to age-length indices calculated from a survey for that stock. The likelihood score that is calculated gives some measure as to how well the data from the model fits to the data from the calculated survey index distribution.
2794 :    
2795 :     \bigskip
2796 :     To specify a SurveyDistribution likelihood component, the format required in the main likelihood file is as follows:
2797 :    
2798 :     {\small\begin{verbatim}
2799 :     [component]
2800 :     name <name for the likelihood component>
2801 :     weight <weight for the likelihood component>
2802 :     type surveydistribution
2803 :     datafile <name for the datafile>
2804 :     areaaggfile <area aggregation file specifying areas>
2805 :     lenaggfile <length aggregation file specifying lengths>
2806 :     ageaggfile <age aggregation file specifying ages>
2807 :     stocknames <vector of the names of the stocks>
2808 :     fittype <fit type>
2809 :     parameters <fit type parameters>
2810 :     <suitability parameters>
2811 :     epsilon <epsilon>
2812 :     likelihoodtype <likelihood type>
2813 :     \end{verbatim}}
2814 :    
2815 :     The $<$stocknames$>$ vector contains a list of all the stocks to be aggregated into a single pseudo stock for the purposes of the data comparison. The $<$suitability parameters$>$ define the suitability of the survey fleet that was used to collect the survey index data. This is the same format as the suitability functions for the stock, as discussed in section~\ref{sec:suitability} above. Note that only one set of suitability values is defined, which will be applied to all the stocks for this likelihood component.
2816 :    
2817 :     \bigskip
2818 :     The $<$fit type$>$ defines what function is to be used to calculate the survey index distribution from the modelled population. Currently, there are two functions defined, and the valid function names are:
2819 :    
2820 :     \bigskip
2821 :     linearfit - use a linear function\newline
2822 :     powerfit - use a power function
2823 :    
2824 :     \bigskip
2825 :     The $<$fit type parameters$>$ is a vector of 2 parameters that are used to calculate the survey index values from the modelled population. The $<$epsilon$>$ value is used whenever the calculated probability is very unlikely, although the exact format of this depends on the likelihood type that is to be used when calculating the likelihood score.
2826 :    
2827 :     \bigskip
2828 :     The $<$likelihood type$>$ defines what function is to be used to compare the modelled survey index distribution to the input survey index distribution. Currently, there are 4 functions defined, and the valid function names are:
2829 :    
2830 :     \bigskip
2831 :     multinomial - use a multinomial function\newline
2832 :     pearson - use a Pearson function\newline
2833 :     gamma - use a gamma function\newline
2834 :     log - use a log function
2835 :    
2836 :     \bigskip
2837 :     Finally, the file specified by $<$datafile$>$ contains a list of the age-length survey indices that Gadget is to use to fit the likelihood function to, aggregated according to the aggregation files specified, for the numbers calculated in the model. The format of this file is given below:
2838 :    
2839 :     {\small\begin{verbatim}
2840 :     <year> <step> <area> <age> <length> <number>
2841 :     \end{verbatim}}
2842 :    
2843 :     where $<$number$>$ is the survey index for the timestep/area/age/length combination.
2844 :    
2845 :     \subsection{Linear Fit}
2846 :     The linear fit function calculates the survey index for the modelled population from equation~\ref{eq:surveydistfit1} below:
2847 :    
2848 :     \begin{equation}\label{eq:surveydistfit1}
2849 :     \widehat{I}_{tral} = q_{0} S_{l} \big( N_{tral} + q_{1} \big)
2850 :     \end{equation}
2851 :    
2852 :     where:\newline
2853 :     $<$ S $>$ is the calculated suitability value for that length group\newline
2854 :     $<$ N $>$ is the model population for that time/area/age/length combination
2855 :    
2856 :     \subsection{Power Fit}
2857 :     The power fit function calculates the survey index for the modelled population from equation~\ref{eq:surveydistfit1} below:
2858 :    
2859 :     \begin{equation}\label{eq:surveydistfit2}
2860 :     \widehat{I}_{tral} = q_{0} S_{l} N_{tral} ^{q_{1}}
2861 :     \end{equation}
2862 :    
2863 :     where:\newline
2864 :     $<$ S $>$ is the calculated suitability value for that length group\newline
2865 :     $<$ N $>$ is the model population for that time/area/age/length combination
2866 :    
2867 :     \subsection{Multinomial Function}
2868 :     The multinomial function calculates the likelihood component from equation~\ref{eq:surveydist1} below:
2869 :    
2870 :     \begin{equation}\label{eq:surveydist1}
2871 :     \ell = \sum_{\it time}\sum_{\it areas} \bigg( \log \big(\sum_{\it ages}\sum_{\it lengths} \widehat{I}_{tral} \big) - {\frac { \displaystyle \sum_{\it ages}\sum_{\it lengths} \big(\widehat{I}_{tral} \log (I_{tral} + \epsilon) \big)} { \displaystyle \sum_{\it ages}\sum_{\it lengths} I_{tral}} } \bigg)
2872 :     \end{equation}
2873 :    
2874 :     where:\newline
2875 :     $<$ I $>$ is the data survey index for that time/area/age/length combination\newline
2876 :     $<\widehat{I}>$ is the model survey index for that time/area/age/length combination
2877 :    
2878 :     \subsection{Pearson Function}
2879 :     The Pearson function calculates the likelihood component from equation~\ref{eq:surveydist2} below:
2880 :    
2881 :     \begin{equation}\label{eq:surveydist2}
2882 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it ages}\sum_{\it lengths} \Big( {\frac{ ( I_{tral} - \widehat{I}_{tral} ) ^2} {\widehat{I}_{tral} + \epsilon}} \Big)
2883 :     \end{equation}
2884 :    
2885 :     where:\newline
2886 :     $<$ I $>$ is the data survey index for that time/area/age/length combination\newline
2887 :     $<\widehat{I}>$ is the model survey index for that time/area/age/length combination
2888 :    
2889 :     \subsection{Gamma Function}
2890 :     The gamma function calculates the likelihood component from equation~\ref{eq:surveydist3} below:
2891 :    
2892 :     \begin{equation}\label{eq:surveydist3}
2893 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it ages}\sum_{\it lengths} \Big( {\frac{ I_{tral}} { (\widehat{I}_{tral} + \epsilon )} + \log ({\widehat{I}_{tral} + \epsilon}}) \Big)
2894 :     \end{equation}
2895 :    
2896 :     where:\newline
2897 :     $<$ I $>$ is the data survey index for that time/area/age/length combination\newline
2898 :     $<\widehat{I}>$ is the model survey index for that time/area/age/length combination
2899 :    
2900 :     \subsection{Log Function}
2901 :     The log function calculates the likelihood component from equation~\ref{eq:surveydist4} below:
2902 :    
2903 :     \begin{equation}\label{eq:surveydist4}
2904 :     \ell = \sum_{\it time}\sum_{\it areas} \Big( \log \Big( {\frac{ \displaystyle \sum_{\it ages}\sum_{\it lengths} \widehat{I}_{tral}} { \displaystyle \sum_{\it ages}\sum_{\it lengths} I_{tral}}} \Big) \Big) ^2
2905 :     \end{equation}
2906 :    
2907 :     where:\newline
2908 :     $<$ I $>$ is the data survey index for that time/area/age/length combination\newline
2909 :     $<\widehat{I}>$ is the model survey index for that time/area/age/length combination
2910 :    
2911 :     \section{StomachContent}\label{sec:stomach}
2912 :     The StomachContent likelihood component is used to compare consumption data sampled from the model with stomach content data obtained by analysing the stomach contents of various predators. This data can be used to give an indication of the diet composition of the stock. The likelihood score that is calculated gives some measure as to how well the consumption data from the model fits to the data from the stomach contents. Care is needed when making this comparison, since the data will give information on the stomach content at the time of capture of the predator, where as the Gadget simulation can only give information about the modelled consumption of the prey by the predator.
2913 :    
2914 :     \bigskip
2915 :     To specify a StomachContent likelihood component, the format required in the main likelihood file is as follows:
2916 :    
2917 :     {\small\begin{verbatim}
2918 :     [component]
2919 :     name <name for the likelihood component>
2920 :     weight <weight for the likelihood component>
2921 :     type stomachcontent
2922 :     function <function name>
2923 :     datafile <name for the datafile>
2924 :     epsilon <epsilon>
2925 :     areaaggfile <area aggregation file specifying areas>
2926 :     predatornames <vector of the names of the predators>
2927 :     predatorlengths
2928 :     lenaggfile <length aggregation file specifying predator lengths>
2929 :     preyaggfile <prey aggregation file specifying preys>
2930 :     \end{verbatim}}
2931 :    
2932 :     %The $<$predatortype$>$ defines how the predator data will be structured for the purposes of the data comparison. There are currently two options available, to specify a length-structured predator or an age-structured predator. To specify a predator that is length based, the format of the $<$predatortype$>$ in the likelihood file should be as follows:
2933 :    
2934 :     %{\small\begin{verbatim}
2935 :     %...
2936 :     %predatornames <vector of the names of the predators>
2937 :     %predatorages
2938 :     %ageaggfile <age aggregation file specifying predator ages>
2939 :     %preyaggfile <prey aggregation file specifying preys>
2940 :     %\end{verbatim}}
2941 :    
2942 :     The optional $<$epsilon$>$ value is used whenever the calculated probability is very unlikely, although the exact format of this depends on the function that is to be used when calculating the likelihood score. This means that the likelihood component is not dominated by one or two stray values, since these will be reset back to less unlikely values. The default value for $<$epsilon$>$ is 10, which is used whenever it is not defined in the input file.
2943 :    
2944 :     \bigskip
2945 :     The $<$predatornames$>$ vector contains a list of all the predators to be aggregated into a single pseudo predator for the purposes of the data comparison.
2946 :    
2947 :     \bigskip
2948 :     The $<$function name$>$ defines what likelihood function is to be used to compare the modelled consumption data to the input stomach content data. Currently, there is only one likelihood function defined, so the valid function name is:
2949 :    
2950 :     \bigskip
2951 :     scsimple - use a simple ratio function
2952 :     %scnumbers
2953 :     %scamounts
2954 :     %scratios
2955 :    
2956 :     \bigskip
2957 :     Finally, the file specified by $<$datafile$>$ contains a list of the stomach content data that Gadget is to use to fit the likelihood function to, aggregated according to the aggregation files specified, for the consumption calculated in the model. The format of this file is given below:
2958 :    
2959 :     {\small\begin{verbatim}
2960 :     <year> <step> <area> <predator> <prey> <ratio>
2961 :     \end{verbatim}}
2962 :    
2963 :     where $<$ratio$>$ is the ratio of prey $<$prey$>$ in the stomachs of predator $<$predator$>$ for the timestep/area combination, where $<$prey$>$ is defined in the prey aggregation file, and $<$predator$>$ is defined in the predator length aggregation file.
2964 :    
2965 :     \subsection{SCSimple Function}
2966 :     The scsimple function calculates the likelihood component by comparing the ratio of the consumption of different preys by a predator in the model to the ratio of the preys found in the stomach contents data specified in the input file, as shown in equation~\ref{eq:stomach1} below:
2967 :    
2968 :     \begin{equation}\label{eq:stomach1}
2969 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it predators}\sum_{\it preys} \Big( P_{trpp} - \pi_{trpp} \Big) ^2
2970 :     \end{equation}
2971 :    
2972 :     where:\newline
2973 :     $<$ P $>$ is the ratio of the stomach content data for that time/area/predator/prey combination\newline
2974 :     $<\pi>$ is the ratio of the modelled consumption for that time/area/predator/prey combination
2975 :    
2976 :     %\subsection{SCNumbers Function}
2977 :     %The scnumbers function calculates the likelihood component by
2978 :     %as shown in equation~\ref{eq:stomach2} below:
2979 :    
2980 :     %\begin{equation}\label{eq:stomach2}
2981 :     %\ell = 2 \sum_{\it time}\sum_{\it areas}\sum_{\it predator} \Bigg( \log N_{trp}! - \sum_{\it prey} \log N_{trpp}! + \sum_{\it prey} \Big( N_{trpp} \log {\frac{\nu_{trpp}}{\sum \nu_{trpp}}} \Big) \Bigg)
2982 :     %\end{equation}
2983 :    
2984 :     %where:\newline
2985 :     %$<$ N $>$ is the data sample size for that time/area/predator/prey combination\newline
2986 :     %$<\nu>$ is the model sample size for that time/area/predator/prey combination
2987 :    
2988 :     \section{Recaptures}\label{sec:recaptures}
2989 :     The Recaptures likelihood component is used to compare recaptures data from tagging experiments within the model with recaptures data obtained from tagging experiments, aggregated according to length at recapture. The likelihood score that is calculated gives some measure as to how well the data from the model fits the recaptures data.
2990 :    
2991 :     \bigskip
2992 :     To specify a Recaptures likelihood component, the format required in the main likelihood file is as follows:
2993 :    
2994 :     {\small\begin{verbatim}
2995 :     [component]
2996 :     name <name for the likelihood component>
2997 :     weight <weight for the likelihood component>
2998 :     type recaptures
2999 :     datafile <name for the datafile>
3000 :     function <function name>
3001 :     areaaggfile <area aggregation file specifying areas>
3002 :     lenaggfile <length aggregation file specifying recapture lengths>
3003 :     fleetnames <vector of the names of the fleets>
3004 :     \end{verbatim}}
3005 :    
3006 :     The $<$fleetnames$>$ vector contains a list of all the fleets to be aggregated into a single pseudo fleet for the purposes of the data comparison.
3007 :    
3008 :     \bigskip
3009 :     The $<$function name$>$ defines what likelihood function is to be used to compare the modelled recaptures data to the input recaptures data. Currently, there is only one likelihood function defined, so the only valid function name is:
3010 :    
3011 :     \bigskip
3012 :     poisson - use a Poisson function
3013 :    
3014 :     \bigskip
3015 :     Finally, the datafile is a list of the recaptures that Gadget is to use to fit the likelihood function to, aggregated according to the aggregation files specified, for the numbers calculated in the model. The format of this file is given below:
3016 :    
3017 :     {\small\begin{verbatim}
3018 :     <tagid> <year> <step> <area> <length> <number>
3019 :     \end{verbatim}}
3020 :    
3021 :     where $<$number$>$ is the number of recaptures for the tag/timestep/area/length combination.
3022 :    
3023 :     \subsection{Poisson Function}
3024 :     The Poisson function calculates the likelihood component from equation~\ref{eq:recap1} below:
3025 :    
3026 :     \begin{equation}\label{eq:recap1}
3027 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it lengths} \Big( N_{trl} + \log \nu_{trl}! - N_{trl} \log \nu_{trl} \Big)
3028 :     \end{equation}
3029 :    
3030 :     where:\newline
3031 :     $<$ N $>$ is the number of observed recaptures for that time/area/length combination\newline
3032 :     $<\nu>$ is the number of modelled recaptures for that time/area/length combination
3033 :    
3034 :     \section{RecStatistics}\label{sec:recstat}
3035 :     The RecStatistics likelihood component is used to compare statistical data sampled from tagged subpopulations within the model with statistical data obtained from the fish returned from tagging experiments. This is used to compare biological data, such as the mean length at age, and is similar to the CatchStatistics likelihood component (see section~\ref{sec:catchstat}). The likelihood score that is calculated gives some measure as to how well the data from the model fits to the data from the recaptures.
3036 :    
3037 :     \bigskip
3038 :     To specify a RecStatistics likelihood component, the format required in the main likelihood file is as follows:
3039 :    
3040 :     {\small\begin{verbatim}
3041 :     [component]
3042 :     name <name for the likelihood component>
3043 :     weight <weight for the likelihood component>
3044 :     type recstatistics
3045 :     datafile <name for the datafile>
3046 :     function <function name>
3047 :     areaaggfile <area aggregation file specifying areas>
3048 :     fleetnames <vector of the names of the fleets>
3049 :     \end{verbatim}}
3050 :    
3051 :     The $<$fleetnames$>$ vector contains a list of all the fleets to be aggregated into a single pseudo fleet for the purposes of the data comparison.
3052 :    
3053 :     \bigskip
3054 :     The $<$function name$>$ defines what likelihood function is to be used to compare the modelled statistical data to the input statistical data. Currently, there are three likelihood functions defined, and the format of the statistical data given in the file specified by $<$datafile$>$ depends on the likelihood function used. The valid functions are:
3055 :    
3056 :     \bigskip
3057 :     lengthcalcstddev - use a weighted sum of squares of mean length\newline
3058 :     lengthgivenstddev - use a weighted sum of squares of mean length with given standard deviation\newline
3059 :     lengthnostddev - use a unweighted sum of squares of mean length
3060 :    
3061 :     \subsection{Weighted Sum of Squares of Mean Length}
3062 :     This likelihood function calculates the likelihood score based on a weighted sum of squares of the mean length, with the weighting given by calculating the variance of length of the modelled population, as shown in equation~\ref{eq:recstat1} below:
3063 :    
3064 :     \begin{equation}\label{eq:recstat1}
3065 :     \ell = \sum_{\it tags}\sum_{\it time}\sum_{\it areas} \Big(\frac{(x-\mu)^2} {\sigma^2} N\Big)
3066 :     \end{equation}
3067 :    
3068 :     where:\newline
3069 :     $<$ x $>$ is the sample mean length from the data\newline
3070 :     $<\mu>$ is the mean length calculated from the model\newline
3071 :     $<\sigma>$ is the standard deviation of the length, calculated from the model\newline
3072 :     $<$ N $>$ is the sample size
3073 :    
3074 :     \bigskip
3075 :     For this RecStatistics function, the format of the statistical data required in the file specified by $<$datafile$>$ is given below:
3076 :    
3077 :     {\small\begin{verbatim}
3078 :     <tagid> <year> <step> <area> <number> <mean>
3079 :     \end{verbatim}}
3080 :    
3081 :     where $<$number$>$ is the number of samples for the tag/timestep/area combination, and $<$mean$>$ is the mean length of these samples.
3082 :    
3083 :     \subsection{Weighted Sum of Squares of Mean Length\newline With Given Standard Deviation}
3084 :     This likelihood function calculates the likelihood score based on a weighted sum of squares of the mean length, with the weighting given the variance of length of the input population, as shown in equation~\ref{eq:recstat2} below:
3085 :    
3086 :     \begin{equation}\label{eq:recstat2}
3087 :     \ell = \sum_{\it tags}\sum_{\it time}\sum_{\it areas} \Big(\frac{(x-\mu)^2} {s^2} N\Big)
3088 :     \end{equation}
3089 :    
3090 :     where:\newline
3091 :     $<$ x $>$ is the sample mean length from the data\newline
3092 :     $<\mu>$ is the mean length calculated from the model\newline
3093 :     $<$ s $>$ is the standard deviation of the length from the data\newline
3094 :     $<$ N $>$ is the sample size
3095 :    
3096 :     \bigskip
3097 :     For this RecStatistics function, the format of the statistical data required in the file specified by $<$datafile$>$ is given below:
3098 :    
3099 :     {\small\begin{verbatim}
3100 :     <tagid> <year> <step> <area> <number> <mean> <stddev>
3101 :     \end{verbatim}}
3102 :    
3103 :     where $<$number$>$ is the number of samples for the tag/timestep/area combination, $<$mean$>$ is the mean length of these samples and $<$stddev$>$ is the standard deviation of the length of these samples.
3104 :    
3105 :     \subsection{Unweighted Sum of Squares of Mean Length}
3106 :     This likelihood function calculates the likelihood score based on a unweighted sum of squares of the mean length, with the variance of the length of the population assumed to be 1, as shown in equation~\ref{eq:recstat3} below:
3107 :    
3108 :     \begin{equation}\label{eq:recstat3}
3109 :     \ell = \sum_{\it tags}\sum_{\it time}\sum_{\it areas} \Big((x-\mu)^2 N\Big)
3110 :     \end{equation}
3111 :    
3112 :     where:\newline
3113 :     $<$ x $>$ is the sample mean length from the data\newline
3114 :     $<\mu>$ is the mean length calculated from the model\newline
3115 :     $<$ N $>$ is the sample size
3116 :    
3117 :     \bigskip
3118 :     For this RecStatistics function, the format of the statistical data required in the file specified by $<$datafile$>$ is given below:
3119 :    
3120 :     {\small\begin{verbatim}
3121 :     <tagid> <year> <step> <area> <number> <mean>
3122 :     \end{verbatim}}
3123 :    
3124 :     where $<$number$>$ is the number of samples for the tag/timestep/area combination, and $<$mean$>$ is the mean length of these samples.
3125 :    
3126 :     \section{MigrationPenalty}\label{sec:migpenalty}
3127 :     The MigrationPenalty likelihood component is used to give a penalty whenever there is a negative migration value from the migration matrices (which is meaningless). The MigrationPenalty component is used (rather than the BoundLikelihood component) since the values in the migration matrices are calculated from more than one parameter, and it is not necessarily the individual parameters that are wrong, rather the combination of the parameters that give the migration matrix value that is wrong. The likelihood component that is used is based on the sum of squares of the migration values, given by the equation below:
3128 :    
3129 :     \begin{equation}\label{eq:migpenalty}
3130 :     \ell = \left( \sum_{ij}^{} M_{ij}^{p_0} \right)^{p_1}
3131 :     \end{equation}
3132 :    
3133 :     \bigskip
3134 :     The use of 2 power coefficients gives increased flexibility for the likelihood component. In general, a higher value of $p_1$ applies a higher penalty to ''many small negative values'', where as a higher value of $p_0$ applies a higher penalty to ''few large negative values''. For a simple sum of squares of the migration matrix values, $p_0$ should be set to 2, and $p_1$ should be set to 1.
3135 :    
3136 :     \bigskip
3137 :     To specify a MigrationPenalty likelihood component, the format required in the main likelihood file is as follows:
3138 :    
3139 :     {\small\begin{verbatim}
3140 :     [component]
3141 :     name <name for the likelihood component>
3142 :     weight <weight for the likelihood component>
3143 :     type migrationpenalty
3144 :     stockname <name for the stock to check>
3145 :     powercoeffs <p0> <p1>
3146 :     \end{verbatim}}
3147 :    
3148 :     Note that it is not possible to aggregate more than one stock into a single pseudo stock for this likelihood component.
3149 :    
3150 :     \section{CatchInKilos}\label{sec:catchinkilos}
3151 :     The CatchInKilos likelihood component is used to compare the overall catch from the modelled fleets with landings data. This can be done for any fleet that has landings data available, but will give more useful information when used with fleets of type ''LinearFleet'', since the ''TotalFleet'' fleet type will catch the amount specified in the input file (see section~\ref{chap:fleet} for more information on the available fleet types).
3152 :    
3153 :     \bigskip
3154 :     To specify a CatchInKilos likelihood component, the format required in the main likelihood file is as follows:
3155 :    
3156 :     {\small\begin{verbatim}
3157 :     [component]
3158 :     name <name for the likelihood component>
3159 :     weight <weight for the likelihood component>
3160 :     type catchinkilos
3161 :     datafile <name for the datafile>
3162 :     function <function name>
3163 :     aggregationlevel <0 or 1> ; 1 to aggregate data over the whole year
3164 :     epsilon <epsilon>
3165 :     areaaggfile <area aggregation file specifying areas>
3166 :     fleetnames <vector of the names of the fleets>
3167 :     stocknames <vector of the names of the stocks>
3168 :     \end{verbatim}}
3169 :    
3170 :     The optional flag $<$aggregationlevel$>$ is used to specify whether the catch data should be aggregated over the whole year (by setting aggregation level to 1) or not aggregated, and calculated for each timestep (by setting aggregation level to 0). If this line is not specified, then an aggregation level of 0 is assumed, and the catch data is not aggregated over the whole year.
3171 :    
3172 :     \bigskip
3173 :     The $<$fleetnames$>$ vector contains a list of all the fleets to be aggregated into a single pseudo fleet for the purposes of the data comparison. Similarly, the $<$stocknames$>$ vector contains a list of all the stocks to be aggregated into a single pseudo stock.
3174 :    
3175 :     \bigskip
3176 :     The optional $<$epsilon$>$ value is used in the likelihood function to avoid problems that would arise from taking the logarithm of zero. Epsilon is added to both the modelled and observed landings data, to ensure that these values are always positive, and thus should be set to a small number. The default value for $<$epsilon$>$ is 10, which is used whenever it is not defined in the input file.
3177 :    
3178 :     \bigskip
3179 :     The $<$function name$>$ defines what likelihood function is to be used to compare the modelled catch to the input catch. Currently, there is only one likelihood function defined, so the only valid function name is:
3180 :    
3181 :     \bigskip
3182 :     sumofsquares - use a log sum of squares function
3183 :    
3184 :     \bigskip
3185 :     Finally, the file specified by $<$datafile$>$ contains the landings data that Gadget is to use to fit the likelihood function to for the catch calculated in the model. The format of this file is given below:
3186 :    
3187 :     {\small\begin{verbatim}
3188 :     <year> <step> <area> <fleet> <biomass>
3189 :     \end{verbatim}}
3190 :    
3191 :     where $<$biomass$>$ is the catch for the timestep/area/fleet combination. The $<$step$>$ column is optional if the $<$aggregationlevel$>$ flag has been set to 1, since the data will be aggregated over the whole year. In this case, it is possible to specify the landings data in the following format:
3192 :    
3193 :     {\small\begin{verbatim}
3194 :     <year> <area> <fleet> <biomass>
3195 :     \end{verbatim}}
3196 :    
3197 :     \subsection{Sum of Squares Function}
3198 :     The sum of squares function calculates the likelihood component from equation~\ref{eq:catchtons} below:
3199 :    
3200 :     \begin{equation}\label{eq:catchtons}
3201 :     \ell = \sum_{\it time}\sum_{\it areas}\sum_{\it fleets} (\log(N_{trf} + \epsilon) - \log(\nu_{trf} + \epsilon))^2
3202 :     \end{equation}
3203 :    
3204 :     where:\newline
3205 :     $<$ N $>$ is the catch biomass for that time/area/fleet combination\newline
3206 :     $<\nu>$ is the modelled catch biomass for that time/area/fleet combination
3207 :    
3208 :     \chapter{Print Files}\label{chap:print}
3209 :     The print files are used to control the output from the Gadget model (and not the output from the optimisation process). To avoid writing the model output from each iteration of a optimising process (and thus generating very large files), any printfile settings are ignored if Gadget is started with the -l switch.
3210 :    
3211 :     \bigskip
3212 :     To define print files in the Gadget model, the ''main'' file must contain a list of the data files that contain the description of the printer classes required, and the format for this is shown below:
3213 :    
3214 :     {\small\begin{verbatim}
3215 :     printfiles <names of the print files>
3216 :     \end{verbatim}}
3217 :    
3218 :     The print files contain a list of various type of printer classes, separated by the keyword [component], that output different information from the model, and the name of the file that the information is to be written to. All the output is written as a plain ASCII text file that can be viewed in any text editor. The format of the print file is follows:
3219 :    
3220 :     {\small\begin{verbatim}
3221 :     [component]
3222 :     type <printer type>
3223 :     <printer data>
3224 :     \end{verbatim}}
3225 :    
3226 :     The printer data for each printer type is covered in the sub sections below. The $<$printer type$>$ defines the type of output that will be generated from the Gadget model, and there are currently 11 valid printer types defined in Gadget. These are:
3227 :    
3228 :     \bigskip
3229 :     StockStdPrinter\newline
3230 :     StockFullPrinter\newline
3231 :     StockPrinter\newline
3232 :     PredatorPrinter\newline
3233 :     PredatorOverPrinter\newline
3234 :     PreyOverPrinter\newline
3235 :     StockPreyFullPrinter\newline
3236 :     StockPreyPrinter\newline
3237 :     PredatorPreyPrinter\newline
3238 :     LikelihoodPrinter\newline
3239 :     LikelihoodSummaryPrinter
3240 :    
3241 :     \newpage %JMB insert page break
3242 :     \section{StockStdPrinter}\label{sec:stockstdprinter}
3243 :     The printer type to output the standard details of a stock is called ''StockStdPrinter''. This printer type is defined by specifying the stock and timesteps of interest. The file format for this component is given below:
3244 :    
3245 :     {\small\begin{verbatim}
3246 :     [component]
3247 :     type stockstdprinter
3248 :     stockname <name of the stock>
3249 :     scale <scaling factor>
3250 :     printfile <name for the output file to be created>
3251 :     precision <precision to be used in the output file>
3252 :     printatstart <0 or 1> ; 1 to print at start of timestep
3253 :     yearsandsteps <ActionAtTime to determine when to print>
3254 :     \end{verbatim}}
3255 :    
3256 :     The optional $<$scale$>$ factor is used to scale the size of the stock, which can be used to display the stock in terms of thousands of fish, for example. The default value for this parameter is 1, which will ensure that no scaling will take place.
3257 :    
3258 :     \bigskip
3259 :     The optional $<$precision$>$ value is used to specify the number of digits to be used when printing the information to the specified output file, overriding the default settings for this printer type.
3260 :    
3261 :     \bigskip
3262 :     The optional flag $<$printatstart$>$ is used to specify whether the information about the stock should be printed at the start or the end of the timestep. If this is set to 1, then the stock information as it is at the start of the timestep is printed, before any other calculation has taken place (see appendix~\ref{chap:order} for more information on the order of the calculations). The default value for $<$printatstart$>$ is 0, which means that the information at the end of the timestep is printed, and is used whenever the flag is not specified in the input file.
3263 :    
3264 :     \bigskip
3265 :     The output that is generated from this printer type is a file containing the following information for the stock specified on the $<$stockname$>$ line:
3266 :    
3267 :     {\small\begin{verbatim}
3268 :     year-step-area-age-number-length-weight-stddev-consumed-biomass
3269 :     \end{verbatim}}
3270 :    
3271 :     where:\newline
3272 :     $<$number$>$ is the stock population for that timestep/area/age combination\newline
3273 :     $<$length$>$ is the mean length for that timestep/area/age combination\newline
3274 :     $<$weight$>$ is the mean weight for that timestep/area/age combination\newline
3275 :     $<$stddev$>$ is the standard deviation for the length for that timestep/area/age combination\newline
3276 :     $<$consumed$>$ is the stock population that has been consumed by all the predators (including fleets) for that timestep/area/age combination\newline
3277 :     $<$biomass$>$ is the stock biomass that has been consumed by all the predators (including fleets) for that timestep/area/age combination
3278 :    
3279 :     \section{StockFullPrinter}\label{sec:stockfullprinter}
3280 :     The printer type to output some more detailed information about a stock is called ''StockFullPrinter''. This printer type is defined by specifying the stock and timesteps of interest. The file format for this component is given below:
3281 :    
3282 :     {\small\begin{verbatim}
3283 :     [component]
3284 :     type stockfullprinter
3285 :     stockname <name of the stock>
3286 :     printfile <name for the output file to be created>
3287 :     precision <precision to be used in the output file>
3288 :     printatstart <0 or 1> ; 1 to print at start of timestep
3289 :     yearsandsteps <ActionAtTime to determine when to print>
3290 :     \end{verbatim}}
3291 :    
3292 :     The optional $<$precision$>$ value is used to specify the number of digits to be used when printing the information to the specified output file, overriding the default settings for this printer type.
3293 :    
3294 :     \bigskip
3295 :     The optional flag $<$printatstart$>$ is used to specify whether the information about the stock should be printed at the start or the end of the timestep. If this is set to 1, then the stock information as it is at the start of the timestep is printed, before any other calculation has taken place (see appendix~\ref{chap:order} for more information on the order of the calculations). The default value for $<$printatstart$>$ is 0, which means that the information at the end of the timestep is printed, and is used whenever the flag is not specified in the input file.
3296 :    
3297 :     \bigskip
3298 :     The output that is generated from this printer type is a file containing the following information for the stock specified on the $<$stockname$>$ line:
3299 :    
3300 :     {\small\begin{verbatim}
3301 :     year-step-area-age-length-number-weight
3302 :     \end{verbatim}}
3303 :    
3304 :     where:\newline
3305 :     $<$number$>$ is the population for that timestep/area/age/length combination\newline
3306 :     $<$weight$>$ is the mean weight for that timestep/area/age/length combination
3307 :    
3308 :     \section{StockPrinter}\label{sec:stockprinter}
3309 :     The printer type to output information about (one or more) stocks, with the information aggregated into a convenient grouping, is called ''StockPrinter''. This printer type is defined by specifying the stocks, areas, age groups, length groups and timesteps of interest. The file format for this component is given below:
3310 :    
3311 :     {\small\begin{verbatim}
3312 :     [component]
3313 :     type stockprinter
3314 :     stocknames <vector of the names of the stocks>
3315 :     areaaggfile <area aggregation file specifying areas>
3316 :     ageaggfile <age aggregation file specifying ages>
3317 :     lenaggfile <length aggregation file specifying lengths>
3318 :     printfile <name for the output file to be created>
3319 :     precision <precision to be used in the output file>
3320 :     printatstart <0 or 1> ; 1 to print at start of timestep
3321 :     yearsandsteps <ActionAtTime to determine when to print>
3322 :     \end{verbatim}}
3323 :    
3324 :     Note that this printer type can aggregate more than one stock into a combined pseudo stock for the output file.
3325 :    
3326 :     \bigskip
3327 :     The optional $<$precision$>$ value is used to specify the number of digits to be used when printing the information to the specified output file, overriding the default settings for this printer type.
3328 :    
3329 :     \bigskip
3330 :     The optional flag $<$printatstart$>$ is used to specify whether the information about the stock should be printed at the start or the end of the timestep. If this is set to 1, then the stock information as it is at the start of the timestep is printed, before any other calculation has taken place (see appendix~\ref{chap:order} for more information on the order of the calculations). The default value for $<$printatstart$>$ is 0, which means that the information at the end of the timestep is printed, and is used whenever the flag is not specified in the input file.
3331 :    
3332 :     \bigskip
3333 :     The output that is generated from this printer type is a file containing the following information for all the stocks specified on the $<$stocknames$>$ line:
3334 :    
3335 :     {\small\begin{verbatim}
3336 :     year-step-area-age-length-number-weight
3337 :     \end{verbatim}}
3338 :    
3339 :     where:\newline
3340 :     $<$area$>$ is the label for the area from the area aggregation file\newline
3341 :     $<$age$>$ is the label for the age group from the age aggregation file\newline
3342 :     $<$length$>$ is the label for the length group from the length aggregation file\newline
3343 :     $<$number$>$ is the population for that timestep/area/age/length combination\newline
3344 :     $<$weight$>$ is the mean weight for that timestep/area/age/length combination
3345 :    
3346 :     \section{PredatorPrinter}\label{sec:predatorprinter}
3347 :     The printer type to output information about predation, with the information aggregated into a convenient grouping, is called ''PredatorPrinter''. This printer type is defined by specifying the predators, preys, areas, length groups and timesteps of interest. The file format for this component is given below:
3348 :    
3349 :     {\small\begin{verbatim}
3350 :     [component]
3351 :     type predatorprinter
3352 :     predatornames <vector of the names of the predators>
3353 :     preynames <vector of the names of the preys>
3354 :     areaaggfile <area aggregation file specifying areas>
3355 :     predlenaggfile <length aggregation file specifying predator lengths>
3356 :     preylenaggfile <length aggregation file specifying prey lengths>
3357 :     biomass <0 or 1> ; 1 to print biomass consumed
3358 :     printfile <name for the output file to be created>
3359 :     precision <precision to be used in the output file>
3360 :     yearsandsteps <ActionAtTime to determine when to print>
3361 :     \end{verbatim}}
3362 :    
3363 :     Note that this printer type can aggregate more than one predator into a combined pseudo predator, and more than one prey into a pseudo prey, for the output file.
3364 :    
3365 :     \bigskip
3366 :     The optional flag $<$biomass$>$ is used to specify whether the information about the consumption of the preys by the predators is printed by biomass consumed or by number consumed. If this is set to 1 then information about the consumption is printed by biomass consumed. If this is set to 0 then this information is printed by number consumed. The default value for $<$biomass$>$ is 1, which means that the consumption by biomass will be printed if this flag is not specified in the input file.
3367 :    
3368 :     \bigskip
3369 :     The optional $<$precision$>$ value is used to specify the number of digits to be used when printing the information to the specified output file, overriding the default settings for this printer type.
3370 :    
3371 :     \bigskip
3372 :     The output that is generated from this printer type is a file containing the following predation information for all the predators specified on the $<$predatornames$>$ line, consuming all the preys specified on the $<$preynames$>$ line:
3373 :    
3374 :     {\small\begin{verbatim}
3375 :     year-step-area-pred-prey-amount
3376 :     \end{verbatim}}
3377 :    
3378 :     where:\newline
3379 :     $<$area$>$ is the label for the area from the area aggregation file\newline
3380 :     $<$pred$>$ is the label for the predator length group from the length aggregation file\newline
3381 :     $<$prey$>$ is the label for the prey length group from the length aggregation file\newline
3382 :     $<$amount$>$ is the biomass (or number) consumed for that timestep/area/predator length/prey length combination, depending on the value of the $<$biomass$>$ flag in the input file
3383 :    
3384 :     \section{PredatorOverPrinter}\label{sec:predatoroverprinter}
3385 :     The printer type to output information about predator over consumption (where a predator has failed to eat the required amount of prey since the prey is not available), with the information aggregated into a convenient grouping, is called ''PredatorOverPrinter''. This printer type is defined by specifying the predators, areas, length groups and timesteps of interest. The file format for this component is given below:
3386 :    
3387 :     {\small\begin{verbatim}
3388 :     [component]
3389 :     type predatoroverprinter
3390 :     predatornames <vector of the names of the predators>
3391 :     areaaggfile <area aggregation file specifying areas>
3392 :     lenaggfile <length aggregation file specifying lengths>
3393 :     printfile <name for the output file to be created>
3394 :     precision <precision to be used in the output file>
3395 :     yearsandsteps <ActionAtTime to determine when to print>
3396 :     \end{verbatim}}
3397 :    
3398 :     Note that this printer type can aggregate more than one predator into a combined pseudo predator for the output file.
3399 :    
3400 :     \bigskip
3401 :     The optional $<$precision$>$ value is used to specify the number of digits to be used when printing the information to the specified output file, overriding the default settings for this printer type.
3402 :    
3403 :     \bigskip
3404 :     The output that is generated from this printer type is a file containing the following over-consumption information for all the predators specified on the $<$predatornames$>$ line:
3405 :    
3406 :     {\small\begin{verbatim}
3407 :     year-step-area-length-biomass
3408 :     \end{verbatim}}
3409 :    
3410 :     where:\newline
3411 :     $<$area$>$ is the label for the area from the area aggregation file\newline
3412 :     $<$length$>$ is the label for the length group from the length aggregation file\newline
3413 :     $<$biomass$>$ is the biomass that the predator failed to consume for that timestep/area/length combination
3414 :    
3415 :     \section{PreyOverPrinter}\label{sec:preyoverprinter}
3416 :     The printer type to output information about prey over consumption (where there has been insufficient prey for a predator to consume), with the information aggregated into a convenient grouping, is called ''PreyOverPrinter''. This printer type is the inverse of the PredatorOverPrinter printer type, in that it gives the same information, but from the point of view of the preys, not the predators. This printer type is defined by specifying the preys, areas, length groups and timesteps of interest. The file format for this component is given below:
3417 :    
3418 :     {\small\begin{verbatim}
3419 :     [component]
3420 :     type preyoverprinter
3421 :     preynames <vector of the names of the preys>
3422 :     areaaggfile <area aggregation file specifying areas>
3423 :     lenaggfile <length aggregation file specifying lengths>
3424 :     printfile <name for the output file to be created>
3425 :     precision <precision to be used in the output file>
3426 :     yearsandsteps <ActionAtTime to determine when to print>
3427 :     \end{verbatim}}
3428 :    
3429 :     Note that this printer type can aggregate more than one prey into a combined pseudo prey for the output file.
3430 :    
3431 :     \bigskip
3432 :     The optional $<$precision$>$ value is used to specify the number of digits to be used when printing the information to the specified output file, overriding the default settings for this printer type.
3433 :    
3434 :     \bigskip
3435 :     The output that is generated from this printer type is a file containing the following over-consumption information for all the preys specified on the $<$preynames$>$ line:
3436 :    
3437 :     {\small\begin{verbatim}
3438 :     year-step-area-length-biomass
3439 :     \end{verbatim}}
3440 :    
3441 :     where:\newline
3442 :     $<$area$>$ is the label for the area from the area aggregation file\newline
3443 :     $<$length$>$ is the label for the length group from the length aggregation file\newline
3444 :     $<$biomass$>$ is the biomass of the prey that was unavailable, for that timestep/area/length combination
3445 :    
3446 :     \section{StockPreyFullPrinter}\label{sec:stockpreyfullprinter}
3447 :     The printer type to output detailed information about a prey is called ''StockPreyFullPrinter''. This printer type is defined by specifying the prey and timesteps of interest. The file format for this component is given below:
3448 :    
3449 :     {\small\begin{verbatim}
3450 :     [component]
3451 :     type stockpreyfullprinter
3452 :     preyname <name of the prey>
3453 :     printfile <name for the output file to be created>
3454 :     precision <precision to be used in the output file>
3455 :     yearsandsteps <ActionAtTime to determine when to print>
3456 :     \end{verbatim}}
3457 :    
3458 :     The optional $<$precision$>$ value is used to specify the number of digits to be used when printing the information to the specified output file, overriding the default settings for this printer type.
3459 :    
3460 :     \bigskip
3461 :     The output that is generated from this printer type is a file containing the following information for the prey specified on the $<$preyname$>$ line:
3462 :    
3463 :     {\small\begin{verbatim}
3464 :     year-step-area-age-length-number-biomass
3465 :     \end{verbatim}}
3466 :    
3467 :     where:\newline
3468 :     $<$number$>$ is the total population consumed for that timestep/area/age/length combination\newline
3469 :     $<$biomass$>$ is the total biomass consumed for that timestep/area/age/length combination
3470 :    
3471 :     \section{StockPreyPrinter}\label{sec:stockpreyprinter}
3472 :     The printer type to output information about (one or more) preys, with the information aggregated into a convenient grouping, is called ''StockPreyPrinter''. This printer type is defined by specifying the preys, areas, age groups, length groups and timesteps of interest. The file format for this component is given below:
3473 :    
3474 :     {\small\begin{verbatim}
3475 :     [component]
3476 :     type stockpreyprinter
3477 :     preynames <vector of the names of the preys>
3478 :     printfile <name for the output file to be created>
3479 :     areaaggfile <area aggregation file specifying areas>
3480 :     ageaggfile <age aggregation file specifying ages>
3481 :     lenaggfile <length aggregation file specifying lengths>
3482 :     precision <precision to be used in the output file>
3483 :     yearsandsteps <ActionAtTime to determine when to print>
3484 :     \end{verbatim}}
3485 :    
3486 :     Note that this printer type can aggregate more than one prey into a combined pseudo prey for the output file.
3487 :    
3488 :     \bigskip
3489 :     The optional $<$precision$>$ value is used to specify the number of digits to be used when printing the information to the specified output file, overriding the default settings for this printer type.
3490 :    
3491 :     \bigskip
3492 :     The output that is generated from this printer type is a file containing the following information for all the preys specified on the $<$preynames$>$ line:
3493 :    
3494 :     {\small\begin{verbatim}
3495 :     year-step-area-age-length-number-biomass
3496 :     \end{verbatim}}
3497 :    
3498 :     where:\newline
3499 :     $<$area$>$ is the label for the area from the area aggregation file\newline
3500 :     $<$age$>$ is the label for the age group from the age aggregation file\newline
3501 :     $<$length$>$ is the label for the length group from the length aggregation file\newline
3502 :     $<$number$>$ is the total population consumed for that timestep/area/age/length combination\newline
3503 :     $<$biomass$>$ is the total biomass consumed for that timestep/area/age/length combination
3504 :    
3505 :     \section{PredatorPreyPrinter}\label{sec:predatorpreyprinter}
3506 :     The printer type to output detailed information about predator-prey combinations, with the information aggregated into a convenient grouping, is called ''PredatorPreyPrinter''. This printer type is defined by specifying the predators, preys, areas, age groups, length groups and timesteps of interest. The file format for this component is given below:
3507 :    
3508 :     {\small\begin{verbatim}
3509 :     [component]
3510 :     type predatorpreyprinter
3511 :     predatornames <vector of the names of the predators>
3512 :     preynames <vector of the names of the preys>
3513 :     areaaggfile <area aggregation file specifying areas>
3514 :     ageaggfile <age aggregation file specifying prey ages>
3515 :     lenaggfile <length aggregation file specifying prey lengths>
3516 :     printfile <name for the output file to be created>
3517 :     precision <precision to be used in the output file>
3518 :     yearsandsteps <ActionAtTime to determine when to print>
3519 :     \end{verbatim}}
3520 :    
3521 :     Note that this printer type can aggregate more than one predator into a combined pseudo predator, and more than one prey into a pseudo prey, for the output file.
3522 :    
3523 :     \bigskip
3524 :     The optional $<$precision$>$ value is used to specify the number of digits to be used when printing the information to the specified output file, overriding the default settings for this printer type.
3525 :    
3526 :     \bigskip
3527 :     The output that is generated from this printer type is a file containing the following predation information for all the predators specified on the $<$predatornames$>$ line, consuming all the preys specified on the $<$preynames$>$ line:
3528 :    
3529 :     {\small\begin{verbatim}
3530 :     year-step-area-age-length-number-biomass-mortality
3531 :     \end{verbatim}}
3532 :    
3533 :     where:\newline
3534 :     $<$age$>$ is the label for the prey age group from the age aggregation file\newline
3535 :     $<$length$>$ is the label for the prey length group from the length aggregation file\newline
3536 :     $<$number$>$ is the number consumed for that timestep/area/age/length combination\newline
3537 :     $<$biomass$>$ is the biomass consumed for that timestep/area/age/length combination\newline
3538 :     $<$mortality$>$ is the effective annual mortality induced in the prey by the predation for that timestep/area/age/length combination
3539 :    
3540 :     \section{LikelihoodPrinter}\label{sec:likelihoodprinter}
3541 :     The printer type to output detailed information about a likelihood component is called ''LikelihoodPrinter''. This printer type is defined by specifying the likelihood component and timesteps of interest. The file format for this component is given below:
3542 :    
3543 :     {\small\begin{verbatim}
3544 :     [component]
3545 :     type likelihoodprinter
3546 :     likelihood <name of the likelihood component>
3547 :     printfile <name for the output file to be created>
3548 :     \end{verbatim}}
3549 :    
3550 :     The output that is generated from this printer type is a file containing the internal model information for the likelihood component specified on the $<$likelihood$>$ line, in the same format as the data in the input file for that component, allowing the user to easily compare the modelled data to the input data. The exact format of this output file will vary according to the likelihood component chosen. Some examples of output are:
3551 :    
3552 :     \begin{enumerate}
3553 :     \item CatchDistribution likelihood component (see section~\ref{sec:catchdist})
3554 :     {\small\begin{verbatim}
3555 :     year-step-area-age-length-number
3556 :     \end{verbatim}}
3557 :     \item CatchStatistics likelihood component (see section~\ref{sec:catchstat})
3558 :     {\small\begin{verbatim}
3559 :     year-step-area-age-number-mean[-stddev]
3560 :     \end{verbatim}}
3561 :     \item SurveyIndices likelihood component (see section~\ref{sec:surveyindices})
3562 :     {\small\begin{verbatim}
3563 :     year-step-area-index-number
3564 :     \end{verbatim}}
3565 :     \end{enumerate}
3566 :    
3567 :     \section{LikelihoodSummaryPrinter}\label{sec:likelihoodsummaryprinter}
3568 :     The printer type to output summary information about all the likelihood components that are in use for the current simulation is called ''LikelihoodSummaryPrinter''. The file format for this component is given below:
3569 :    
3570 :     {\small\begin{verbatim}
3571 :     [component]
3572 :     type likelihoodsummaryprinter
3573 :     printfile <name for the output file to be created>
3574 :     \end{verbatim}}
3575 :    
3576 :     The output that is generated from this printer type is a file containing summary information for all the likelihood components that have been defined for the current simulation:
3577 :    
3578 :     {\small\begin{verbatim}
3579 :     year-step-area-component-weight-score
3580 :     \end{verbatim}}
3581 :    
3582 :     where:\newline
3583 :     $<$component$>$ is the name of the likelihood component\newline
3584 :     $<$weight$>$ is the weight of the likelihood component\newline
3585 :     $<$score$>$ is the score from the likelihood component for that timestep/area combination
3586 :    
3587 :     \chapter{Parameter File}\label{chap:param}
3588 :     The parameter file is used to specify the initial values for the switches that are to be used in the Gadget model (see What Does The \# Mean?, section~\ref{sec:whatdoeshash}). This file is specified by a ''-i $<$filename$>$'' command line option when Gadget is started, for example, this would take the parameter information from a file called ''inputfile.txt'':
3589 :    
3590 :     {\small\begin{verbatim}
3591 :     gadget -s -i inputfile.txt
3592 :     \end{verbatim}}
3593 :    
3594 :     This file contains a list of all the switches, their initial value, the lower and upper bounds and a flag to note whether the optimiser should optimise that switch or not. The first line of this file must contain the column headings, and then subsequent lines should list all switches that are used. An example of this file format is shown below:
3595 :    
3596 :     {\small\begin{verbatim}
3597 :     switch value lower upper optimise
3598 :     <name> <value> <lower> <upper> <0 or 1> ; 1 to optimise this parameter
3599 :     \end{verbatim}}
3600 :    
3601 :     Note that if Gadget is performing a simulation run, then the ''optimise'' column is still required, although the value of the optimise flag will have no affect on the outcome of the simulation.
3602 :    
3603 :     \bigskip
3604 :     In some cases an initial value for a parameter is not known, or a random starting point is wanted (for example, to ensure that the value of the starting point has little affect on the outcome of the optimisation). This is done by specifying the keyword ''random'' instead of an initial value, which will ensure that Gadget will set the initial value for that parameter to a random point within the bounds. This is shown in the example below, where the initial value for the parameter ''age2'' will be set to a random point between 1 and 10:
3605 :    
3606 :     {\small\begin{verbatim}
3607 :     age2 random 1 10 1 ; random value between 1 and 10
3608 :     \end{verbatim}}
3609 :    
3610 :     \chapter{Optimisation File}\label{chap:optim}
3611 :     The optimisation file is used to specify the type of optimisation to be used, along with any parameters that are needed for the optimisation algorithm. This file is specified by a ''-opt $<$filename$>$'' command line option when Gadget is started, for example, this would take the optimisation information from a file called ''optinfo.txt'':
3612 :    
3613 :     {\small\begin{verbatim}
3614 :     gadget -l -opt optinfo.txt
3615 :     \end{verbatim}}
3616 :    
3617 :     There are three types of optimisation algorithms currently implemented in Gadget - these are one based on the Hooke \& Jeeves algorithm, one based on the Simulated Annealing algorithm and one based on the Broyden-Fletcher-Goldfarb-Shanno (''BFGS'') algorithm. These algorithms are described in more detail in the following sections. Gadget can also combine two or more of these algorithms into a single hybrid algorithm, that should result in a more efficient search for an optimum solution.
3618 :    
3619 :     \bigskip
3620 :     All the optimisation techniques used by Gadget attempt to minimise the likelihood function. That is, they look for the best set of parameters to run the model with, in order to get the best fit according to the likelihood functions you have specified. Thus, the optimiser is attempting to minimize a single one-dimensional measure of fit between the model output and the data, which can lead to unexpected results.
3621 :    
3622 :     \bigskip
3623 :     The optimisation process will tend to produce realistic values for the most significant parameters (typically growth, recruitment in large year classes and fishing selectivity) before finding realistic values for less significant parameters. It should be noted that the parameters governing recruitment and growth in the last few years with data in a simulation will be among the last to settle on realistic values. It is important to ensure that an optimum solution has been reached before accepting the model, especially if the model is to be used to predict the population into the future or to examine the strength of the last few year classes.
3624 :    
3625 :     \section{Hooke \& Jeeves}\label{sec:hooke}
3626 :     \subsection{Overview}\label{subsec:hookeover}
3627 :     Hooke \& Jeeves is a simple and fast optimising method, but somewhat unreliable, and it is often described as a 'hill climbing' technique. From the initial starting point the algorithm takes a step in various 'directions', and conducts a new model run. If the new likelihood score is better than the old one then the algorithm uses the new point as it's best guess. If it is worse then the algorithm retains the old point. The search proceeds in series of these steps, each step slightly smaller than the previous one. When the algorithm finds a point which it cannot improve on with a small step in any direction then it accepts this point as being the 'solution', and exits. It can be seen that this renders the scheme vulnerable to producing local solutions, accepting a local dip as being the solution even if a better solution exists elsewhere, beyond a local 'hill' that the algorithm cannot see past. In order to combat this tendency it is strongly recommended that you re-run the optimisation, using the final point of one run as the start of the next. This will effectively re-set the searching step size to large steps, and give Gadget a chance of escaping from local solutions. Finding the same result twice in a row does not guarantee it is the best possible solution, but finding different results certainly indicates that the larger result is not the solution you are seeking.
3628 :    
3629 :     \bigskip
3630 :     The Hooke \& Jeeves algorithm used in Gadget is derived from that originally presented by R. Hooke and T. A. Jeeves, ''Direct Search Solution of Numerical and Statistical Problems'' in the April 1961 (Vol. 8, pp. 212-229) issue of the Journal of the ACM, with improvements presented by Arthur F Kaupe Jr., ''Algorithm 178: Direct Search'' in the June 1963 (Vol 6, pp.313-314) issue of the Communications of the ACM.
3631 :    
3632 :     \bigskip
3633 :     Hooke \& Jeeves is the default optimisation method used for Gadget, and will be used if no optimisation information file is specified.
3634 :    
3635 :     \subsection{File Format}\label{subsec:hookefile}
3636 :     To specify the Hooke \& Jeeves algorithm, the optimisation file should start with the keyword ''[hooke]'', followed by (up to) 4 lines giving the parameters for the optimisation algorithm. Any parameters that are not specified in the file are given default values, which work reasonably well for simple Gadget models. The format for this file, and the default values for the optimisation parameters, are shown below:
3637 :    
3638 :     {\small\begin{verbatim}
3639 :     [hooke]
3640 :     hookeiter 1000 ; number of hooke & jeeves iterations
3641 :     hookeeps 1e-04 ; minimum epsilon, hooke & jeeves halt criteria
3642 :     rho 0.5 ; step length adjustment factor
3643 :     lambda 0 ; initial value for the step length
3644 :     \end{verbatim}}
3645 :    
3646 :     \subsection{Parameters}\label{subsec:hookepar}
3647 :     \subsubsection{hookeiter}
3648 :     This is the maximum number of Gadget model runs that the Hooke \& Jeeves algorithm will use to try to find the best solution. If this number is exceeded, Gadget will select the best point found so far, and accept this as the 'solution', even though it has not met the convergence criteria. A warning that Gadget has stopped without finding a solution that meets the convergence criteria will be printed.
3649 :    
3650 :     \subsubsection{hookeeps}
3651 :     This is the criteria for halting the Hooke \& Jeeves algorithm at a minimum, and accepting the current point as the 'solution'. The algorithm has ''converged'' when the size of each step in the search has been reduced to less than this value, and no further improvements can be made. This means that each parameter in the Gadget model is less than hookeeps from their value at the (local) optimum. Larger values of hookeeps give a quicker running time, but a less accurate estimate of the minimum. Conversely, smaller values will give a longer running time, but a more accurate estimate of the minimum.
3652 :    
3653 :     \subsubsection{rho}
3654 :     This is the resizing multiplier for the step length of the search made by the algorithm. The Hooke \& Jeeves algorithm works by taking ''steps'' from one estimate of a optimum, to another (hopefully better) estimate of the optimum. Taking big steps gets to the minimum more quickly, at the risk of 'stepping over' an excellent point. When no improvements to the minimum can be made by taking steps of the current length, the step length is reduced by multiplying it by rho.
3655 :    
3656 :     \bigskip
3657 :     Small values of rho correspond to big step length changes, which make the algorithm run more quickly. However, there is a chance that these big changes will accidentally overlook a promising point, leading to non-convergence. Larger values of rho correspond to smaller step length changes, which force the algorithm to carefully examine nearby points instead of optimistically forging ahead, which improves the probability of convergence. The value of rho must be between 0 and 1.
3658 :    
3659 :     \subsubsection{lambda}
3660 :     This is the initial value for the size of the steps in the search, which will be used for the the first search, before any modification to the step length. All the parameters in the Gadget model are initially scaled so that their value is 1, and the initial search will then look at the points $1 \pm \lambda$ for the next optimum. Setting lambda to zero will set the initial value for the step length equal to rho. The value of lambda must be between 0 and 1.
3661 :    
3662 :     %\subsubsection{bndcheck}
3663 :    
3664 :     \section{Simulated Annealing}\label{sec:simann}
3665 :     \subsection{Overview}\label{subsec:simannover}
3666 :     Simulated Annealing is a global optimisation method that distinguishes between different local minimum. From the initial starting point the algorithm takes a random step in various directions, and conducts a new model run. If the new likelihood score is better than the old one then the algorithm uses the new point as it's best guess. If it is worse then the algorithm may accept this point, based on the probabilistic ''Metropolis Criteria'', and thus the algorithm can escape from a local minimum. The search proceeds in series of these steps, with the point that gives the overall lowest likelihood score is stored as a ''best point''. The algorithm exits when a stable point is found which cannot be improved on with a small step in any direction, and the Metropolis Criteria rejects all the steps away from the current best point. The best point is then accepted as being the 'solution'.
3667 :    
3668 :     \bigskip
3669 :     The Metropolis Criteria will accept a move in an uphill direction (ie. a point with a worse likelihood score) based on a function of both the size of the move and a parameter termed ''temperature'', and is given in equation~\ref{eq:metropolis} below:
3670 :    
3671 :     \begin{eqnarray}\label{eq:metropolis}
3672 :     M & = & e^{\displaystyle \frac{-\Delta F} {t}} \nonumber \\
3673 :     P & = &
3674 :     \begin{cases}
3675 :     1 & \textrm{if $M$ > $r$} \\
3676 :     0 & \textrm{otherwise}
3677 :     \end{cases}
3678 :     \end{eqnarray}
3679 :    
3680 :     where:\newline
3681 :     $<\Delta F>$ is the change in likelihood score\newline
3682 :     $<$ t $>$ is the ''temperature'' of the algorithm\newline
3683 :     $<$ r $>$ is a random number between 0 and 1
3684 :    
3685 :     \bigskip
3686 :     Note that when the ''temperature'' is very high (t $\rightarrow \infty$), the Metropolis Criteria will always accept any 'uphill' move, and the Simulated Annealing algorithm will simplify to a form of a random search algorithm. Conversely, when the temperature is very low (t $\rightarrow$ 0), the Metropolis Criteria will always reject any 'uphill' move, and the Simulated Annealing algorithm will simplify to a form of a hill-climbing algorithm, similar to Hooke \& Jeeves. By slowly reducing the temperature of the algorithm, the number of uphill moves that are accepted are reduced and the algorithm will find a minimum.
3687 :    
3688 :     \bigskip
3689 :     The terminology for the Simulated Annealing algorithm comes from a metaphor with the thermodynamic process of cooling molten metals. At very high temperatures, the atoms in molten metals move very fast, and slow considerably at lower temperatures. If the metal is cooled slowly (termed ''annealing''), the atoms have time to line up to form a highly ordered, strong, crystalline structure. If the metal is cooled too quickly (''quenching'') the resulting solid will have a weaker, less ordered, structure.
3690 :    
3691 :     \bigskip
3692 :     In comparison to the Hooke \& Jeeves optimisation algorithm, where Hooke \& Jeeves performs a 'local' stepwise search, Simulated Annealing searches much more widely over the surface in order to find the best point. By doing this it is less likely than Hooke \& Jeeves to be fooled by a local minimum, and more likely to home in on the true optimum. However the price to paid for doing this is that it can take considerably more computer time to reach a solution.
3693 :    
3694 :     \bigskip
3695 :     The Simulated Annealing algorithm used in Gadget is derived from that presented by Corana et al, ''Minimising Multimodal Functions of Continuous Variables with the 'Simulated Annealing' Algorithm'' in the September 1987 (Vol. 13, pp. 262-280) issue of the ACM Transactions on Mathematical Software and Goffe et al, ''Global Optimisation of Statistical Functions with Simulated Annealing'' in the January/February 1994 (Vol. 60, pp. 65-100) issue of the Journal of Econometrics.
3696 :    
3697 :     \subsection{File Format}\label{subsec:simannfile}
3698 :     To specify the Simulated Annealing algorithm, the optimisation file should start with the keyword ''[simann]'', followed by (up to) 11 lines giving the parameters for the optimisation algorithm. Any parameters that are not specified in the file are given default values, which work reasonably well for simple Gadget models. The format for this file, and the default values for the optimisation parameters, are shown below:
3699 :    
3700 :     {\small\begin{verbatim}
3701 :     [simann]
3702 :     simanniter 2000 ; number of simulated annealing iterations
3703 :     simanneps 1e-04 ; minimum epsilon, simann halt criteria
3704 :     t 100 ; simulated annealing initial temperature
3705 :     rt 0.85 ; temperature reduction factor
3706 :     nt 2 ; number of loops before temperature adjusted
3707 :     ns 5 ; number of loops before step length adjusted
3708 :     vm 1 ; initial value for the maximum step length
3709 :     cstep 2 ; step length adjustment factor
3710 :     lratio 0.3 ; lower limit for ratio when adjusting step length
3711 :     uratio 0.7 ; upper limit for ratio when adjusting step length
3712 :     check 4 ; number of temperature loops to check
3713 :     \end{verbatim}}
3714 :    
3715 :     \subsection{Parameters}\label{subsec:simannpar}
3716 :     \subsubsection{simanniter}
3717 :     This is the maximum number of Gadget model runs that the Simulated Annealing algorithm will use to try to find the best solution. If this number is exceeded, Gadget will select the best point found so far, and accept this as the 'solution', even though it has not met the convergence criteria. A warning that Gadget has stopped without finding a solution that meets the convergence criteria will be printed.
3718 :    
3719 :     \subsubsection{simanneps}
3720 :     This is the criteria for halting the Simulated Annealing algorithm at a minimum, and accepting the current point as the 'solution'. The algorithm has ''converged'' if the point found at the end of a temperature loop is within simanneps of the best point, and is also within simanneps of the point found at the end of the last 'check' temperature loops. This will mean that during each of the last 'check' temperature loops, the accepted point has moved less than simanneps away from the overall best point, showing that the best point found so far is stable. Lower values for simanneps will give a more stable estimate of the minimum, at the cost of a longer running time. Note that the convergence criteria is only checked at the end of each temperature loop.
3721 :    
3722 :     \subsubsection{t}
3723 :     This is the initial value for the ''temperature'' of the Simulated Annealing algorithm, used to control the speed of the convergence of the algorithm, using the Metropolis Criteria given in equation~\ref{eq:metropolis} above. High values for the temperature (t $\gg \Delta F$) will mean that most of the uphill moves are accepted, and the algorithm will be performing a random search, which is computationally very intensive. Low values for the temperature (t $\ll \Delta F$) will mean that most of the uphill moves are rejected and the algorithm will be performing an inefficient local search.
3724 :    
3725 :     \subsubsection{rt}
3726 :     This is the temperature reduction factor, used to lower the temperature of the algorithm as it moves closer to the minimum. Higher values here will mean that the temperature is reduced slowly, which will mean that the algorithm is will examine the search area more thoroughly, leading to better convergence at a cost of much higher computational time. Lower values of rt will mean that the temperature is reduced quickly, leading to faster convergence, possibly to a local minimum that the algorithm cannot escape from (this is analogous to ''quenching'' in the thermodynamic metaphor). The value of rt must be between 0 and 1.
3727 :    
3728 :     \subsubsection{nt}
3729 :     This is the number of loops that the algorithm will perform before reducing the temperature parameter. Higher values here will mean that the algorithm will explore the current search area more thoroughly, improving the chance of finding a global minimum, at the cost of considerably higher computational time. Conversely, lower values will mean that the current search area is not explored as thoroughly, with a corresponding reduction in computation time. Note that each temperature loop consists of all of the ''ns'' step loops.
3730 :    
3731 :     \subsubsection{ns}
3732 :     This is the number of loops that the algorithm will perform before adjusting the maximum step length parameter. The maximum step length is periodically adjusted so that approximately half of all moves are accepted, since too many, or too few, accepted moves is a waste of computational effort.
3733 :    
3734 :     \bigskip
3735 :     When the algorithm adjusts the maximum step length, the ratio of accepted moves to rejected moves since the last adjustment of the maximum step length is taken into account. If more moves are accepted than rejected, the maximum step length will fall and so the search will focus on the most promising area. However, if more moves are rejected that accepted, the maximum step length will rise so the search area will widen.
3736 :    
3737 :     \subsubsection{vm}
3738 :     This is the initial maximum step length for the Simulated Annealing algorithm. The maximum step length will get adjusted during the optimisation process. Note that each of the steps taken by the Simulated Annealing algorithm are not uniform, and will have a random length of between zero and the maximum step length.
3739 :    
3740 :     \bigskip
3741 :     It is important to note that unlike the Hooke \& Jeeves algorithm, the parameters are not scaled during the optimisation process, and so the maximum step length should be selected so that the initial search area will cover the area of interest. For efficient use of the Simulated Annealing algorithm, it is recommended that the parameters to be estimated are scaled (by the user) so that they are all approximately the same order of magnitude.
3742 :    
3743 :     \subsubsection{cstep, lratio and uratio}
3744 :     These parameters control how the maximum step length for the Simulated Annealing algorithm is adjusted, at the end of each of the ''ns'' step loops. The algorithm keeps track of the number of moves that are accepted and rejected for each direction, and then adjusts the value of the maximum step length for each direction so that the ratio of accepted to rejected moves is approximately 50:50. The maximum step length for each direction is adjusted according to equation~\ref{eq:vm} below:
3745 :    
3746 :     \begin{equation}\label{eq:vm}
3747 :     vm_{i} =
3748 :     \begin{cases}
3749 :     vm_{i} * (1 + \frac{C (R_{i} - U)}{L}) & \textrm{if $R_{i} > U$} \\
3750 :     vm_{i} / (1 + \frac{C (L - R_{i})}{L}) & \textrm{if $R_{i} < L$} \\
3751 :     vm_{i} & \textrm{otherwise}
3752 :     \end{cases}
3753 :     \end{equation}
3754 :    
3755 :     where:\newline
3756 :     $< R_{i} >$ is the ratio of accepted moves for direction i\newline
3757 :     $<$ C $>$ is the value of the ''cstep'' parameter\newline
3758 :     $<$ U $>$ is the value of the ''uratio'' parameter\newline
3759 :     $<$ L $>$ is the value of the ''lratio'' parameter
3760 :    
3761 :     \subsubsection{check}
3762 :     This is the number of temperature loops that the Simulated Annealing algorithm will check to confirm that the current best point that has been found is a stable minimum, so that it can be accepted as a solution.
3763 :    
3764 :     \section{BFGS}\label{sec:bfgs}
3765 :     \subsection{Overview}\label{subsec:bfgsover}
3766 :     BFGS is a quasi-Newton optimisation method that uses information about the gradient of the function at the current point to calculate the best direction to look in to find a better point. Using this information, the BFGS algorithm can iteratively calculate a better approximation to the inverse Hessian matrix, which will lead to a better approximation of the minimum value.
3767 :    
3768 :     \bigskip
3769 :     From an initial starting point, the gradient of the function is calculated and then the algorithm uses this information to calculate the best direction to perform a linesearch for a point that is ''sufficiently better''. The linesearch that is used in Gadget to look for a better point in this direction is the ''Armijo'' linesearch. The algorithm will then adjust the current estimate of the inverse Hessian matrix, and restart from this new point. If a better point cannot be found, then the inverse Hessian matrix is reset and the algorithm restarts from the last accepted point.
3770 :    
3771 :     \bigskip
3772 :     For a point at a stable minimum, the magnitude of the gradient vector will be zero, since there is no direction that the algorithm can move in to find a better local point. However, finding such a point using an iterative process can take an infinite number of steps, so the algorithm exits when the magnitude of the gradient vector is less than a small number. The current point is then accepted as being the 'solution'.
3773 :    
3774 :     \bigskip
3775 :     The ''Armijo'' linesearch calculates the stepsize that is to be used to move to a point that is ''sufficiently better'', along the search direction vector calculated from the gradient, to be $\beta^n$, where n is the first integer that satisfies the Armijo rule given by inequality~\ref{eq:armijo} below:
3776 :    
3777 :     \begin{equation}\label{eq:armijo}
3778 :     f(x) - f(x + \beta^{n}d) \geq - \sigma \beta^{n}d \nabla f(x) ^{T}
3779 :     \end{equation}
3780 :    
3781 :     where:\newline
3782 :     $<\nabla f(x)>$ is the gradient of the function at the current point\newline
3783 :     $<$ d $>$ is the search direction vector
3784 :    
3785 :     \bigskip
3786 :     In comparison to the other optimising algorithms that are currently implemented in Gadget, BFGS performs a local search, and so it doesn't cover the wide search area that the Simulated Annealing algorithm can use to look for an optimum. BFGS will usually take more computer time to find an optimum than the Hooke \& Jeeves algorithm, since numerically calculating the gradient of the function is computationally very intensive. However, the optimum found by the BFGS algorithm will usually be better than that found by the Hooke \& Jeeves algorithm, since a gradient search method is usually more accurate than a stepwise search method.
3787 :    
3788 :     \bigskip
3789 :     The BFGS algorithm used in Gadget is derived from that presented by Dimitri P Bertsekas, ''Nonlinear Programming'' ($2^{nd}$ edition, pp22-61) published by Athena Scientific. The forward difference gradient algorithm used to calculate the gradient is derived from that presented by Dennis and Schnabel, ''Numerical Methods for Unconstrained Optimisation and Nonlinear Equations'' (''Classics'' edition, published by SIAM).
3790 :    
3791 :     \subsection{File Format}\label{subsec:bfgsfile}
3792 :     To specify the BFGS algorithm, the optimisation file should start with the keyword ''[bfgs]'', followed by (up to) 7 lines giving the parameters for the optimisation algorithm. Any parameters that are not specified in the file are given default values, which work reasonably well for simple Gadget models. The format for this file, and the default values for the optimisation parameters, are shown below:
3793 :    
3794 :     {\small\begin{verbatim}
3795 :     [bfgs]
3796 :     bfgsiter 10000 ; number of bfgs iterations
3797 :     bfgseps 0.01 ; minimum epsilon, bfgs halt criteria
3798 :     sigma 0.01 ; armijo convergence criteria
3799 :     beta 0.3 ; armijo adjustment factor
3800 :     gradacc 1e-06 ; initial value for gradient accuracy
3801 :     gradstep 0.5 ; gradient accuracy adjustment factor
3802 :     gradeps 1e-10 ; minimum value for gradient accuracy
3803 :     \end{verbatim}}
3804 :    
3805 :     \subsection{Parameters}\label{subsec:bfgspar}
3806 :     \subsubsection{bfgsiter}
3807 :     This is the maximum number of Gadget model runs that the BFGS algorithm will use to try to find the best solution. If this number is exceeded, Gadget will select the best point found so far, and accept this as the 'solution', even though it has not met the convergence criteria. A warning that Gadget has stopped without finding a solution that meets the convergence criteria will be printed.
3808 :    
3809 :     \subsubsection{bfgseps}
3810 :     This is the criteria for halting the BFGS algorithm at a minimum, and accepting the current point as the 'solution'. The algorithm has ''converged'' if the magnitude of the gradient vector is less than bfgseps. Lower values of bfgseps will give a better estimate of the minimum, at the cost of a considerably increased running time. At the true minimum, the magnitude of the gradient vector will be zero, since there would be no direction for the algorithm to move to, but this point could take an infinite number of iterations to find.
3811 :    
3812 :     \subsubsection{sigma}
3813 :     This is the criteria for stopping the Armijo linesearch at a point that is ''sufficiently better'', and recalculating the gradient of the function at this new point. Lower values of sigma will increase the size of the acceptance region of the Armijo linesearch (by relaxing the condition for the inequality, see equation~\ref{eq:armijo} above), which will mean that the linesearch will stop earlier, leading to larger steps by the BFGS algorithm. Conversely, higher values of sigma will decrease the size of the acceptance region, which will mean that the BFGS algorithm will take smaller steps. The value of sigma must be between 0 and 1, and should be close to zero.
3814 :    
3815 :     \subsubsection{beta}
3816 :     This is the adjustment factor for the Armijo linesearch, used to calculate the size of the step taken by the linesearch to find the next point. Lower values of beta will mean that the size of the step that the algorithm tries to take in the direction of the gradient vector is smaller, but the step is more likely to be in the acceptance region. Conversely, higher values of beta will result in larger steps being tried, but these steps are more likely to be rejected since they may be outside the acceptance region. The value of beta must be between 0 and 1.
3817 :    
3818 :     %\subsubsection{step}
3819 :    
3820 :     \subsubsection{gradacc, gradstep and gradeps}
3821 :     These parameters control the accuracy that is used for the gradient calculations. The gradient of the function is calculated numerically by Gadget using a forward difference algorithm, as shown in equation~\ref{eq:grad} below:
3822 :    
3823 :     \begin{equation}\label{eq:grad}
3824 :     \nabla f(x) \approx \frac{f(x + \delta x) - f(x)} {\delta x}
3825 :     \end{equation}
3826 :    
3827 :     where:\newline
3828 :     $<\delta>$ is the value of the ''gradacc'' parameter
3829 :    
3830 :     \bigskip
3831 :     When the BFGS algorithm is reset (that is, if the Armijo linesearch fails to find a better point) the gradient accuracy parameter is made smaller to increase the level of accuracy that is used in the gradient calculations. This is done by multiplying the gradacc parameter by the gradstep parameter, which is a simple reduction factor (and as such must be between 0 and 1). To prevent the gradacc parameter getting too small, the BFGS algorithm will stop once the value of gradacc is less that the value of gradeps. Both gradacc and gradeps must be between 0 and 1, with gradeps smaller than gradacc, and the gradient calculations are more accurate when the gradacc parameter is very small.
3832 :    
3833 :     \section{Combining Optimisation Algorithms}\label{sec:combine}
3834 :     \subsection{Overview}\label{subsec:combineover}
3835 :     This method attempts to combine the global search of the Simulated Annealing algorithm and the more rapid convergence of the local searches performed by the Hooke \& Jeeves and BFGS algorithms. It relies on the observation that the likelihood function for many Gadget models consists of a large 'valley' in which the best solution lies, surrounded by much more 'rugged' terrain.
3836 :    
3837 :     \bigskip
3838 :     A period of Simulated Annealing at the start of the optimisation run serves to move the search into this valley, at which point the Simulated Annealing algorithm becomes inefficient so the Hooke \& Jeeves algorithm and/or the BFGS algorithm takes over and homes in on a solution within that valley. Hopefully the Simulated Annealing algorithm will have moved the current point to the correct side of any 'hills' to avoid the local searches becoming trapped into an unrealistic local minimum.
3839 :    
3840 :     \subsection{File Format}\label{subsec:combinefile}
3841 :     To specify a combination of optimisation algorithms, the optimisation file should simply list the algorithms that should be used, along with the parameters for each optimisation algorithm. Any parameters that are not specified in the file are given default values, which work reasonably well for simple Gadget models. As an example, the format for this file used to specify all three optimisation algorithms, and the default values for the optimisation parameters, is shown below:
3842 :    
3843 :     {\small\begin{verbatim}
3844 :     [simann]
3845 :     simanniter 2000 ; number of simulated annealing iterations
3846 :     simanneps 1e-04 ; minimum epsilon, simann halt criteria
3847 :     t 100 ; simulated annealing initial temperature
3848 :     rt 0.85 ; temperature reduction factor
3849 :     nt 2 ; number of loops before temperature adjusted
3850 :     ns 5 ; number of loops before step length adjusted
3851 :     vm 1 ; initial value for the maximum step length
3852 :     cstep 2 ; step length adjustment factor
3853 :     lratio 0.3 ; lower limit for ratio when adjusting step length
3854 :     uratio 0.7 ; upper limit for ratio when adjusting step length
3855 :     check 4 ; number of temperature loops to check
3856 :     [hooke]
3857 :     hookeiter 1000 ; number of hooke & jeeves iterations
3858 :     hookeeps 1e-04 ; minimum epsilon, hooke & jeeves halt criteria
3859 :     rho 0.5 ; step length adjustment factor
3860 :     lambda 0 ; initial value for the step length
3861 :     [bfgs]
3862 :     bfgsiter 10000 ; number of bfgs iterations
3863 :     bfgseps 0.01 ; minimum epsilon, bfgs halt criteria
3864 :     sigma 0.01 ; armijo convergence criteria
3865 :     beta 0.3 ; armijo adjustment factor
3866 :     gradacc 1e-06 ; initial value for gradient accuracy
3867 :     gradstep 0.5 ; gradient accuracy adjustment factor
3868 :     gradeps 1e-10 ; minimum value for gradient accuracy
3869 :     \end{verbatim}}
3870 :    
3871 :     It should be noted that the optimisation algorithms will be performed in the order that they are specified in the input file, so for this example the order will be: first Simulated Annealing, second Hooke \& Jeeves and finally BFGS.
3872 :    
3873 :     \subsection{Parameters}\label{subsec:combinepar}
3874 :     The parameters for this combined optimisation algorithm are the same as for the individual algorithms, and are described in sections \ref{subsec:hookepar} (for the Hooke \& Jeeves parameters), \ref{subsec:simannpar} (for the Simulated Annealing parameters) and \ref{subsec:bfgspar} (for the BFGS parameters).
3875 :    
3876 :     \section{Repeatability}\label{sec:repeat}
3877 :     The optimisation algorithms used by Gadget contain a random number generator, used to randomise the order of the parameters (to ensure that the order of the parameters has no effect on the optimum found) and to generate the initial direction chosen by the algorithm to look for a solution. For the Simulated Annealing algorithm, this is also affects the Metropolis criteria used to accept any changes in an 'uphill' direction.
3878 :    
3879 :     \bigskip
3880 :     The use of a random number generator means that it is unlikely that two optimising runs will produce exactly the same 'optimum', even if they start from the same point (although it is hoped that the optima would be very similar if a stable starting point was chosen). This causes a problem with repeatability, since there is no guarantee that an optimising run can be repeated. However, it is possible to 'seed' the random number generator with an integer to avoid this problem. To specify a seed for the random number generator, an extra line must be added to the optimisation file, as shown below:
3881 :    
3882 :     {\small\begin{verbatim}
3883 :     seed n ; seed the random number generator with n
3884 :     \end{verbatim}}
3885 :    
3886 :     It is also possible to specify the value that is used to seed the random number generator from the command line, by starting Gadget with the ''-seed <number>'' switch. It should be noted that any value for the seed that is specified in the optimisation file will override the value that is specified as a command line option.
3887 :    
3888 :     \chapter{Output Files}\label{chap:output}
3889 :     The model output files contain information about the optimisation process (and not information about the stocks in the model - see the section on the Print Files, section~\ref{chap:print}, for information on these). The output files are specified by some of the commandline parameters used to start Gadget. There are three types of output file.
3890 :    
3891 :     \section{Parameter Output}\label{sec:paramoutput}
3892 :     The parameter output file is automatically generated by Gadget every time that Gadget is run. If Gadget is not started with the ''-p $<$filename$>$'' option, this file will be called ''params.out''. This file contains information about the values of the switches at the end of the Gadget run, in the same format as for the column output file. In the header of this file there will be information about the Gadget run, followed by the final overall likelihood score and the total number of iterations. There is then the information about the switches used in the Gadget run - the name, value, lower bound, upper bound and whether the switch is to be optimised.
3893 :    
3894 :     \bigskip
3895 :     This file is written in the same format as the parameter input file, and it can be used as the starting point for a subsequent Gadget run.
3896 :    
3897 :     \section{Likelihood Output}\label{sec:likelihoodoutput}
3898 :     The likelihood output file is generated when Gadget is started with the ''-o $<$filename$>$'' option, and the output is written to the file specified after that option, so, for example, this would write the output to a file called ''likelihood.txt'':
3899 :    
3900 :     {\small\begin{verbatim}
3901 :     gadget -l -o likelihood.txt
3902 :     \end{verbatim}}
3903 :    
3904 :     The likelihood output file is split into three sections, separated by a line containing a brief comment. The first section lists the names of the switches used in the model, together with some information about where that switch is used.
3905 :    
3906 :     \bigskip
3907 :     The second part of the likelihood output file contains information about the likelihood components used in the optimisation of the model. The names of the components are listed, along with an identifier to the type and the weight assigned to the component.
3908 :    
3909 :     \bigskip
3910 :     The final part of the likelihood output file contains the output from the optimisation process. There is a single line for each iteration of the optimisation, containing the iteration number followed by a tab character, then the value of each switch, followed by a gap (2 tab characters), followed by the value of each of the likelihood components, followed by another gap (again, 2 tab characters) followed by the overall likelihood score for that iteration.
3911 :    
3912 :     \bigskip
3913 :     For a long optimisation run, this can result in this file being quite large. The default option is for this line to be written for each iteration, but this can be changed using the ''-print $<$number$>$'' option, which will only write out this line every $<$number$>$ iterations, as shown in the example below:
3914 :    
3915 :     {\small\begin{verbatim}
3916 :     gadget -l -o likelihood.txt -print 10
3917 :     \end{verbatim}}
3918 :    
3919 :     which will set Gadget to write this information, to the file ''likelihood.txt'', after every 10th iteration.
3920 :    
3921 :     \section{Log Output}\label{sec:logoutput}
3922 :     The log output file is generated when Gadget is started with the ''-log $<$filename$>$'' option, and the output is written to the file specified after that option, so, for example, this would write the output to a file called ''gadget.log'':
3923 :    
3924 :     {\small\begin{verbatim}
3925 :     gadget -log gadget.log
3926 :     \end{verbatim}}
3927 :    
3928 :     The log file contains a listing of the actions that Gadget is performing, as those actions are being performed - an entry can be made whenever data is read from a file, or a likelihood score is calculated, for example. The log file is of most use when initially setting up and debugging a Gadget model, since it makes it easy to trace what Gadget is doing, so, for example, the details of the last actions that were performed before displayed a warning message are recorded.
3929 :    
3930 :     \bigskip
3931 :     This log file that is generated can be a large file if Gadget is performing an optimising run. It is possible to control the amount of information that is written to the log file using the ''-loglevel $<$number$>$'' command line option. The valid values for the loglevel number, and the associated meanings, are given in the list below:
3932 :    
3933 :     \bigskip
3934 :     \begin{tabular}{cl}
3935 :     {\bf loglevel} & {\bf meaning} \\
3936 :     0 & no output, only used in conjunction with the Paramin optimiser \\
3937 :     1 & output informational messages only (cannot be set from the command line) \\
3938 :     2 & also output error messages (default value for an optimising run) \\
3939 :     3 & also output warning messages (default value for a simulation run) \\
3940 :     4 & also output debug messages (only useful when debugging Gadget code) \\
3941 :     5 & also output detailed messages (default value if a log file is specified) \\
3942 :     \end{tabular}
3943 :    
3944 :     \bigskip
3945 :     Examples of valid loglevel values include:
3946 :    
3947 :     \begin{enumerate}
3948 :     \item specifying a log file (called ''gadget.log'') for an optimising run that only includes informational and error messages (and not the more detailed messages that would be written to the log file by default)
3949 :     {\small\begin{verbatim}
3950 :     gadget -l -log gadget.log -loglevel 2
3951 :     \end{verbatim}}
3952 :     \item specifying a log file for a simulation run that includes error and warning messages (note that it is not possible to disable the warning messages during a simulation run)
3953 :     {\small\begin{verbatim}
3954 :     gadget -s -log gadget.log -loglevel 3
3955 :     \end{verbatim}}
3956 :     \end{enumerate}
3957 :    
3958 :     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3959 :     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Paramin chapter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3960 :     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Edited by GuĂ°mundur Einarsson %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3961 :     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Summer 2012 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3962 :     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3963 :    
3964 :     \chapter{Paramin}\label{chap:paramin}
3965 :     This chapter describes how to run Gadget with paramin which runs the optimization routines in parallel. The current version of paramin is implemented with MPI, Message passing interface, which handles all the message passing between the master process, paramin, and the slave processes, Gadget instances. The setup is very similar to a normal Gadget run, all the Gadget input files are the same, it's only the execution which differs.
3966 :    
3967 :     \section{Installation}\label{sec:paramininstall}
3968 :     In order to begin one must first download and install a version of MPI. This version of paramin is made with an implementation of MPI-2 called
3969 :     OPEN-MPI, one can download the MPI library and a wrapper compiler called mpic++ from their website www.open-mpi.org. Now before trying to run paramin
3970 :     make sure you have the newest version of Gadget downloaded. Now open the Makefile with your favorite text-editor and uncomment the section referring
3971 :     to a Gadget Network version and comment out the lines which refer to an install without MPI. Now you should open a console window and navigate to the
3972 :     folder where you saved Gadget. Make sure you have the make utility installed, to check if so you can write the following in the console:
3973 :    
3974 :     {\small\begin{verbatim}
3975 :     which make
3976 :     \end{verbatim}}
3977 :     If it is installed the console should prompt you with something similar to the following
3978 :    
3979 :     {\small\begin{verbatim}
3980 :     /usr/bin/make
3981 :     \end{verbatim}}
3982 :    
3983 :     Which is the path to the executable, if the console outputs
3984 :     {\small\begin{verbatim}
3985 :     make: Command not found.
3986 :     \end{verbatim}}
3987 :    
3988 :     The make utility is either not installed or the executable is not found in the PATH global variable, note that make comes with almost all modern UNIX
3989 :     systems. Now you can simply type make in the console and the program should be compiled and you get an executable, let's assume it's called gadget-PARA. Now
3990 :     paramin is dependent on some Gadget objects, so you now need to type the following in the console:
3991 :    
3992 :     {\small\begin{verbatim}
3993 :     make libgadgetinput.a
3994 :     \end{verbatim}}
3995 :    
3996 :     Now you are ready to start compiling paramin. Download the newest version of paramin and open the paramin folder in the console. You need to edit the
3997 :     Makefile and add the path to the directory where you installed Gadget as described above. Now you can run the make command to compile paramin and get
3998 :     an executable, let's assume it's called paramin.
3999 :    
4000 :     \section{Running paramin}\label{sec:runparamin}
4001 :     To be able to run paramin it's ideal to add the path of the two executables, gadget-PARA and paramin to the global variable PATH. If you're running
4002 :     a bash console you can edit the \texttt{.bashrc} to add it, you can also copy the executables to the directory of PATH, but you probably need root
4003 :     access to do that. Now you can call the functions from the console. Here is an example of a typical paramin run:
4004 :    
4005 :     {\small\begin{verbatim}
4006 :     mpirun paramin -i <filename> -opt <filename> -network <filename>
4007 :     -o <filename> -function gadget-PARA -s -n -i <filename> > <filename>
4008 :     \end{verbatim}}
4009 :    
4010 :     Now because paramin is implemented with MPI we need to call mpirun when we run it. Now there are several files we need to call and a few switches
4011 :     we need. The \texttt{-i <filename>} switch tells paramin which file holds the parameters and their initial values, this file is the same as the
4012 :     params.in file used in Gadget (see Parameter Files, chapter~\ref{chap:param}, for more information on the format of this file). The
4013 :     \texttt{-i} switch with the same \texttt{<filename>} has to be on Gadget as well.
4014 :     \\
4015 :     \\
4016 :     Next we need to specify the
4017 :     optimization parameters with the \texttt{-opt <filename>} switch, the preceding file contains the information of which type of optimization run to
4018 :     perform for more information see Parameter Files, chapter~\ref{chap:param}, it's the same format as the optimization file for Gadget.
4019 :     \\
4020 :     \\
4021 :     The next switch tells paramin how many subprocesses paramin will spawn, this switch is not in Gadget. Note that having at least 8 subprocesses will
4022 :     greatly improve the time of the run, but there is no need to let the number of subprocesses exceed the number of parameters, optimally it should be
4023 :     best to have as many subprocesses as the number of parameters, but then one should have access to at least that many processing cores.
4024 :     A sample file which tells paramin
4025 :     to spawn 30 subprocesses looks like this:
4026 :    
4027 :     {\small\begin{verbatim}
4028 :     ;
4029 :     ;Sample network file
4030 :     ;
4031 :     numproc 30
4032 :     \end{verbatim}}
4033 :    
4034 :     The \texttt{-o <filename>} switch specifies which file to output the optimized parameters. This file will also contain information about the optimization
4035 :     run, how much overall time was taken and how much time was taken for each optimizing algorithm. The format of this outputted file is the same
4036 :     as the one used as input, so the output can be used as a starting point for later runs.\\
4037 :     \\
4038 :     The \texttt{-function gadget-PARA} -switch tells paramin the name of the executable it will spawn as it's subprocess, in this case it's the gadget-PARA
4039 :     executable
4040 :     we made earlier. The user can also make his own function to optimize with paramin. Now Gadget also needs parameters, we pass to it the \texttt{-s} and
4041 :     \texttt{-n} switch to make it go to network mode, then Gadget knows it's running with paramin. Finally we can add \texttt{> <filename>} to specify
4042 :     a file for the output of the run, this is not necessary but recommended.
4043 :     \subsection{Additional information}
4044 :     If you're running a potentially very long run on a remote host it's
4045 :     recommended to use the \texttt{screen} utility, for more information type \texttt{man screen} in the console. It allows you to detach the session
4046 :     so it lives after you log out of your SSH session. In short you can type \texttt{screen} at the console to open a new screen session. Now run the
4047 :     script or program you want to run and type \texttt{ctrl-a d}, and you detach the session. Now you can safely exit from the remote host. To retrieve
4048 :     your session on your next login simply type \texttt{screen -r} and you enter the screen session, then you can close it by typing \texttt{exit} in
4049 :     the console. Another option is to run the desired command with the \texttt{nohup} prefix, it makes the command immune to hangups.\\
4050 :     \\
4051 :     As stated earlier paramin can be used to optimize almost any function which can be defined within the C++ language. The rosenbrock function
4052 :     is oftenly used to test nonlinear optimization algorithms because it's quite challenging for methods which do not rely on the gradient of the function.
4053 :     A sample rosenbrock function and instruction on how to compile and run it should be available on the MRI website under paramin. This function
4054 :     can be used as a template for the optimization of any function definable in the C++ language, future work will be to add a parser and an R interface,
4055 :     so paramin can be called from within an R session using an R defined function.\\
4056 :     \\
4057 :     Paramin was originally written with PVM, but since PVM is no longer supported it was migrated to MPI.
4058 :     More information on the migration process from PVM to MPI can be found on the MRI website, there one can also find study on the improvement in time
4059 :     relative to the number of processes spawned for each optimization routine.
4060 :     \subsection{Running paramin on multiple hosts/cluster}
4061 :     As stated above when we run paramin in the console it has to be invoked with the \texttt{mpirun} command. The \texttt{mpirun} command can take
4062 :     some optional arguments. First of all it can take the argument \texttt{-np <numproc>} where numproc is the desired number of processes one wants to
4063 :     start. This argument is \textbf{not} necessary with paramin because we define the number of subprocesses in the network file and paramin spawns them
4064 :     dynamically. The next optional argument we will discuss is the $-$$-$\texttt{hostfile <filename>}. \texttt{<filename>} is a name of a file which holds
4065 :     the name of the hosts in the cluster and how many processors are available on each node. The authentication in the execution process is done via
4066 :     ssh, so public keys have to be shared to allow for remote login and execution between hosts. The programs desired to run in parallel have to be
4067 :     installed on each host for this to work. For more information see the FAQ entries on the OPEN-MPI webpage, there are more things that need to be taken
4068 :     into consideration. Here is an example hostfile from the open-mpi FAQ:
4069 :    
4070 :     {\small\begin{verbatim}
4071 :     # This is an example hostfile. Comments begin with #
4072 :     #
4073 :     # The following node is a single processor machine:
4074 :     comp1
4075 :    
4076 :     # The following node is a dual-processor machine:
4077 :     comp2.dualcore slots=2
4078 :    
4079 :     # The following node is a quad-processor machine, and we absolutely
4080 :     # want to disallow over-subscribing it:
4081 :     comp3.quadcore slots=4 max-slots=4
4082 :     \end{verbatim}}
4083 :    
4084 :     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4085 :     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End of Paramin chapter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4086 :     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4087 :    
4088 :     \chapter{References}\label{chap:reference}
4089 :     Anon. 2002. Development of Structurally Detailed Statistically Testable Models of Marine Populations (dst$^{2}$). QLK5-CT1999-01609. Progress Report for 1 January to 31 December 2001. Marine Research Institute Report No. 87, Marine Research Institute, Reykjavik, Iceland.\newline
4090 :    
4091 :     Anon. 2003. Development of Structurally Detailed Statistically Testable Models of Marine Populations (dst$^{2}$). QLK5-CT1999-01609. Progress Report for 1 January to 31 December 2002. Marine Research Institute Report No. 98, Marine Research Institute, Reykjavik, Iceland.\newline
4092 :    
4093 :     Bertsekas, D.P. 1999. Nonlinear Programming. Athena Scientific $2^{nd}$ edition, pp22-61.\newline
4094 :    
4095 :     Bogstad, B., Hiis Hauge, K., and Ulltang, {\O}. 1997. MULTSPEC - A Multispecies Model for Fish and Marine Mammals in the Barents Sea. Journal of Northwest Atlantic Fisheries Science. vol 22: pp317-341.\newline
4096 :    
4097 :     Bogstad, B., Tjelmeland, S., Tjelta, T. and Ulltang, {\O}. 1992. Description of a Multispecies Model for the Barents Sea (MULTSPEC) and a Study of its Sensitivity to Assumptions on Food Preferences and Stock Sizes of Minke Whales and Harp Seals. Institute of Marine Research Technical Report SC/44/O 9, Institute of Marine Research, Bergen, Norway.\newline
4098 :    
4099 :     Dennis, J.E., and Schnabel, R.B. 1996. Numerical Methods for Unconstrained Optimisation and Nonlinear Equations. SIAM ''Classics'' edition.\newline
4100 :    
4101 :     Corana, A., Marchesi, M., Martini, C., and Ridella, S. 1987, Minimising Multimodal Functions of Continuous Variables with the 'Simulated Annealing' Algorithm. ACM Transactions on Mathematical Software vol 13: pp262-280.\newline
4102 :    
4103 :     Fr{\o}ysa, K.G., Bogstad, B., and Skagen, D.W. 2002. Fleksibest - an Age-Length Structured Fish Stock Assessment Tool with Application to Northeast Arctic Cod (Gadus morhua L.). Fisheries Research vol 55: pp87-101.\newline
4104 :    
4105 :     Goffe, W.L., Ferrier, G.D., and Rogers, J. 1994. Global Optimisation of Statistical Functions with Simulated Annealing Journal of Econometrics. vol. 60: pp65-100.\newline
4106 :    
4107 :     Hooke, R., and Jeeves, T.A. 1961. Direct Search Solution of Numerical and Statistical Problems. ACM Journal. vol 8: pp212-229.\newline
4108 :    
4109 :     Jones, R., and Johnston, C. 1977. Growth, Reproduction and Mortality in Gadoid Fish Species. Fisheries Mathematics, Academic Press, pp37-62.\newline
4110 :    
4111 :     Kaupe, A.F. 1963. Algorithm 178: Direct Search. ACM Communications. vol 6: pp313-314.\newline
4112 :    
4113 :     Stef\'{a}nsson, G., and P\'{a}lsson, \'{O}.K. 1997. BORMICON. A Boreal Migration and Consumption Model. Marine Research Institute Report 58, Marine Research Institute, Reykjavik, Iceland.\newline
4114 :    
4115 :     Tjelmeland, S., and Bogstad, B. 1998. MULTSPEC - A Review of a Multi-Species Modelling Project for the Barents Sea. Fisheries Research vol 37: pp127-142.\newline
4116 :    
4117 :     \appendix
4118 :     \chapter{Order of Calculations}\label{chap:order}
4119 :     It is important to understand the order that Gadget performs the calculations, since this could have an effect on the way the user might structure the model. For each timestep of the simulation, the order of the calculations is:
4120 :    
4121 :     \begin{enumerate}
4122 :     \item {\bf printing}. \textit{Optional} printing of the model information at the beginning of the timestep, before any calculations have taken place for this timestep. Note that the default printing takes places towards the end of the timestep.
4123 :     \item {\bf migration}. Move the stocks around between the areas in the model, using migration matrices as described in section~\ref{sec:stockmigrate}.
4124 :     \item {\bf consumption}. Calculate the predation by, and consumption of, the stocks in the model. Since a predator can consume more than one prey, and a prey can be consumed by more than one predator, the consumption calculations take place in 4 stages:
4125 :     \begin{enumerate}
4126 :     \item calculate the amount that each predator wants to consume of each prey, assuming that there is enough prey to meet these demands.
4127 :     \item check that each prey is not ''over consumed'', to ensure that no more than 95\% of the available prey biomass is consumed on a single timestep.
4128 :     \item adjust the consumption of the predators to avoid overconsumption of the preys.
4129 :     \item reduce the population of the preys according to the adjusted amount that the predators consumed.
4130 :     \end{enumerate}
4131 :     Note that the consumption calculations include the ''consumption'' of the stocks by any fleets in the model.
4132 :     \item {\bf natural mortality}. Reduce the population of the stocks in the model by removing a proportion due to natural mortality.
4133 :     \item {\bf growth}. Calculate any increase in length and weight of the stocks, and move any fish that will become mature (see section~\ref{sec:stockmature}) into temporary storage.
4134 :     \item {\bf spawning}. Calculate the affect that spawning will have on the adult stocks, and place any spawned stock into temporary storage.
4135 :     \item {\bf maturation}. Add the newly matured fish (calculated as part of the growth update) into the model. Note that this comes after the mature fish have spawned, which means that a fish cannot become mature and spawn in the same timestep.
4136 :     \item {\bf recruitment}. Add any new recruits to the model, including both the recruits specified directly and the recruits specified as part of the spawning process. Note that this comes after the consumption calculations, so that new recruits cannot be consumed on the same timestep as they have been added into the model.
4137 :     \item {\bf straying}. Move fish between stocks in the model that are straying, as described in section~\ref{sec:stockstray}.
4138 :     \item {\bf likelihood comparison}. Calculate the likelihood score for each of the individual likelihood components. Note that most of the likelihood components use data that is based on the catch by a fleet, which has been calculated as part of the consumption process.
4139 :     \item {\bf printing}. Default printing of the model information at the end of the timestep, after the calculations have taken place for this timestep.
4140 :     \item {\bf ageing}. If this is the last timestep of the year, increase the age of the fish in the model. As part of this process, the oldest age group (the plus group) can move to another stock (see section~\ref{sec:stockmove}).
4141 :     \end{enumerate}
4142 :    
4143 :     \chapter{Recent Changes}\label{chap:change}
4144 :     A version of this user guide was printed and published as a Marine Research Institute report, available from the MRI, Reykjavik (Hafranns\'{o}knastofnunin Fj\"{o}lrit nr. 120). That published version of the user guide described the input file formats for Gadget version 2.1.00. Since the publication of that report, a number of changes to the Gadget software have been implemented, to fix any bugs that have been found and to add new features. Some of these changes have resulted in small changes to the format of the input files, and these user visible changes are summarised below.
4145 :    
4146 :     \section{Gadget version 2.1.01}\label{sec:v2101}
4147 :     \begin{itemize}
4148 :     \item removed the need to specify the lengths of the fleets (see section~\ref{chap:fleet})
4149 :     \item added new suitability functions, the Richards suitability function and the Gamma suitability function (see section~\ref{sec:suitability})
4150 :     \item added a fleet that uses catch in numbers data (see section~\ref{sec:numberfleet})
4151 :     \item added an ''energycontent'' section for the preys (see section~\ref{sec:stockprey} and section~\ref{chap:other})
4152 :     \end{itemize}
4153 :    
4154 :     \section{Gadget version 2.1.02}\label{sec:v2102}
4155 :     \begin{itemize}
4156 :     \item simplified the format for the migration data (see section~\ref{sec:stockmigrate})
4157 :     \item added prey preference parameters to allow for a Type III functional response when one stock is consuming another (see section~\ref{sec:consumption})
4158 :     \end{itemize}
4159 :    
4160 :     \section{Gadget version 2.1.03}\label{sec:v2103}
4161 :     \begin{itemize}
4162 :     \item changed the otherfood file format to specify the biomass of otherfood available, rather than the density of the otherfood (see section~\ref{sec:foodamounts})
4163 :     \item added a fleet that extends the LinearFleet to take the different catchability of the various stocks into account (see section~\ref{sec:effortfleet})
4164 :     \item added the StockPreyPrinter to the list of available printer classes (see section~\ref{sec:stockpreyprinter})
4165 :     \item added the PredatorPreyPrinter to the list of available printer classes (see section~\ref{sec:predatorpreyprinter}) to replace the old PredPreyStdAgePrinter and PredPreyStdLengthPrinter printer classes, which are no longer supported
4166 :     \end{itemize}
4167 :    
4168 :     \section{Gadget version 2.1.04}\label{sec:v2104}
4169 :     \begin{itemize}
4170 :     \item removed the need to specify the areas, predators or timesteps when calculating the score for the Understocking likelihood component (see section~\ref{sec:understocking})
4171 :     \end{itemize}
4172 :    
4173 :     \section{Gadget version 2.1.05}\label{sec:v2105}
4174 :     \begin{itemize}
4175 :     \item added a fleet that implements a simple harvest control rule (see section~\ref{sec:quotafleet})
4176 :     \item added a survey index likelihood component that can use an index based on acoustic data (see section~\ref{subsec:sibyacoustic})
4177 :     \item added a survey index likelihood component that can use an index based on effort data (see section~\ref{subsec:sibyeffort})
4178 :     \item removed the need to specify the timesteps for the LikelihoodPrinter printer class, since the output is generated on the timesteps that the likelihood components have data for (see section~\ref{sec:likelihoodprinter})
4179 :     \item changed the ''half feeding value'' format to specify the biomass of the prey, rather than the density of the prey (see section~\ref{sec:consumption})
4180 :     \end{itemize}
4181 :    
4182 :     \section{Gadget version 2.1.06}\label{sec:v2106}
4183 :     \begin{itemize}
4184 :     \item this version only contains bug fixes, so there are no changes to the format of the input files
4185 :     \end{itemize}
4186 :    
4187 :     \end{document}

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge