Crop planting strategy optimization method and system under multi-constraint condition, and cloud platform
Through improved mixed integer linear programming agricultural model and improved genetic algorithm, combined with K-means clustering and K-S test method, multi-constraint conditions and optimize planting strategies, the problem of difficulty in maximizing profits in existing technology under multi-constraint conditions is solved, and the economic benefits and planting efficiency of the planting plan are significantly improved.
Patent Information
- Application Number
- CN202510266342.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-07
- Publication Date
- 2025-04-04
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
It is difficult to maximize profits under multi-constraint conditions, and genetic algorithms are prone to fall into local optimization when solving large-scale mixed integer programming problems, with slow convergence speed, and lack in-depth mining of the dynamic correlation of planting data.
The improved mixed integer linear planning agricultural model is adopted, combined with improved genetic algorithms for dynamic optimization, and through technical means such as K-means clustering method and K-S inspection method, multiple constraints such as planting area, yield, repeated strand constraints, plot spacing, and crop rotation requirements are integrated to optimize the planting strategy.
A planting strategy that maximizes profits under multiple constraints has been realized, which has significantly improved the economic benefits of the planting plan, effectively reduced the risk of unsalable sales, and optimized resource allocation through centralized planting, which has improved planting efficiency.
Smart Images

Figure CN119761601A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of agricultural planting technology, and in particular to a method, system and cloud platform for optimizing crop planting strategies under multiple constraints. Background Art
[0002] Scientific agricultural planting strategies can increase yields, improve quality, save costs, protect the environment, and enhance agricultural sustainability. With the rapid development of modern agriculture, how to efficiently utilize arable land resources and formulate scientific planting strategies based on local conditions has become the key to increasing crop returns and promoting rural economic development.
[0003] However, various uncertainties such as climate change, market fluctuations and planting costs make it a huge challenge to develop effective crop planting plans. In addition, many current planting strategies rely on experience or single factor analysis, lacking systematic integration and dynamic optimization of multiple constraints. For example, traditional methods do not fully incorporate constraints such as plot concentration, crop rotation cycle, land type adaptation, and crop substitutability, resulting in limited economic benefits of planting plans and a high risk of unsalability. In addition, existing genetic algorithms are prone to falling into local optimality and slow convergence when solving large-scale mixed integer programming problems, and lack in-depth mining of the dynamic correlation of planting data.
[0004] Therefore, how to achieve a planting strategy that maximizes profits under multiple constraints has become a technical problem that needs to be solved urgently. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method, system and cloud platform for optimizing crop planting strategies under multiple constraints to at least partially solve the above problems.
[0006] According to a first aspect of an embodiment of the present invention, a method for optimizing crop planting strategies under multiple constraints is provided, comprising inputting crop data into an improved mixed integer linear programming agricultural model constructed, defining the decision variables of the improved mixed integer linear programming agricultural model as a continuous variable including crop planting area and a discrete variable including whether to plant, the objective function of the improved mixed integer linear programming agricultural model is used to maximize the total planting profit, and the multiple constraints of the improved mixed integer linear programming agricultural model include planting area constraints, yield constraints, continuous cropping restriction constraints, plot spacing constraints, rotation constraints, land type constraints and special planting requirement constraints for crop classification; dynamically optimizing the improved mixed integer linear programming agricultural model through an improved genetic algorithm, and iteratively solving the planting strategy for the input crop data; classifying the crop types in the crop data through the K-means clustering method, and optimizing and adjusting the planting strategy in combination with the loss coefficient of the expected sales volume; analyzing the relationship between the planting cost, the sales price and the expected sales volume through the KS test method and the Spearman correlation coefficient analysis method, so as to further optimize the planting strategy.
[0007] According to a second aspect of an embodiment of the present invention, a crop planting strategy optimization system under multiple constraints is provided, comprising: a model construction module, for inputting crop data into an improved mixed integer linear programming agricultural model constructed, defining the decision variables of the improved mixed integer linear programming agricultural model as a continuous variable including crop planting area and a discrete variable whether to plant, the objective function of the improved mixed integer linear programming agricultural model is used to maximize the total planting profit, and the multiple constraints of the improved mixed integer linear programming agricultural model include planting area constraints, yield constraints, continuous cropping restriction constraints, plot spacing constraints, rotation constraints, land type constraints and special planting requirement constraints for crop classification; a solution module, for dynamically optimizing the improved mixed integer linear programming agricultural model through an improved genetic algorithm, and iteratively solving the planting strategy for the input crop data; a first optimization module, for classifying the crop types in the crop data through a K-means clustering method, and optimizing and adjusting the planting strategy in combination with the loss coefficient of the expected sales volume; a second optimization module, for analyzing the relationship between the planting cost, the sales price and the expected sales volume through a KS test method and a Spearman correlation coefficient analysis method, so as to further optimize the planting strategy.
[0008] According to a third aspect of an embodiment of the present invention, a cloud platform for optimizing crop planting strategies under multiple constraints is provided, and the cloud platform includes the crop planting strategy optimization system under multiple constraints as described in the second aspect.
[0009] In summary, the scheme of the embodiment of the present invention is based on the improved mixed integer linear programming agricultural model, with maximizing the total planting profit as the objective function, and integrating multiple types of constraints such as planting area restrictions, repeated cropping constraints, plot concentration, crop rotation requirements and land type adaptation. The present invention uses an improved genetic algorithm for dynamic optimization, accelerates convergence through elite retention strategy and adaptive crossover mutation probability, combines K-means clustering to analyze crop substitutability and introduces sales loss coefficient to optimize layout, and further reveals the nonlinear relationship between cost, price and sales volume through KS test and Spearman correlation analysis, and finally integrates into the cloud platform. The present invention realizes a planting strategy that maximizes profits under multiple constraints, significantly improves the economic benefits of the planting plan, effectively reduces the risk of unsalable products, and optimizes resource allocation through centralized planting, thereby improving planting efficiency and providing scientific decision-making support for agricultural planning under multiple constraints. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0011] Figure 1 A flowchart of the steps of the crop planting strategy optimization method under multiple constraints of the present invention; Figure 2 For Figure 1 The corresponding overall technical route flow chart; Figure 3 A platform framework execution diagram of a cloud platform for optimizing crop planting strategies under multiple constraints of the present invention; Figure 4 It is the flow chart of genetic algorithm; Figure 5 It is a schematic diagram of two-point intersection; Figure 6 It is an iteration curve graph; Figure 7 This is the K-means clustering flow chart; Figure 8 is the silhouette score map for different numbers of clusters; Fig. 9 It is a data clustering diagram; Fig.10 This is the KS inspection flow chart; Fig.11 is the correlation heat map; Fig.12 Reading flow chart for terrain data. DETAILED DESCRIPTION
[0012] In order to have a clearer understanding of the technical features, purposes and effects of the embodiments of the present application, the specific implementation methods of the embodiments of the present application are now described with reference to the accompanying drawings.
[0013] In this document, “exemplary” means “serving as an example, instance or illustration”, and any diagram or implementation described in this document as “exemplary” should not be interpreted as a more preferred or more advantageous technical solution.
[0014] In order to simplify the drawings, only the parts related to the present application are schematically shown in each figure, and they do not represent the actual structure of the product. In addition, in order to simplify the drawings and facilitate understanding, in some figures, only one or more of the parts with the same structure or function are schematically drawn or only one or more of them are marked.
[0015] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in the field based on the embodiments in the embodiments of the present invention should fall within the scope of protection of the embodiments of the present invention.
[0016] The specific implementation of the embodiment of the present invention is further described below in conjunction with the accompanying drawings of the embodiment of the present invention.
[0017] See also Figure 1 , Figure 2 The crop planting strategy optimization method under multiple constraints of this embodiment mainly includes the following steps: Step S101, inputting crop data into the constructed improved mixed integer linear programming agricultural model, defining the decision variables of the improved mixed integer linear programming agricultural model as continuous variables including crop planting area and discrete variables including whether to plant, the objective function of the improved mixed integer linear programming agricultural model is used to maximize the total planting profit, and the multiple constraints of the improved mixed integer linear programming agricultural model include planting area constraint, yield constraint, continuous cropping restriction constraint, plot spacing constraint, rotation constraint, land type constraint and special planting requirement constraint of crop classification; It should be understood that crop data includes the number of years for continuous cropping, crop rotation compatibility, minimum planting spacing requirements, crop types, crop planting amounts, etc. Crop data also includes terrain data. Terrain data includes collected land attributes and other parameters, which are also part of the process for crop planting.
[0018] Step S102, dynamically optimizing the improved mixed integer linear programming agricultural model by using an improved genetic algorithm, and iteratively solving a planting strategy for the input crop data; Step S103, classifying the crop types in the crop data by using a K-means clustering method, and optimizing and adjusting the planting strategy in combination with the loss coefficient of the expected sales volume; Step S104, analyzing the relationship between the planting cost, the sales price and the expected sales volume by using the KS test method and the Spearman correlation coefficient analysis method, so as to further optimize the planting strategy.
[0019] In summary, the scheme of the embodiment of the present invention is based on the improved mixed integer linear programming agricultural model, with maximizing the total planting profit as the objective function, and integrating multiple types of constraints such as planting area restrictions, repeated cropping constraints, plot concentration, crop rotation requirements and land type adaptation. The present invention uses an improved genetic algorithm for dynamic optimization, accelerates convergence through elite retention strategy and adaptive crossover mutation probability, combines K-means clustering to analyze crop substitutability and introduces sales loss coefficient to optimize layout, and further reveals the nonlinear relationship between cost, price and sales volume through KS test and Spearman correlation analysis, and finally integrates into the cloud platform. The present invention realizes a planting strategy that maximizes profits under multiple constraints, significantly improves the economic benefits of the planting plan, effectively reduces the risk of unsalable products, and optimizes resource allocation through centralized planting, thereby improving planting efficiency and providing scientific decision-making support for agricultural planning under multiple constraints.
[0020] Optionally, among the decision variables of the improved mixed integer linear programming agricultural model, the continuous variable Indicates Year Planting crops in The planted area on the plots is a discrete variable Indicates Year Is the crop in the Planting on plots, discrete variable The values are as follows: .
[0021] Optionally, the objective function of the improved mixed integer linear programming agricultural model is expressed as: ; in, represents the total profit of growing crops, Indicates the time of the tth year Planting crops in The yield per mu of land, Indicates Year time Planting crops in The planting area on the plot, Indicates Year time The unsold crops, Indicates Planting crops in The unit price of a plot of land, Indicates Planting crops in The planting cost on each plot of land.
[0022] Optionally, the multiple constraints of the improved mixed integer linear programming agricultural model include: Planting area constraints: the planting area of each crop cannot exceed the corresponding plot area: ; in, Indicates Year time Planting crops in The planting area on the plot, Indicates The size of the planting area of each plot; The planting area of each crop in a designated plot of land should meet the following requirements: ; Where n is the area coefficient, Indicates j The lower limit of the planting area of crops on a designated plot; Yield constraints: the output of each crop cannot exceed the expected sales volume of the year to reduce the situation of unsalable crops: ; ; in, Indicates the expected sales volume of the crops grown; Constraints on repeated cropping: Each crop cannot be planted continuously in the same plot of land, otherwise the yield will be reduced: ; in, It is a discrete variable of whether to plant or not, and it is forbidden to plant the same crop continuously on the same plot; The spacing between plots is constrained, and the planting plots of each crop are kept concentrated: After numbering each plot and the tillage type, calculate the maximum planting distance between two planting plots To ensure that crops are grown in concentrated plots: ; The maximum planting distance Indicates Year The maximum distance between crop plots, and The two plots are numbered respectively. They are the cultivated land type numbers of the two plots. and is the weight coefficient; ; in, D Represents the maximum spacing between all plots planted with the same crop in a given year.
[0023] Rotation constraint: beans must be planted on each plot every three years: ; in, represents the set of all legume plants; Land type constraints are defined as follows: flat dry land, terraced fields and hillside land are only suitable for growing single-season food crops: ; in, represents the set of flat dry land types, represents the set of terraced fields, represents the set of cultivated land types as hillside land, Indicated in t Time, i Plots planted j The area of crops when planted; Among them, irrigated land can be used to grow a single crop of rice or two crops of vegetable crops: ; in, Indicates the set of irrigated land types; The special planting requirements of crop classification divide vegetables into vegetables with special planting conditions, recorded as special vegetables, and vegetables without special planting conditions, recorded as non-special vegetables: Among them, the planting requirements for the first and second seasons of irrigated land are: ; Requirements for planting in the first and second seasons of ordinary greenhouses: ; Smart greenhouse planting requirements: ; Optionally, the improved mixed integer linear programming agricultural model is expressed as: ; .
[0024] Optionally, the improved mixed integer linear programming agricultural model is dynamically optimized by an improved genetic algorithm to iteratively solve a planting strategy for the input crop data, including: Performing chromosome encoding on the designable variables: performing chromosome encoding on the designable variables of the improved mixed integer linear programming agricultural model by using binary Gray encoding; Population initialization: According to the binary Gray coding method adopted, a set of initial chromosomes is randomly generated. The initial chromosomes represent individuals in the population. Each individual in the population is a potential planting strategy. Set the fitness function and calculate the fitness value of individuals in the population: Evaluate the fitness of each individual in the population by setting the fitness function, which is used to measure the quality of each individual; Elite retention strategy: adopting the elite retention strategy, retaining a group of individuals with the best performance from the current population as elite individuals to the next generation population, and increasing the number of retained elite individuals as the number of iterations increases, so as to accelerate the convergence speed of the improved mixed integer linear programming agricultural model; Linear sorting probability selection operation: All individuals in the population are sorted according to their fitness values, and the probability of each individual being selected for mating is determined by ranking linear gradient descent, where individuals with higher fitness values have a higher probability of being selected; Crossover and mutation operation: select individuals with high fitness values for crossover and mutation operations to generate new individuals; Individual retention: The generated new individuals and elite individuals form a new population and enter the next round of genetic iteration; Determine the stopping condition and output the optimal solution: use the gradient calculation based on the fitness value to determine whether the improved mixed integer linear programming agricultural model converges. If the fitness gradient function value is less than the preset threshold, the improved mixed integer linear programming agricultural model is judged to converge, the stopping condition is triggered, the optimal genotype is output, and the planting strategy is decoded.
[0025] It should be understood that the designable variables include: the planting area of different crops in each plot, the planting decision of crops in each time period, and the allocation of agricultural resources to different plots and crops.
[0026] Optionally, the basic process of the K-means clustering method includes: a. Determine the number of clusters: Divide the crop data into multiple clusters, that is, determine the K value; b. Initial centroid selection: randomly select K crop data points as the initial centroid; c. Data point allocation: Based on the Euclidean distance metric, each crop data point is divided into the cluster corresponding to the centroid closest to it, thus forming K clusters; d. Centroid update: recalculate the centroid of each cluster to get a new centroid, which is the mean of all crop data points in the corresponding cluster; e. Iterative optimization: Repeat steps c and d until the centroid position converges or reaches the set iteration limit.
[0027] Optionally, the relationship between the planting cost, the sales price and the expected sales volume is analyzed by the KS test method and the Spearman correlation coefficient analysis method to further optimize the planting strategy, including: First, the KS test method is used to determine whether the expected sales volume, the sales price, and the planting cost conform to the normal distribution, wherein the calculation steps of the KS test method include: Calculate the empirical distribution function: Calculate the empirical distribution function F based on the sample data; Compare distribution differences: compare the difference between the empirical distribution function F and the theoretical distribution function G; Calculate the KS statistic: Determine the maximum difference between the empirical distribution function and the theoretical distribution function ; Calculate the P value: According to and sample size h, calculate the P value by table lookup or numerical method; When the expected sales volume, the sales price and the planting cost do not satisfy the normal distribution, the Spearman correlation coefficient analysis method is used to analyze the relationship between the planting cost, the sales unit price and the expected sales volume, so as to further optimize the planting strategy.
[0028] The scheme of the present invention inputs crop data, establishes an improved MILP mixed integer linear programming agricultural model under constraints, applies an improved genetic algorithm to solve the best solution, and performs K-means clustering analysis and substitution analysis on crops. The K-S test is used to analyze the correlation. If the normal distribution is satisfied, the correlation is directly analyzed and a heat map is generated. If it is not satisfied, the Spearman correlation coefficient is used to analyze the correlation and then generate a heat map.
[0029] The present invention also provides a crop planting strategy optimization system under multiple constraints, comprising: A model building module, used for inputting crop data into an improved mixed integer linear programming agricultural model, defining the decision variables of the improved mixed integer linear programming agricultural model as a continuous variable including crop planting area and a discrete variable including whether to plant crops, the objective function of the improved mixed integer linear programming agricultural model is used to maximize the total planting profit, and the multiple constraints of the improved mixed integer linear programming agricultural model include planting area constraint, yield constraint, continuous cropping restriction constraint, plot spacing constraint, rotation constraint, land type constraint and special planting requirement constraint for crop classification; A solution module, used for dynamically optimizing the improved mixed integer linear programming agricultural model by improving the genetic algorithm, and iteratively solving the planting strategy for the input crop data; A first optimization module is used to classify the crop types in the crop data by using a K-means clustering method, and optimize and adjust the planting strategy in combination with a loss coefficient of expected sales volume; The second optimization module is used to analyze the relationship between the planting cost, the sales price and the expected sales volume through the KS test method and the Spearman correlation coefficient analysis method, so as to further optimize the planting strategy.
[0030] The system of this embodiment is used to implement the corresponding methods in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here. In addition, the functional implementation of each module in the system of this embodiment can refer to the description of the corresponding parts in the aforementioned method embodiments, which will not be repeated here.
[0031] The present invention also provides a cloud platform for optimizing crop planting strategies under multiple constraints, and the cloud platform includes the above-mentioned crop planting strategy optimization system under multiple constraints.
[0032] Specifically, the scheme of the present invention is further described according to the following examples: Step S101, inputting crop data into the constructed improved mixed integer linear programming agricultural model, defining the decision variables of the improved mixed integer linear programming agricultural model as a continuous variable including the crop planting area and a discrete variable whether to plant, the objective function of the improved mixed integer linear programming agricultural model is used to maximize the total planting profit, and the multiple constraints of the improved mixed integer linear programming agricultural model include planting area constraints, yield constraints, continuous cropping restriction constraints, plot spacing constraints, rotation constraints, land type constraints and special planting requirement constraints for crop classification: like Figure 3 As shown in the figure, the integrated architecture design of a cloud platform for optimizing crop planting strategies under multiple constraints is as follows: 1. Data layer: Integrate historical planting data, real-time sensor data (soil moisture, light, etc.) and user input parameters.
[0033] 2. Model layer: deploy MILP model (improved mixed integer linear programming agricultural model) and improved genetic algorithm, and provide API interface calls.
[0034] 3. Application layer: Visually display the optimization plan, support plan export and remote monitoring.
[0035] In a cloud platform for optimizing crop planting strategies under multiple constraints, users can independently access the existing agricultural planting database in the platform and select data that adapts to local agricultural conditions according to actual needs. Land data collected in real time by sensors can be transmitted to the cloud platform through the cloud, and users can also manually enter relevant agricultural production data. The information in the data storage layer will be transmitted to the basic capability layer, and the improved mixed integer linear programming (MILP) agricultural model will be used to plan the land for planting. The cloud platform provides efficient agricultural planning services through an integrated hardware and software architecture to ensure that the planting strategy is closely matched with local actual conditions.
[0036] For agricultural production planning, a reasonable planting plan is to achieve higher returns on crops. According to the sales of different crops, abnormal sales are divided into two situations: unsalable and discounted sales. The optimal planting plan for each crop is given under the premise of maximizing profits. Since the two situations are only different in the method of profit calculation, and profit is used as the objective function of the model, the biggest difference between the two situations lies in the difference in objective functions.
[0037] The total profit can be calculated by the planting area, planting unit price and planting cost, so the objective function of the improved mixed integer linear programming agricultural model is: ; in, represents the total profit of growing crops, Indicates the time of the tth year Planting crops in The yield per mu of land, Indicates Year time Planting crops in The planting area on the plot, Indicates Year time The unsold crops, Indicates Planting crops in The unit price of a plot of land, Indicates Planting crops in The planting cost on each plot of land.
[0038] Among the decision variables of the improved mixed integer linear programming agricultural model, the continuous variable Indicates Year Planting crops in The planted area on the plots is a discrete variable Indicates Year Is the crop in the Planting on plots, discrete variable The values are as follows: .
[0039] It should be understood that since the above decision variables include both integers and continuous decimals, it is a mixed situation, and the MILP mixed integer linear programming agricultural model, that is, the improved mixed integer linear programming agricultural model, needs to be adopted.
[0040] Among them, the constraints obtained according to the actual farming situation are as follows: Constraint 1. The planting area of each crop cannot exceed the area of the corresponding plot:
[0041] in, Indicates Year time Planting crops in The planting area on the plot, Indicates The size of the planting area of each plot.
[0042] Constraint 2: The output of each crop cannot exceed the expected sales volume of the year to reduce the situation of unsalable crops:
[0043]
[0044] in, Indicates Expected sales of the crop.
[0045] Constraint 3. Each crop cannot be planted repeatedly on the same plot of land, otherwise the yield will be reduced: ; in, It is a discrete variable of whether to plant or not, and it is forbidden to plant the same crop continuously on the same plot; Constraint 4. The planting area of each crop in a certain plot cannot be too small. The planting area of each crop in a designated plot should meet the following requirements: ; Among them, n represents the area coefficient. The smallest planting area of all plots in that year is analyzed, and the crop with the smallest area in the plot is taken, which is recorded as n. Indicates j The lower limit of the planting area of crops on a designated plot of land.
[0046] Constraint 5. The planting areas of each crop should be kept as concentrated as possible and not too scattered: Here, the present invention introduces the maximum planting distance , indicating the Year The maximum distance between crop plots. This maximum distance helps ensure that crop plots are as concentrated as possible, thereby optimizing management and resource allocation. After each plot is numbered and numbered by farming type, the distance between two planting plots is calculated. Here’s how: ; The maximum planting distance Indicates Year The maximum distance between crop plots, and The two plots are numbered respectively. They are the cultivated land type numbers of the two plots. and is the weight coefficient.
[0047] ; in, D Indicates the maximum distance between all plots planted with the same crop in a certain year (a specified year). The distance threshold can be determined by analyzing historical planting data or the planting distribution of the previous year. Usually, a reasonable upper limit is set to ensure that the planting plots of the same crop remain moderately concentrated in spatial distribution.
[0048] Constraint 6. Satisfy the rotation constraint. Since soil containing legume root fungi is conducive to the growth of other crops, legumes must be planted once every three years on each plot: ; in, Represents the set of all legume plants.
[0049] Constraint 7. The planting constraints generated by land type are defined as follows: flat dry land, terraced fields and hillside land are only suitable for planting single-season food crops: ; in, represents the set of flat dry land types, represents the set of terraced fields, represents the set of cultivated land types as hillside land, Indicated in t Time, i Plots planted j The area under cultivation when growing crops.
[0050] Among them, irrigated land can be used to grow a single crop of rice or two crops of vegetable crops: ; in, Indicates the set of irrigated land types.
[0051] Constraint 8. Vegetables are divided into special vegetables (vegetables with special growing conditions) and non-special vegetables (vegetables without special growing conditions).
[0052] Among them, the planting requirements for the first and second seasons of irrigated land are: ; Requirements for planting in ordinary greenhouses in the first and second seasons (to ensure food safety, edible fungi are only planted in ordinary greenhouses): ; Constraint 9. Requirements for smart greenhouse cultivation: ; In summary, the established MILP mixed integer linear programming model, namely the improved mixed integer linear programming agricultural model, is as follows: ; .
[0053] Step S102: dynamically optimize the improved mixed integer linear programming agricultural model through an improved genetic algorithm, and iteratively solve the planting strategy for the input crop data: In a specific embodiment, see Figure 4 As shown, by simulating the mechanism of natural evolution, through operations such as selection, crossover and mutation, individuals in the solution space are gradually optimized to search for the optimal solution. The improved genetic algorithm consists of the following steps: (1) Chromosome encoding of designable variables Coding is the process of mapping an individual's phenotype to a genotype. In order to avoid the Hamming cliff problem, the present invention uses binary Gray coding. This method allows adjacent codes to change only one bit to reduce the possibility of erroneous transmission and decoding.
[0054]
[0055] represents the nth bit of the Gray code, Represents the nth bit of the binary code, Represents the n+1th bit of the binary code, is the exclusive OR operator.
[0056] (2) Population initialization The population is a set of potential solution individuals. In order to ensure the convergence efficiency of the model and the diversity of chromosomes, the population size is set to N.
[0057] In a specific embodiment, the population size N=300 is initialized, and individuals that meet the constraints are randomly generated. The fitness directly uses the objective function value: .
[0058] Fitness represents the fitness of the improved mixed integer linear programming agricultural model, and PT represents the total profit of growing crops.
[0059] (3) Set the fitness function and calculate the fitness value of each individual in the population. For the maximum crop yield problem, the fitness function is used to measure the quality of each individual in the population. The fitness function is:
[0060] represents the i-th individual in the population at time t, It is for individuals The fitness evaluation of is the maximum value of all individual fitness values at time t, Represents the fitness function of the i-th individual in the population at time t.
[0061] For the cost minimization problem, the fitness function is used to evaluate the adaptability of individuals in the population to solve the problem. The fitness function is:
[0062] represents the upper limit of the cost, is the cost fitness evaluation value corresponding to the individual, Represents the fitness function for the cost minimization problem.
[0063] (4) Elite retention strategy In order to improve the convergence efficiency of the model, an elite retention strategy is introduced into the genetic algorithm. This strategy maintains the high-quality genetic diversity of the population by retaining the individuals with the best fitness in each generation, ensuring that they directly enter the next generation and participate in the crossover operation. The number of elite individuals adopts a dynamic adjustment mechanism and gradually expands as the number of iterations increases, which not only avoids falling into the local optimum in the early stage, but also accelerates the convergence process in the later stage. This mechanism effectively balances the relationship between exploration and development, and significantly improves the global search capability and convergence speed of the algorithm.
[0064] In a specific embodiment, the individuals with the highest fitness of M=50 in each generation are retained and directly enter the next generation to prevent the loss of high-quality genes. At the same time, M is dynamically adjusted and gradually increased to M=200 as the number of iterations increases to balance exploration and development.
[0065] (5) Linear sorting probability selection operation The probability of each individual being selected for mating is determined by the individual's fitness. All individuals in the population are sorted according to their fitness, and the probability of an individual being selected for mating decreases linearly according to the ranking. (6) Two-point intersection In a specific embodiment, Figure 5 As shown, a two-point crossover operator is used to mate between chromosomes, the mother randomly sets two crossover points of the coding string, and then performs partial gene exchange to generate offspring.
[0066] (7) Mutation The mutation process takes each segment of the chromosome as a unit and performs a bit inversion operation. Mutation will increase the diversity of the population, but it will also affect the convergence of the model. Therefore, the present invention adopts a mutation gradient descent strategy, namely:
[0067] in, t is the iterative algebra, pm is the mating probability.
[0068] (8) Individual retention This step will retain the best M individuals in the population and enter the next round of genetic iteration.
[0069] (9) Determine the stopping condition and output the optimal solution In a specific embodiment, the present invention uses a gradient calculation based on the fitness value to determine whether the model converges. The gradient function of the fitness value is:
[0070] represents the fitness value of the population at the tth iteration, represents the gradient of the fitness value, represents the fitness value of the population at the t-1th iteration, represents the fitness value of the population at the t-2th iteration, Represents the fitness value of the population at the t-3th iteration.
[0071] If the fitness gradient function value is less than the threshold value 0.0001, it can be determined that the improved mixed integer linear programming agricultural model converges, triggering the stop condition, outputting the best genotype, and decoding to obtain the best solution, namely the planting strategy.
[0072] The established planning model is solved by genetic algorithm to obtain the optimal genotype. In order to confirm whether the algorithm converges, the tracking curve of iterative fitness is drawn to track the population evolution.
[0073] In a specific embodiment, N=300, M=200, and a crop planting plan for a certain area is planned. The result is as follows: Figure 6 , that is, the algorithm is iterated and solved. It can be found that after a finite number of iterations, the model begins to converge, indicating that the effect is good.
[0074] Step S103, classifying the crop types in the crop data by using a K-means clustering method, and optimizing and adjusting the planting strategy in combination with the loss coefficient of the expected sales volume; Specifically, K-means clustering is performed on crops to divide crops with similar per-acre yield, cost, and unit price into different clusters, so as to identify the substitutability and complementarity between them, and optimize and adjust them in combination with the loss coefficient of expected sales volume; The core idea of K-means is to divide n objects in a data set into K clusters so that the sum of the distances from each object to the center of its cluster is minimized. It iteratively adjusts the distribution of clusters so that the data points within a cluster are as similar as possible, while the differences between data points between clusters are as large as possible.
[0075] In a specific embodiment, Figure 7 As shown in Figure 2, the basic process of K-means clustering is as follows: a. Determine the number of clusters: Divide the crop data into multiple clusters, that is, determine the K value; b. Initial centroid selection: randomly select K crop data points as the initial centroid; c. Data point allocation: Based on the Euclidean distance metric, each crop data point is divided into the cluster corresponding to the centroid closest to it, thus forming K clusters; d. Centroid update: recalculate the centroid of each cluster to get a new centroid, which is the mean of all crop data points in the corresponding cluster; e. Iterative optimization: Repeat steps c and d until the centroid position no longer changes significantly, i.e. convergence, or the set iteration limit is reached.
[0076] On this basis, the clustering results are further optimized and adjusted in combination with the loss coefficient of expected sales volume to better meet actual needs.
[0077] Among them, for any two points, their Euclidean distance is:
[0078] represents the coordinates of the i-th component of vector x, represents the coordinates of the i-th component of vector y, Represents the Euclidean distance between vector x and vector y.
[0079] In a specific embodiment, in order to select the optimal cluster number K, multiple cluster numbers are clustered cyclically, and the silhouette score is used for judgment, and the silhouette score change graph is obtained as shown in Figure 8 As shown. By observing the example graph, we can find that the slope is the largest when the number of categories is 2, indicating that the effect of dividing into 2 categories is the best. Fig. 9 As shown, from Fig. 9 It can be seen that the data of the two categories are clearly divided.
[0080] Crops in the same category should be considered to have strong substitutability. When they are planted in the same plot, they will compete for nutrient resources, and the expected sales of both crops will be reduced. Therefore, the invention introduces the expected sales loss coefficient to represent the reduction in the expected sales of crops:
[0081] in, and Respectively and The loss coefficient, Indicates the nth cluster and The distance between two points, Represents the maximum distance between all points in the nth cluster. As the maximum difference between the empirical distribution functions, T 1 It represents the first category after clustering. T 2 It represents the second category after clustering. When the distance between the points represented by two crops is closer, it means that the substitutability is stronger and the competition is more intense, then the coefficient is smaller and the loss is greater.
[0082] Step S104, analyzing the relationship between the planting cost, the sales price and the expected sales volume by using the KS test method and the Spearman correlation coefficient analysis method, so as to further optimize the planting strategy.
[0083] For correlation analysis, the present invention assumes that the expected sales volume of all types of crops have a similar relationship with the sales price and planting cost. In order to preliminarily measure the relationship between the expected sales volume, sales price and planting cost, the KS test is first used to determine the normal distribution of the three types of data, and then the correlation coefficient test is used accordingly.
[0084] The KS test is based on the maximum difference between the cumulative distribution functions of the two distributions. For a single sample test, the KS test compares the empirical cumulative distribution function of the sample with the theoretical cumulative distribution function, such as Fig.10 As shown, the calculation steps are as follows: 1. Calculate the empirical distribution function: Calculate the empirical distribution function F based on the sample data; 2. Compare distribution differences: Calculate the difference between the empirical distribution function F and the theoretical distribution function G; 3. Calculate the KS statistic: Calculate the maximum difference between the empirical distribution functions ; 4. Calculate the P value: Based on the KS statistic and sample size h to look up the table or calculate the P value by numerical method. If the P value is less than the significance level (such as 0.05), the null hypothesis is rejected, indicating that the sample does not conform to the theoretical distribution or the distributions of the two samples are different.
[0085] Among them, when the above quantities, i.e. expected sales volume, sales price and planting cost, do not satisfy the normal distribution, the Spearman correlation coefficient can be used to analyze the cost, unit price and sales volume, i.e. planting cost, sales unit price and expected sales volume, so as to further optimize the planting strategy.
[0086] Spearman is a nonparametric statistical method used to measure the monotonic relationship between two variables. It does not require the data to conform to a normal distribution or a linear relationship, so it is particularly effective when dealing with nonlinear data or non-normally distributed data. The formula for calculating the correlation size is:
[0087] represents the Spearman correlation coefficient, Indicates the rank (i.e., the position after sorting) of the two variables. The difference in ranks corresponding to the observations, h represents the sample size.
[0088] In a specific embodiment, the data is analyzed to finally obtain a correlation coefficient heat map, such as Fig.11 As shown, there is a positive correlation between cost and unit price, but the correlation is very weak. There is a negative correlation between cost and sales volume, and between sales volume and unit price, and the correlation is slightly weaker.
[0089] In a specific embodiment, the MILP agricultural planning model is constructed by integrating factors such as land conditions, crop relevance, sales conditions, cultivation environment and greenhouse types, and is displayed to users in real time through the cloud platform. The cloud platform supports users to manually input land condition information and also provides high-precision positioning reading functions.
[0090] Furthermore, in a specific embodiment, the crop planting strategy optimization system under multiple constraints provided by the present invention, in addition to including a model building module, a solution module, a first optimization module, and a second optimization module, also designs and implements a complete image acquisition, processing, and transmission subsystem based on an STM32F4 development board and an OV7670 camera module to meet the needs of high-precision terrain data acquisition. This subsystem, through the combination of hardware and software, can efficiently complete the functions of environmental image acquisition, format conversion, data transmission, and remote monitoring, providing reliable technical support for the acquisition and analysis of terrain data, see Fig.12 Reading flow chart for terrain data, Fig.12 The agricultural management cloud platform is the crop planting strategy optimization cloud platform under multiple constraints of the present invention.
[0091] Among them, the composition and working principle of this subsystem are as follows: 1. Image acquisition module: The core of the subsystem uses the OV7670 camera module to capture environmental images. The OV7670 is a low-power, cost-effective CMOS image sensor that supports the output of image data in RGB565 format. The camera module is connected to the STM32F4 development board through a hardware interface, and the collected image data is transmitted to the development board for processing in real time.
[0092] 2. Image processing module: As the main control unit, the STM32F4 development board is responsible for receiving the RGB565 format image data transmitted by OV7670 and converting it into BMP format through the built-in algorithm. BMP format is a common bitmap format with the characteristics of simple structure and strong compatibility, which is convenient for subsequent storage and analysis.
[0093] 3. Data transmission module: The subsystem supports multiple data transmission methods, such as: wired transmission, that is, uploading data to a local server or cloud platform through the communication module (such as UART, SPI or Ethernet interface) of the STM32F4 development board; wireless transmission, that is, remote data transmission through an extended wireless module (such as Wi-Fi, Bluetooth or 4G module), uploading the collected image data and other sensor data to the cloud platform for remote access and management.
[0094] 4. Data storage and processing: The data uploaded to the cloud platform will be used for model transfer learning. By analyzing and learning different terrain data, the subsystem can continuously optimize the algorithm, adapt to diverse terrain environments, and provide support for system updates. In addition, the cloud platform also supports long-term storage of data for subsequent query and analysis.
[0095] 5. Remote monitoring function: Users can access the cloud platform through the Internet to view the environmental images captured by the camera and other sensor data (such as temperature, humidity, air pressure, etc.) in real time. The subsystem provides a friendly user interface, supports remote monitoring and data visualization, and users can grasp the environmental conditions anytime and anywhere, realizing efficient remote management and decision support.
[0096] In a specific embodiment, rice and vegetables are planted in a plain area. Data such as plot area, soil type, and historical sales are input to the cloud platform; the mixed integer linear programming agricultural model is improved to automatically generate planting plans, optimize the planting ratio of rice and vegetables and plot distribution; the improved genetic algorithm converges after 2,000 generations of iterations, and outputs the optimal plan that increases total profit by 18%; the cloud platform monitors the risk of unsalable products in real time and dynamically adjusts the vegetable planting area for the second season.
[0097] In summary, the present invention solves the problem that existing planting strategies rely on experience or single factor analysis and do not make full use of modern mathematical theories and optimization algorithms. The method of the present invention is based on a cloud platform, and the back end adopts an improved mixed integer linear programming (MILP) model to integrate multiple constraints such as land conditions, crop correlation, sales conditions, cultivation environment and greenhouse type, and is combined with an improved genetic algorithm for auxiliary calculation, which can autonomously plan the optimal planting strategy for different scenarios. At the same time, considering the impact of crop correlation on the agricultural economy, the present invention further optimizes the planting strategy through cluster analysis and verification. For terrain recognition, the present invention provides two solutions: manual input and automatic recognition, and uploads the collected data to the cloud platform for model transfer learning to improve the adaptability and robustness of the model to different terrains. The present invention realizes the optimization of crop planting strategies under multiple constraints, provides farmers with efficient agricultural production solutions, and guarantees and improves their economic benefits.
[0098] It should be understood that although this specification is described according to various embodiments, not every embodiment contains only one independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation methods that can be understood by those skilled in the art.
[0099] The above implementation methods are only used to illustrate the embodiments of the present application, and are not limitations on the embodiments of the present application. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the spirit and scope of the embodiments of the present application. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present application. The scope of patent protection of the embodiments of the present application should be limited by the claims.
Claims
1. A method for optimizing crop planting strategies under multiple constraints, characterized in that: include: Input crop data into an improved mixed integer linear programming agricultural model, define the decision variables of the improved mixed integer linear programming agricultural model as a continuous variable including crop planting area and a discrete variable including whether to plant crops, the objective function of the improved mixed integer linear programming agricultural model is used to maximize the total profit of planting, and the multiple constraints of the improved mixed integer linear programming agricultural model include planting area constraints, yield constraints, continuous cropping restriction constraints, plot spacing constraints, rotation constraints, land type constraints and special planting requirement constraints for crop classification; Dynamically optimizing the improved mixed integer linear programming agricultural model by improving the genetic algorithm, and iteratively solving the planting strategy for the input crop data; Classifying the crop types in the crop data by using a K-means clustering method, and optimizing and adjusting the planting strategy in combination with the loss coefficient of the expected sales volume; The relationship between planting cost, sales price and the expected sales volume was analyzed by KS test and Spearman correlation coefficient analysis to further optimize the planting strategy.
2. The method according to claim 1, characterized in that Among the decision variables of the improved mixed integer linear programming agricultural model, the continuous variable Indicates Year Planting crops in The planted area on the plots is a discrete variable Indicates Year Is the crop in the Planting on plots, discrete variable The values are as follows: 。 3. The method according to claim 1, characterized in that The objective function of the improved mixed integer linear programming agricultural model is expressed as: ; in, represents the total profit of growing crops, Indicates the time of the tth year Planting crops in The yield per mu of land, Indicates Year time Planting crops in The planting area on the plot, Indicates Year time The unsold crops, Indicates Planting crops in The unit price of a plot of land, Indicates Planting crops in The cost of planting on a plot of land.
4. The method according to claim 3, characterized in that The multiple constraints of the improved mixed integer linear programming agricultural model include: Planting area constraints: the planting area of each crop cannot exceed the corresponding plot area: ; in, Indicates Year time Planting crops in The planting area on the plot, Indicates The size of the planting area of each plot; The planting area of each crop in a designated plot of land should meet the following requirements: ; Where n is the area coefficient, Indicates j The lower limit of the planting area of crops in a designated plot; Yield constraints: the output of each crop cannot exceed the expected sales volume of the year to reduce the situation of unsalable crops: ; ; in, Indicates the expected sales volume of the crops grown; Constraints on repeated cropping: Each crop cannot be planted continuously in the same plot of land, otherwise the yield will be reduced: ; in, It is a discrete variable of whether to plant or not, and it is forbidden to plant the same crop continuously on the same plot; The spacing between plots is constrained, and the planting plots of each crop are kept concentrated: After numbering each plot and the tillage type, calculate the maximum planting distance between two planting plots To ensure that crops are grown in concentrated plots: ; The maximum planting distance Indicates Year The maximum distance between crop plots, and The two plots are numbered respectively. are the cultivated land type numbers of the two plots respectively. and is the weight coefficient; ; in, D It represents the maximum spacing between all plots planted with the same crop in a given year; Rotation constraint, beans are planted once every three years on each plot: ; in, represents the set of all legume plants; Land type constraints are defined as follows: flat dry land, terraced fields and hillside land are only suitable for growing single-season food crops: ; in, represents the set of flat dry land types, represents the set of terraced fields, represents the set of cultivated land types as hillside land, Indicated in t Time, i Plots planted j The area of crops when planted; Among them, irrigated land is used to grow rice in one season or vegetable crops in two seasons: ; in, Indicates the set of irrigated land types; The special planting requirements of crop classification divide vegetables into vegetables with special planting conditions, recorded as special vegetables, and vegetables without special planting conditions, recorded as non-special vegetables: Among them, the planting requirements for the first and second seasons of irrigated land are: ; Requirements for planting in the first and second seasons of ordinary greenhouses: ; Smart greenhouse planting requirements: 。 5. The method according to claim 4, characterized in that The improved mixed integer linear programming agricultural model is expressed as: ; 。 6. The method according to claim 1, characterized in that The improved genetic algorithm is used to dynamically optimize the improved mixed integer linear programming agricultural model, and the planting strategy for the input crop data is iteratively solved, including: Performing chromosome encoding on the designable variables: performing chromosome encoding on the designable variables of the improved mixed integer linear programming agricultural model by using binary Gray encoding; Population initialization: According to the binary Gray coding method adopted, a set of initial chromosomes is randomly generated. The initial chromosomes represent individuals in the population. Each individual in the population is a potential planting strategy. Set the fitness function and calculate the fitness value of individuals in the population: Evaluate the fitness of each individual in the population by setting the fitness function, which is used to measure the quality of each individual; Elite retention strategy: adopting the elite retention strategy, retaining a group of individuals with the best performance from the current population as elite individuals to the next generation population, and increasing the number of retained elite individuals as the number of iterations increases, so as to accelerate the convergence speed of the improved mixed integer linear programming agricultural model; Linear sorting probability selection operation: All individuals in the population are sorted according to their fitness values, and the probability of each individual being selected for mating is determined by ranking linear gradient descent, where individuals with higher fitness values have a higher probability of being selected; Crossover and mutation operation: select individuals with high fitness values for crossover and mutation operations to generate new individuals; Individual retention: The generated new individuals and elite individuals form a new population and enter the next round of genetic iteration; Determine the stopping condition and output the optimal solution: use the gradient calculation based on the fitness value to determine whether the improved mixed integer linear programming agricultural model converges. If the fitness gradient function value is less than the preset threshold, the improved mixed integer linear programming agricultural model is judged to converge, the stopping condition is triggered, the optimal genotype is output, and the planting strategy is decoded.
7. The method according to claim 1, characterized in that The basic process of the K-means clustering method includes: a. Determine the number of clusters: Divide the crop data into multiple clusters, that is, determine the K value; b. Initial centroid selection: randomly select K crop data points as the initial centroid; c. Data point allocation: Based on the Euclidean distance metric, each crop data point is divided into the cluster corresponding to the centroid closest to it, thus forming K clusters; d. Centroid update: recalculate the centroid of each cluster to get a new centroid, which is the mean of all crop data points in the corresponding cluster; e. Iterative optimization: Repeat steps c and d until the centroid position converges or reaches the set iteration limit.
8. The method according to claim 1, characterized in that: The relationship between the planting cost, the sales price and the expected sales volume is analyzed by the KS test method and the Spearman correlation coefficient analysis method to further optimize the planting strategy, including: First, the KS test method is used to determine whether the expected sales volume, the sales price, and the planting cost conform to the normal distribution, wherein the calculation steps of the KS test method include: Calculate the empirical distribution function: Calculate the empirical distribution function F based on the sample data; Compare distribution differences: compare the difference between the empirical distribution function F and the theoretical distribution function G; Calculate the KS statistic: Determine the maximum difference between the empirical distribution function and the theoretical distribution function ; Calculate the P value: According to and sample size h, calculate the P value by table lookup or numerical method; When the expected sales volume, the sales price and the planting cost do not satisfy the normal distribution, the Spearman correlation coefficient analysis method is used to analyze the relationship between the planting cost, the sales unit price and the expected sales volume, so as to further optimize the planting strategy.
9. A system for optimizing crop planting strategies under multiple constraints, using the method for optimizing crop planting strategies under multiple constraints as claimed in any one of claims 1 to 8, characterized in that: include: A model building module, used for inputting crop data into an improved mixed integer linear programming agricultural model, defining the decision variables of the improved mixed integer linear programming agricultural model as a continuous variable including crop planting area and a discrete variable including whether to plant crops, the objective function of the improved mixed integer linear programming agricultural model is used to maximize the total planting profit, and the multiple constraints of the improved mixed integer linear programming agricultural model include planting area constraint, yield constraint, continuous cropping restriction constraint, plot spacing constraint, rotation constraint, land type constraint and special planting requirement constraint for crop classification; A solution module, used for dynamically optimizing the improved mixed integer linear programming agricultural model by improving the genetic algorithm, and iteratively solving the planting strategy for the input crop data; A first optimization module is used to classify the crop types in the crop data by using a K-means clustering method, and optimize and adjust the planting strategy in combination with a loss coefficient of expected sales volume; The second optimization module is used to analyze the relationship between the planting cost, the sales price and the expected sales volume through the KS test method and the Spearman correlation coefficient analysis method, so as to further optimize the planting strategy.
10. A cloud platform for optimizing crop planting strategies under multiple constraints, characterized in that: The cloud platform includes the crop planting strategy optimization system under multiple constraints as described in claim 9.
Citation Information
Cited By
Crop intelligent planting decision-making method and system
CN120612113A
An intelligent crop planting decision method and system
CN120612113B
Agricultural land utilization efficiency optimization analysis system based on multi-source data fusion
CN121189568A
Optimization analysis system for agricultural land use efficiency based on multi-source data fusion
CN121189568B