Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 13, No. 2, 2024 113 Research on Optimal Crop Planting Strategy Based on Linear Programming with Sample Average Approximation Shi Chen1, *, Kengtai Peng2 1School of Automation, Guangdong University of Technology, Guangzhou, China 2School of Computer Science and Technology, Guangdong University of Technology, Guangzhou, China *Corresponding author: 2470683884@qq.com Abstract: Using linear programming, sample average approximation and other methods, this paper mainly focuses on the optimization of crop planting strategies in China, and conducts in-depth research to formulate the optimal planting scheme for the period from 2024 to 2030. Firstly, we preprocesses data on rural plot types and crop characteristics, and proposes the optimal crop planting scheme based on linear programming by considering crop sales, planting costs, mu yield, etc. Subsequently, this paper introduces uncertainties such as fluctuations in market demand and climate change, and constructs a dynamic planning model of planting scheme through the Sample Average Approximation (SAA) method. Finally, combined with the correlation analysis between crops, this paper proposes a comprehensive optimization model of planting scheme based on Spearman correlation, which effectively improves the overall return and ensures the robustness of the scheme. Keywords: Linear Programming, Cluster Analysis, Sample Average Approximation, Correlation Analysis. 1. Introduction With the development of agricultural markets and the increase in crop diversity, rural crop planting decisions have become more complex. Especially under such special geographic and climatic conditions as the mountainous regions of North China, a reasonable planting strategy not only needs to consider geographic and climatic conditions, but also needs to face fluctuations in market demand, crop yields and cost changes. In this study, we first pre-processed data on rural land types and crop attributes, and designed an optimal crop planting plan using linear programming methods, taking into account factors such as crop sales, planting costs and yields [1-2]. Then, considering the volatility of market demand and the uncertainty of climate, this paper used the sample average approximation (SAA) method to construct a dynamic planning model to cope with these uncertainties [3- 4]. Finally, by analyzing the correlation among different crops and combining with Spearman correlation analysis, this paper proposes a comprehensive and optimized planting scheme model, aiming to improve the overall return and ensure the stability of the scheme [5-6]. 2. Optimization Model of Crop Planting Scheme Based on Linear Programming We first collected and obtained the type, area, and type of crops that can be planted in 34 plots in a village in the mountainous region of North China, as well as 2023 planting information related to each type of crop, including planting plots, planting area, acreage, and planting cost. Table 1 shows some of the data collected, including information on the land number, plot type, and acre yield of the hill village. Table 1. Information on land and crops to be planted in 2023 in a rural area in China Crop name Plot type Planting season Yield per mu/kg Cost/RMB Unit price/Yuan Planting area Crop type Whether legume soya bean semi-arid Single season 400 400 2.50-4.50 72 Grain yes black soya bean semi-arid Single season 500 500 6.50-8.50 0 Grain yes Red beans semi-arid Single season 400 400 7.50-9.00 0 Grain yes Mung beans semi-arid Single season 350 350 6.00-8.00 68 Grain yes Crawler beans semi-arid Single season 415 415 6.00-7.50 0 Grain yes Wheat semi-arid Single season 800 800 3.00-4.00 80 Grain no Corn semi-arid Single season 1000 1000 2.50-3.50 90 Grain no Grain semi-arid Single season 400 400 6.00-7.50 55 Grain no Sorghum semi-arid Single season 630 630 5.50-6.50 0 Grain no Millet semi-arid Single season 525 525 6.50-8.50 0 Grain no Buckwheat semi-arid Single season 110 110 30.0-50.0 0 Grain no Pumpkin semi-arid Single season 3000 3000 1.00-2.00 0 Grain no Sweet potato semi-arid Single season 2200 2200 2.50-4.00 0 Grain no Shinola semi-arid Single season 420 420 5.00-6.00 0 Grain no Barley semi-arid Single season 525 525 3.00-4.00 0 Grain no 114 2.1. Data preprocessing based on cluster analysis In order to handle the large amount of complex data collected, optimize the planting scheme and simplify the decision-making process, we used the K-means clustering algorithm to classify the plots and crops. We labeled different lands and then normalized the area and serial number information before using it for cluster analysis. The land types are divided into four clusters and visualized as shown in Figure 1. Figure 1. K-means clustering of land types After land clustering, different plots are divided into 4 clusters, the leftmost center has the advantage of being able to grow in two seasons while having no land constraints and the disadvantage of having a smaller area, while the rightmost center has the advantage of having a large area but is affected by various aspects like land constraints, climate constraints etc. From left to right, each cluster center represents an increase in land area and constraints. Considering the above factors, we can achieve greater benefits by planning the land properly when planting. Since there are crops characterized by three dimensions: acre yield, selling price, and planting cost, we label different crops and then perform PCA dimensionality reduction on the crop data before using it for cluster analysis. As shown in Figure 2, the crop information is divided into four clusters and visualized. Figure 2. K-means clustering of crops based on PCA dimensionality reduction In the figure of clustering after downscaling crops using PCA, the crops are divided into 4 categories and are more concentrated. The 4 clustering centers are defined in order from the left as high economic efficiency center, medium- high economic efficiency center, medium-low economic efficiency center, and low economic efficiency center. On this basis, planting can be considered to plant more high economic efficiency crops to increase profits, while other crops are subject to constraints to ensure that relatively more efficient crops can be planted relatively more. 2.2. Optimal crop planting scheme based on linear programming Planning for optimal crop cultivation involves careful matching of different types of plots and crops. We categorize all plots of land into five main types: flat and dry land, terraced land, hillside land, irrigated land, and greenhouses (including ordinary greenhouses and smart greenhouses), each of which has its own specific suitability for crop cultivation. For example, flat dry land, terraced land and hillside land are suitable for growing food crops in one season a year, but not rice; watered land is flexible and can be used to grow one season of rice or two seasons of vegetables; and greenhouses, both ordinary and smart, are suitable for growing vegetables and edible mushrooms in two seasons a year (with the exception of Chinese cabbages, white radishes and carrots). In the following model, we defined decision variables and constructed objective functions and constraints based on sales volume, acreage and cost, and finally solved the optimal planting strategy by maximizing the profit from crop sales. Define the decision variable, , , 1 if plot i plants is crop j in season t 0 else i j tx     (1) where i, j,kx denotes the i -th plot; j {1, , }m  denotes the crop; {1,2}t denotes the season, 1t  is the first season and 2t  is the second season. The objective function is to maximize the total return, which consists of the revenue from the sale of the crop minus the cost of growing it:  j j j i, j,k i, j,k max p v C x   (2) where jp is the unit yield of the 𝑗 -th crop; jv is the market price of the 𝑗-th crop; jC is the cost of growing the 𝑗-th crop; , ,i j kx is the i-th area of crop planted in the 𝑘-th season of 𝑗-th plot. In order to make the constructed linear programming model fit the specific situation of the village, we propose a complete rich set of constraints as follows: (1) Climate and crop seasonal constraints As the countryside is located in the mountainous region of northern China, where temperatures are low all year round, most of the arable land is limited to one crop season per year. Therefore, open cropland is constrained to a single cropping season per year, except for two seasons of vegetables that may 115 be grown on watered land. The constraints are as follows:  , ,2 flat and dry land, terraced land, hillside land open cropland , ,0i j jx j S S    (3) where  denotes the type of plot and jS denotes the area of the 𝑗-th plot, the above equation indicates that for flat dry land, terraced land, and hillside type of plots, they can only be planted in the first season and no crop can be planted in the second season. (2) Plot type and crop suitability constraints Depending on the type of plot, there exists a specific suitability for crop cultivation. Flat drylands, terraces, hillsides: only food crops can be grown, and rice cannot be grown. Watered land: can grow one season of rice or two seasons of vegetables, of which the first season can grow a variety of vegetables, except cabbage, white radish and carrot, and the second season can only grow cabbage, white radish or carrot. The constraints are: i, j,2x 0 j , , ,cabbage whiteradish redradish wateredlandi      (4) where , ,cabbage whiteradish redradish   are the types of produce as cabbage, white radish, and red radish respectively. Depending on the type of plot, there are specific restrictions on crops and seasons. Flat drylands, terraces, hillsides Only single-season grain crops may be grown, not rice. And only the first season's crop can be grown, not the second season:     i, j,1 rice Flat drylands terraces hillsides i, j,2 Flat drylands terraces hillsides x 0, j if i , , x 0, j if i , ,                 (5) Watered land It is possible to grow a single season of rice or two seasons of vegetables. If you choose to grow rice, you can only grow it for one season and for the first season. vegetables rice i, j,2 watered land rice i, j,1 i, j,2 i, j,1 j j x 0 j if i , j x x 0 if x 0                    (6) If you grow two seasons of vegetables, you can grow a variety of vegetables in the first season, but not cabbage, white radish or carrot, and in the second season you can only grow one of cabbage, white radish or carrot.     i, j,1 cabbage white radish carrot watered land i, j,2 cabbage white radish carrot watered land x 0, j , , i x 0, j , , i                 (7) General shed A wide variety of vegetables can be grown in the first season, with the exception of cabbage, white radishes, and carrots:  i, j,i cabbage , white radish carrot General shed ,x 0 j , , , i      (8) Only edibles can be grown in the second season: i, j,2 edibles General shed ,x 0 j ,i    (9) Intelligent greenhouses Smart greenhouses can grow two seasons of vegetables per year, but not cabbages, white radishes or carrots:  i, j,i cabbage , white radish carrot Intelligent greenhouses x 0, j , , , i      (10) (3) Limitations of greenhouse cultivation The growing requirements for ordinary greenhouses and smart greenhouses are different respectively. Ordinary greenhouses can grow a variety of vegetables (except cabbage, white radish and carrot) in the first season, and can only grow edible mushrooms in the second season. Edible fungi can only be planted in the fall and winter. Smart greenhouses can grow two seasons of vegetables per year, except cabbage, white radish and carrot. The constraints are:     i, j,i cabbage , white radish carrot General shed i, j,2 edibles General shed i, j,i cabbage , white radish carrot Intelligent greenhouses , x 0, j , , , i x 0 j , i x 0, j , , , i                          (11) Crop rotation requirements for legumes Legumes benefit the soil and are required to be planted on each plot at least once every three years:   legumles 3 i, j,k each plot k 1 j ,x 1 i        k (12) This means at least one legume planting in three years within each plot. Crop heavy cropping restrictions The same crop cannot be grown consecutively in the same plot or shed each season to avoid yield reductions caused by heavy cropping. The constraints are: i, j,k i, j,k 1 ,x x 0 i, j   (13) Indicates that the same crop cannot be grown in the same plot for two consecutive seasons. Limitations of decentralized cultivation For ease of management and cultivation, each crop should not be spread too thinly each season, i.e., the number of crops planted on a plot should not be too high. The constraints are: i, j,k max i x i, k.   (14) where max  indicates the maximum number of crop species that can be grown per plot per season. Minimum planting area for a single plot The acreage of each crop in a single plot must be greater than a certain minimum , for example: This constraint ensures that the crop is not planted too small to be manageable. 116 i, j,k min i, j,kx S i, j,k if x 0.  , (15) Market demand constraints The total production of a crop should not exceed the market demand, defining the market demand coefficient for a crop, the relationship between production and demand is: i, j,k j j i i x p ?S j.     (16) where i is the market demand coefficient and jp is the unit yield of crop 𝑖 . To obtain the appropriate market demand coefficient, corn and soybean demand from 2021 to 2023 were analyzed and their average values were taken to obtain the projected market demand coefficient of 2.3%. By using these constraints and objective functions to ensure that crop suitability, seasonality and crop rotation requirements are met in different plot types and seasons while maximizing the total return, we obtained the optimal planting strategy and profit obtained for each season between the three years 2024-2026. The optimal planting scheme solved by the linear programming model yields a profit in each quarter, and the total profit obtained in all quarters is ¥7851693.87. 3. A Dynamic Planning Model for Planting Schemes Based on Sample Average Approximation In order to simulate the impact of market and climate fluctuations on planting strategies, this paper introduces the fluctuating factors of planting cost, selling price, and acreage. We optimize the planting scheme from 2024 to 2030 by dealing with multiple uncertainties through the Sample Average Approximation (SAA) method, which transforms the stochastic crop optimization problem into a deterministic problem to solve. The planting scheme is adjusted year by year through dynamic planning to ensure the robustness of the optimal crop combination. The sample average approximation algorithm is a method for dealing with optimization problems containing random variables. It transforms the original stochastic optimization problem into a deterministic optimization problem to be solved by taking a set of samples from the probability distribution of the random variable and then using the average of these samples to approximate the expected value of the objective function or constraint in the original problem. Define the objective function as:    a bN N2030 yab yab yab yab yab y 2024 a 1 b 1 max min P ,?T V C ?S .         (17) where 𝑦 is the year (2024~2030); 𝑝 is the plot number; 𝑐 is the crop number; ypcP is the total production of the crop grown on the plot 𝑝 in year 𝑦 ; ypcT is the sales volume of the crop c in year 𝑦; ypcP is the sales price of the crop 𝑦 in year 𝑐 ; ypcC is the planting cost of the crop 𝑐 in year 𝑦 ; ypcA and is the area of the 𝑐 crop grown on the plot 𝑝. Probabilistic modeling of variables such as crop prices, yields, and planting costs based on historical data is sampled from known distributions to generate samples. For each sample scenario, we compute its objective function and then construct the sample average objective function:       a bN NN 2030 i yab yab yab yab yab i 1 y 2024 a 1 b 1 1 min P ,?T V C ?S . N            (18) The main fluctuations considered are as follows: Crop yields and fluctuations Each crop's acreage is affected from year to year by weather, climate, and other factors, so we assumed that acreage fluctuates by ±10%:  yab b yab y yP p ?S 1 , [ 0.1,0.1].       (19) y is the fluctuation of acreage yield in 𝑦 -th year, assuming a random variable of [-0.1, 0.1]. Crop sales volumes and fluctuations The market demand (sales volume) for each crop is also subject to some uncertainty. For food crops, it is assumed that sales volumes will grow at a rate of 5 to 10 percent per year; for other crops, sales volumes will vary within a range of ±5 percent:  yab b y food crops y yT T 1 , if b [0.05,0.1]; else [ 0.05,0.1]         (20) where bT is the initial sales volume for the 2023 crop; is the fluctuation in sales volume in year. The sales price of vegetable crops grows at a rate of 5% per year, whereas the price of edible mushroom crops decreases at a rate of 1% to 5% per year, especially for morel mushrooms, where the price decreases by 5% per year:   1 1 . y yab b bV V     (21) where bV is the sales price of the crop in 2023; b is the rate of price increase or decrease for the crop : for vegetables 0.05b  , for morels 0.05b   and for other edibles [ 0.05, 0.01]b    . Crop cultivation costs and fluctuations Annual planting costs will increase with market conditions, assuming a 5% annual increase in planting costs: y 1 yab bC C 1.05 .  (22) where bC is the per-acre planting cost for the 2023 crop. The optimal acreage is found by solving the sample-averaged objective function to maximize the overall return under multiple market scenarios. We find that the solution does not change much as the sample size increases and hence the solution is more robust. Based on the profit obtained for each quarter of the dynamically planned optimal planting scenario, the total profit obtained for all quarters was¥10,648,019.72. According to the law of large numbers, as the number of samples increases, the sample mean approximation converges to the true expectation, ensuring the validity of the SAA method. 117 4. A Comprehensive Optimization Model for Planting Scenarios Considering Substitutability and Complementarity A comprehensive optimization model for planting scenarios considering substitutability and complementarity In actual agricultural practice, certain crops have the potential to substitute for each other. This means that one crop can be grown in place of another under certain circumstances or conditions and this substitution does not significantly affect the efficiency, economic benefits or ecological balance of the agricultural output. Spearman's correlation coefficient analysis captures the relationship between crops more accurately, quantifying their complementarities and mutual exclusivities. The correlation matrix provides a scientific basis for crop planting decisions and helps optimize planting combinations to maximize returns. To assess the substitutability of different crops, we utilized the following complementarity coefficients defined below:  max 0, .ij ij  (23) If 0ij  , then the crops i and j are complementary and the complementarity coefficient is positive, otherwise the complementarity coefficient is 0. Similarly, we define the mutual exclusivity coefficient:  max 0, . ij ij   (24) If 0ij  , then the crops i and j are mutually exclusive and the coefficient of mutual exclusivity is positive, otherwise the coefficient of mutual exclusivity is 0. Combining the Spearman's correlation coefficient and the gain model discussed earlier, the final optimization model is:   n n n 1 1 1, n total limit 1 max z x x x x x subject to x ?S , x 0 , x x ?S if 0 i i ij i j ij i j i i j j i i i i j ij i i                             (25) where zi denotes the basic unit area yield of the crop 𝑖 and 𝑆 is the total available cropland area. In practical applications, the optimal planting strategy can be derived by combining the historical data of crops and dynamically adjusting and to adapt to different planting conditions and market demands. In practice, the optimal planting strategy can be derived by combining historical crop data and dynamically adjusting and adapting to different growing conditions and market demands. The total profit gained for all seasons is¥12,149,126.90. 5. Conclusions In this paper, a set of optimized crop planting strategies is proposed for planting planning in the mountainous regions of North China from 2024 to 2030 through cluster analysis, linear programming, the present mean approximation method and Spearman correlation analysis. It is shown that by introducing uncertainty factors and analyzing complementarities among crops, it can effectively improve returns and maintain the robustness of planting strategies under market fluctuations. References [1] Wang Xiaoming, Zhang San. Research on ecological optimization of crop cultivation [J]. Agricultural Science, 2019(5): 45-50. [2] Zhou Xue, Zhao Yongman, Wang Xiangyang. Research on the equipping of agricultural machinery of 105 regiment based on mathematical planning method[J]. Xinjiang Agricultural Mechanization,2018,(01):36-39. [3] Li Hua. Research on agricultural optimization model based on dynamic planning [D]. Peking University, 2021. [4] Yang Yijiang,Yang Yiwen. Dynamic planning model and its application in determining the best planting scheme for crops[J]. Guangdong Chemical Industry,2013,40(14):70-71. [5] Xu Weichao. A review of correlation coefficient research [J]. Journal of Guangdong University of Technology,2012,(3): 12- 17. [6] Zhang Zhengjia, Chi Liang, Yang Haicheng, et al. Analysis of spatial and temporal changes in crop cropping structure in the Yellow Huaihai region[J/OL]. China Agricultural Resources and Zoning,1-10.