Next Article in Journal
Exploring Imperatives in Generation Z’s Approach to the Future of the Environment
Previous Article in Journal
Sustainable Management of Fruit By-Products Through Design Thinking: Development of an Innovative Food Product
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Agroecosystem Modeling and Sustainable Optimization: An Empirical Study Based on XGBoost and EEBS Model

School of Computer Science and Engineering, Guangdong Ocean University, Zhanjiang 529500, China
*
Author to whom correspondence should be addressed.
Sustainability 2025, 17(15), 7170; https://doi.org/10.3390/su17157170
Submission received: 30 June 2025 / Revised: 3 August 2025 / Accepted: 5 August 2025 / Published: 7 August 2025
(This article belongs to the Section Sustainable Agriculture)

Abstract

As agricultural land continues to expand, the conversion of forests to farmland has intensified, significantly altering the structure and function of agroecosystems. However, the dynamic ecological responses and their interactions with economic outcomes remain insufficiently modeled. This study proposes an integrated framework that combines a dynamic food web model with the Eco-Economic Benefit and Sustainability (EEBS) model, utilizing empirical data from Brazil and Ghana. A system of ordinary differential equations solved using the fourth-order Runge–Kutta method was employed to simulate species interactions and energy flows under various land management strategies. Reintroducing key species (e.g., the seven-spot ladybird and ragweed) improved ecosystem stability to over 90%, with soil fertility recovery reaching 95%. In herbicide-free scenarios, introducing natural predators such as bats and birds mitigated disturbances and promoted ecological balance. Using XGBoost (Extreme Gradient Boosting) to analyze 200-day community dynamics, pest control, resource allocation, and chemical disturbance were identified as dominant drivers. EEBS-based multi-scenario optimization revealed that organic farming achieves the highest alignment between ecological restoration and economic benefits. The model demonstrated strong predictive power ( R 2 = 0.9619, RMSE = 0.0330), offering a quantitative basis for green agricultural transitions and sustainable agroecosystem management.

1. Introduction

Against the backdrop of global population growth and increasing demand for food security, the scale of agricultural land has rapidly expanded, and the conversion of forests into farmland has become one of the predominant processes of land-use change in tropical and subtropical regions [1,2,3]. According to the Food and Agriculture Organization of the United Nations (FAO), between 2000 and 2020, global agricultural expansion accounted for nearly 90% of net forest loss, with approximately 70% of this forest conversion occurring in Latin America and Africa [4,5]. Numerous studies have shown that such transformations significantly weaken the carbon sequestration capacity of regional ecosystems. For instance, in tropical regions, soil carbon storage in farmland has decreased by 30–50% compared to forests [6], with an average annual net carbon release of 1.0–2.2 Pg C yr−1 [7]. These changes also result in habitat fragmentation, loss of species diversity, and degradation of ecological network structures [8]. Current modeling studies still lack systematic quantification of restoration pathways and ecosystem–agriculture synergies across different time scales [9].
In modern intensive agricultural systems, chemical inputs, including herbicides, insecticides, and fertilizers, are still widely used to achieve high yields. According to FAOSTAT data from the FAO, global agricultural use of active pesticide ingredients reached approximately 3.7 million tons in 2022, with pesticide application intensity per unit area continuing to rise in tropical regions [10]. However, this widespread use has also led to a marked decrease in soil pH and a significant decline in microbial diversity indices [11]. Furthermore, studies have shown that the abundance of predators and pollinators in agricultural habitats has decreased by more than 60% compared to natural ecosystems [12]. Current research primarily focuses on the impacts of single-factor disturbances or static system states. In contrast, studies simulating the dynamic responses of ecosystems to complex disturbance interactions—such as resource competition, predation pressure, and human intervention—remain limited [13,14,15]. To address this gap, dynamic modeling with differential equations and field data is crucial for the quantification of species population changes and energy flows during the transition from forest to farmland [16,17].
At the same time, biological control strategies are regarded as critical alternative solutions for promoting the transition to green agriculture and reducing reliance on chemical inputs. Previous studies have shown that, within a particular spatial scale, the introduction of a single functional predator species (such as birds or bats) can reduce pest population densities by 20–40%, significantly enhancing system stability and self-regulation capacity [18,19,20]. However, most existing models are confined to short-term cycles and single-species intervention scenarios, lacking integrated simulations of collaborative mechanisms among functional species across multi-trophic structures [21]. Additionally, the competitive impacts of invasive plants such as ragweed have long been underestimated. According to survey data from the U.S. Department of Agriculture, ragweed has colonized approximately 12 million hectares of farmland in North America, leading to an average 22% reduction in crop yields and disrupting local plant communities by altering nutrient cycling processes [22,23]. However, the mechanisms by which it acts as a disturbance factor in agricultural ecosystems have yet to be effectively incorporated into ecological modeling frameworks.
To address the challenges mentioned above, this study develops a multi-trophic dynamic food web model that, for the first time, systematically incorporates the resource competition effects of invasive plants (such as ragweed) into an ecological evolution framework [24,25]. The model is solved using the fourth-order Runge–Kutta numerical method and calibrated with field data from Brazil and Ghana to simulate the dynamic evolution of ecosystem stability during the conversion of forests to farmland. In the modeling process, key ecological indicators—including biomass, soil nutrient content, and predation rates—were collected for representative species such as ladybugs, pests, ragweed, and native plants. The simulation period spans 200 days, capturing the ecological succession patterns of the system under medium-term disturbance scenarios. The study uses XGBoost to analyze feature importance across different scenarios, pinpointing pest pressure, nutrient competition, and chemical interventions as key drivers of ecosystem stability [26,27]. This method improves model interpretability by capturing nonlinear ecological and agricultural interactions while ensuring theoretical consistency. On this basis, an Ecological–Economic Benefit and Sustainability (EEBS) model is proposed, integrating multi-dimensional indicators such as crop yield, ecological stability, and ecosystem service functions. Unlike previous dual-objective models that treat environmental and economic outcomes in a loosely coupled manner, EEBS structurally embeds ecological stability indicators (e.g., biodiversity, soil health, and pest regulation) alongside economic returns, enabling quantitative assessment of trade-offs and synergies. This model is used to systematically evaluate the environmental and economic synergy pathways under a composite management strategy that combines organic agriculture with biological control.

