|
Freefarm | |
|
Hem
Kontakta oss |
Dynamic optimization
ProloguePicture this: You have a computer program that with fantastic accuracy can tell you what to feed your animals, both with respect to animal health and economy. So far this has been nothing but a dream, no computer program is better than the nutritional knowledge of the person using it. But perhaps that is going to change?!
Search functionsTake a look at this function:f(x,y) = (y-x2)2 + (1-x)2 The picture below is a 3D-plot of the function.
The function is called Rosenbrock's banana function and is a classic function. Mathematicians use it to test search functions. The minimum of the function is in the point x=1, y=1 and the value is 0. Note that this is not a linear function. Let's say that we are in a boat on a lake, looking for the deepest place. The depth of the lake is described by the banana function. Our tool is a long tape measure that we can sink down. How are we going to find the deepest place?
One way would be to divide the lake into a grid and measure in each intersection. However, if we did not make the grid fine enough, we risk missing the deepest point. Perhaps it would also take us to long. If we, in addition to that, add a third dimension like temperature as a function of f(x,y,z) where z is the depth of the lake, we would get an enormous amount of measuring points. Thus, this method seams to be inefficient Another way would be to make continuous measurements along a strait line. At the deepest point we can make a new line 90 degrees from the first one, search along the new one, and repeat this until we find the deepest place. But, if there is two places fairly fare away from each other and not too much difference in depth, we might risk finding the second deepest place. A third way would be to more or less randomly choose three points. The points would make a triangle. The corner of the triangle which is the deepest would probably point in the direction of the deepest place. By testing in that direction, and expand and shrink the triangle in a clever way, we should be able to rather quickly find the deepest place. This is exactly how the down-hill-simplex method works. It can be (and is) used for dynamic optimization. The down-hill-simplex method is described in the literature, including suggestions of how to implement it in a computer program. I have used an example program from Numerical recipes as a base when working with dynamic optimization. In the applet below (an applet is a small Java-program that runs on a home page) shows how the search function works as it step by step search for the minimum of the banana function. There is a delay built in the program so that we can follow what happens. When it reaches the minimum it makes a short pause, and then start over again.
The figures at the top shows the value of the function f(x,y) where x and y represents the coordinates of each corner in the triangle. Finally the down-hill-simplex finds a point very near to 1,1 with the value of almost f(1,1)=0 (Note that computers write numbers close to zero as e.g. 1E-7 which corresponds to 0.00000001). This example shows how to search for minimum in a non-linear function.
Dynamic systemsFilling a leaking bath tub is a dynamic system.
The bath tub is a system that is changing itself over time, that is it is a dynamic system. Depending on the in-flow and out-flow of water the water level will change. In a similar way one can picture the rumen of an animal. The more of energy and protein the faster will the metabolism of micro organisms be. On the other hand, the faster the metabolism the more pH will decrease, which is inhibiting microbiological activity. In the same time, acids will flow out of the rumen, and perhaps equilibrium will be reached at some point. Let's assume that we have the following totally fictitious dynamic system which should resemble a feeding animal. (Please ignore that this is a "corny" example, we are only going fore the principals of dynamic systems. Especially ignore that this system would be possible to treat with classic mathematic instead of numerical (computer based) methods.).
Black line = roughage
Please test the following settings and note the uptake of nutrient B:
When I tested this myself I got the following values of
total uptake of nutrient B: Note that the increase of 5 units of roughage did give a lager increase in uptake of nutrient B when the level of grain was 5 compared with 10.
Optimizing a dynamic systemBy combining these two methods one can perform dynamic optimization.. This is of course very interesting for everyone interested in modern dynamic feeding standards for dairy cows. In a dynamic model it is not certain that the double level of grain will correspond to the double amount of nutrients absorbed. First all feedstuffs must be evaluated in relationship with all other ingredients in the ration. Only then can the total ration get a nutritional value. This means that ordinary linear methods used in e.g. Opti-kuckeliku will not work.The key concept in dynamic optimization is to see the objective function built up by both the price and levels of different ingredients, and also the divergence of nutrient levels compared to the desired restrictions of nutrients for the animal. If a nutrient level is more or less than what we consider appropriate we add a large number to the objective function. This is how to do it:
If one would like to use dynamic optimization for dairy cows and it should work under real farming conditions one would have to find out, understand and have access tot he following:
I personally can't imagine any thing more fun and challenging than to answerer those questions! But seriously, why invest in dynamic optimization? The answer is that when using a liner model the result is always extreme. The user must always ask the question, can I feed this to my animals? Sometimes the calculated ration will be terrific, but the user will not dare to use it. Sometimes the result might me a disaster, but the user will not find out about before the animals do… Dynamic optimization, on the other hand, might produce the strangest looking combinations of feedstuffs, but we can trust the results and safely feed the proposed ration to our animals and it also perhaps might be noticeable cheaper.
Written by Mattias Malmgren, date: 2003-08-26 |