Usage
Choose your settings and click "Results". This will trigger the follwing calculations. Details of the implementation and references to the original publications can be found in the source code available from https://github.com/jvail/dairy.js/tree/master/src.
This is only an brief illustration of the library's functionality: feed evaluation, herd structure, milk yield, requirements, intake, grouping & diet optimization. Tested only with the latest (09.2014) Firefox & Chrome browser. Additinal output (lmfit&GLPK) is visible in the browser's console (CTRL+SHIFT+J).
Curve fitting
The Wood lactation curve is fitted to the provided lactation data to obtain the three parameters of the Wood curve. A best fit is achived with a Levenberg-Marquardt least-squares minimization implemented in lmfit.js.
Herd structure
The structure of the herd (demographics) is calculated to estimate the percentage of cows of parities 1 to 3 (>2). The simulation adjusts heifer availability (either "sell or buy") if there are too many or not enough heifers available to achiev the target herd size. Currently there is not adjustment for a seasonal distribution of calvings. The cows are then evently distrituted throughout calving interval (days post partum).
Milk & milk solids
The obtained Wood parameters are used to calculate milk yield and solids. Both are adjusted for parity. Initial milk yield of parity 1 & 2 is scaled subject to the weight at calving compared to mature body weight.
Requirements & intake
Both energy and protein requirements for each cow are calculated using the chosen system (DE, FI, FR, GB). The intake capacity is calculated with a fill value based system from INRA. Therefore the units of intake capacity are fill values (LFU).
Grouping
The cows are grouped as such that the variance of requirement devided by intake capacity is minimized within groups: Cows within groups require a "similar" energy and protein density and energy:protein ratio in their diet. This is achived by applying the k-means algorithm. Since the result of k-means depends on the initially chosen points the results of two runs with equal settings might slightly vary. To prevent this k-means runs several times and the best solution is returned.
Diet
The diets are calculated with a linear program using glpk.js for an average cow within each group. Diets 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 upper and lower bound of the RNB and concentrate dy matter in diet is below or equals the maximum (see settings). The violations of energy requirments are weighted by the factor 10 compared to protein. Although the system specific protein requirements are calculate and presented the diet always uses only the German protein system (uCP, RNB). Energy is always expressed in the chosen system's unit. This is due to requirements and limitations in the original project (SOLID) this library was developed for. Also this is the reason for not having a constraint for the diet's fibre content. In low-input dairying feeds with very low fibre content wont be abundantly available. If necessary, adding such a constaint to the LP wont be difficult.
Feed selection
Milk yield settings
Herd settings
System & Ration
Wood function fitted to milk yield data vs. days post partum
cows per parity and heifers bought or sold in % of herd size
milk kg for all cows in herd vs. days post partum
milk fat % for all cows in herd vs. days post partum
milk protein % for all cows in herd vs. days post partum
intake capacity in fill units of all cows in herd vs. days post partum
kg body weight of all cows in herd vs. days post partum
kg body weight changes of all cows in herd vs. days post partum
energy requirements of all cows in herd vs. days post partum
protein requirements of all cows in herd vs. days post partum
grouping criteria: protein req. / intake capacity vs. energy req. / intake capacity (normalized)
group changes vs. age in days (during a lifetime of a cow)
dry matter intake and diets for avg. cow in groups w/o dry group
requirement violation for avg. cow in group in % of total requirements