Allowing random variability in your simulation
Some rare events on the farm have large impacts. The occurrence of such events is critical to understanding long term farming outcomes and risk. Examples of such events include a wildfire burning your pasture, the death of an important animal such as a breeding sire or draught animal, a severe drought, or even a piece of equipment breaking down due to lack of maintenance. The likelihood of these events happening may change as a result of the activities performed on the farm and therefore the available resources such as labour and finances.
Random process may also occur in a more subtle way in your simulation and, while not as catastrophic, may still explain important variation in the system (see the description of the individual based ruminant model in the current sources of variation section below for full details). The process of modelling your farming system involves describing the state of the farm and all the mathematical equations used to describe processes. Some equations have parameters that describe a probability or the chance that something might happen. An example of this is the probability of conceiving twins, it doesn't happen all the time, but some conceptions result in multiple births and should be considered in our simulations. A single simulation of the farm is therefore just that, one realisation of the likely outcomes predicted by the model. While this is useful for understanding management decisions, a model that can explain the likely variability in outcomes is a more valuable tool.
CLEM provides functionality to consider variable processes through the use of random numbers that are applied to particular calculations to determine the model outcome. If two runs of the model uses the same set of random numbers, they will both produce the same realisation of the system. However, if different random numbers are used for each run of the simulation model, each run effectively provides a different realisation based on the stochastic decisions that needed to be made. Running sufficient random simulations provides the expected variability and risk of extreme or unexpected outcomes in the farming system.

The random number sequence used is calculated by the computer (it's actually a pseudo-random sequence, but this detail is not important here) and is based on a seed or value to start the calculations. If the same seed is used between runs, the outcome will be identical as the same sequence of random numbers will be applied. If however, two runs use different seeds, the outcome will be different due to different sequences of numbers being used. A way to ensure each run is different, and not having to change the seed each time, is to use the current time the simulation is performed (or another or another random number if two simulations could be performed at the same time) as the seed. This seed is defined in the properties of Random number generator placed below the Simulation component. An error will be raised if your simulation requires random numbers and this component has not been supplied.

At present, the majority of random variation in CLEM is applied to the Managing ruminants model, but future activities can have this variability added as needed.

The decision to use an individual based ruminant model allows for a whole range of novel questions to be answered by CLEM that relate to the natural variation in the herd. But to achieve this we had to move away from the deterministic approach to modelling populations where you can have a proportion of an individual (e.g. 3.6 female calves) and accurately track each individual. The individual-based approach means you can't have less than one individual and so we needed to apply a stochastic approach to simulate many decisions in the herd, thus introducing random variability into CLEM.

Imagine we have 9 individuals in our herd and an annual mortality rate of 50%. In a deterministic model we would multiply the 9 individuals by 0.5 and end up with 4.5 individuals in the next time-step. With an individual-based model we can't have half an individual so need to apply a different approach. To achieve this CLEM applies the probability of dying (0.5) to each individual in the herd as a binary decision of whether an individual survives or dies. To do this we use the next random number in the sequence (as a value between 0 and 1) and if less than or equal to 0.5 (mortality) the individual is considered to die, and if >0.5 (survival) the individual lives.
Therefore, the outcomes of this annual mortality calculation is based on probability and the random sequence of numbers used which could result in any combination of all surviving to all dying, or anything in between, but the random numbers dictate the likelihood of each outcome with most of the time 4 or 5 individuals would die, but the rare events are also possible some of the time, just like a game of chance with cards or die.

The process of simulating breeding in the ruminant model also includes a range of probabilities that need to be applied to a subset of the herd. These determine the likelihood of a female breeder conceiving, carrying twins, losing offspring during pregnancy and even the sex ratio of offspring.

One way to add variability to the initial set up of the simulation is to apply a spread of initial weights to the individuals in a cohort (same age and sex). This ensures that all the individuals can respond differently to processes that depend on weight such as conception rather than acting as an identical group. This in turn starts to provide variability in birth months etc. This is achieved by randomly selecting the weight to assign from a normally distributed population around the mean (weight specified) with a specified standard deviation such that 99% of all individuals will be within 3 standard deviations above and below the mean.

The amount of rainfall both in volume and seasonal distribution is critical to crop and pasture growth. While CLEM currently uses the output form other models, it could be that each simulation of CLEM used the outcomes of a different rainfall sequence to indicate the likely carry-on effects to the herd and farm outcomes.
This is now partially achieved with the Rainfall shuffler

It may be that particular tasks need to select a number of individuals from the herd with no means of deciding which individuals. For example a lack of labour may mean that only 75% of a group of individuals can be moved to pasture. We could just select the first 75% of the group or we could apply a 75% chance to each individual until the desired group was selected. This is achieved by using Sort randomise and Take from filtered components in the Ruminant group used to identify the individuals
See next section - Running a simulation