Breed for milking timer
CLEM.Timers.ActivityTimerBreedForMilking
Manages the timing of and the individuals offered to breeding to maintain continuous milk production.
This component is currently in development. Please report any issues to the developers.

A timer is used to determine whether a component (usually an Activity) can perform its task in the current time-step (see Using timers). While timers are usually associated with the clock, or the state of a resource, this "smart" timer contains logic to determine when breeding should occur in order to maintain continuous milk production from the breeders available and the herd status. It uses the properties of the parent Controlled mating and Breed ruminants components as well as the breed parameters of the breed associated with the Breed activity.
The logic is designed to be dynamic over time accounting for losses of breeders and failed pregnancies.

The following parameters are used to define this activity

Females can be rested after lactation to allow for recovery of condition prior to the next mating. This specifies the number of time steps (months) to rest.
>= 0
This currently assumes the full lactation period is reached. There is no ability for resting during the last stages of lactation (e.g. cease lactation) if milking stops (i.e. lactation will continue in the absence of milking and suckling).

As milk production declines in the later stages of lactation, you may need to shorten the lactation period and get the female back in calf for the next milking opportunity. This parameter specifies how many months short of the full lactation period the breeder can be mated.
>= 0
The female will continue lactating until conception is successful or the full lactation period is reached. Additional logic will be added to cease lactation if milking stops and there is no suckling calf so resting and shortened lactation can be simulated.

This section provides details of how the continuous breeding is performed.

At the start if the simulation this component will get the number of months of milk production from the breed parameters of the breed associated with the parent (grandparent) Breed ruminants which may be modified by the Shorten lactation parameter. The minimum conception interval is calculated the previous value, Gestation length and Rest months. From this value we can determine the number of milkings (lactations) needed to cover the conception interval (MilkingsPerConceptionCycle). We also calculate the end of gestation cycle offset (StartBreedCycleGestationOffsett) that determines when the next breeding cycle commences from currently pregnant breeders.

This component subscribes to the CLEMDoCutAndCarry clock event each month (see Events) to perform calculations to determine if breeding is needed. While not specifically associated with this activity the timing of CLEMDoCutAndCarry ensures that all calculations are performed before the important CLEMAnimalBreeding event.
A list of all breeders in the herd is provided which is then reduced to only those less than the maximum breeding age (respected by controlled mating) and if no individuals are found the timer returns false and no controlled mating is (can be) performed. The maximum number possible for each breeding cycle (MaximumBreedersPerCycle) is then calculated from the number of breeder and MilkingsPerConceptionCycle.
Those breeders currently lactating are next found and if they exist, decisions can be made about the cycle and timing of next conception. If the StartBreedCycleGestationOffsett is positive (starts after birth), this means there is a period immediately after birth where there cannot be any individuals mated, or the next cycle will not commence at the correct time. If individuals are inside this zone, no breeding occurs.
Next, the individuals currently pregnant are found. This group gives us further insight into the state of the breeding/lactation cycle. We can estimate the number of lactation cycles expected within the breed gestation length
This value is the ration of lactation length to gestation length. A value less than 1 means there are multiple breeding windows during the gestation period to ensure continuous milk production.
Next, those pregnant within the first lactation cycle of gestation are found. It is only this pool of individuals that can be added to via breeding to influence future lactation. This group can be increased up to MaximumBreedersPerCycle. For this calculation we require an additional user defined property BreedingSpreadMonths that defines how spread out conceptions can be across this window, or how clumped the births and lactation should be. A value of one will ensure all births are in the same month, but may also limit the ability to breed the maximum number required.
These calculation allow us to determine the number needed. This number of individuals are taken from the list of those able to breed this time step and offered to the Controlled mating activity to proceed with mating.
This process is designed to handle the scope of scenarios with respect to the conception and lactation status of the herd, the number needed and the lactation cycle to either enable or disable this timer and restrict the performing of the controlled mating component.

The following status values apply to this activity and are shown in Activities performed report:
![]() |
blank | No breeding was needed in this time-step |
![]() |
success |
The timer was successful suggesting breeding was needed and individuals were available |
See also