2. Study Area and Data Preparation

2.1. Selection of Study Areas

This study focuses on two regions from different continents that have experienced significant forest-to-farmland conversions in order to validate the applicability and robustness of the proposed modeling framework. As illustrated in Figure 1, global forest cover has undergone notable changes, particularly in developing countries, underscoring the representativeness of the selected areas [28]. The two countries chosen are Brazil and Ghana, representing distinct agricultural development patterns: the former is characterized by large-scale mechanized agriculture in an emerging economy, while the latter exemplifies smallholder-driven agricultural expansion in a lower-income setting. These countries differ in their ecological conditions, policy orientations, and socioeconomic contexts, enabling a comprehensive analysis of land-use change diversity and complexity. This cross-regional choice not only demonstrates the model’s adaptability across markedly different ecological and socio-economic contexts but also ensures that the contrasting drivers, scales, and institutional settings provide a rigorous test of its generalizability to other regions undergoing forest-to-farmland conversion. The rationale for selecting these two regions is outlined as follows:
Brazil: Brazil has faced extensive deforestation in recent years, primarily driven by agricultural expansion. Additionally, human interventions have had a severe impact on biodiversity. These conditions provide a critical case for exploring organic farming practices and the balance between agricultural productivity and ecological conservation.
Ghana: In Ghana, agricultural expansion is a significant contributor to deforestation. Historical changes in forest cover indicate that agricultural activities have accelerated deforestation and disrupted ecosystem stability. Thus, Ghana offers a valuable opportunity to study sustainable agricultural development and forest recovery in a smallholder farming context.
By conducting a comparative study of these two representative countries, this research aims to examine how different scales and pathways of agricultural expansion influence the evolutionary trajectories of agroecosystems. Moreover, the selection of these contrasting regions enables a robust test of the proposed model’s adaptability and generalizability across varying ecological and socio-economic contexts. As shown in Figure 2, both Brazil and Ghana have experienced substantial declines in forest cover over the past decades, driven by multiple factors, including agricultural expansion, wildfires, and logging activities.
While this study focuses on Brazil and Ghana, the proposed modeling framework is inherently scalable to other regions. However, applying the model in different contexts requires careful consideration of local institutional frameworks, socio-economic conditions, and agricultural practices. Regional adaptations may involve adjusting for policy environments, market dynamics, and local farming systems to ensure the model remains robust across diverse geographical settings.

2.2. Data Sources and Preprocessing

To support model construction and validation, this study collected and integrated multi-dimensional datasets from Brazil and Ghana, encompassing biophysical, ecological, and agricultural variables. The primary data sources and associated variables are summarized in Table 1.
The dataset primarily spans the period from 2000 to 2022, during which both Brazil and Ghana experienced significant deforestation and agricultural expansion. The spatial resolution varies by data type, encompassing national, provincial, and plot-level records. After collection, the datasets underwent preprocessing, including imputation of missing values—mainly using mean or nearest-neighbor interpolation—and removal of anomalous data points to ensure data integrity and robustness for model development. These datasets were employed for model initialization, validation of dynamic processes, and comparative scenario analysis within the ecological–economic framework.
As illustrated in Figure 3, factors influencing eco-economic benefits and sustainability include agricultural inputs, ecological regulation, policy incentives, and market demand. These variables collectively shape the system’s response mechanisms.
Building on the ecological and agricultural features of the chosen study areas, we further created a dynamic modeling framework to simulate ecosystem changes and energy flow patterns during the transition from forest to farmland. The structure of the model and its underlying assumptions are detailed in the next section.

3. Methods

3.1. Dynamic Modeling of Agricultural Ecosystems

To illustrate the structural changes and interspecies interaction mechanisms within agricultural ecosystems after forest-to-farmland conversion, we created a dynamic food web model. This model encompasses producers, primary consumers; secondary consumers; decomposers; and external disturbance factors, such as herbicides and insecticides. The core components of the model are presented in Table 2.

3.1.1. Establishment of Mathematical Relationship Equations

Model parameters were calibrated using a combination of field data from Brazil and Ghana (e.g., species abundance and soil nutrient levels) and ecological interactions (e.g., predation rates and growth rates). For parameters with limited empirical data, we conducted sensitivity analysis by varying values within ±20% of the baseline to assess robustness. This approach ensures transparency while addressing data scarcity.
To further explore the interspecific relationships, this study employs a system of differential equations to describe the dynamic processes by which the species population precisely changes over time:
(1)
Crop Growth
d C d t = r C × C a C I × I × C d C × C
where r C is the intrinsic growth rate of the crops, a C I is the attack rate of insects on crops, and d C is the natural mortality rate.
(2)
Weed Growth
d W d t = r W × W h × W d W × W
where r W is the intrinsic growth rate of weeds, h is the effectiveness coefficient of the herbicide, and d W is the natural mortality rate.
(3)
Insect Population Growth
d I d t = e I C × a I C × C × I m I B × B × I p × I
where e I C is the energy conversion efficiency of insects from crop consumption, m I B is the predation efficiency of bats on insects, and p is the effectiveness coefficient of insecticides.
(4)
Bird Population Growth
d B d t = e B I × a I B × I × B d B × B
where e B I is the efficiency of energy transfer from insects to birds and d B is the natural mortality rate.
(5)
Bat Growth
d B t d t = e B t I × m I B t × I × B t d B t × B t
where e B t I is the efficiency of energy transfer from insects to bats, m I B t is the predation efficiency of bats on insects, and d B t is the natural mortality rate.
Soil microbial and earthworm population fluctuations are mainly influenced by the supply of litter and root exudates; therefore, their dynamic changes are simplified as functions of these factors.

3.1.2. Modeling Energy Flow in the Food Chain

