Frontiers in Computing and Intelligent Systems ISSN: 2832-6024 | Vol. 10, No. 3, 2024 59 An Exploration of Crop Planting Based on Simulated Annealing Algorithm and Mixed Integer Linear Programming Yifan Wei 1, †, *, Mingye Ji 1, †, Cuicui Wang 2, † 1 College of Mechanical Engineering, Tianjin Renai College, Tianjin, China 2 School of Economics and Management, Tianjin Renai College, Tianjin, China * Corresponding author: Yifan Wei (Email: 1979083882@qq.com) † These authors also contributed equally to this work Abstract: This paper is dedicated to exploring the optimal planting scheme of crops through the comprehensive use of various computer optimization algorithms, and is expected to provide a scientific decision-making basis for crop planting from 2024 to 2030. Firstly, based on Mixed Integer Linear Programming (MILP) and Simulated Annealing Algorithm, this paper analyzes the planting area and benefits of different crops based on the existing plot types and crop cultivation in rural arable land to find the optimal planting plan. Secondly, when facing the uncertainty factors of the future market, this paper quantifies the risk by dynamic programming and genetic algorithm, combining the parameters such as the sales price, planting cost and expected sales volume of the crops, to optimize the planting decision, and considering the substitutability and complementary relationship between the crops. Then, Pearson correlation coefficient and cross-elasticity coefficient are introduced to analyze the correlation between variables such as crop sales price and planting cost, and constrained optimization. Finally, integrating multiple model algorithms, this paper proposes a crop planting strategy that maximizes the comprehensive benefits. Keywords: Simulated Annealing Algorithm; Mixed Integer Linear Programming; Dynamic Programming; Genetic Algorithm; Pearson's Correlation Coefficient; Cross Elasticity Coefficient. 1. Optimization Analysis of Planting Scenarios This paper plans to find the best planting program for agricultural products by data analysis of data on crop planting and marketing of 1201 acres of cultivated land in the countryside. 1.1. Establishment of Planting Program 1.1.1. Determination of Decision Variables In solving the optimal planting program, the decision variable is positively related to the constraints and needs to be balanced with the cost, and production efficiency. represents the area in acres of the th crop planted on the th piece of land in year . This variable is a continuous variable, and its value can be taken as a percentage of the total area of the th piece of land. This variable is a continuous variable that can take values in the range of 0 and the available land area. is a binary variable that determines whether the th crop is planted on the th plot in year . This variable is used to determine whether the lth crop is planted on the th plot. The introduction of this variable allows the model to flexibly adjust the planting decision according to market demand, crop growth cycle and available resources. If a crop has a low demand in the current market or there is a planting conflict with other crops on the same land, the model can avoid planting that crop by setting 0. 1, if plot “ j” is planted with crop “ i” 0, otherwise (1) is a binary variable indicating whether a crop is planted on plot in year and the crop can be planted for two seasons: 1 ,If two seasons planted and crop ‘ i’ planted 0, otherwise (2) The scenario where the crop is grown for two seasons applies mainly to smart greenhouses (where vegetables can be grown for two seasons), which need to be distinguished by using a different binary variable Z for the greenhouses. 1.1.2. Determine the Parameters : the selling price of the th crop in year ; : the planting cost of the th crop in year ; : the expected sales volume of the th crop in year ; : the mu yield of the th crop in year . 1.1.3. Establishment of Constraints (1) Total cultivated area constraints The cultivated area of each plot in each year cannot exceed the total area: ∑ , ∀j, t (3) (2) Minimum limitation of crop planting area The planted area of each crop must not be smaller than the minimum area: min ⋅ , ∀i, j, t (4) (3) Crop suitable plot constraint The crop must be planted on a suitable plot: ⋅ 0 ′ , ∀t (5) (4) Crop re-cropping constraint 60 The same crop cannot be planted continuously in the same plot: 1, ∀i, j, t (6) Since here is the year, if two crops can be planted in a year, the following constraint is added: : denotes whether crop is planted in the th plot in season 1 of year . : denotes whether crop is planted in the th plot in season 2 of year . Two seasons in the same year are restricted to two seasons in a year, and the same crop cannot be planted: 1, ∀i, j, t (7) Here, the same crop cannot be grown in season 2 of year and season 1 of year 1. (5) Special grouping restriction for shed use Smart greenhouses can grow crops in two seasons, and the following constraints need to be introduced to distinguish the cultivation of smart greenhouses: , ∀i, j (8) 1, ∀j, t (9) This constraint ensures that each shed can grow two crops per year and that the shed is only allowed to select crops that meet the requirements. 1.1.4. The Objective Function for each year Scenario 1: In this scenario, it is assumed that when the production of a crop exceeds the expected sales volume, the excess cannot be sold (i.e., the crop is wasted). Therefore, there is a need to maximize the benefit to the extent that it can be sold properly. In case of stranded waste, the objective is: Maximize ∑ , ,   ⋅ min , ⋅ ⋅ ∑ , ,   ⋅ ⋅ (10) Scenario 2: In this scenario, it is assumed that the excess of sales over the expected sales volume can still be sold at 50% of the original price, so the benefit of the price reduction for the excess is considered while maximizing the benefit of the normal sales. When selling at a reduced price, the goal is to: Maximize ∑ , ,   ⋅ min , ⋅ ⋅ ∑ , ,   0.5 ⋅ ⋅ max 0, ⋅ ⋅ ∑ , ,   Cit ⋅ Aijt ⋅ Xijt (11) Specific explanation about the objective function: P : the selling price of crop in year , in Yuan/ton; : the acre yield of crop in year , in tons/acre. This value determines the amount of crop that can be produced per acre; : the acreage (in acres) of crop in year in plot . This is the decision variable that determines the amount of crop that can be produced per acre. This is the decision variable that determines how much acreage of crop will be planted on each plot; : a binary decision variable that indicates whether or not crop will be planted on plot in year ; and ,: the expected amount of crop to be sold in tons in year . This is the amount of each crop that can be marketed in the marketplace in year . This value determines the amount of crop that can be produced per acre. This is the maximum amount of each crop that can be normally sold in the market; ⋅ ⋅ : this is the total amount of the crop produced on plot . If this value exceeds , the exceeding part cannot be sold normally; C : the cultivation cost of crop in year (unit: yuan/acre); : the area of crop cultivated in the th plot. 1.1.5. General Objective of the Planning Model The overall objective is to maximize the total benefits over the period 2024 2030: max ∑   t (12) max ∑   t (13) 1.2. Planting Optimization Model Solution 1.2.1. Planting Analysis Results Presentation After determining the changes of decision variables, parameters, constraints and other uncertainties, we construct a model related to the optimal planting strategy for the future from 2024 to 2030, and solve it through the simulated annealing algorithm, and establish a model based on mixed integer programming (MILP), which is suitable for solving the problem of consecutive time periods, reflecting the optimal strategy of planting, as shown in Figure 1. Figure 1. Simulated annealing cruise trajectory To summarize the results of the analysis: this section involves a variety of uncertainties and aims to put limited land resources to full use to determine the optimal planting plan to maximize profits. Within the limited range of 1201 acres of land area and its sales, and to achieve the maximum production benefits derived from sales minus the cost of planting, subject to crop rotation, crop planting area, suitability of land, heavy cropping, the type of plot, the constraints of smart greenhouses, in order to cope with the factors brought about by the conditions of the market, climate, soil and other factors, the first season and the second season of a year, respectively, planted a variety of crops, such as wheat, vegetables and so on. From the results: in the first season, the main crops are planted, and the planted area accounts for a relatively large proportion of the area because maize and cereals are the dominant crops among the grains. 61 Compared to the first season, the area planted in the second season is greatly reduced, which may be affected by uncertainties such as climate, soil conditions, etc. Therefore, in the second season, some vegetables are started to be planted. 1.2.2. Maximum Yield Results Presentation There are three constraints in predicting the future planting scenario, the constraint of plot type, smart shed; the constraint of planting beans once in three years, etc.; and the constraint of planting area size. A mixed integer programming and simulated annealing model is built thus obtaining the total maximum profit (million dollars) for the next 7 years when the products sold are completely sold out as: max 3526.74 (14) When there is a lag in selling the product, the total maximum profit (million dollars) is: max 3238.96 (15) 2. Planting Uncertainty Analysis 2.1. Potential Risk Analysis 2.1.1. Constraints (1) Expected sales volume For wheat and corn, their sales volume is assumed to grow by 5% ∼ 10% per year. To capture this uncertainty, the annual sales volume is assumed to grow according to the random variable , where takes values ranging from 1.05 to 1.10. ⋅ ∈ 1.05,1.10 , ∀ ∈ 2024,⋯ ,2030 (16) For the other crops, the sales volume is relatively stable with a fluctuation range of 5%. Therefore, it is assumed that the fluctuation of sales volume is represented by the random variable , where takes values ranging from 0.95 to 1.05. ⋅ ∈ 0.95,1.05 , ∀ ∈ 2024,⋯ ,2030 (17) (2) Acre yield The acre yield of all crops fluctuates 10% per year and can be expressed as a random variable with values ranging from 0.9 to 1.1. ⋅ ∈ 0.9,1.1 , ∀ ∈ 2024,⋯ ,2030 (18) (3) Planting cost The planting cost of the crop increases by 5% per year, which can be calculated by the recursive formula: (19) (4) Selling prices The selling price of food crops is basically stable and is not modeled dynamically. The sales price of vegetable crops increases by about 5% per year, which can be represented by the random variable , where ∈ 1.05 , 1. 05 . ⋅ ∈ 1.05,1.05 , ∀ ∈ 2024,⋯ ,2030 (20) The sales price of edible mushroom crops decreases by 1- 5% per year, especially for morel mushrooms by 5%. Therefore, the random variable is used to denote the decline in the price of edible mushrooms: ⋅ 1 , ∈ 0.01,0.05 , ∀ ∈ 2024,⋯ ,2030 (21) 2.1.2. Objective Function By adding a risk penalty term to the objective function to balance the high return and high-risk penalty terms, the model will tend to reduce the overall planting program risk by selecting lower risk crop combinations. The objective function can be constructed by subtracting the risk penalty from the expected return. The objective function can be adjusted as: max ∑    ∑    ∑     ⋅ ⋅ ⋅ min 1, ⋅ ⋅ ⋅ ∑     ⋅ (22) The first part is the expected return of the crop, considering the uncertainty of prices, yields, sales and growing costs. The second part ⋅ ∑   ⋅ is the risk penalty term, where: is the risk index of crop ; is the risk coefficient, which is used to control the effect of risk on the objective function. If the value of is large, the model will be more conservative and tend to choose lower-risk crops; if the value of is small, the model will pay more attention to the return and be willing to take more risks. The risk index of crop can be expressed as a weighted sum of the following weights. ⋅ market ⋅ climate ⋅ pests ⋅ cost (23) 2.2. Uncertainty Solving and Analysis Figure 2. Data related to market turnover from 2013 to 2022 62 According to the farm related area in 2013 2022, the farm arable land area in China has slightly increased, and the state- owned farm arable land area has a total of 7,039 thousand hectares, of which the state-owned farms have a larger share of 5,108 thousand hectares of grain crops sown. As can be seen from the market price icons of previous years, the production price index of agricultural products and grains fluctuates a lot, especially in 2021 when the production price index of corn reached 126. As can be seen from Figure 2, the market turnover of agricultural products fluctuates year by year but the overall trend is growth, and the market turnover of vegetables is more stable with little fluctuation. Figure 3. Optimal cruising trajectory map Figure 4. Optimal cruise trajectory map The market price fluctuation every year, the influence of climate and pests and diseases and other factors will make the price fluctuate greatly, which will have an impact on the overall profit. Analyzing the impact of the market, pests and diseases, climate, and market in previous years, as shown in Figure 3: climate risk has the greatest impact on all crops. Vegetables and Climate risk has the greatest impact on all crops. Especially vegetables and edible mushrooms. This is because vegetables and edibles are more demanding and vulnerable to climate change, while climate has a lower impact on wheat and maize, and pests and diseases have a higher impact on vegetables, followed by edibles. So, crops such as vegetables require more protection and incur more costs. It costs more to grow these crops, so there is also a greater cost risk. Market risk has less impact on all crops, especially wheat and corn, indicating that the market prices of wheat and corn are relatively stable. Vegetables, on the other hand, and edibles have more volatile market prices, which can affect the choices made when planting and control yields. The optimal cruising trajectory graph established by genetic algorithm is shown in Figure 4, which can optimize the path of its cruising for planting and derive the optimal planting strategy, considering that there are different types of plots such as up-slope land, irrigated land, terraced land, and flat drought etc., and the different colors in the graph indicate the different types of plots. Starting from the uncertainty factors such as climate, pests and diseases, and market fluctuations. As can be seen from the figure, the blue line is the optimal cruising path, which passes through several plots, and the goal is to make the cruising path maximize the adaptability and avoid high-risk areas. New constraints are introduced under the constraints of the previous model to increase the impact of risk on crop yield and sales, which makes the prediction of the maximum profit for the next seven years in the previous model more complete. The maximum profit for each year is reduced because of various risks, but because some risks are uncontrollable, the maximum total profit for seven years (million dollars) is derived in: max 2765.28,3175.42 (24) 3. Correlation and Substitutability Analysis 3.1. Establishing Correlation 3.1.1. Application of Pearson's Correlation Coefficient First, according to the correlation analysis in the text, by combining historical data, and then get the sales volume, planting cost and sales price data, followed by the introduction of Pearson correlation coefficient to analyze the correlation between the sales volume, planting cost and sales price of crops. The Pearson correlation coefficient is calculated as follows: 63 , (25) Correlation between sales price and sales volume: , (26) Correlation of planting cost with sales volume: , (27) is the sales volume of the crop; is the sales price of the crop; Cov , is the covariance between sales volume and price; and are the standard deviation of sales volume and price, respectively; is the planting cost of the crop; is the sales price of the crop; Cov , is the covariance between planting cost and price. 3.1.2. Cross Elasticity Coefficient The algorithm uses crop substitution measurement and crop complementarity measurement to find the variables suitable for substitution and the variables suitable for complementarity, which in turn increase the revenue of their crops and provide effective data for the subsequent objective function to determine the variables. The cross-elasticity formula is as follows: ∆ / ∆ / (28) Complementarity coefficient calculation: (29) 3.2. Determination of Objective Function Based on Correlation Analysis Based on the previous objective function, the objective function after adding the influence of correlation factor can be written as: maxZ ∑    ∑    ∑     ⋅ ⋅ ⋅ min 1, ⋅ ⋅ ∑     ⋅ (30) Where. Sales volume : The formula ⋅ 1 is introduced to describe the correlation between sales volume and price through the correlation with price. Cost of cultivation : The equation ⋅ 1 is introduced through the correlation with price, describing the correlation between cost and price. Complementary benefits: ⋅ ⋅ , introducing complementary benefits between crops. 3.3. Constraints (1) Substitutability constraint Crops are substitutable for each other and cannot be grown on the same plot at the same time, adding the following constraints: 1, ∀ , (31) (2) Complementarity constraint Complementary crops generate additional benefits between each other, so the correlation constraint is added and reacted in its objective function, and the additional benefit generated between complementary crops is . (3) Sales volume and price correlation constraints There is often a positive correlation between market demand and price. (4) Planting cost and price correlation constraints Planting cost and price tend to be negatively correlated. The is the correlation coefficient between sales volume and price calculated from historical data. 3.4. The Results Demonstrate Figure 5. Correlation between sales volume and sales price From the analysis of Figure 5: According to Spearman correlation analysis, the correlation coefficient between sales volume and sales price is -0.796, this calculation shows that there is a negative correlation between sales volume and sales price. When sales volume increases, sales price decreases; when sales volume decreases, sales price increases. 3.5. Conclusion Macro Analysis Correlation Under uncertainty, increased consideration of substitutability and complementarity between crops reveals a negative correlation between sales volume and sales price, and a positive correlation between cost and sales price. With this condition to further organize the optimization model and data to get the optimal planting plan and find the maximum profit (million yuan) as: max 4217.69 (32) When the reasonable arrangement of sales volume, sales price and cost can have a great increase in the total profit. 4. Conclusion In this study, the planting strategy of rural crops is deeply explored by simulated annealing algorithm and mixed integer linear programming (MILP). Firstly, the data of arable land type, planting area, yield and cost were analyzed with the help of MILP algorithm, and the optimal planting plan in 2023 was clarified, and the maximum revenue could reach 37,267,400 yuan. Secondly, combining dynamic programming and genetic algorithm, the sales price and market trend in the next 5 to 10 years were studied, considering the climate, market demand and other risk factors, and predicting the maximum total return between 29,652,800 yuan and 33,754,200 yuan. In addition, through the application of Pearson's correlation coefficient and cross-elasticity coefficient, the relationship between crop sales price and planting cost was analyzed, and 64 alternative and complementary crops were identified to further optimize planting decisions. References [1] Cheng Yongfeng, Wu Xinyun,Xiong Caiquan. A linear mixed- integer programming algorithm for solving the minimum dominating set [J]. Journal of Hubei University of Technology, 2022, 37(01): 29-33. [2] XI Feng, LIN Fengchun. Research on dynamic cooperative path planning combining simulated annealing algorithm and genetic algorithm[J]. Ship Science and Technology, 2024, 46 (19):161-164. [3] LI Mengxia, WANG Xiaoyu, ZENG Junguo. Research on dynamic path planning for logistics based on heuristic variable neighborhood search[J]. China Aviation Weekly, 2024, (31): 88-90. [4] LI Jiayang, WANG Zhenhua, ZHANG Jihong, et al. Optimal water distribution analysis of canal system based on improved adaptive genetic algorithm[J/OL]. Journal of Irrigation and Drainage Machinery Engineering,1-8[2024-11-22]. http: // kns. cnki. net/ kcms/ detail/ 32. 1814. TH. 20241119.1508.002.html. [5] ZHAO Li, WANG Xiaogang, WANG Ning,et al. Fully generalized spatial modulation visible optical communication system based on Pearson correlation coefficient selection[J]. Journal of Optics,2024,44(04):116-124. [6] Pan Lin, Ma Shihua, Leng Kaijun, et al. Manufacturers' alliance pricing decision problem in many-to-one supply chain considering demand cross-elasticity[J]. Management Review, 2021, 33(10): 313-324.DOI: 10.14120/j.cnki.cn11-5057/f. 2021. 10.025.