New software for estimating feed demand is on its way

fodring12SOLID-partners are developing software intended to optimise feeding management within organic and conventional low input dairy systems. First part of the model – a simulation of feed demand – is ready. It works as a useful library or starting point for other users and developers.

Jan Vaillant and Lisa Baldinger, WP3

SOLID partners in WP3 are in the midst of developing a decision support system (DSS) – a software – that supports farmers and consultants to evaluate measures in terms of their ability to reduce risks of feed shortages on low input dairy farms – both orga­nic and conventional. The system has three major parts: A simulation of feed demand, feed supply and a diet optimization. The first part has just been published as an open-source JavaScript library. Apart from being used within SOLID-DSS we believe it might be a useful library or starting point for other users and developers.

The library called dairy.js covers several routines to simulate dairy cow herds for both productive cows and (still under development) young stock, for instance herd structure, intake, requirements and milk yields.

The source code is available at and some illustrative examples can be found at this website. Potential use cases range from simulation, web-based decision support, rapid model prototyping, education or scientific modeling. We tried to keep the code structure as simple as possible to make it easy to re-use, modify only parts and use them in any environment (web, web-worker, node.js) and we welcome any contribution to the library. Additionally utility tools for curve fitting and MILP/LP solving have been ported to JavaScript and are available in a public repository. Details of the implementation and relevant references to scientific publications can be found inside the source code files.

Here we describe the different aspects of the library:

Herd structure
The structure of the herd and demographics is calculated with a simple, deterministic model to estimate the percentage of cows per parities 1 to 3 (>2) within the herd. The simulation adjusts heifer availability (either “sell or buy”) if there are too many or not enough heifers available to achieve the target herd size. An adjustment for different calving patterns, a seasonal distribution is still under development.

Milk & milk solids
In order to simulate milk yield on arbitrary time steps we apply a Wood lactation curve. If parameters for the Wood curve are not available it is possible to fit the equation to milk yield data to obtain the three parameters of the Wood curve. A best fit is achieved with a Levenberg-Marquardt least-squares minimization implemented in lmfit.js. The obtained Wood parameters are used to calculate milk yield and solids. Both are then adjusted for parity.

Requirements & intake
Both energy and protein requirements for each cow may be calculated and expressed in units for different systems (Germany, France, Finland and the Great Britain). Since SOLID-DSS requires the estimation of a cow’s intake from grazing we have implemented parts of the GrazeIn model and thus intake is calculated using a fill value based system from INRA. Therefore the units of intake capacity are fill values. Requirements include energy and protein for maintenance, production, gestation, body weight change and grazing activity.

If necessary and applicable on a target farm the cows may be separated into several groups. Within dairy.js this is done by minimizing the sum of variance of the cow’s requirements divided by their intake capacity within groups i.e. cows within groups require a “similar” energy and protein density in their diet. This is achieved by applying the k-means algorithm.

Means to calculate diets are included here but since this is probably the most important and difficult part, the design has not yet been fixed. Diets are calculated with a linear program using glpk.js and are optimized as such that the total sum of relative (to the cow’s requirements) violations (nutrients in diet / nutrients required) is minimized (Nutrients are energy and protein) subject to the following constraints: feed intake equals intake capacity, the Ruminal Nitrogen Balance (RNB) of the diet is within or equals the recommended upper and lower bound of the RNB and concentrate by matter in diet is below or equals a user defined maximum. The violations of energy requirements should be weighted higher compared to protein since the underlying intake equations with respect to concentrate substitution requires a non-mobilizing cow to have a zero energy balance. Although the system specific protein requirements can be calculate with dairy.js the diet optimization used in SOLID-DSS will always use only the German protein system (uCP, RNB). This is due to the complexity of other, probably more advanced though not necessarily better protein systems, requiring input parameters that are not provided by the crop models used to estimate feed supply. However energy is always expressed in system specific units.

Apart from missing functionality, parts of the library still require additional testing and evaluation. In particular the implementation of concentrate substitution rates in a linear program is challenging. However our tests seem to suggest that the error in intake estimation will be acceptable especially in a low-input system when concentrate feeding will be substantially below 40% of total dry matter intake.


Jan Vaillant, Leibniz Centre for Agricultural Landscape Research, Germany & Lisa Baldinger, University of Natural Resources and Life Sciences, Austria, WP3



Leave a Reply

Your email address will not be published. Required fields are marked *