In agricultural ecosystems, energy flows along the food chain from lower to higher trophic levels, accompanied by thermal losses. We constructed a typical three-trophic-level food chain (crops → insects → predators) and introduced energy conversion efficiency parameters to calculate the energy transfer processes at each level.
For each trophic level, the energy dynamics can be described using the following differential equations:
Producers (P):
d E P d t = r P × E P c P I × E P
where r P is the intrinsic growth rate of the producers and c P I is the proportion of producers consumed by primary consumers.
Primary Consumers (I):
d E I d t = e I P × c P I × E P c I B × E I
where e I P is the energy transfer efficiency from producers to primary consumers (set here at 10%, i.e., 0.1) and c I B is the proportion of primary consumers consumed by secondary consumers.
Secondary Consumers (B):
d E B d t = e B I × c I B × E I d B × E B
where e B I is the energy transfer efficiency from primary consumers to secondary consumers (also set at 10%, i.e., 0.1) and d B is the natural mortality rate of secondary consumers.
Energy Flow from Producers to Primary Consumers:
E I B ( t + t ) = e B I × c I B × E I ( t )
Total Energy Flow:
The total energy flow can be considered as the sum of energy transfers between all adjacent trophic levels. Therefore, over a given time period, the total energy flow ( E total ( t ) ) can be expressed as follows:
E total ( t ) = E P I ( t ) + E I B ( t )
To make the above equations more concrete, we apply hypothetical numerical values. For example, if the initial energy of the producers is E P I ( 0 ) = 100 kJ and cPI = 0.5 (meaning half of the energy is consumed by primary consumers), then the energy transferred from producers to primary consumers after the first month will be
E P I ( 1 ) = 0.1 × 0.5 × 1000 = 50 kJ .
Next, if the initial energy of the primary consumers is E I B ( 0 ) = 200 kJ and cIB = 0.6 (meaning 60% of the energy is consumed by secondary consumers), then the energy transferred from primary consumers to secondary consumers after the first month will be
E I B ( 1 ) = 0.1 × 0.6 × 200 = 12 kJ .
Therefore, by the end of the first month, the total energy flow ( E total ( t ) ) will be
E t o t a l ( t ) = E P I ( 1 ) + E I B ( 1 ) = 50 + 12 = 62 kJ .
Through continuous iteration of this process, we can update energy levels at each time point in real time and comprehensively calculate the energy flow characteristics over the entire period. In summary, we developed a coupled population–energy dynamic model for agricultural ecosystems that can simulate system operation under the influence of multiple trophic levels and disturbance factors. Next, we introduce species return and ecological intervention mechanisms to further explore the recovery potential and regulatory pathways of agricultural ecosystems.

3.2. Ecological Restoration and Species Return Simulation

In the process of forest conversion to farmland, the ecological system undergoes significant disturbances. However, over time, as edge habitats gradually recover, some native or key species begin to recolonize the agricultural ecosystem. This process has important ecological implications for enhancing biodiversity, restoring soil fertility, and improving system stability.

3.2.1. Species Return Quantity

The quantity of returning species reflects the gradual recovery of native species within the agricultural ecosystem. Although this number increases over time, its growth rate is limited by the current environmental carrying capacity.
d R d t = γ R ( 1 R R max )
where γ is the growth rate of species re-establishment and R max is the maximum limit of the re-established species population.
R ( t ) = R 0 · e α t · ( 1 R ( t ) K )
where R 0 is the initial number of re-establishing species, α is the rate of species re-establishment, and K is the maximum number of species the ecosystem can support.

3.2.2. Changes in Ecosystem Stability and Soil Fertility Recovery

As species return, the stability of the ecosystem may undergo adjustments. Increasing species diversity and strengthening interspecies interactions contribute to the recovery process and enhance system stability.
d E S d t = β · R ( t ) K · ( 1 E S )
where β is the impact coefficient of species re-establishment on ecosystem stability.
E S ( t ) = E S 0 + β · R ( t ) K
where E S 0 is the initial ecosystem stability and β is the contribution of species re-establishment to stability.
The return of plant species, in particular, plays a positive role in soil recovery by promoting nitrogen fixation and the decomposition of organic matter, thereby enhancing soil fertility.
d S F R d t = δ S F R · ( 1 S F R S F R max )
where δ is the soil recovery rate and S F R max is the maximum value of soil fertility restoration.
S F R ( t ) = S F R 0 + η · R ( t )
where S F R 0 is the initial soil fertility and η is the impact coefficient of species re-establishment on soil fertility restoration.
As edge habitats recover and mature over time, native species progressively recolonize these areas. The return of species alters the local ecosystem’s structure and function. Especially in agricultural ecosystems, the interactions between these species and the existing environment can trigger significant ecological changes. To explore these changes more deeply, we introduce two distinct species into the model to assess their potential impacts on the agricultural ecosystem.

3.2.3. Selecting Seven-Spot Ladybird and Ragweed as Representative Returning Species

The seven-spot ladybird serves as a natural enemy of agricultural pests, feeding on aphids, whiteflies, and similar insects, which effectively suppresses pest populations, reduces pesticide use, and indirectly boosts crop yields, thereby enhancing ecosystem stability.
Ragweed, a highly competitive invasive plant, is widely distributed along the boundaries between farmland and forests. Its rapid growth and high resource competitiveness can suppress crop growth and disrupt the stability of agricultural ecosystems.

3.2.4. Impact of Herbicide Removal on Ecosystem Stability

As ecosystems gradually mature and stabilize, crops naturally reduce their reliance on chemical inputs, allowing them to better integrate into their ecological surroundings. Therefore, we further investigate how ecosystems respond when herbicides and other chemical substances are removed and assess the potential impacts of introducing bats as new environmental agents. Additionally, we apply the XGBoost algorithm to identify key pathways and strategies for restoring the balance of agricultural ecosystems.
(1)
Plant Population Dynamics
Following the cessation of herbicide use, plant populations will no longer be disturbed by chemical agents, potentially triggering recovery or fluctuations in plant population sizes. The specific changes depend on environmental factors and the adaptability of the involved plant species.
d P d t = r P ( 1 P k ) α P I
where r is the plant growth rate, k is the carrying capacity of the environment for plants, and α represents the predation interaction between plants and insects.
(2)
Insect Population Dynamics
Insect populations have a direct impact on plant growth and development. Following the removal of herbicides, insect populations may recover, which, in turn, influences the growth dynamics of plants further.
d I d t = b I ( 1 I I max ) γ I C
where b is the insect growth rate, I max is the insect carrying capacity, γ is the coefficient representing the impact of chemicals on insects, and C denotes the concentration of herbicides.
(3)
Ecosystem Stability Index
Ecosystem stability is closely related to the interactions among species. After the removal of herbicides, ecosystem stability will gradually recover through the establishment of competitive and predatory relationships among species.
d E S I d t = α · P ( t ) k β · I ( t ) I max
where α and β are parameters reflecting the interactions between plants and insects.
(4)
Herbicide Concentration
With the removal of herbicides, their concentration gradually decreases. This change serves as an important indicator of the herbicide removal process.
d C d t = δ C
To analyze the impact of herbicide removal on ecosystem stability, we use the fourth-order Runge–Kutta method for numerical solutions. The Runge-Kutta method is a widely used numerical algorithm for solving initial value problems in ordinary differential equations, offering a good balance between computational accuracy and cost, effectively avoiding the overhead associated with higher-order methods.
In summary, through dynamic simulations and the introduction of key species, the stability and self-regulation capacity of agricultural ecosystems are significantly enhanced. To further explore system optimization pathways and the benefits of multi-dimensional management strategies, we developed an eco-economic benefit evaluation model, as detailed in the next section.

