# 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:

**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.**migration**. Move the stocks around between the areas in the model, using migration matrices as described in section 4.11.**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:calculate the amount that each predator wants to consume of each prey, assuming that there is enough prey to meet these demands.

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.

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

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.

**natural mortality**. Reduce the population of the stocks in the model by removing a proportion due to natural mortality (see section 4.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.12) into temporary storage.**spawning**. Calculate the affect that spawning will have on the adult stocks, and place any spawned stock into temporary storage (see section 4.15).**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.12).**recruitment**. Add any new recruits to the model, including both the recruits specified directly (see section 4.14) and the recruits specified as part of the spawning process (see section 4.15). 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.**straying**. Move fish between stocks in the model that are straying, as described in section 4.17.**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.**printing**. Default printing of the model information at the end of the timestep, after the calculations have taken place for this timestep.**ageing**. Increases the age of the fish in the model, optionally moving/transitioning the oldest fish to a different stock (see section 4.13). This process takes place in 3 stages:If it’s a transition step, set aside transitioning fish.

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

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