Pig feed formula optimization method based on data driving
By optimizing whale optimization algorithm and introducing Levy flight strategy, the problems of randomness and low efficiency in feed formula optimization in the prior art are solved, efficient feed composition optimization and cost reduction are achieved, and pig growth rate is improved.
Patent Information
- Application Number
- CN202411046770.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-11-22
AI Technical Summary
When the existing pig feed formula optimization methods face complex parameters and restrictive conditions, it is difficult to obtain the optimal solution. In particular, the randomness of the whale optimization algorithm leads to low search efficiency and insufficient accuracy, which cannot meet the needs of feed formula optimization.
By optimizing the parameters of the Whale Optimization Algorithm (WOA) and introducing Levy flight strategy, a secondary optimized Whale Optimization Algorithm (AWOA) is formed to improve search efficiency and accuracy, and combine the fitness function and penalty terms to optimize the feed formula.
It significantly improves the efficiency and accuracy of feed ingredient optimization, improves pig growth rate and feed cost-effectiveness, reduces the randomness of traditional methods, and ensures the balanced proportion of nutrients.
Smart Images

Figure CN119005244A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of intelligent formula optimization, and in particular relates to a data-driven pig feed formula optimization method. Background Art
[0002] Traditional pig feed formula optimization methods, such as linear programming, mixed integer programming, and heuristic algorithms, can solve the problem to a certain extent, but when faced with complex practical situations, such as many parameters and complex constraints, their performance is often lacking and it is difficult to obtain the optimal solution. In response to these problems, researchers have begun to introduce more advanced optimization algorithms, such as genetic algorithms and particle swarm algorithms. These algorithms draw on biological behaviors in nature to improve search efficiency and solution quality. However, although these algorithms are superior to traditional methods in some aspects, they still cannot fully meet the needs of feed formula optimization. In recent years, researchers have proposed more swarm intelligence optimization algorithms in order to find more accurate and efficient solutions to feed formula optimization problems.
[0003] The whale optimization algorithm is an intelligent swarm optimization algorithm proposed by Mirjalili M et al. in 2016. Compared with other swarm algorithms, such as the sparrow optimization algorithm and the locust optimization algorithm, the mathematical model of the whale optimization algorithm is relatively simple, and the algorithm has stronger search performance. However, the randomness of the algorithm is still an important issue. Especially in the feed formula optimization problem, excessive randomness may cause the algorithm to generate a large number of invalid solutions during the search process, thereby reducing the optimization efficiency and the search accuracy. Summary of the invention
[0004] The purpose of the present invention is to provide a data-driven pig feed formula optimization method to solve the problems existing in the above-mentioned prior art.
[0005] To achieve the above object, the present invention provides a method for optimizing pig feed formula based on data-driven, comprising the following steps:
[0006] S1. Construct objective function based on pig breeding data;
[0007] S2. Optimize the whale optimization algorithm WOA to obtain an optimized whale optimization algorithm;
[0008] S3. Optimize the Levy flight strategy and introduce it into the optimized whale optimization algorithm to obtain the secondary optimized whale optimization algorithm AWOA;
[0009] S4. The whale optimization algorithm AWOA based on quadratic optimization performs parameter optimization on the objective function to determine the optimal formula of pig feed.
[0010] Optionally, the pig breeding data includes: pig growth rate, feed consumption and environmental factors.
[0011] Optionally, the objective function is constructed as follows: minimizing the economic cost z is used as the objective function:
[0012] min(z)=c1x1+c2x2+............c j x j
[0013] The constraints are as follows:
[0014] x1+x2+x3........+x j =1
[0015] Among them, x j is the proportion of the jth raw material in one kilogram of feed formula, c j Represents the price of the jth raw material.
[0016] Optionally, optimizing the whale optimization algorithm WOA specifically includes: optimizing parameters a, b and r in WOA, wherein a is a linearly decaying variable, and b and r are randomly generated constants.
[0017] Optionally, the optimization of parameter a is as follows: changing the attenuation mode from linear attenuation to exponential attenuation. The attenuation formula of the optimized parameter a is:
[0018]
[0019] Where t is the current iteration number and t_half is half of the maximum iteration number.
[0020] Optionally, the optimization of the parameter r is specifically as follows: adjusting the generation method of the parameter r, and the value formula of the optimized parameter r is:
[0021]
[0022] Where t is the current iteration number, T is the maximum iteration number, and q is a random number between [0,1].
[0023] Optionally, the optimization of parameter b is specifically as follows: associating the value of parameter b with the fitness difference of the whale optimization algorithm, and adjusting the value of parameter b in real time.
[0024] Optionally, the optimization of the Levy flight strategy is specifically: optimizing the step length of the classic Levy flight strategy, and the optimized Levy flight strategy step length formula is:
[0025]
[0026] Among them, f current is the algorithm fitness at the last iteration, f previous is the algorithm fitness of this iteration, β is the parameter in the Levy distribution, and its value range is [1,2]; v and u are random numbers in the standard normal distribution, α is the learning rate, and s is the step size.
[0027] Optionally, the whale optimization algorithm AWOA based on quadratic optimization performs parameter optimization on the objective function, specifically:
[0028] 1) Initialize algorithm-related parameters, including solution dimension, maximum number of iterations, and parameters in three behavior modes;
[0029] 2) Define a fitness function to evaluate the quality of each ratio scheme; the fitness function has two evaluation indicators: total cost and whether each nutrient element meets the standard;
[0030] 3) Enter the main loop and update the position of each whale through three behaviors to optimize the raw material ratio plan;
[0031] 4) In each iteration, the fitness values of all whales are compared and the current optimal solution is updated, that is, the ratio scheme with the lowest total cost and meeting the nutritional requirements is found;
[0032] 5) If the maximum number of iterations is reached, output the result; otherwise, return to 3).
[0033] Optionally, the fitness function expression is as follows:
[0034] f(x)=min(z)+Penalty(x)
[0035] Among them, min(z) is the total cost, Penalty(x) is the penalty term, and the expression is as follows:
[0036]
[0037] Among them, b j It is the necessary amount of various nutrients; N ij It is a matrix representing the nutrients contained in each raw material; K is the penalty factor. The penalty factor K=10000 is initially set. By gradually adjusting and observing the distribution of fitness values, a suitable penalty factor is finally found so that the solution that does not meet the nutritional requirements is significantly penalized, thereby guiding the algorithm to find the optimal solution.
[0038] The technical effects of the present invention are:
[0039] The present invention remodels the parameters in the WOA model and links them with fitness. At the same time, the Levy flight strategy is optimized and added to the behavior pattern of the algorithm, so as to improve the search efficiency while ensuring the search accuracy, realize efficient feed composition optimization, and significantly improve the growth rate of pigs and feed cost-effectiveness. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0041] Figure 1 is the Ackley function fitness curve when not optimized in the embodiment of the present invention;
[0042] Figure 2 is the Ackley function fitness curve when the optimization parameter a in the embodiment of the present invention;
[0043] Figure 3 Ackley function fitness curve when the optimization parameters b and r are in the embodiment of the present invention;
[0044] Figure 4 is a curve showing a change in average value under different determination ranges in an embodiment of the present invention;
[0045] Figure 5 is the Ackley function fitness curve under different Levy flight strategies in the embodiment of the present invention;
[0046] Figure 6 , 7 ] are Ackley function curves under different optimization algorithms in the embodiments of the present invention. DETAILED DESCRIPTION
[0047] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0048] Embodiment 1
[0049] like Figure 1-7 As shown, this embodiment provides a data-driven pig feed formula optimization method, including:
[0050] 1 Algorithm Principle and Optimization Strategy
[0051] 1.1 Principles of WOA
[0052] The Whale Optimization Algorithm is a group optimization intelligent algorithm that simulates the predation behavior of whales in nature. The predation behaviors of whales mainly include the following three types: foaming net attack, search prey, and encirclement of prey. Therefore, the algorithm mathematically models these three behaviors and controls the selection of the three behavior modes by parameters p and A, where p is a random number between [0,1]; A is a random number between [-2,2]. The WOA principle is as follows:
[0053] 1) When p≥0.5, the mathematical model of the foaming network attack is as follows:
[0054]
[0055]
[0056] in, Represents the spatial coordinate X j+1 kth component; X * represents the position vector of the current best whale individual; b and L are the spiral shape constant and spiral direction constant, b is a random number between [0.5,1.5]; L is 1 or -1; D k Represents the step length from a whale individual to the best whale individual.
[0057] 2) When p < 0.5 and |A| ≥ 1, the mathematical model of search and predation is as follows:
[0058]
[0059]
[0060] A=2ar-a ((5)
[0061] C=2r (6)
[0062] Among them, X rend represents the position vector of a random individual; a is a variable that gradually decays from 2 to 0 with the number of iterations; r is a random number between [0,1].
[0063] 3) When p < 0.5 and |A| < 1, the mathematical model of encircling the prey is as follows:
[0064]
[0065]
[0066] Among them, except that the update of individual whale positions is related to the best whale individual, other parameters are consistent with the above formula.
[0067] The WOA process is as follows:
[0068] Step 1: Initialize algorithm related parameters.
[0069] Step 2: The control parameter p starts to take random values and makes the first judgment. If p < 0.5, the foaming net attack behavior mode is executed. If p ≥ 0.5, the second judgment is made.
[0070] Step 3: Based on p≥0.5, the control parameter A starts to take random values and performs a second judgment. If |A|≥1, the search and prey operation is performed; if |A|<1, the encirclement and prey operation is performed.
[0071] Step 4: This round of position change is completed, and the third judgment is performed. If the current number of iterations is less than the maximum number of iterations, the current number of iterations is increased by one, and the process returns to Step 2.
[0072] Step 5: If the current number of iterations reaches the maximum number of iterations, the algorithm ends and the result is output.
[0073] 1.2 Algorithm Optimization
[0074] From equations (1), (5), and (6), we can see that parameters a, b, and r directly affect the whale position update in the three behavior modes. However, the parameter settings in WOA are relatively random, which leads to a large randomness of the algorithm, and the optimization speed and effect are significantly affected by the initial solution. Therefore, optimizing these parameters is the key to improving the performance of the algorithm. In order to further improve the performance of the algorithm, based on parameter optimization, the Levy flight strategy is introduced, combined with the three behavior modes in WOA, and the Levy flight step is linked to the fitness difference.
[0075] 1.2.1 Algorithm parameter optimization
[0076] In WOA, a is a linearly decaying variable, and b and r are randomly generated constants. Therefore, these parameters will cause WOA to have greater randomness, and multiple tests with the same test function will result in several very different results (the differences are mainly reflected in the selection of the initial solution and the algorithm iteration speed). Now the three parameters are linked to the fitness difference between two adjacent iterations of the algorithm. In theory, the algorithm will change the parameters according to the complexity of the optimization problem and the current optimal solution generated by each iteration, so that the algorithm has better performance. The optimization method is as follows:
[0077] 1) a is a parameter that exists in the two behavior modes of the bubble net attack (spiral update position) and search predation (moving towards random individuals). The original decay formula of a is as follows:
[0078] a=2-t×(2÷t_max) (9)
[0079] Among them, t_max is the maximum number of iterations. From the above formula, we can see that the parameter a will decay linearly from 2 to 0 with the number of iterations. The purpose of decay is to allow the algorithm to transition from extensive search for the global optimal solution to local search for the global optimal solution. However, linear decay maintains a uniform decay rate throughout the iteration process, which means that the decay rate is the same in the early and late stages of optimization. Due to insufficient exploration in the early stage, the algorithm may not be able to effectively avoid falling into the local optimal solution; and in the later stage of optimization, linear decay leads to slow convergence and cannot quickly locate the global optimal solution. In view of the above problems, consider changing the decay mode from linear decay to exponential decay. Due to its own properties, exponential decay has little difference from the linear function in the early stage, but as the number of iterations increases, exponential decay will accelerate rapidly in the later stage. Therefore, exponential decay can not only maintain a large search range in the early stage of optimization, ensure that the algorithm fully explores the solution space and avoids falling into the local optimal solution; but also quickly reduce the search range in the later stage of optimization, improve the convergence speed, and locate the global optimal solution faster. In addition, by adjusting the decay rate at different stages, exponential decay can better balance exploration and development, thereby improving the overall optimization efficiency. The decay formula of a after optimization is as follows:
[0080]
[0081] Where t is the current iteration number; t_half is half of the maximum iteration number. From formula (10), we can see that the larger the denominator of the exponential of e, the faster the decay rate of a will be. Therefore, if the decay is too early, the algorithm will perform local concentrated search in the early stage, thus losing the ability of extensive search. In order to maintain the balance between the algorithm's extensive search ability and local search ability, the denominator is set to half of the maximum iteration number.
[0082] 2) r exists in two behavioral modes: searching for prey (moving towards random individuals) and surrounding prey (moving towards the best individual). As can be seen from formula (6), r will directly affect the calculation of vector C, which is a scaling factor used to simulate the distance between the whale and the target (the current optimal solution). Due to the randomness of r, vector C is also random, which ensures that the whale will not move along the same path every time when approaching the target, thereby increasing the randomness of the search process. To address the above problems, the generation method of r can be adjusted to increase its correlation and gradient information to improve the diversity and search efficiency of the algorithm while retaining a certain degree of randomness. The formula for the value of r after optimization is as follows:
[0083]
[0084] Where T is the maximum number of iterations; q is a random number between [0,1]. In the early stages of optimization, more randomness is allowed to explore the approximate location of the global optimal solution. In the later stages of optimization, this formula can increase the certainty of r, thereby making better use of the local optimal solution that has been discovered.
[0085] b is a parameter that exists in the behavior mode of the foaming network attack (spiral update position). This parameter plays a role in adjusting the tightness of the spiral. In WOA, b will be randomly selected in the initialization phase of the algorithm and remain unchanged until the end of the algorithm. From formula (1), it can be seen that if the value of b is too small (close to 0.5), the radius of the spiral will be small, which is not conducive to the extensive search in the early stage of the algorithm. If the value of b is large (close to 1.5), the radius of the spiral will be large, which is not conducive to the local search in the later stage of the algorithm. In view of the above problems, the value of b can be adjusted in real time to make the value of b associated with the fitness difference of the algorithm, so as to dynamically adjust the tightness of the spiral to meet the needs of different optimization stages. Specifically, in the early stage of optimization, the fitness difference is large and the b value should be large to increase the search range; in the later stage of optimization, the fitness difference is small and the b value should be small to enhance the local search accuracy. The value formula of b after optimization is as follows:
[0086] b=b0=1 (12)
[0087]
[0088] b new =bh×Δfitness (14)
[0089] Δfitness=fitness n -fitness n+1 (15)
[0090] b=max(min(b,b max ),b min ) (16)
[0091] Among them, b0 is the initial value. From formula (15), we can see that two discrimination operations (b max =1.5, b min=0.5) to prevent b from being too large or too small; h is the learning rate, set to 0.05; Δfitness is the difference in fitness between the algorithm in the last iteration and the current iteration. When the fitness gradually becomes smaller, it means that the algorithm is close to the global optimal solution. In order to avoid the algorithm falling into local optimization, the spiral radius should be appropriately increased. On the contrary, if the fitness gradually increases, it means that the algorithm is gradually moving away from the minimum value. Therefore, the spiral radius should be appropriately reduced to allow the algorithm to focus more on searching for the minimum value. In WOA, L is the parameter that controls the direction of the spiral. It does not change after updating, and its value remains 1 or -1, that is, clockwise spiral rise or counterclockwise spiral rise. Formula (13) is the expression of the fitness function, f max and f min are the minimum and maximum values of the Ackley function in the current population respectively.
[0092] 1.2.2 Behavior pattern optimization
[0093] In WOA, in addition to adaptively operating parameters to optimize performance, the Levy flight strategy can also be added to the three behavior modes to enhance the local and global search of WOA. The Levy flight strategy is an efficient search strategy. Since its step size follows the Levy distribution, this strategy, when added to the algorithm, allows the algorithm to perform a wider range of searches and more refined local searches. The formula for the Levy flight strategy is as follows:
[0094]
[0095]
[0096] Among them, β is the parameter in the Levy distribution, and its value range is [1,2]; v and u are random numbers in the standard normal distribution.
[0097] In the classic Levy flight strategy, there is also a large degree of randomness. The performance of Levy flight depends largely on its parameter settings, such as the scale parameter of the step size. Inappropriate parameter settings may lead to inefficient algorithms. For example, too large a step size may cause the search to be too random and unable to explore promising areas in detail; while too small a step size may fall into a local optimum. Therefore, combining the step size in the Levy flight strategy with the algorithm fitness can theoretically reduce its randomness. At the same time, the step size will be updated according to the real-time search situation of the algorithm. The optimized Levy flight strategy step size formula is as follows:
[0098]
[0099] Among them, f current is the algorithm fitness at the last iteration, f previousis the algorithm fitness of this iteration, and the other parameters are consistent with formula (18). The fitness function is consistent with formula (13). In theory, this method can increase the step size when the fitness changes greatly, so as to conduct a wider search; and reduce the step size when the fitness changes little, so as to conduct a more refined search. This can more effectively improve the performance of the algorithm.
[0100] 2 Experimental Procedure
[0101] 2.1 Ablation Experiment and Parameter Adjustment
[0102] In order to better analyze the impact of the three parameters and the Levy flight strategy on the overall algorithm, a test function was selected for parameter ablation experiments. The test function is the Ackley function. The Ackley function has many minimum points, which can test the algorithm's global judgment ability and its ability to escape when it falls into a local optimal solution. The dimension of the Ackely function can be set larger to match the number of ingredients in the subsequent feed. In addition, the feed optimization problem is a nonlinear problem with many value restrictions. The Ackley function is also a nonlinear test function that can effectively test whether the algorithm can handle nonlinear complex problems. The Ackley function expression is as follows:
[0103]
[0104] The larger the value of a is, the faster the function decreases near the global minimum, and the more difficult it is for the algorithm to escape from the local minimum. The smaller the value of b is, the more drastic the function changes. The larger the value of c is, the more and denser the local minimum of the function will be.
[0105] The more complex the optimization problem is; d is the dimension of the solution vector. In subsequent tests, a, b, c, and d are 20, 0.2, 2π, and 10 respectively.
[0106] The above Ackley function is used to test the whale algorithm when it is not optimized, only optimized parameter b, and optimized parameters a and r (parameters a and r exist in the same behavior mode, so the two parameters are optimized at the same time and compared with other situations). The visualization results are shown in the figure below Figure 1-3 As shown, the fitness function is consistent with formula (13):
[0107] Figure 1 , 2 , 3 are the fitness curves when not optimized, only optimizing parameter a, and optimizing parameters b and r. Figure 2 It can be seen from the curve that when only parameter a is optimized, the algorithm fitness curve is smoother and the iteration speed is faster than that without optimization; Figure 3It can be seen from the curve that when optimizing the optimization parameters b and r, although the fitness curve is smoother than the former, the optimization speed is slightly slower than the former. In the original WOA, the probabilities of the bubble net attack, search and prey, and encirclement of prey behavior modes being selected are 50%, 25%, and 25%, respectively. Therefore, the selection probability of the latter two behavior modes can be increased by modifying the judgment range of p. The judgment range of p is divided into ten cases from less than 0.5 to less than 1. The Ackley function is used to perform thirty tests in each of the ten cases. The difference between the final result and the theoretical value of 0 is taken and the average is taken. The average value curve for each case is shown as follows: Figure 4 As shown (in order to better reflect the difference, the theoretical value of the Ackley function is changed to 1), it can be found that when the judgment condition is p < 0.65, the algorithm can get the theoretical value of 0 every time. Therefore, in order to maximize the benefit of parameter optimization, the judgment condition of the behavior mode is changed from p < 0.5 to p < 0.65.
[0108] Based on the above parameter optimization, the Ackley function is used to test the algorithm after adding the ordinary Levy strategy and the algorithm after adding the optimized Levy flight strategy. The visualization results are shown in the figure below. Figure 5 As shown:
[0109] Depend on Figure 5 It can be seen that the fitness of the algorithm after adding the ordinary Levy flight strategy (dashed line) did not drop to 0 during the entire round of testing, and even fell into local optimization for a long time. This is because the random selection of the step size is too long, causing the algorithm to jump out of the neighborhood of the current solution too early and move away from the optimal solution, causing the fitness to drop slowly or even remain unchanged. However, the fitness of the algorithm after adding the optimized Levy flight strategy (solid line) has been tending to a smooth decline throughout the entire round of testing. This test proves that the randomness of the optimized Levy flight strategy is significantly reduced. Adding this strategy can balance the algorithm's search mode and enable the algorithm to exert better optimization capabilities.
[0110] 2.2 Function Testing
[0111] In order to test AWOA's ability to solve complex problems, several test functions are selected to test AWOA, IMWOA (initial population optimization strategy), and MSWOA (position change strategy) 100 times, and the average and optimal values are compared. The test function (f3 is generally used for two-dimensional problem testing, which can convert independent variables x and y into The form controls the function dimension by adjusting the value of n) and the test results. The test function is shown in Table 1, where f1 is a unimodal function; f2 is a multimodal function; and the rest are mixed functions. The test results are shown in Table 2:
[0112] Table 1 Benchmark functions
[0113]
[0114] Table 2 Test results
[0115]
[0116] As can be seen from the data in the above table, AWOA performs best in the test functions. For simple unimodal functions, AWOA reached the theoretical optimal value in each test, showing its high efficiency and accuracy in simple optimization problems. In multimodal functions, AWOA effectively avoids falling into the local optimal solution through its improved global search mechanism, showing strong global search capabilities and high stability. For complex mixed functions, AWOA uses its improved global search mechanism, with average and optimal values of -779.16 and -782.92, respectively, which are close to the theoretical optimal value of -783.318, proving that it effectively avoids the possibility of falling into the local optimal solution, showing strong global search capabilities and high stability.
[0117] In order to more intuitively reflect the impact of the optimization strategy on the algorithm, the above Ackley function test is also used to test the three optimization algorithms, and the global minimum searched in each iteration is compared. The resulting visualization image is as follows: Figure 6 , 7 As shown:
[0118] Depend on Figure 6 , 7 It can be seen that the initial value of MSWOA (dashed line) is relatively high, and its decreasing trend is relatively slow, and finally converges to a relatively high optimal value after several iterations; IMWOA (line segment) has a smaller initial value and a faster initial decreasing speed than MSWOA, but during the iteration process, its optimization effect gradually slows down, and finally converges to an optimal value that is lower than MSWOA but still not ideal; AWOA (solid line) decreases rapidly at the beginning of the iteration, showing a faster convergence speed, and keeps the optimal value low throughout the iteration process. AWOA introduces an adaptive parameter strategy to adjust each parameter in real time in each iteration. This strategy significantly improves the local optimization ability of the algorithm, allowing the algorithm to find a better solution faster and reduce the possibility of falling into the local optimum. Through the optimized Levy flight strategy, AWOA can conduct a large-scale exploration in a complex search space, thereby improving the global search ability, so AWOA can find a better value faster in the early iterations.
[0119] 2.3 Feed formula optimization
[0120] The above function tests show that AWOA can show stronger performance when dealing with nonlinear, high-dimensional, and multi-minima problems. Next, AWOA is used to optimize the pig feed formula.
[0121] 2.3.1 Material preparation
[0122] Table 3 shows the feed raw materials and their nutritional components (selected from NRC (2001)). In pig feed, various raw materials play different roles to ensure the healthy growth and good production performance of pigs. Corn is the main energy source in feed, providing high energy, promoting rapid growth of pigs and improving feed conversion rate. Wheat bran provides a certain amount of energy and crude protein, is rich in fiber, helps improve the digestive system of pigs and prevent constipation. In addition to the above raw materials, there are also meal feeds, such as cottonseed meal, fish meal, etc.
[0123] Table 3 Feed raw materials and their nutritional components
[0124]
[0125]
[0126] Table 4 shows the required daily amounts of nutrients for 50-80 kg fattening pigs.
[0127]
[0128] Table 5 shows the cost of raw materials and the upper and lower limits of use.
[0129] Table 5 Raw material information
[0130]
[0131] 2.3.2 Optimization process
[0132] Let x j (x j >0) is the proportion of the jth raw material in one kilogram of feed formula, such as x 1-13 Respectively represent the proportion of corn, wheat bran (according to the order of Table 3) and other raw materials in the formula; a ij Indicates the proportion of the i-th nutrient element in the j-th raw material, for example, a 1-14j represents the proportion of digestible energy, crude protein (in the order of Table 3) and other nutrients in the jth raw material; b i represents the required amount of the ith nutrient element; c j Denotes the price of the jth raw material, and assumes that the economic cost Z is the objective function. Therefore, the objective function is as follows:
[0133] min(z)=c1x1+c2x2+.........c j xj (twenty one)
[0134] The constraints are as follows:
[0135] x1+x2+x3........+x j =1 (23)
[0136] As can be seen from the above table, there are 14 nutrients in pig feed. Therefore, there are 14 inequalities established according to formula (22).
[0137] The specific implementation steps of AWOA in the feed ratio problem are as follows:
[0138] Step 1: Initialize algorithm-related parameters, such as the dimension of the solution, the maximum number of iterations, and the parameters under the three behavior modes.
[0139] Step 2: Define the fitness function to evaluate the quality of each ratio scheme. The fitness function has two evaluation indicators: total cost and whether each nutrient element meets the standard (based on the data in Table 4).
[0140] Step 3: Enter the main loop and update the position of each whale through three behaviors to optimize the raw material ratio plan.
[0141] Step 4: In each iteration, compare the fitness values of all whales and update the current optimal solution, that is, find the ratio with the lowest total cost and meeting the nutritional requirements.
[0142] Step5: If the maximum number of iterations is reached, output the result, otherwise return to Step3.
[0143] The fitness function expression in Step 2 is as follows:
[0144] f(x)=min(z)+Penalty(x) (24)
[0145] Among them, min(z) is the total cost, which is consistent with formula (21), and Penalty(x) is the penalty term, which is expressed as follows:
[0146]
[0147] Among them, b j It is the necessary amount of various nutrients; N ij It is a matrix established through Table 3, which represents the nutrients contained in each raw material; K is the penalty factor, and the penalty factor K=10000 is initially set. By gradually adjusting and observing the distribution of fitness values, a suitable penalty factor is finally found, so that the solution that does not meet the nutritional requirements is significantly penalized, thereby guiding the algorithm to find the optimal solution.
[0148] 2.3.3 Optimization Results
[0149] Table 6 shows the optimization results of the above feed formula under three algorithms:
[0150] Table 6 Optimization results comparison table
[0151]
[0152]
[0153] From the data in the table, we can see that AWOA has achieved an optimized ingredient ratio by increasing the proportion of corn and reducing the use of soybean meal, oil and sodium hydrogen phosphate. The formula contains higher levels of protein, calcium and phosphorus, which is beneficial to increasing the growth rate and weight of pigs
[20] . While all nutritional elements meet the standards, its cost has decreased by about 6.17% compared to the unimproved state, while the traditional WOA has only decreased by 2.23% compared to the unimproved state.
[0154] 3 Conclusion
[0155] The adaptive whale algorithm improves the parameters on the basis of the traditional whale algorithm, mainly targeting the balance problem between the exploration and development phases in the algorithm to enhance its global search capability and convergence speed. At the same time, the Levy flight strategy is added to the three behavior modes to enhance the exploration capability and diversity of the whale algorithm in complex search spaces. Through the test experiments, it can be seen that the global search capability of the algorithm has been improved, and the number of times it falls into local optimization has been reduced. In the feed optimization problem, while ensuring that all nutrients meet the standards, the feed cost has been reduced, which also shows that the adaptive whale algorithm can handle the problem of minimum solution very well. Therefore, the algorithm can also be used to solve other global minimum problems.
[0156] The above is only a preferred specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data-driven pig feed formula optimization method, characterized in that: The following steps are involved: S1. Construct objective function based on pig breeding data; S2. Optimize the whale optimization algorithm WOA to obtain an optimized whale optimization algorithm; S3. Optimize the Levy flight strategy and introduce it into the optimized whale optimization algorithm to obtain the secondary optimized whale optimization algorithm AWOA; S4. The whale optimization algorithm AWOA based on quadratic optimization performs parameter optimization on the objective function to determine the optimal formula of pig feed.
2. The data-driven pig feed formula optimization method according to claim 1, characterized in that: The pig breeding data include: pig growth rate, feed consumption and environmental factors.
3. The data-driven pig feed formula optimization method according to claim 1, characterized in that: The objective function is specifically constructed as follows: minimizing the economic cost z is the objective function: min(z)=c1x1+c2x2+............c j x j The constraints are as follows: x1+x2+x3........+x j =1 Among them, x j is the proportion of the jth raw material in one kilogram of feed formula, c j Represents the price of the jth raw material.
4. The data-driven pig feed formula optimization method according to claim 1, characterized in that: The optimization of the whale optimization algorithm WOA is specifically as follows: optimizing the parameters a, b and r in the WOA, wherein a is a linearly decaying variable, and b and r are both randomly generated constants.
5. The data-driven pig feed formula optimization method according to claim 4, characterized in that: The optimization of parameter a is as follows: the attenuation mode is changed from linear attenuation to exponential attenuation. The attenuation formula of the optimized parameter a is: Where t is the current iteration number and t_half is half of the maximum iteration number.
6. The data-driven pig feed formula optimization method according to claim 4 is characterized in that: The optimization of parameter r is as follows: adjusting the generation method of parameter r, and the value formula of the optimized parameter r is: Where t is the current iteration number, T is the maximum iteration number, and q is a random number between [0,1].
7. The data-driven pig feed formula optimization method according to claim 4 is characterized in that: The optimization of parameter b is specifically as follows: the value of parameter b is associated with the fitness difference of the whale optimization algorithm, and the value of parameter b is adjusted in real time.
8. The data-driven pig feed formula optimization method according to claim 1, characterized in that: The optimization of the Levy flight strategy is specifically as follows: optimizing the step length of the classic Levy flight strategy. The optimized Levy flight strategy step length formula is: Among them, f current is the algorithm fitness at the last iteration, f previous is the algorithm fitness of this iteration, β is the parameter in the Levy distribution, and its value range is [1,2]; v and u are random numbers in the standard normal distribution, α is the learning rate, and s is the step size.
9. The data-driven pig feed formula optimization method according to claim 1, characterized in that: The whale optimization algorithm AWOA based on quadratic optimization performs parameter optimization on the objective function, specifically: 1) Initialize algorithm-related parameters, including solution dimension, maximum number of iterations, and parameters in three behavior modes; 2) Define the fitness function to evaluate the pros and cons of each ratio scheme; The fitness function has two evaluation indicators: total cost and whether each nutrient element meets the standard; 3) Enter the main loop and update the position of each whale through three behaviors to optimize the raw material ratio plan; 4) In each iteration, the fitness values of all whales are compared and the current optimal solution is updated, that is, the ratio scheme with the lowest total cost and meeting the nutritional requirements is found; 5) If the maximum number of iterations is reached, output the result; otherwise, return to 3).
10. The data-driven pig feed formula optimization method according to claim 9, characterized in that: The fitness function expression is as follows: f(x)=min(z)+Penalty(x) Among them, min(z) is the total cost, Penalty(x) is the penalty term, and the expression is as follows: Among them, b j It is the necessary amount of various nutrients; N ij It is a matrix representing the nutrients contained in each raw material; K is the penalty factor. The penalty factor K=10000 is initially set. By gradually adjusting and observing the distribution of fitness values, a suitable penalty factor is finally found so that the solution that does not meet the nutritional requirements is significantly penalized, thereby guiding the algorithm to find the optimal solution.
Citation Information
Cited By
Visual interaction method for fish feed formula design
CN120319367A
Multi-unmanned aerial vehicle cooperative path planning method based on multi-strategy improved whale algorithm
CN120993965A
Multi-robot cooperative path planning method based on multi-strategy improved whale optimization algorithm
CN120993965B
