# 15 Order of Calculations

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:

1. printing. 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.

2. migration. Move the stocks around between the areas in the model, using migration matrices as described in section 4.9.

3. 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:

1. calculate the amount that each predator wants to consume of each prey, assuming that there is enough prey to meet these demands.

2. 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.

3. adjust the consumption of the predators to avoid overconsumption of the preys.

4. reduce the population of the preys according to the adjusted amount that the predators consumed.

Note that the consumption calculations include the “consumption” of the stocks by any fleets in the model.

4. natural mortality. Reduce the population of the stocks in the model by removing a proportion due to natural mortality (see section 4.5).

5. growth. Calculate any increase in length and weight of the stocks (see section 4.3), and move any fish that will become mature (see section 4.10) into temporary storage.

6. spawning. Calculate the affect that spawning will have on the adult stocks, and place any spawned stock into temporary storage (see section 4.13).

7. 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 (see section 4.10).

8. recruitment. Add any new recruits to the model, including both the recruits specified directly (see section 4.12) and the recruits specified as part of the spawning process (see section 4.13). 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.

9. straying. Move fish between stocks in the model that are straying, as described in section 4.15.

10. 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.

11. printing. Default printing of the model information at the end of the timestep, after the calculations have taken place for this timestep.

12. ageing. Increases the age of the fish in the model, optionally moving/transitioning the oldest fish to a different stock (see section 4.11). This process takes place in 3 stages:

1. If it’s a transition step, set aside transitioning fish.

2. If it’s the stock’s birthday (hard-coded to the final step of the year), then increase the age of all fish.

3. Increase the age of any transitioning fish, and move into their new stocks.