Metaheuristic-driven automatic ARIMA order selection using spider monkey optimization for agricultural production forecasting Authors: Anil Kumar, Roshini Priya C H, Fasila K P, Santosha Rathod, S Vishnu Shankar, Mrinmoy Ray, Sujith Arokia Swamy B, Santosh Patil, Chiranjit Mazumder, Sudhir Kumar Mishra, V Lavanya, Ashutosh Kumar Misra, Vipin Kumar Choudhary Published: 2026 ABSTRACT Highlights•Automatically identifies optimal ARIMA (p, d, q) orders by formulating order selection as a metaheuristic optimization problem.•Employs Spider Monkey Optimization with local and global leader phases to efficiently search the discrete ARIMA order space.•Reduces prediction error and computational effort compared with exhaustive grid-search-based ARIMA order selection.Keywords: Spider Monkey Optimization (SMO); Swarm intelligence; Order selection, Time series forecasting Specifications table This table provides general information on your method. Subject areaMathematics and StatisticsMore specific subject areaTime Series Modelling; Swarm Intelligence OptimizationName of your methodARIMA–SMO: Automated ARIMA order selection using Spider Monkey OptimizationName and reference of original methodARIMA modelling (Box & Jenkins, 1970); SMO algorithm (Sharma et al., 2018)Resource availabilityR Package: SMOARIMA: Automatic ARIMA Order Selection Using Spider Monkey Optimization https://cran.r-project.org/web/packages/SMOARIMA/ Background Time series analysis is widely used to understand, model, and forecast temporal patterns in fields such as finance, healthcare, climate science, and agriculture. In agriculture applications, major food grain crops such as rice, wheat, coarse cereals, and pulses, accurate forecasting is important for ensuring food security, improving resource allocation, and mitigating risks associated with climate variability. The ability to accurately forecast crop production helps farmers, policymakers, and supply-chain managers make informed decisions. One of the most widely embraced models is the Autoregressive Integrated Moving Average (ARIMA) model, as it is simple and can capture linear dependence in time series data [1]. The performance of ARIMA model depends on appropriate selection of autoregressive (p), differencing (d), and moving average (q) orders, usually these orders are determined by trial and error, which is time-consuming and would not give satisfactory results [2]. To make the order selection process more automated and efficient, statistical metrics like the Akaike Information Criterion (AIC), Bayesian Information Criterion (BIC) and Final Prediction error (FPE) are usually used. In this regard, several researchers have used metaheuristic algorithms to identify parameters in ARIMA or ARMA models. Grid search is computationally expensive and infeasible when p, d and q are large and with large-scale datasets [3]. Researchers used metaheuristic algorithms like Genetic Algorithms which are successful in identifying orders and parameters of ARIMA models [4,5]. Although these evolutionary strategies improved search efficiency and addressed challenges such as premature convergence and fixed operator controls (mutation and crossover), they still struggle to adapt effectively to multimodal landscapes. To achieve lower AIC values and faster convergence, the Firefly Algorithm was introduced, which motivated the adoption of swarm intelligence (SI) techniques [6]. Majority of traditional SI algorithms namely Particle Swarm Optimization (PSO), Ant Colony Optimization (ACO), and Artificial Bee Colony (ABC) use hard grid like population structures, which restricts their adaptiveness to dynamical search landscapes. To overcome these challenges, Spider Monkey Optimization (SMO) algorithm presented in the Memetic Computing was used which mimics the fission-fusion social dynamics of the spider monkeys as they forage [7,8]. The effectiveness of SMO has been demonstrated across diverse optimization problems including resource allocation and scheduling in fog computing environments [9], statistical and optimization applications [10], predictive modelling using artificial neural networks [11], deep neural network hyperparameter tuning [12], and intrusion detection systems [13]. This Spider Monkey Optimization (SMO) approach has multi-group, socially networked search based on the foraging behaviour of spider monkeys. The Spider Monkey Optimization (SMO) algorithm provides a balanced exploration–exploitation mechanism, helping to avoid premature convergence and local minima. Its effectiveness in forecasting time-series has been evidenced in recent research [8] in which a better model to forecast air-quality was constructed using a SMO approach. SMO demonstrates two concepts of swarm intelligence: division of labor and self-organization. Each group has their local leader and overall search process has one global leader. This paper presents an ARIMA model optimized using SMO aims to enhance accuracy of forecast by choosing orders automatically while reducing computational costs. The proposed approach will attempt to address the flaws associated with the manual grid search techniques by utilizing the benefits ofSMO to present a more efficient time series forecasting algorithm by selecting the proper orders. Method details Methodology The ARIMA SMO model is based on a combination of standard ARIMA modeling and population-based metaheuristic optimization algorithm SMO to automate the process of choosing optimal model orders [7]. Instead of performing trial-and-error or grid-based search to select ARIMA order, this approach takes the ARIMA order selection as an optimization problem with the objective of selecting (p, d, q) to minimize AIC or prediction error. The order of ARIMA configuration is a candidate order configuration of each monkey in the SMO population. The position of each spider monkey represents a candidate ARIMA order configuration (p, d, q) and its fitness equals the performance of ARIMA configuration on training information. Over time the optimizer maintains the population of candidate models. The optimization process in SMO proceeds through two major phases, namely: a) Local Leader Phase and b) Global Leader Phase. The SMO algorithm incorporates a fission-fusion social restructuring mechanism to ensure the diversity of the population and to prevent premature convergence. This method provides dynamic restructuring when stagnation of performance is detected, either within the subgroup or the whole population [3]. In case stagnation is identified, subgroups can be reconfigured or agents performing poorly can be reinitiated to identify different parts of the search space. Adaptive restructuring of this kind improves the refreezing capability of the algorithm, as well as its effective search dynamics. Through repeated steps of such coordination processes, it gradually converges to a more optimal order of ARIMA. The global leader is considered as the final solution, and it will be the combination of p, d, q that performed best in the process of optimization. Proposed ARIMA–SMO order selection methodology Under this section, the ARIMA SMO hybrid optimization strategy, such as integration of the ARIMA modelling model with the Spider Monkey Optimization algorithm to automatically and efficiently to select the best ARIMA (p, d, q) parameters, is explained. Definition of ARIMA (p, d, q) The ARIMA model denoted as ARIMA (p, d, q), is a widely used statistical framework for time series forecasting. It combines autoregressive (AR), differencing (I), and moving average (MA) components to capture temporal dependencies and underlying patterns in sequential data. where Φ(B)=(1−φ1B−…−φpBp) represents the AR operator, Θ(B)=(1−θ1B−…−θqBq) represents the MA operator and (1−B)d denotes the differencing operator applied d times. The Box–Jenkins methodology is commonly used to identify appropriate values of p, d, and q and to estimate the corresponding model parameters. In an ARIMA (p, d, q) model, the parameter p represents the autoregressive order, which specifies the number of lagged observations included to capture the dependence of the current value on its past values. The parameter d denotes the degree of differencing, indicating the number of times the original time series is differenced to achieve stationarity. The parameter q corresponds to the moving average order, defining the number of lagged forecast errors incorporated to model short-term shock effects in the series. Under the SMO model, the position of a monkey will be the candidate ARIMA order. Each configuration is evaluated by training the model on the training data and evaluating a performance measure of interest. ARIMA order configuration represents each monkey position in the SMO population. Each candidate is tested in terms of fitness by model fitting to training data. 1. Objective Function: 1. Objective Function: The overall objective of this study is to identify the optimal ARIMA order combination (p, d, q) by minimizing a composite fitness function that jointly considers model goodness-of-fit and forecasting accuracy. Examples of common objective functions are: a.AIC (Akaike Information Criterion): balances model fit and complexity. AIC (Akaike Information Criterion): balances model fit and complexity. b.BIC (Bayesian Information Criterion): like AIC but penalizes complexity more heavily. BIC (Bayesian Information Criterion): like AIC but penalizes complexity more heavily. c.RMSE (Root Mean Squared Error): measures the deviation between predicted and observed values. RMSE (Root Mean Squared Error): measures the deviation between predicted and observed values. 2. Encoding SMO Positions 2. Encoding SMO Positions Each monkey’s position in the SMO population represents a candidate ARIMA order configuration. The fitness of each candidate is evaluated through model fitting on training data. a.(p, d, q): integer values representing ARIMA orders. (p, d, q): integer values representing ARIMA orders. b.(ϕ, θ): the autoregressive (ϕ) and moving average (θ) coefficients estimated for the given orders. (ϕ, θ): the autoregressive (ϕ) and moving average (θ) coefficients estimated for the given orders. 2.1 Discretization of Continuous SMO Positions 2.1 Discretization of Continuous SMO Positions The Spider Monkey Optimization algorithm operates in a continuous search space, whereas ARIMA parameters require discrete integer values. Therefore, a rounding-based discretization mechanism was adopted. Xi = (xp, xd, xq) p = round(xp) d = round(xd) q = round(xq) Boundary constraints were enforced to ensure valid ARIMA configurations: p ∈ [0, Pmax], d ∈ [0, Dmax], q ∈ [0, Qmax] Values exceeding the allowable search bounds were clipped to the nearest valid boundary value. ARIMA search space and parameter constraints The candidate ARIMA orders were restricted to a predefined feasible search space: These limits were selected for three reasons. First, they limit unnecessary model complexity and reduce the computational burden associated with repeated ARIMA model fitting. Second, they reduce the risk of overfitting, particularly because the agricultural production series considered in this study consist of relatively short annual time series. Third, the same search-space constraints were applied to all optimization methods to ensure a fair comparison. The SMO algorithm generates continuous candidate positions internally. Therefore, each position was transformed into a valid ARIMA order by rounding its components to the nearest integer and clipping the resulting values to the specified bounds. The same feasible ARIMA search space was used when evaluating the GA, PSO, BO, and Auto-ARIMA methods. Consequently, the performance comparison reflects differences in the optimization strategies rather than differences in the allowable ARIMA model orders. 3. SMO Phases for ARIMA order selection 3. SMO Phases for ARIMA order selection a. Local Leader Phase a. Local Leader Phase During this stage, each group uses the optimal solution that was the best as identified by the local leader to optimize the parameters of the candidates. This phase focuses on the development of the existing promising solutions, which is achieved by searching the surrounding neighborhood of the local leader. This is to detect and exploit the possible enhancements thus improving the overall effectiveness of the solutions. b. Global Leader Phase b. Global Leader Phase In this case, the global leader guides the whole population to the new regions in the search space. This method will avoid premature convergence and allow different exploration to avoid into local minima. c. Decision Phase (Group Reorganization) c. Decision Phase (Group Reorganization) During this phase groups will reorganize periodically based on the assessment of performance. Monkeys with lower performances levels may shift to new groups, thereby allowing swarm to explore the balance on exploration and exploitation. After iteratively going through these phases, the SMO effectively seeks the ARIMA order that minimizes the selected objective function, thereby improving forecast performance and reducing computational cost compared with conventional grid-search techniques. Simulation and implementation Hyperparameter selection and convergence criteria The principal hyperparameters used in the proposed ARIMA–SMO framework are presented in Table 1. The SMO population consisted of 30 spider monkeys, initially divided into five groups. The maximum number of optimization iterations was set to 80. The local and global leader limits were set to 10 and 15 iterations, respectively. These limits controlled the activation of the local reinitialization and global group-reorganization mechanisms when no improvement in fitness was observed. The ARIMA order search space was defined by the following bounds: Table 1Hyperparameter configuration of the proposed ARIMA–SMO framework.HyperparameterDescriptionValuePopulation size (N)Total number of spider monkeys30Number of groups (G)Initial subgroup divisions5Maximum iterations (Tmax)Optimization iterations80Local leader limitLocal stagnation threshold10Global leader limitGlobal stagnation threshold15αWeight balancing AIC and RMSE0.5PmaxMaximum AR order3DmaxMaximum differencing order2QmaxMaximum MA order3Training–testing splitChronological data split87:13 Hyperparameter configuration of the proposed ARIMA–SMO framework. Each candidate solution was rounded to the nearest valid integer and clipped to these limits before the ARIMA model was fitted. The composite fitness function used equal weighting for the two objective components, with α = 0.5. This value was fixed before the comparative experiments and was not tuned separately for individual datasets. To ensure reproducibility, all stochastic optimization experiments were conducted using a fixed random seed of 42. The same seed was used for the initialization of the SMO population and, where applicable, for the stochastic competing methods. The data were divided into training and testing subsets using a chronological split, ensuring that observations from the future were not used during model estimation. Preliminary sensitivity experiments showed that larger population sizes and iteration counts resulted in negligible improvements in forecasting accuracy while increasing computational cost; therefore, the selected values provided a suitable trade-off between solution quality and runtime. Convergence was assumed when either (i) the maximum iteration counts Tmax = 80 was reached or (ii) the global best fitness value showed no improvement for 15 consecutive iterations. This criterion ensured termination after optimization progress had effectively stabilized. The ARIMA order-selection problem was formulated using a composite objective function that jointly considers statistical model fit and out-of-sample forecasting performance. The fitness function was defined as where AICnorm ​and RMSEnorm​ denote the normalized AIC and RMSE values obtained for the candidate ARIMA(p, d, q) model. Lower fitness values indicate better candidate solutions. AIC was included because it accounts for both goodness of fit and model complexity, thereby discouraging unnecessarily complex ARIMA specifications. RMSE was included because it directly measures the magnitude of forecasting errors. Optimizing AIC alone could select a model with good in-sample fit but weaker forecasting performance, whereas optimizing RMSE alone could favour a more complex model without adequately penalizing additional parameters. The composite objective function therefore provides a compromise between parsimony and predictive accuracy. Because AIC and RMSE are measured on different numerical scales, both quantities were normalized before they were combined. Min–max normalization was applied within each optimization run which prevents one component from dominating the fitness function solely because of its numerical scale. The weighting parameter was fixed at α=0.5, assigning equal importance to model parsimony and predictive accuracy. This value was selected a priori to avoid dataset-specific tuning and was kept constant across all datasets and competing methods. Therefore, the reported comparison does not result from adjusting the objective-function weight to favour the proposed method. Preliminary experimentation indicated that this setting provides stable convergence and consistent forecasting performance across all datasets. All experiments were repeated with fixed random seeds to ensure reproducibility and fair comparison. A random seed value of 42 was used throughout all optimization experiments. Step 1: Initialization of Parameters The algorithm initiates with the specification of the total number of spider monkeys N and division into G groups with respect to the SMO framework. The search space (p, d, q) of the ARIMA model is then specified, by setting up the lower and upper limits of the each of the parameters. The monkeys are each assigned a starting position by randomly sampling a candidate (p, d, q) configuration within these search bounds that are predetermined. The maximum number of iterations, Tmax is defined and the stagnation limits of both the local and global leaders (local limit and global limit) which are used to control the activation of the reorganization steps in the optimization process. Step 2: Evaluation of Fitness The ARIMA model with parameters (pi, di, qi) is trained on the training data to the respective ith monkey in the population. After model estimation, two important performance measures are calculated namely the Akaike Information Criterion (AICi) and the Root Mean Squared Error (RMSEi). These are then added to create a weighted fitness. The fitness value for each monkey was computed using equation (2). The weighted fitness formulation is adopted to jointly account for model parsimony (AIC) and predictive accuracy (RMSE), where the weighting parameter α ∊ [0,1] controls the relative importance of complexity versus prediction error. Once the fitness values for all monkeys have been obtained, the population is ranked in ascending order, with lower fitness values indicating better performance. Step 3: Leader Assignment At this point, the leaders in the SMO population are recognized. •Local Leaders: In each group, the monkey with the minimal fitness value of any given group is assigned as the local leader with respect to the group, the best performing candidate in that sub-group. Local Leaders: In each group, the monkey with the minimal fitness value of any given group is assigned as the local leader with respect to the group, the best performing candidate in that sub-group. •Global Leader: In the entire population of monkeys, the one with the lowest total fitness value is chosen to be the global leader. Global Leader: In the entire population of monkeys, the one with the lowest total fitness value is chosen to be the global leader. Step 4: Iterative Optimization (for each iteration = 1 to Tmax) 4.1 Local Leader Phase (Exploitation) 4.1 Local Leader Phase (Exploitation) In this phase, each monkey redefines its ARIMA order by updating its position relative to the local leader of its group. The update mechanism is defined as: where ϕ∼U(0,1). Updated positions are clipped to remain within the specified parameter bounds. If the new configuration gives an improved fitness score, the update is accepted. 4.2 Global Leader Phase (Exploration) 4.2 Global Leader Phase (Exploration) To promote global exploration, each monkey also updates its position relative to the global leader: If new fitness improves, the position is updated accordingly. 4.3 Update Leaders 4.3 Update Leaders Re-identify the Local Leaders and the Global Leader after each iteration. i.If Global Leader stagnates for global limit iterations: reorganize all monkeys into new groups. If Global Leader stagnates for global limit iterations: reorganize all monkeys into new groups. ii.If any Local Leader stagnates for local limit iterations: reinitialize its group members (except the leader). If any Local Leader stagnates for local limit iterations: reinitialize its group members (except the leader). 4.4 Decision Phase (Fission–Fusion Mechanism) 4.4 Decision Phase (Fission–Fusion Mechanism) Decision phase makes it more diverse and prevents early convergence. •Global Stagnation: When the global leader fails to get better in a specified number of iterations (global limit), restructuring of the entire population through forming new groups is done. Global Stagnation: When the global leader fails to get better in a specified number of iterations (global limit), restructuring of the entire population through forming new groups is done. •Local Stagnation: If no local leader shows improvement within the given local limit, then the monkeys within the corresponding group, except the leader are reinitialized at new random positions. Local Stagnation: If no local leader shows improvement within the given local limit, then the monkeys within the corresponding group, except the leader are reinitialized at new random positions. This fission-fusion process through adaptation enables the swarm to get out of stagnation and venture into unexploited areas of the search space. 4.5 Termination Condition 4.5 Termination Condition The iterative optimization process continues until either: •the algorithm reaches the maximum number of iterations Tmax​, or the algorithm reaches the maximum number of iterations Tmax​, or •convergence criteria are satisfied. convergence criteria are satisfied. Step 5: Output Results Following the optimization process, the Spider Monkey optimization structure will determine the global leader, whose position is the best ARIMA order configuration. The optimal model is therefore the ARIMA configuration that achieves the minimum fitness value: (p∗,d∗,q∗) =Global Leader position. Based on this set of optimal parameters, the final ARIMA model was fitted using the training data only. The fitted model was then used to generate forecasts for the test period. The forecasts were compared with the observed test-set values using RMSE, MAE, and MAPE. The forecasting measures below are calculated to test how accurate and reliable the choice of the model is: 1. Akaike Information Criterion (AIC) 1. Akaike Information Criterion (AIC) AIC quantifies the trade-off between model fit and complexity, with lower values indicating a more parsimonious model: where: •k = number of estimated parameters, k = number of estimated parameters, •L^= maximized value of the likelihood function. L^= maximized value of the likelihood function. 2. Root Mean Squared Error (RMSE) 2. Root Mean Squared Error (RMSE) RMSE measures the average magnitude of forecast errors: where yt and y^t denote the actual and predicted values of the test dataset. 3. Mean Absolute Error (MAE) 3. Mean Absolute Error (MAE) MAE quantifies average deviation between predicted and observed values: 4. Mean Absolute Percentage Error (MAPE) 4. Mean Absolute Percentage Error (MAPE) MAPE expresses prediction accuracy as a percentage error: Lower MAPE values indicate better forecasting performance. System architecture and computational requirements The proposed ARIMA–SMO framework consists of two interacting modules: the Spider Monkey Optimization engine and the ARIMA forecasting component. The SMO module generates candidate ARIMA (p, d, q) order configurations, which are evaluated by the ARIMA forecasting model using the proposed fitness function. The resulting fitness values are returned to the optimizer to guide subsequent search updates. The system specifications used in this study are summarized in Table 2. Table 2System configuration and software environment used for implementation of the ARIMA–SMO framework.ComponentSpecificationProgramming languageR 4.3Development environmentRStudioOperating systemWindows 11ProcessorIntel Core i7RAM16 GBLibrariesforecast, tseries, stats, Metrics, ggplot2 System configuration and software environment used for implementation of the ARIMA–SMO framework. The computational cost of the ARIMA–SMO framework is primarily determined by the repeated fitting and evaluation of candidate ARIMA models during the optimization process. Let L denote the computational cost of fitting and evaluating one ARIMA model, including parameter estimation and calculation of the selected fitness measures. If N is the population size and Tmax​ is the maximum number of optimization iterations, the approximate worst-case computational complexity of the SMO-based search is For the parameter settings used in this study, N=30 and Tmax =80. Thus, the maximum number of candidate evaluations performed by SMO is approximately 30 × 80 = 2,400, excluding any additional evaluations required during initialization, group reorganization, or final model fitting. For an exhaustive grid search, the number of possible integer-valued ARIMA order combinations within the specified bounds is Therefore, the corresponding computational complexity is With Pmax = 3, Dmax ​ =2, and Qmax ​= 3, exhaustive enumeration involves 4 × 3 × 4 = 48 possible ARIMA order combinations. Consequently, under the bounded search space used in the present study, SMO should be interpreted primarily as an adaptive optimization strategy rather than as a method that necessarily reduces the total number of model evaluations relative to exhaustive grid search. Its potential computational advantage becomes more relevant when the search space is substantially enlarged or when the number of model-order dimensions increases. The actual computational cost also depends on the number of evaluations required for convergence, the time required to fit each ARIMA model, the implementation of the competing methods, and the computational environment. Therefore, theoretical complexity was complemented by an empirical comparison of wall-clock runtime across the evaluated methods. To make the runtime comparison consistent, all methods used the same training data, ARIMA-order bounds, fitness-evaluation procedure, forecasting horizon, and fixed random seed where applicable. The stopping settings were defined before the final comparison and were kept unchanged across the six series. Nevertheless, the runtime results represent the specific software implementations and configurations used in this study; they should therefore be interpreted as empirical comparisons rather than as theoretical evidence that SMO is inherently faster than every competing optimizer. Software availability and reproducibility We have developed a R package, SMOARIMA, to implement the proposed ARIMA–Spider Monkey Optimization (ARIMA–SMO) framework. The package contains the Spider Monkey Optimization engine, ARIMA modeling, discretization and boundary-handling procedures, the composite AIC-RMSE fitness function, example datasets and analysis scripts. The package is freely available on the Comprehensive R Archive Network (CRAN) at the webpage https://cran.r-project.org/web/packages/SMOARIMA/. The source code and the fixed optimization settings and analysis procedures described in this study enable reproducibility of the proposed optimization framework and the main analyzes conducted in this work. Fig. 1. Graphical abstract for the Metaheuristic-Driven Automatic ARIMA Order Selection Using Spider Monkey Optimization. The flowchart of the proposed ARIMA–SMO method is presented in Fig. 2. Flow chart of the proposed ARIMA–SMO methodology. Advantages of the proposed ARIMA-SMO Framework 1.Instead of exhaustively evaluating all possible combinations, the method uses population-based optimization to adaptively explore the ARIMA parameter space. Instead of exhaustively evaluating all possible combinations, the method uses population-based optimization to adaptively explore the ARIMA parameter space. 2.Creates a strategic balance between exploration of the global and local exploitation, allowing the SMO to successively optimize model orders and continue to explore new fruitful sectors of the search space. Creates a strategic balance between exploration of the global and local exploitation, allowing the SMO to successively optimize model orders and continue to explore new fruitful sectors of the search space. 3.Successfully navigates local minima by adapting to fission-fusion dynamics of SMO that rearranges the swarm to restart global search in case of stagnation. Successfully navigates local minima by adapting to fission-fusion dynamics of SMO that rearranges the swarm to restart global search in case of stagnation. 4.Improves forecasting accuracy while providing competitive computational efficiency compared with conventional ARIMA order-selection methods. Improves forecasting accuracy while providing competitive computational efficiency compared with conventional ARIMA order-selection methods. Pseudo-Code: ARIMA–SMO algorithm for automatic order selection Algorithm: ARIMA–SMO for Automatic ARIMA (p,d,q) Order Selection Objective: Minimize the fitness value defined in equation (2) Inputs: Yt: Time-series data Bounds: p ∈ [0, Pmax], d ∈ [0, Dmax], q ∈ [0, Qmax] N: Population size (number of monkeys) G: Number of groups Tmax: Maximum number of iterations Fitness(): Fitness function defined in equation (2) Outputs: Optimal ARIMA order (p*, d*, q*) Corresponding AIC*, RMSE*, MAE*, MAPE* ## 1. Initialization Generate an initial population of N monkeys: For each monkey i: Randomly initialize (pi, di, qi) within bounds Divide population into G groups Set stagnation counters: local_limit, global_limit ## 2. Fitness Evaluation For each monkey i: Fit ARIMA(pi, di, qi) Compute AICi and RMSEi Compute fitness_i using equation (2) Rank all monkeys (ascending fitness) Assign: LocalLeader_g ← best in each group GlobalLeader ← best across all groups ## 3. Main Optimization Loop For iteration = 1 to Tmax: ## 3.1 Local Leader Phase (Exploitation) For each group g: For each monkey i in group g: Select random j from same group Draw φ ∼ Uniform(0,1) new_position ← position_i + φ*(LocalLeader_g − position_i) + (1−φ)*(position_j − position_i) Clip new_position to bounds Compute fitness_new If fitness_new < fitness_i: position_i ← new_position ## 3.2 Global Leader Phase (Exploration) For each group g: For each monkey i in group g: Select random k from entire population Draw φ ∼ Uniform(0,1) new_position ← position_i + φ*(GlobalLeader − position_i) + (1−φ)*(position_k − position_i) Compute fitness_new If fitness_new < fitness_i: position_i ← new_position ## 3.3 Leader Update For each group g: LocalLeader_g ← best in group g GlobalLeader ← best in population ### 3.4 Decision Phase (Fission–Fusion) If Global Leader not improved for global_limit: Merge all monkeys and reorganize into new groups For each group g: If LocalLeader_g not improved for local_limit: Reinitialize all group members except LocalLeader_g ## 3.5 Termination Check If convergence achieved or iteration = Tmax: Break loop ## 4. Final Evaluation (p*, d*, q*) ← GlobalLeader.position Fit ARIMA (p*, d*, q*) model using the training data and generate forecasts for the held-out test data. Compute AIC*, RMSE*, MAE*, MAPE* Return (p*, d*, q*, AIC*, RMSE*, MAE*, MAPE*) END The test data were not used during ARIMA order selection, SMO optimization, fitness evaluation, or parameter estimation. After the optimal order (p*, d*, q*), was identified using the training data, the final ARIMA model was fitted using the training data only. The fitted model was then used to generate forecasts for the held-out test period. Forecast accuracy was evaluated by comparing these forecasts with the observed test-set values. This procedure prevents information from the test period from influencing model selection or parameter estimation. Method validation Data description Annual production data for major foodgrain crops in India, including rice, wheat, coarse cereals, total cereals, pulses, and total foodgrains, were used in this study. The time frame covered in the dataset takes 75 years from 1950–51 up to 2024–25. The dataset was compiled from official government statistical sources, including the Reserve Bank of India (Series ON2120) and the Ministry of Agriculture and Farmers Welfare, Government of India (Series ON4251), as well as their historical publications spanning the period 1950–2024 [14]. The dataset contains 75 annual observations covering the period 1950–51 to 2024–25. To evaluate forecasting performance under a realistic prediction scenario, a chronological train–test split was adopted. The first 65 observations (approximately 87% of the data) were used for model training and parameter optimization, while the remaining 10 observations were reserved for out-of-sample testing. This temporal partition preserves the sequential nature of the time series and prevents information leakage from future observations into the training process. In addition to the final chronological train–test evaluation, rolling-origin forecasting was used to assess the stability of the results. At each forecast origin, the model was fitted using all observations available up to that point, and the next observation was forecasted. The origin was then advanced sequentially until the end of the evaluation period. Model selection was performed using the available training observations at each origin, and the corresponding forecasts were aggregated to calculate RMSE, MAE, and MAPE. Experimental design and validation strategy A chronological train–test evaluation was used to assess the forecasting performance of the proposed ARIMA–SMO framework. For each time series, the observations were ordered chronologically and divided into a training set and a test set. The training set was used for ARIMA model estimation, SMO-based order optimization, and evaluation of candidate solutions. The test set was not used during optimization or model selection and was reserved exclusively for final out-of-sample forecast evaluation. For every optimization method, including SMO, GA, PSO, BO, and Auto-ARIMA, candidate ARIMA orders were generated and evaluated using the training data only. After the optimal ARIMA order had been selected, the corresponding model was fitted using the training data and used to generate forecasts for the test period. Forecast accuracy was then assessed using RMSE, MAE, and MAPE. AIC was reported as a model-selection and goodness-of-fit measure, whereas the test-set forecasting measures were used to evaluate out-of-sample predictive performance. The same chronological data partition, ARIMA search bounds, evaluation criteria, and forecasting horizon were used for all competing methods. The search bounds were The random seed was fixed at 42 to ensure reproducibility of the stochastic optimization procedures. For Bayesian Optimization, the search domain was defined on the same discrete grid used by SMO. BO-generated values were rounded and clipped to this grid before ARIMA model fitting. Thus, all optimization methods were evaluated under identical ARIMA-order restrictions, and the comparison reflects differences in search behaviour rather than unequal model-complexity constraints. Results The convergence behaviour of the ARIMA–SMO algorithm was assessed across all six agricultural production series by tracking the global best fitness over 80 iterations (Fig. 3). Across all crops, the algorithm achieved rapid and stable convergence well within the maximum iteration limit, confirming the computational efficiency of the proposed framework over conventional grid-search approaches. The earliest convergence was observed for Pulses (fitness = 0.83102, iteration ∼1), indicating that the initial SMO population already contained a near-optimal ARIMA configuration. Total Cereals and Total Foodgrains converged sharply within the first 6–7 iterations (fitness = 0.81601 and 0.82006, respectively), reflecting the global leader mechanism's ability to rapidly redirect the swarm toward superior order combinations. Wheat exhibited a characteristic stepwise descent from ∼0.813 to 0.81040 by iteration 10, validating the sequential transition from local exploitation to global exploration inherent in the SMO's leader update phases. Coarse Cereals recorded the latest convergence (∼iteration 20, fitness = 0.78960) and the lowest final fitness value among all series, suggesting a comparatively complex optimization landscape. Rice converged smoothly to 0.80172 by iteration 15 with negligible variation. In all cases, the fitness curve remained completely flat after convergence, with no oscillation or deterioration across the remaining iterations, demonstrating that the fission-fusion social restructuring mechanism effectively prevented stagnation and premature convergence. The consistently narrow range of converged fitness values (0.78960–0.83102) across all six series further confirms the robustness and solution quality of the ARIMA–SMO framework. Convergence curves of the proposed ARIMA–SMO algorithm for different agricultural production series: (i) rice, (ii) wheat, (iii) coarse cereals, (iv) total cereals, (v) pulses, and (vi) total food grains. Tables 3, 4, 5, 6, 7, 8 summarize the forecasting performance and optimal model configurations obtained using the competing ARIMA order selection approaches across different agricultural production series. Table 3Comparison of optimization-based ARIMA order selection approaches for rice production forecasting.Optimization MethodARIMA OrderAICBICRMSE(Test)MAE(Test)MAPE(Test)Runtime(s)Genetic Algorithm(3,2,1)742.85756.9192.4870.365.9173.84Particle Swarm Optimization(2,2,1)724.67738.4286.1164.295.1865.92Bayesian Optimization(2,2,0)709.54721.8881.2660.834.7958.11Spider Monkey Optimization(2,2,0)701.3714.1678.6458.74.4754.63 Comparison of optimization-based ARIMA order selection approaches for rice production forecasting. Table 4Comparison of optimization-based ARIMA order selection approaches for wheat production forecasting.Optimization MethodARIMA OrderAICBICRMSE(Test)MAE(Test)MAPE(Test)Runtime(s)Genetic Algorithm(1,2,2)676.84689.7796.5889.718.94103.62Particle Swarm Optimization(0,2,3)659.27671.3589.4483.158.0192.41Bayesian Optimization(0,2,2)643.91655.8484.7679.637.4885.27Spider Monkey Optimization(0,2,2)636.12648.9881.9977.327.1681.08 Comparison of optimization-based ARIMA order selection approaches for wheat production forecasting. Table 5Comparison of optimization-based ARIMA order selection approaches for coarse cereals production forecasting.Optimization MethodARIMA OrderAICBICRMSE(Test)MAE(Test)MAPE(Test)Runtime(s)Genetic Algorithm(1,2,2)659.42666.8344.9136.747.9252.84Particle Swarm Optimization(0,2,3)641.76648.5840.2832.687.0845.63Bayesian Optimization(0,2,2)626.88633.4437.8530.916.6141.22Spider Monkey Optimization(0,2,2)620.95627.3736.2429.856.3338.7 Comparison of optimization-based ARIMA order selection approaches for coarse cereals production forecasting. Table 6Comparison of optimization-based ARIMA order selection approaches for total cereals production forecasting.Optimization MethodARIMA OrderAICBICRMSE(Test)MAE(Test)MAPE(Test)Runtime(s)Genetic Algorithm(3,2,1)821.56835.2450.8238.716.9467.84Particle Swarm Optimization(2,2,1)801.47814.3646.3733.846.1159.42Bayesian Optimization(2,2,0)786.63798.9543.5831.185.7354.26Spider Monkey Optimization(2,2,0)779.81792.6741.9530.065.4850.93 Comparison of optimization-based ARIMA order selection approaches for total cereals production forecasting. Table 7Comparison of optimization-based ARIMA order selection approaches for pulses production forecasting.Optimization MethodARIMA OrderAICBICRMSE(Test)MAE(Test)MAPE(Test)Runtime(s)Genetic Algorithm(3,2,2)567.48585.9236.8429.9712.41112.84Particle Swarm Optimization(2,2,3)548.63565.1132.4126.3811.08101.52Bayesian Optimization(2,2,2)535.92551.4830.1124.7410.4694.36Spider Monkey Optimization(2,2,2)528.75545.928.7823.5910.0389.97 Comparison of optimization-based ARIMA order selection approaches for pulses production forecasting. Table 8Comparison of optimization-based ARIMA order selection approaches for total food grains production forecasting.Optimization MethodARIMA OrderAICBICRMSE(Test)MAE(Test)MAPE(Test)Runtime(s)Genetic Algorithm(3,2,1)836.27850.8143.9633.687.74158.42Particle Swarm Optimization(2,2,1)814.73827.9439.8430.416.88145.67Bayesian Optimization(2,2,0)799.18811.7237.1228.546.39136.24Spider Monkey Optimization(2,2,0)792.64805.535.7527.426.11131.38 Comparison of optimization-based ARIMA order selection approaches for total food grains production forecasting. The comparison of optimization-based ARIMA order selection methods for forecasting agricultural production reveals that Spider Monkey Optimization (SMO) consistently outperformed Genetic Algorithm (GA), Particle Swarm Optimization (PSO), and Bayesian Optimization (BO) across all six datasets. For rice production, SMO selected the ARIMA (2,2,0) model and achieved the lowest AIC (701.30), BIC (714.16), RMSE (78.64), MAE (58.70), MAPE (4.47%), and runtime (54.63 s), indicating superior model fit, forecasting accuracy, and computational efficiency. Similar results were observed for wheat production, where SMO selected ARIMA (0,2,2) and obtained the lowest values of AIC (636.12), BIC (648.98), RMSE (81.99), MAE (77.32), MAPE (7.16%), and runtime (81.08 s). For coarse cereals production, SMO again demonstrated the best performance by selecting ARIMA (0,2,2) and recording the minimum AIC (620.95), BIC (627.37), RMSE (36.24), MAE (29.85), MAPE (6.33%), and runtime (38.70 s). In the case of total cereals production, the ARIMA (2,2,0) model identified by SMO yielded the lowest AIC (779.81), BIC (792.67), RMSE (41.95), MAE (30.06), MAPE (5.48%), and computational time (50.93 s). Likewise, for pulses production, SMO selected ARIMA (2,2,2) and achieved the smallest AIC (528.75), BIC (545.90), RMSE (28.78), MAE (23.59), MAPE (10.03%), and runtime (89.97 s). For total food grains production, SMO once again identified ARIMA (2,2,0) as the optimal model and produced the lowest AIC (792.64), BIC (805.50), RMSE (35.75), MAE (27.42), MAPE (6.11%), and runtime (131.38 s). Across all six agricultural production series, SMO consistently achieved the lowest AIC, BIC, RMSE, MAE, MAPE, and runtime compared with GA, PSO, and BO. The selected ARIMA structures were generally more parsimonious while yielding superior forecasting accuracy. These results indicate that the adaptive exploration–exploitation mechanism of SMO enables more efficient identification of optimal ARIMA orders than competing optimization strategies. Since Spider Monkey Optimization (SMO) consistently outperformed all competing metaheuristic optimization approaches in terms of forecasting accuracy and computational efficiency, an additional comparison was conducted with the widely used Auto-ARIMA procedure (Table 9). Unlike GA, PSO, BO, and SMO, which formulate ARIMA order identification as an optimization problem, Auto-ARIMA employs an information-criterion-based stepwise search strategy for automatic order selection. The comparison revealed that ARIMA-SMO consistently achieved lower out-of-sample forecasting errors across all agricultural production series. These findings indicate that optimization-driven order selection can provide substantial improvements in predictive performance. Although Auto-ARIMA required lower computational effort owing to its stepwise search mechanism, the superior forecasting accuracy obtained by ARIMA-SMO demonstrates the effectiveness of the proposed framework for agricultural production forecasting. Table 9Comparison of forecasting accuracy between Auto-ARIMA and the proposed ARIMA-SMO framework.SeriesAuto-ARIMA OrderAuto-ARIMA RMSEARIMA-SMO RMSEImprovement (%)Rice(0,1,1)145.4178.6445.92Wheat(1,1,0)100.6481.9918.53Coarse Cereals(0,1,1)85.7136.2457.72Total Cereals(0,1,1)291.2841.9585.59Pulses(0,1,1)58.7428.7851.00Total Foodgrains(0,1,1)344.2835.7589.62 Comparison of forecasting accuracy between Auto-ARIMA and the proposed ARIMA-SMO framework. Tables 10, 11, 12, 13, 14, 15. Table 10Diebold–Mariano (DM) test statistics comparing the forecasting performance of optimization-based ARIMA models for rice production.Model ComparisonDM Statisticp-valueSMO vs GA-3.420.001SMO vs PSO-2.870.006SMO vs BO-2.110.039BO vs GA-2.260.028PSO vs GA-1.980.051BO vs PSO-0.840.403 Diebold–Mariano (DM) test statistics comparing the forecasting performance of optimization-based ARIMA models for rice production. Table 11Diebold–Mariano test statistics comparing the forecasting performance of optimization-based ARIMA models for wheat production.Model ComparisonDM Statisticp-valueSMO vs GA-3.670.001SMO vs PSO-2.940.005SMO vs BO-2.080.041BO vs GA-2.490.017PSO vs GA-2.030.047BO vs PSO-1.360.182 Diebold–Mariano test statistics comparing the forecasting performance of optimization-based ARIMA models for wheat production. Table 12Diebold–Mariano test statistics comparing the forecasting performance of optimization-based ARIMA models for coarse cereals production.Model ComparisonDM Statisticp-valueSMO vs GA-3.810.001SMO vs PSO-2.760.008SMO vs BO-1.970.049BO vs GA-2.580.014PSO vs GA-2.110.039BO vs PSO-1.240.221 Diebold–Mariano test statistics comparing the forecasting performance of optimization-based ARIMA models for coarse cereals production. Table 13Diebold–Mariano test statistics comparing the forecasting performance of optimization-based ARIMA models for total cereals production.Model ComparisonDM Statisticp-valueSMO vs GA-3.540.001SMO vs PSO-2.680.009SMO vs BO-1.890.048BO vs GA-2.430.019PSO vs GA-2.020.045BO vs PSO-1.170.237 Diebold–Mariano test statistics comparing the forecasting performance of optimization-based ARIMA models for total cereals production. Table 14Diebold–Mariano test statistics comparing the forecasting performance of optimization-based ARIMA models for pulses production.Model ComparisonDM Statisticp-valueSMO vs GA-3.710.001SMO vs PSO-2.830.007SMO vs BO-1.960.046BO vs GA-2.510.016PSO vs GA-2.080.041BO vs PSO-1.290.203 Diebold–Mariano test statistics comparing the forecasting performance of optimization-based ARIMA models for pulses production. Table 15Diebold–Mariano test statistics comparing the forecasting performance of optimization-based ARIMA models for total food grains production.Model ComparisonDM Statisticp-valueSMO vs GA-3.630.001SMO vs PSO-2.790.007SMO vs BO-1.920.047BO vs GA-2.470.018PSO vs GA-2.140.036BO vs PSO-1.210.229 Diebold–Mariano test statistics comparing the forecasting performance of optimization-based ARIMA models for total food grains production. Further, the Diebold–Mariano test was conducted using squared forecast errors as the loss differential function. The test compared one-step-ahead out-of-sample forecasts obtained from the 10-year testing period. Negative DM statistics indicate superior forecasting accuracy of the first model listed in the comparison. The Diebold–Mariano (DM) test results provide indicative evidence of differences in forecasting accuracy among the optimization-based ARIMA models. However, because the comparison is based on only 10 out-of-sample observations, the results should be interpreted cautiously. Across all agricultural production series, the comparisons between SMO and the competing methods yielded negative DM statistics with p-values below 0.05, indicating that the forecasts generated by the SMO-based ARIMA models were significantly more accurate than those obtained using GA, PSO, and BO. The strongest improvements were observed in the SMO versus GA comparisons, where highly significant DM statistics were consistently obtained across all datasets. The differences between SMO and BO were smaller, with p-values close to the 0.05 threshold. These results suggest a possible advantage for SMO, but they should not be interpreted as definitive evidence of practical superiority given the limited test-sample size. The DM test further showed that BO generally outperformed GA, as evidenced by significant negative DM statistics and p-values below 0.05 across all crop categories. Similarly, PSO demonstrated improved forecasting performance relative to GA in most datasets, although the improvement for rice production was only marginally significant (p = 0.051). In contrast, the comparisons between BO and PSO were not statistically significant for any of the production series (p > 0.05), suggesting that the forecasting performances of these two optimization approaches were broadly comparable. Overall, the DM results suggest that SMO was competitive with, and generally more accurate than, the other methods in this application. Nevertheless, the small test sample limits the strength of statistical conclusions, and the observed differences should be regarded as indicative rather than definitive. Discussion The results indicate that SMO is a competitive approach for automatic ARIMA order selection in the agricultural production series examined. SMO produced lower test-set errors than GA, PSO, and BO across all six series, but the improvements over BO were relatively modest, generally around 3–4% in RMSE. Because the out-of-sample evaluation used only 10 observations, these differences and the corresponding DM-test results should be interpreted cautiously rather than as definitive evidence of universal superiority.The superior performance of SMO can be attributed to its adaptive fission–fusion search mechanism, which enhances population diversity and facilitates efficient exploration of the ARIMA parameter space. Consequently, SMO is less prone to premature convergence and is able to identify more suitable model configurations. In addition to improving forecasting accuracy, SMO required less computational time than the competing optimization methods, highlighting its potential as a robust and computationally efficient framework for agricultural time-series forecasting. The observed performance reflects both the search dynamics of SMO and the prior information incorporated through its design settings, including the ARIMA-order bounds, population structure, stopping criteria, and the equal AIC–RMSE weighting. These settings were fixed before the comparative experiments and were applied consistently across the datasets; however, they should not be regarded as universally optimal. Applications involving different data frequencies, longer or shorter series, seasonal patterns, or exogenous variables may require sensitivity analysis and re-selection of the search bounds and fitness weights. Limitations and future research directions Although the proposed ARIMA–SMO framework achieved improved forecasting performance for the agricultural production series considered in this study, certain limitations should be recognized. The optimization process requires repeated estimation of candidate ARIMA models, resulting in higher computational effort than conventional order-selection procedures. While the observed execution times were acceptable for the datasets analyzed, computational requirements may increase as the search space expands. In addition, the proposed framework is developed for univariate ARIMA modelling and therefore remains dependent on the assumptions underlying ARIMA models. As a result, forecasting performance may be affected when dealing with highly non-linear dynamics, structural changes, or complex non-stationary behaviour that cannot be adequately captured through differencing. Future studies may extend the proposed optimization strategy to seasonal, hybrid, or other advanced forecasting frameworks and evaluate its performance on larger and more diverse datasets to further assess scalability and generalizability. A further limitation is the small out-of-sample evaluation period, which contained only 10 observations. Forecast-error estimates and DM-test statistics can be unstable in such small samples, particularly when differences between methods are modest. Although a standard DM test was used, future work should apply small-sample corrections, such as the Harvey–Leybourne–Newbold adjustment, and evaluate the methods using longer test periods, rolling-origin experiments, and larger benchmark datasets. Ethics statements Not applicable: no human or animal subjects. Related research article Sharma, H., Hazrati, G. and Bansal, J.C., 2018. Spider monkey optimization algorithm. In Evolutionary and swarm intelligence algorithms (pp. 43–59). Cham: Springer International Publishing. For a published article None Declaration of competing interest The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper. Acknowledgment This research did not receive any specific grant from funding agencies in the public, commercial, or not-for-profit sectors. Footnotes Supplementary material associated with this article can be found, in the online version, at doi:10.1016/j.mex.2026.104152. Contributor Information Fasila K P, Email: fasilakp00@gmail.com. Santosha Rathod, Email: santosha.rathod@icar.org.in. Mrinmoy Ray, Email: mrinmoyray.iasri@icar.org.in. Supplementary materials Data availability Data will be made available on request. References Associated Data Supplementary Materials Data Availability Statement Data will be made available on request.