3.3. Agricultural Ecosystem Optimization and Strategy Evaluation

Building on the previous simulations, we further explore optimization pathways for regulating ecosystem mechanisms from a management intervention perspective to enhance the long-term stability and sustainability of agricultural ecosystems. Specifically, this study focuses on introducing key regulatory species, identifying critical factors affecting ecological recovery, and constructing an eco-economic coupling model to systematically assess the combined effects of different agricultural management strategies on environmental stability and economic benefits.

3.3.1. Impact of Bat Introduction on the Restoration of Ecological Balance

(1)
Bat Population Dynamics
Bats play an important role in pest control and pollination within ecosystems—their introduction results in a gradual increase in population size, generating positive ecological effects.
d B d t = ξ B ( 1 B B max ) η B I
where ξ is the bat growth rate, B max is the bat carrying capacity, and η is the predation efficiency of bats on insects.
(2)
Pest Population Dynamics
Bats play an important role in controlling pest damage to plants. Their introduction regulates pest population sizes, thereby influencing plant growth.
d P d t = α P β B P
where α is the natural growth rate of pests and β is the predation rate of bats on pests.
(3)
Plant Population Dynamics
The plant population size is influenced by the dual effects of pest control and the introduction of bats.
d P d t = r P ( 1 P k ) α P I
(4)
Ecosystem Stability
The introduction of bats and the control of pests contribute to the enhancement of ecosystem stability.
d E S I d t = α · P ( t ) k β · I ( t ) I max
(5)
Influence of Other Species
In addition to bats, the introduction of other species (such as predators or pollinators) may also play a positive role in restoring ecosystem balance. This indicator can be used to measure the impact of other species on ecological restoration.
O I = α O · e β t
where α O is the intensity of the influence of other species and β is the decay rate following species introduction.

3.3.2. Application of the XGBoost Algorithm to Solve Agricultural Ecological Restoration Balance

XGBoost (Extreme Gradient Boosting) is a machine learning algorithm based on gradient-boosted decision trees, widely adopted in recent years for its outstanding performance. Compared to traditional gradient boosting algorithms, XGBoost introduces several improvements, making it more efficient and accurate when handling large-scale datasets. Its core idea is to construct a series of weak classifiers (typically, decision trees) and iteratively adjust them based on previous errors to enhance prediction accuracy progressively. During the iterative process, XGBoost minimizes the loss function and introduces regularization terms to control model complexity, effectively preventing overfitting. Furthermore, XGBoost employs advanced optimization techniques, including column sampling, gradient histograms, and parallel computation, which significantly enhance computational efficiency. Figure 4 shows a schematic diagram of the structure of the XGBoost algorithm.
  • Objective Function:
L ( θ ) = t = 1 n I ( y i , y ^ i ) + k = 1 K Ω ( f k )
where I ( y i , y ^ i ) is the loss function, representing the error between the predicted and actual values, and Ω ( f k ) is the regularization term, which penalizes model complexity to avoid overfitting.
2.
Regularization Term:
Ω ( f k ) = γ T + 1 2 λ j = 1 T w j 2
where T is the number of leaf nodes in the tree, w j is the weight of each leaf node, and γ and λ are the hyperparameters for regularization.
3.
Gradient Update:
f t + 1 ( x ) = f t ( x ) + η · δ f t ( x )
where f t ( x ) is the model in iteration t , η is the learning rate, and δ f t ( x ) is the optimization increment in round t . Through this optimization process, XGBoost can more effectively fit complex data structures while efficiently preventing overfitting.
Model parameters were initialized using empirical measurements, published data, and literature-derived ranges, with expert judgment supplementing unavailable data. This multi-source approach ensured ecologically and economically realistic values. Sensitivity analysis then identified parameters with significant predictive influence.

3.3.3. Eco-Economic Benefit and Sustainability Model

The EEBS model tackles complexity issues by using hierarchical parameter estimation and modular design, all while preserving its main dual-objective optimization framework to balance profit maximization and sustainability improvements.
The objective function should reflect the primary motivation for farmers to adopt organic farming practices—namely, improving both economic benefits and sustainability.
Maximize · Z = α · Profit + β · Sustainability
where α and β are weighting coefficients used to balance the relationship between economic benefits and sustainability.
Economic Benefit Function:
The economic benefit mainly derives from the market price of crops, their yield, and production costs. Specifically,
Profit = P organic · Y organic C organic
where P organic is the market price of organic crops, Y organic is the yield of organic crops, and C organic is the cost of producing organic crops.
Although the market price of organic crops is generally higher, their production costs may also be correspondingly elevated; therefore, this constraint needs to be taken into account in the analysis. The sustainability objective can be expressed as follows:
Sustainability = f ( PestControl , CropHealth , Biodiversity , SoilHealth )
where each factor (such as pest control and crop health) can be quantified based on its positive impact on the ecosystem. In the model, practical constraints need to be considered. The following are possible constraints:
  • Budget Constraint
Organic farming may require higher initial investments; therefore, the available capital of farmers serves as a key constraint.
C organic B
where B is the farmer’s budget.
2.
Crop Yield Constraint:
The yield of organic farming may be lower than that of conventional farming; therefore, it is necessary to set a minimum yield threshold to ensure basic crop production.
Y organic Y min
where Y min is the minimum yield desired by the farmer.
3.
Sustainability and Ecological Conservation Constraint:
Organic farming emphasizes the protection of soil health and biodiversity; therefore, it is essential to ensure that farming practices do not cause negative impacts on the ecosystem.
Biodiversity Biodiversity min SoilHealth SoilHealth min
4.
Market Demand Constraint:
The organic crops produced by farmers must meet market demand.
Y organic D max
where D max is the maximum market demand for organic crops.
5.
Production Efficiency Constraint:
Organic farming may face higher production costs, so optimizing cost efficiency is necessary.
C organic Y organic γ
where γ is the acceptable ratio of production cost to yield.
Overall Model:
Combining the objective function and the constraints, the final model can be expressed as follows:
Maximize Z = α · ( P organic · Y organic C organic ) + β · f ( PestControl , CropHealth , Biodiversity , SoilHealth )
subject to : C organic B Y organic Y min Biodiversity Biodiversity min SoilHealth SoilHealth min Y organic D max C organic Y organic γ
By combining the objective functions and constraints, the final model enables multi-dimensional evaluation of the comprehensive benefits of various agricultural management strategies.

4. Results and Discussion

4.1. Experimental Configuration

To ensure comparability across simulations and model training, all computational experiments were performed on the same platform. The hardware configuration includes a 13th Gen Intel Core i5-13500H processor (2.60 GHz; Intel Corporation, Santa Clara, CA, USA), NVIDIA GeForce RTX 4050 Laptop GPU, and 16 GB of RAM, running Windows 11 (Version 10.0.22631, SP0). The processor architecture is Intel 64, Family 6, Model 186, Stepping 2 (GenuineIntel).
The algorithms were implemented in Python 3.11, with model training performed using the XGBoost framework for Gradient Boosting Decision Trees (GBDTs) and feature importance analysis. Visualization of simulation results was carried out using open-source libraries such as Matplotlib 3.7.1 and Seaborn 0.12.0.

4.2. Ecological Effects of Species Reintroduction and Edge Habitat Recovery

As agroecosystems transition from disturbed to restored states, maturing edge habitats provide ecological conditions that facilitate the recolonization of species. Figure 5 illustrates trends in ecosystem stability and soil fertility under both species reintroduction scenarios.
Under the lady beetle scenario, the stability index remained above 90%, with pest populations effectively controlled. This reduced pesticide dependence and enabled the establishment of a biologically regulated system. Additionally, the soil fertility index recovered to approximately 95% of its baseline value after 100 simulation days.
In contrast, ragweed reintroduction increased total biomass but hurt crop yields due to aggressive competition for water, light, and nutrients. The system’s stability declined to approximately 65%, and soil degradation accelerated, thereby delaying the recovery of fertility.
These contrasting roles illustrate their functional positions within the ecosystem. Lady beetles act as trophic regulators, enhancing resilience via top-down pest control. Ragweed, as an invasive competitor, disrupts nutrient flows and ecological balance.
These findings highlight the importance of distinguishing between “beneficial recolonization” and “harmful invasion” in edge ecosystem management. Introducing species without evaluating their ecological roles may result in secondary environmental crises. Restoration success depends not only on species abundance but also on functional traits and the positioning of trophic levels within the ecosystem. Priority should be given to keystone species capable of initiating positive feedback loops and stabilizing food web dynamics.

4.3. Impacts of Chemical Removal and Ecological Control

While chemical herbicides and pesticides are effective in the short term, long-term use disrupts food web structure and weakens natural regulatory mechanisms. To assess the potential of biological control as an alternative, we simulated a scenario involving the complete removal of herbicides and the introduction of natural predators (bats and birds).
Figure 6 presents population dynamics after herbicide withdrawal. Initially, insect populations surged due to the loss of chemical suppression, resulting in sharp declines in crop yields and fluctuations in the stability index. To restore balance, bats and birds were introduced as natural insectivores.
Although both are predators, interspecific competition still occurs, mainly due to niche overlap. We developed a differential equation system modeling the interactions among bats, birds, insects, and crops and solved it numerically using the fourth-order Runge–Kutta method over 200 days.
Figure 7 shows changes in the abundance of each species group after the introduction of bats and birds.
Results showed a turning point in insect populations around day 40, followed by steady declines. Ecosystem stability improved significantly from day 50 onward. Despite some mid-term suppression of bat growth by birds, the two formed a complementary diurnal–nocturnal predation regime, enhancing control efficacy.
To identify key drivers of stability, we applied XGBoost for feature importance analysis using simulation outputs. The top five features influencing system balance were bat abundance, herbicide concentration, initial crop density, predation efficiency, and weed competition intensity. Figure 8 illustrates the effect on other characteristics in both the herbicide-free and herbicide-treated scenarios with birds. These factors underscore the significance of biological control strength and resource competition in maintaining agroecosystem stability. The central role of predator–prey dynamics suggests that multi-level trophic control networks are critical for sustainable recovery.
To optimize the model under limited data conditions, we further fine-tuned the XGBoost hyperparameters through a comprehensive grid search, as this exhaustive and deterministic search strategy ensures the identification of globally optimal parameter combinations without relying on stochastic variability. Specifically, we systematically evaluated combinations of learning_rate ( η ), max_depth (d), and n_estimators (N) via five-fold cross-validation (see Figure 9). This optimization improves the reliability of subsequent sensitivity analyses, ensuring that the key identified drivers are both statistically solid and ecologically significant. The optimal configuration ( η = 0.1, d = 3, N = 150) achieved outstanding predictive performance with a coefficient of determination of R 2 = 0.9619 (95% CI: 0.958–0.965) and root mean squared error of RMSE = 0.0330 (95% CI: 0.031–0.035). Sensitivity analysis revealed that learning_rate exhibited the dominant influence (Shapley value = 0.62 ± 0.03), demonstrating the model’s robustness to variations in tree complexity parameters.
Model performance metrics (Table 3) confirmed high precision: RMSE = 0.1029 and MSE = 0.0142.
Biological control, particularly through bats, has emerged as an ecologically adaptive and sustainable alternative to chemical inputs, reducing pesticide reliance and minimizing risks of resistance and pollution. Notably, successful restoration depends on predation structure, species coordination, and interaction strength, not merely species abundance.

4.4. Eco-Economic Performance Under Different Agricultural Scenarios

To assess the sustainability of green farming practices, we evaluated three agricultural management scenarios using the EEBS model: conventional chemical agriculture (full herbicide and pesticide application), ecological control-based agriculture (reduced chemicals and predator introduction), and organic agriculture (complete removal of chemicals and full biological control).
Figure 10 shows the proportion of organically managed land in Brazil and Ghana. As of 2022, Brazil’s organic farmland comprised 0.45% of total arable land, while Ghana’s was 0.57% [29].
A multi-objective optimization approach was employed, aiming to balance both ecological stability and economic profitability. Results indicate that moderate predator use, increased planting density, and rotational cropping can jointly enhance both outcomes. Notably, national differences in institutional support, input levels, and market dynamics significantly affect the feasibility of organic adoption.
Our findings align with previous dual-objective studies by Seufert and Ramankutty, confirming the dual advantage of organic agriculture for ecological recovery and profitability. However, our study further reveals that policy and market environments act as mediators, offering a new quantitative lens for evaluating cross-regional policy adaptability.
In addition to the above ecological effects, the model’s applicability and predictive power may be influenced by spatial variability and extreme events. Regional differences in soil types, microclimates, and land use can affect agroecosystem dynamics, such as crop yields and pest control efficiency. Extreme weather events like droughts, floods, and heatwaves may also increase instability. These factors were not fully incorporated in the current model and should be addressed in future research. Integrating spatial data from remote sensing and GIS, along with climate projections, can improve the model’s adaptability across different ecological and climatic contexts.
Overall, our simulation results across scenarios underscore the critical roles of species introduction, chemical withdrawal, and eco-economic optimization in shaping system evolution during forest-to-farmland transitions.

5. Conclusions

This study developed an integrated modeling framework combining a dynamic food web model with an eco-economic sustainability model (EEBS) based on field data from Brazil and Ghana. By solving systems of ordinary differential equations using the fourth-order Runge–Kutta method, we quantified species interactions and energy flows under various agricultural interventions. Key findings include the following: (1) The reintroduction of the seven-spot ladybird and ragweed significantly affected system outcomes. The former enhanced stability (above 90%) and soil fertility (95% recovery), while the latter reduced system resilience. (2) In herbicide-free scenarios, bats and birds played pivotal roles in dampening ecosystem volatility, demonstrating the value of ecological regulation strategies.
Furthermore, XGBoost-based machine learning analysis effectively identified dominant ecological drivers—pest control, resource allocation, and chemical disturbances. This approach improved feature extraction and system interpretability.
EEBS-based simulations confirmed that organic agriculture offers the best trade-off between ecological recovery and economic gain. Grid-tuned XGBoost regression achieved strong predictive accuracy ( R 2 = 0.9619 and RMSE = 0.0330), validating its suitability for the modeling of complex ecosystems.
The proposed “Eco-Dynamics + XGBoost + EEBS” framework addresses limitations in current ecosystem models—namely, insufficient quantification and poor handling of nonlinear interactions. It improves accuracy in tracking system evolution and provides an empirical basis for co-optimizing ecological and economic goals, making it highly relevant to global sustainable agricultural transitions.
Nonetheless, this study has two main limitations: (1) Parameterization relied partly on expert input due to limited, large-scale, long-term empirical data, which was addressed through a hybrid calibration using empirical measurements, literature values, and expert input to ensure ecological plausibility. (2) Spatial heterogeneity and stochastic disturbances were not fully represented, possibly underestimating extreme-event impacts.
While not representing a universal conclusion due to spatial constraints, the framework is inherently scalable through region-specific parameterization of biophysical, economic, and policy variables. Its core methodological contribution lies in bridging ecological theory with computational optimization, offering a transferable tool for sustainable agricultural transitions. Future enhancements will focus on (1) incorporating additional species interactions to better quantify biodiversity’s stabilizing role in single-region studies and (2) integrating remote sensing and geographic information systems (GIS) with uncertainty analysis to improve spatial resolution and scenario flexibility. These advancements will support more precise, dynamic agroecosystem management across scales.

Author Contributions

Conceptualization, M.X.; Methodology, M.X. and Z.Y.; Investigation, Y.L.; Writing—original draft preparation, M.X., Z.Y. and Y.L.; Writing—review and editing, M.X.; Supervision, C.X.; Project administration, C.X.; Funding acquisition, C.X. All authors have read and agreed to the published version of the manuscript.

Funding

Guangdong Ocean University Research Project Initiation Fund (Project No.360302042202).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The original contributions presented in the study are included in the article; further inquiries can be directed to the corresponding author.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Ding, L.J.; Ren, X.Y.; Zhou, Z.Z.; Zhu, D.; Zhu, Y.G. Forest-to-Cropland Conversion Reshapes Microbial Hierarchical Interactions and Degrades Ecosystem Multifunctionality at a National Scale. Environ. Sci. Technol. 2024, 58, 11027–11040. [Google Scholar] [CrossRef]
  2. Mungai, L.M.; Djenontin, I.N.S.; Zulu, L.C.; Messina, J.P. Spatial-temporal modeling of land-use dynamics at the agricultural-forest interface: Insights from Ntchisi District, Malawi. Remote Sens. Appl. Soc. Environ. 2025, 38, 101597. [Google Scholar] [CrossRef]
  3. Valjarević, A.; Morar, C.; Brasanac-Bosanac, L.; Cirkovic-Mitrovic, T.; Djekic, T.; Mihajlović, M.; Milevski, I.; Culafic, G.; Luković, M.; Niemets, L.; et al. Sustainable land use in Moldova: GIS & remote sensing of forests and crops. Land Use Policy 2025, 152, 107515. [Google Scholar] [CrossRef]
  4. FAO. COP26 Agricultural Expansion Drives Almost 90 Percent of Global Deforestation. FAO Newsroom, 11 June 2021. Available online: https://www.fao.org/newsroom/detail/cop26-agricultural-expansion-drives-almost-90-percent-of-global-deforestation/ (accessed on 25 June 2025).
  5. FAO. Global Forest Resources Assessment 2020. FAO Interactive Report, 2023. Available online: https://www.fao.org/interactive/forest-resources-assessment/2020/en/ (accessed on 25 June 2025).
  6. Nayak, N.; Mehrotra, R.; Mehrotra, S. Carbon biosequestration strategies: A review. Carbon Capture Sci. Technol. 2022, 4, 100065. [Google Scholar] [CrossRef]
  7. Li, Y.; Brando, P.M.; Morton, D.C.; Lawrence, D.M.; Yang, H.; Randerson, J.T. Deforestation-induced climate change reduces carbon storage in remaining tropical forests. Nat. Commun. 2022, 13, 1964. [Google Scholar] [CrossRef]
  8. Li, W.; Kang, J.; Wang, Y. Effects of habitat fragmentation on ecosystem services and their trade-offs in Southwest China: A multi-perspective analysis. Ecol. Indic. 2024, 167, 112699. [Google Scholar] [CrossRef]
  9. Gao, H.; Gong, J.; Ye, T.; Maier, M.; Liu, J. Constructing cropland ecological stability assessment method based on disturbance-resistance-response processes and classifying cropland ecological types. Sci. Total Environ. 2024, 930, 172673. [Google Scholar] [CrossRef] [PubMed]
  10. FAO. Pesticides Use and Trade 1990–2022. FAO Statistics Highlights, 16 July 2024. Available online: https://www.fao.org/statistics/highlights-archive/highlights-detail/pesticides-use-and-trade-1990-2022/ (accessed on 25 June 2025).
  11. Xiong, R.; He, X.; Gao, N.; Li, Q.; Qiu, Z.; Hou, Y.; Shen, W. Soil pH amendment alters the abundance, diversity, and composition of microbial communities in two contrasting agricultural soils. Microbiol. Spectr. 2024, 12, e04165-23. [Google Scholar] [CrossRef]
  12. Guzman, L.M.; Elle, E.; Morandin, L.A. Impact of pesticide use on wild bee distributions across the United States. Nat. Sustain. 2024, 7, 1324–1334. [Google Scholar] [CrossRef]
  13. Ndayishimiye, J.C.; Nyirabuhoro, P.; Gao, X.; Chen, H.; Wang, W.; Mazei, Y.; Yang, J. Community responses of testate amoebae (Arcellinida and Euglyphida) to ecological disturbance explained by contrasting assembly mechanisms in two subtropical reservoirs. Sci. Total Environ. 2024, 953, 176058. [Google Scholar] [CrossRef]
  14. Li, J.; Nie, W.; Zhang, M.; Wang, L.; Dong, H.; Xu, B. Assessment and optimization of urban ecological network resilience based on disturbance scenario simulations: A case study of Nanjing city. J. Clean. Prod. 2024, 438, 140812. [Google Scholar] [CrossRef]
  15. Hong, W.; Guo, R.; Li, X.; Liao, C. Measuring urban ecological network resilience: A disturbance scenario simulation method. Cities 2022, 131, 104057. [Google Scholar] [CrossRef]
  16. Zhang, J.; Li, H.; Ren, G.; Zhang, Z.; Nie, S. Advancing sustainable mining practices: A dynamic ecological security and risk warning framework for ion-absorbed rare earth mine. J. Clean. Prod. 2025, 511, 145630. [Google Scholar] [CrossRef]
  17. Dipesh, P.; Kumar, P.; Sharma, A. Mathematical model of Cynodon dactylon’s allelopathic effect on perennial ryegrass for exploring plant-plant interactions based upon ordinary differential equations. Partial Differ. Equ. Appl. Math. 2025, 101254. [Google Scholar] [CrossRef]
  18. Chen, Y.; Xu, Y.; El Idrissi, A.; Long, T.; Liu, Y.; Lu, L. Eco-friendly alginate-urea-fluroxypyr hydrogel for sustainable agriculture: A comprehensive approach to integrated fertilizer delivery and weed control. Int. J. Biol. Macromol. 2025, 310, 143257. [Google Scholar] [CrossRef]
  19. Ocampo-Ariza, C.; Maas, B.; Castro-Namuche, J.P.; Thomas, E.; Vansynghel, J.; Steffan-Dewenter, I.; Tscharntke, T. Trait-dependent responses of birds and bats to season and dry forest distance in tropical agroforestry. Agric. Ecosyst. Environ. 2022, 325, 107751. [Google Scholar] [CrossRef]
  20. Panja, P. Dynamics of a crop, pest and predator model in an agricultural system. Results Control Optim. 2023, 12, 100274. [Google Scholar] [CrossRef]
  21. Ortmans, W.; Mahy, G.; Chauvel, B.; Monty, A. Performance variation of common ragweed (Ambrosia artemisiifolia L.) across invasion levels in Western Europe. Flora-Morphol. Distrib. Funct. Ecol. Plants 2016, 220, 134–141. [Google Scholar] [CrossRef]
  22. Guliyev, H. Ecological footprint spillover effects in Europe: New insights from dynamic spatial panel data model with common shocks. J. Environ. Manag. 2024, 368, 122194. [Google Scholar] [CrossRef]
  23. Yadav, S.P.S.; Mehata, D.K.; Pokhrel, S.; Ghimire, N.P.; Gyawali, P.; Katel, S.; Timilsina, U. Invasive alien plant species (Banmara): Investigating its invasive potential, ecological consequences on biodiversity, and management strategies. J. Agric. Food Res. 2024, 15, 101031. [Google Scholar] [CrossRef]
  24. Zhang, W.; Huang, Q.; Kuang, Y.; Clements, D.R.; Xu, G.; Zhang, F.; Shen, S.; Yin, L.; Day, M.D. Predicting the potential distribution of the invasive weed Mikania micrantha and its biological control agent Puccinia spegazzinii under climate change scenarios in China. Biol. Control 2025, 204, 105754. [Google Scholar] [CrossRef]
  25. Goldson, S.L.; Tomasetto, F.; Popay, A.J. Biological control against invasive species in simplified ecosystems: Its triumphs and emerging threats. Curr. Opin. Insect Sci. 2014, 5, 50–56. [Google Scholar] [CrossRef]
  26. Wu, N.; Zhou, Y.; Yin, S.; Gong, H.; Zhang, C. Revealing the nonlinear impact of environmental regulation on ecological resilience using the XGBoost-SHAP model: Evidence from the Yangtze River Delta region, China. J. Clean. Prod. 2025, 514, 145700. [Google Scholar] [CrossRef]
  27. Shamuxi, A.; Han, B.; Jin, X.; Wusimanjiang, P.; Abudukerimu, A.; Chen, Q.; Zhou, H.; Gong, M. Spatial pattern and driving mechanisms of dryland landscape ecological risk: Insights from an integrated geographic detector and machine learning model. Ecol. Indic. 2025, 172, 113305. [Google Scholar] [CrossRef]
  28. FAO. Global Forest Resources Assessment 2020—Key Findings; Food and Agriculture Organization of the United Nations: Rome, Italy, 2020. [Google Scholar] [CrossRef]
  29. Food and Agriculture Organization of the United Nations (FAO). Share of Arable Land That Is Organic—FAO [Dataset]; with Major Processing by Our World in Data. Land, Inputs and Sustainability: Land Use [Original Data]. 2024. Available online: https://archive.ourworldindata.org/20250624-125417/grapher/share-of-arable-land-which-is-organic.html (accessed on 3 July 2025).
Figure 1. Proportion and distribution of global forest area and annual rates of deforestation and forest expansion over the period of 1990–2020. Adapted from FAO (2020).
Figure 1. Proportion and distribution of global forest area and annual rates of deforestation and forest expansion over the period of 1990–2020. Adapted from FAO (2020).
Sustainability 17 07170 g001
Figure 2. Reasons for the decline in forest cover in Brazil and Ghana over the past decades. (a) Tree cover loss in Brazil by year and cause. (b) Tree cover loss in Ghana by year and cause.
Figure 2. Reasons for the decline in forest cover in Brazil and Ghana over the past decades. (a) Tree cover loss in Brazil by year and cause. (b) Tree cover loss in Ghana by year and cause.
Sustainability 17 07170 g002
Figure 3. Influencing factors of eco-economic benefits and sustainable development.
Figure 3. Influencing factors of eco-economic benefits and sustainable development.
Sustainability 17 07170 g003
Figure 4. Schematic diagram of the XGBoost algorithm.
Figure 4. Schematic diagram of the XGBoost algorithm.
Sustainability 17 07170 g004
Figure 5. Ecosystem stability (left) and soil fertility recovery (right).
Figure 5. Ecosystem stability (left) and soil fertility recovery (right).
Sustainability 17 07170 g005
Figure 6. Process of herbicide population change.
Figure 6. Process of herbicide population change.
Sustainability 17 07170 g006
Figure 7. Introduction of the process of population change in bats and birds.
Figure 7. Introduction of the process of population change in bats and birds.
Sustainability 17 07170 g007
Figure 8. Values for the importance of each feature in both cases.
Figure 8. Values for the importance of each feature in both cases.
Sustainability 17 07170 g008
Figure 9. Sensitivity analysis of the developed agricultural ecological balance assessment model. (a) A 3D scatterplot of hyperparameter combinations in grid search. (b) Impact of hyperparameters on model performance.
Figure 9. Sensitivity analysis of the developed agricultural ecological balance assessment model. (a) A 3D scatterplot of hyperparameter combinations in grid search. (b) Impact of hyperparameters on model performance.
Sustainability 17 07170 g009
Figure 10. Proportion of arable land under organic agriculture in Brazil and Ghana as a percentage of the territory. Data source: FAO (2024), processed by Our World in Data.
Figure 10. Proportion of arable land under organic agriculture in Brazil and Ghana as a percentage of the territory. Data source: FAO (2024), processed by Our World in Data.
Sustainability 17 07170 g010
Table 1. Data websites and their data types.
Table 1. Data websites and their data types.
Data WebsiteData Type
https://www.fao.org/Crop-related data
https://www.globalforestwatch.org/Forest data
https://www.embrapa.br/Agriculture
https://www.sciencedirect.com/Paper
https://www.cnki.net/
Table 2. Model concepts.
Table 2. Model concepts.
RoleOrganismsDescription
ProducerCropsE.g., corn and soybeans.
WeedsNaturally growing plants that may compete with crops for resources.
Primary ConsumerInsectsSmall invertebrates that feed on crops or weeds, such as aphids and beetles.
Secondary ConsumerBirdsSpecies that prey on insects, such as sparrows and woodpeckers.
BatsNocturnal insectivores that help control pest populations and serve as pollinators.
DecomposerSoil MicrobesResponsible for decomposing organic matter such as fallen leaves and crop residues, returning nutrients to the soil.
EarthwormsImprove soil structure and facilitate nutrient cycling.
External FactorsHerbicidesAffect the growth of weeds and non-target plants.
PesticidesDirectly impact insect populations and indirectly affect their natural enemies.
Table 3. Error indicators in the two cases.
Table 3. Error indicators in the two cases.
TreatmentMAEMSERMSE
No Herbicide0.10280.01360.1164
No Herbicide + other species0.10170.01420.1029
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Xu, M.; Yao, Z.; Lu, Y.; Xiong, C. Agroecosystem Modeling and Sustainable Optimization: An Empirical Study Based on XGBoost and EEBS Model. Sustainability 2025, 17, 7170. https://doi.org/10.3390/su17157170

AMA Style

Xu M, Yao Z, Lu Y, Xiong C. Agroecosystem Modeling and Sustainable Optimization: An Empirical Study Based on XGBoost and EEBS Model. Sustainability. 2025; 17(15):7170. https://doi.org/10.3390/su17157170

Chicago/Turabian Style

Xu, Meiqing, Zilong Yao, Yuxin Lu, and Chunru Xiong. 2025. "Agroecosystem Modeling and Sustainable Optimization: An Empirical Study Based on XGBoost and EEBS Model" Sustainability 17, no. 15: 7170. https://doi.org/10.3390/su17157170

APA Style

Xu, M., Yao, Z., Lu, Y., & Xiong, C. (2025). Agroecosystem Modeling and Sustainable Optimization: An Empirical Study Based on XGBoost and EEBS Model. Sustainability, 17(15), 7170. https://doi.org/10.3390/su17157170

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop