Conditional formulas in User Nutrient                        

 

The feature was designed to assign to the user nutrients formulas whose result depends on specific conditions; in other words, a formula can have two possible results, depending on the trueness of the condition. After evaluation, if the condition is true, then the result of the formula is calculated using one of the alternative expressions; if the condition is false, using the other one.

 

                                                                          

    

 

 

In the formula text box of the User nutrients panel, the three parts of the conditional formula must be separated, using couples of braces, as following:

{Condition}{Expression 1}{Expression 2}

Actually, Expression 2 can be omitted if it is not necessary to provide an alternative result when the condition is false. In this case, the last couple of braces can be left empty as following:

{Condition}{Expression 1}{}

As a consequence, given that the condition is = False, the result of the formula will be zero.

The condition consists of a comparison between two expressions (left and right part) through one of the following quantifiers:

 

Greater than

Less than

>=

Greater than or equal to

<=

Less than or equal to

=

Equal to

 

These symbols, along with the braces, are available through their related buttons in a separate group at the right bottom of the panel.

The left and right part can include references to nutrients, numbers and mathematical operators (or functions). For example, the following condition is true if the as fed analytical value for Ca is greater than the one of P:

 

 

During the input of the condition, the text box at the right of the Confirm formula command, shows the actual names of the nutrients involved:

 

 

In this case, the AF radio button is selected to set the reference to the as fed amounts.

It is also possible to input more articulated conditions like the following:

 

 

Meaning: the AF amount of soluble protein is less than or equal to 50% of the AF amount of crude protein.

The alternative expressions 1 and 2, take the same form of a regular formula and can include references to nutrients, numbers and mathematical operators (or functions). They can be included in the formula, separated by braces.

The units of measure of the alternative results of both Expression 1 and Expression 2 must match the one selected for the user nutrient.

With conditional formulas, the behavior determined by Ratio and Recalculates flags remains the same.

 

Examples

 

Condition including the comparison of the value of nutrient with a constant

In this example, the user nutrient gives the value of protein digestibility according NRC Dairy 2001, that is calculated in two different ways, depending on the feed type.

We want to set up a condition that is true if the feed is a forage. One way to do this is to consider the DM value of the Forage nutrient, and see if it is greater than zero. Our condition will be the following:

 

 

The reference to the nutrient is obtained clicking on the name of the nutrient in the list at the bottom-left of the screen.

After entering the condition, it is possible to set up two alternative expressions; the first will be used if the feed is a forage (the condition is true), the second if it is not a forage (the condition is false):

 

The first expression, used if the feed is a forage, can be interpreted as:

EXP(-1.2 × (ADPDM : CPDM)) × 100

Where EXP is the exponential function, ADPDM is the dry matter value of Acid Detergent Protein and CPDM the dry matter value of Crude Protein.

The alternative expression, used if the feed is not a forage is:

 

This can be interpreted as:

(1 – (0.4 × (ADPDM : CPDM))) × 100

Then, the complete formula is:

 

 

The behavior determined by the formula can be tested opening two feeds of different type. In the case of a forage, the value of the user nutrient is calculated through the first expression. For example, if the forage has the following values for ADP and CP:

 

 

The result is calculated as:

EXP(-1.2 × (0.960 : 8.410)) × 100 = 87.199

That is the value displayed for the user nutrient in the related tab:

 

 

The value is in the third column of the grid, since that Ratio check-box of the user nutrient is checked.

In the case of a concentrate, the other expression is evaluated to obtain the value of the nutrient. For example, in case of a concentrate with the following values:

 

 

The result is calculated as:

(1 – (0.4 × (0.628 : 9.04))) × 100 = 97.220

 

 

Condition including the comparison between the values of two nutrients

 

In this second example, the goal is to calculate NDF digestibility according NRC Dairy 2001. aNDFom and NDIP on a DM basis are compared to determine the expression of the estimated digestibility; if aNDFom is greater than NDIP, the value of the NDF digestibility is given by an expression; if not, its value is zero. The condition can be set as following:

 

If the condition is true, the value of the nutrient can be calculated as following:

(0.75 × (aNDFomDM – NDIPDM – ADLDM) × (1 – (ADLDM : (aNDFomDM – NDIPDM)) ^ 0.6)) : aNDFomDM × 100

The resulting expression is:

 

 

In this case there is not an alternative expression for calculating the value, so the second expression is simply:

 

 

With the meaning that if the condition is false, the value of the user nutrient is zero. The complete formula is then:

 

 

 

 

The formula can be tested changing the values of the involved nutrients to see what happens when the condition is true or false. In this example, we consider a feed with the following initial values:

 

 


 

Since aNDFom is greater than NDIP, the resulting expression for the nutrient is:

(0.75 × (60.94 – 1.66 – 4.13) × (1 – (4.13 : (60.94 – 1.66)) ^ 0.6)) : 60.94 × 100 = 56.392

In the user nutrients tab, we have:

 

 

To test what happens when the condition is false, we can bring the aNDFom down to a value lower that 1.66:

 

 

At this point, the condition is false and the resulting value for the user nutrient is zero: