MFO-SFR: An Enhanced Moth-Flame Optimization Algorithm Using an Effective Stagnation Finding and Replacing Strategy

: Moth-ﬂame optimization (MFO) is a prominent problem solver with a simple structure that is widely used to solve different optimization problems. However, MFO and its variants inherently suffer from poor population diversity, leading to premature convergence to local optima and losses in the quality of its solutions. To overcome these limitations, an enhanced moth-ﬂame optimization algorithm named MFO-SFR was developed to solve global optimization problems. The MFO-SFR algorithm introduces an effective stagnation ﬁnding and replacing (SFR) strategy to effectively maintain population diversity throughout the optimization process. The SFR strategy can ﬁnd stagnant solutions using a distance-based technique and replaces them with a selected solution from the archive constructed from the previous solutions. The effectiveness of the proposed MFO-SFR algorithm was extensively assessed in 30 and 50 dimensions using the CEC 2018 benchmark functions, which simulated unimodal, multimodal, hybrid, and composition problems. Then, the obtained results were compared with two sets of competitors. In the ﬁrst comparative set, the MFO algorithm and its well-known variants, speciﬁcally LMFO, WCMFO, CMFO, ODSFMFO, SMFO, and WMFO, were considered. Five state-of-the-art metaheuristic algorithms, including PSO, KH, GWO, CSA, and HOA, were considered in the second comparative set. The results were then statistically analyzed through the Friedman test. Ultimately, the capacity of the proposed algorithm to solve mechanical engineering problems was evaluated with two problems from the latest CEC 2020 test-suite. The experimental results and statistical analysis conﬁrmed that the proposed MFO-SFR algorithm was superior to the MFO variants and state-of-the-art metaheuristic algorithms for solving complex global optimization problems, with 91.38% effectiveness.


Introduction
Global optimization problems are complex and characterized by various properties, for instance, they can be non-linear, non-separable, symmetric, asymmetrical, smooth with narrow ridges, unimodal, and multimodal, and can involve non-differentiable functions and high dimensionality [1,2].These properties create challenges for existing optimization algorithms, and finding the global optimum is one of the long-standing goals in this area of study.To overcome such challenges, a series of metaheuristic algorithms have been introduced using various innovative approaches.Metaheuristic algorithms have exhibited impressive performance in exploring the problem space and approximating the promising regions in reasonable timeframes.They have been widely improved upon and adapted to solve optimization problems in diverse fields such as computer science [3,4], engineering [5,6], and medicine [7][8][9].Metaheuristic algorithms can be classified into two groups: single-solution-based and population-based algorithms [10,11].Single-solutionbased metaheuristic algorithms are more oriented towards exploitation searches and they manipulate a single solution during the optimization process, which increases its potential to easily become stuck in local optima [12].To solve this challenge, population-based metaheuristic algorithms were developed to be more exploration-oriented and to share the information in order to promote significant diversification in the search space [13,14].Based on the source of inspiration, these algorithms can be classified as evolutionary-based, physics-based, human-based, and swarm intelligence-based algorithms [15,16].
Most population-based metaheuristic algorithms lack mechanisms that can maintain population diversity and the imbalance between search strategies and premature convergence problems.Hence, many effective mechanisms have been proposed to alleviate the weaknesses of these algorithms [52,53].The artificial bee colony algorithm (ABC) is a prominent population-based metaheuristic algorithm that suffers from poor local search performance.Hence, Zhu et al. [54] proposed the Gbest-guided ABC (GABC) algorithm to incorporate information on the global best solution into the search strategy in order to improve the ability to exploit the algorithm.Other algorithms that have achieved significant performance improvements in terms of their local search ability are the quick artificial bee colony (qABC), best-so-far ABC [55], and grey artificial bee colony (GABC) algorithms [56].Nadimi-Shahraki et al. [57] introduced a diversity-maintained multi-trial vector-differential evolution algorithm to increase population diversity and suspend the risk of premature convergence during the evolutionary process.
The moth-flame optimization (MFO) algorithm was inspired by the navigation behavior of moths toward a light source in nature and is used to solve global optimization problems.The MFO algorithm benefits from having a straightforward structure and a small number of control parameters, which increases its versatility.However, the MFO algorithm suffers from problems related to low population diversity [58], which leads it to become stuck in unpromising regions and to achieve low-quality solutions.Many MFO variants have been developed by introducing and hybridizing different search strategies and operators to overcome such challenges.Kaur et al. [59] proposed an enhanced moth flame optimization (E-MFO) method to solve global optimization problems.The E-MFO algorithm applied a Cauchy distribution function and the influence of the best flame parameter to enhance its exploration and exploitation capabilities, respectively.Moreover, an adaptive step size and division of iterations were proposed to balance search strategies.Li et al. [60] presented the Lévy-flight moth-flame optimization (LMFO) algorithm to prevent premature convergence into local optima and enable a trade-off between the algorithm's exploration and exploitation abilities during the search process.Khalilpourazari et al. [61] introduced the WCMFO algorithm, which is a hybridized form of two algorithms, the water cycle and moth-flame optimization algorithms, to increase the exploitation ability of MFO and the exploration ability of the water cycle algorithm.To cope with the weaknesses of MFO, Hongwei et al. [62] proposed chaos-enhanced moth-flame optimization (CMFO) using ten chaotic maps.The chaotic maps are applied in population initialization, boundary handling, and the tuning of the distance parameter.Other variants of MFO are sine-cosine moth-flame optimization (SMFO) [63], combining MFO with Gaussian, Cauchy, and Lévy mutations (LGCMFO) [64], the enhancement of the local search mechanism based on shuffled frog leaping and a death mechanism with MFO (ODSFMFO) [65], and the chaotic local search and Gaussian mutation-enhanced MFO (CLSGMFO) approach [66].
Although the mentioned MFO variants have attained effective modifications in performance, they may still suffer from poor population diversity, which leads to premature convergence to local optima and a decrease in the quality of the algorithms' solutions when tackling complex optimization problems.Moreover, due to the approximate nature of metaheuristic algorithms, there is always an opportunity for improvement in their search strategies.Therefore, this study was devoted to proposing an enhanced moth-flame optimization algorithm named MFO-SFR with the aim of solving global optimization problems.The proposed MFO-SFR algorithm is equipped with an effective stagnation finding and replacing (SFR) strategy to establish diversity throughout the search process and overcome the drawbacks of previous MFO approaches.Moreover, the boundary handling of the MFO algorithm is rectified by generating new random solutions in the range of the problem space.Overall, the main contributions of this study can be summarized as follows.

•
We propose the MFO-SFR algorithm, boosting the performance and enriching the diversity of the canonical MFO;

•
We introduce an effective stagnation finding and replacing (SFR) strategy to boost the performance of the search process; and

•
We introduce an archive to incorporate the representative and the global best flames throughout the search process in order to enrich the diversity.
The performance of the proposed MFO-SFR algorithm was assessed with the CEC 2018 test functions [67] in 30 and 50 dimensions.Then, the MFO-SFR algorithm was compared with two sets of MFO variants and well-known optimizers.In the first set of contender algorithms, the canonical MFO [44] and its variants-Lévy-flight moth-flame optimization LMFO [60], an efficient hybrid algorithm based on the water cycle and mothflame algorithms (WCMFO) [61], chaos-enhanced moth-flame optimization (CMFO) [62], death mechanism-based moth-flame optimization (ODSFMFO) [65], the synthesis of the moth-flame optimizer with sine cosine mechanisms (SMFO) [63], and the hybrid of whale and moth-flame optimization (WMFO) [68]-were selected.In the second set, the particle swarm optimization (PSO) [39], krill herd (KH) [69], grey wolf optimization (GWO) [70], the crow search algorithm (CSA) [71], and the horse herd optimization algorithm (HOA) [45] were considered.Furthermore, the results obtained using the proposed and contender algorithms were statistically analyzed using the Friedman test.Ultimately, two well-known mechanical engineering problems from the CEC 2020 test suite [72] were considered to assess the applicability of MFO-SFR in solving real-world optimization problems.The experimental results indicated that the proposed MFO-SFR algorithm boosted the performance of the canonical MFO by using an effective stagnation finding and replacing (SFR) strategy and an archive construction mechanism.Moreover, the statistical analysis revealed that the performance of the proposed MFO-SFR algorithm was superior to that of the contender algorithms.
The structure of the paper is as follows.Section 2 contains a review of related literature.Section 3 presents the MFO algorithm.In Section 4, the proposed MFO-SFR algorithm is explained in detail.Section 5 thoroughly evaluates the MFO-SFR's performance in addressing CEC 2018 benchmark test functions.Section 6 evaluates the applicability of the proposed MFO-SFR using two real-world mechanical engineering problems from the latest CEC 2020 test suite.Finally, Section 6 summarizes the results and outlines possible future directions of research.

Related Works
MFO variants used to solve different optimization problems are reviewed in this section.
Li et al. [60] boosted the performance of the canonical MFO by using the Lévy-flight strategy.Nadimi-Shahraki et al. [73] proved that the canonical MFO suffers from premature convergence, low population diversity, and an imbalance between search strategies in solving global optimization problems.Therefore, they proposed an improved moth-flame optimization (I-MFO) algorithm to cope with the abovementioned deficiencies.The I-MFO algorithm is equipped with the adapted wandering-around search strategy to maintain population diversity and escape from local optima.The chaos-enhanced MFO (CMFO) [62] algorithm was proposed to improve the performance of the MFO algorithm by incorporating chaos maps into population initialization, boundary handling, and parameter tuning.Pelusi et al. [74] proposed the improved moth-flame optimization (IMFO) algorithm using a hybrid phase, a dynamic crossover mechanism, and a fitness-dependent weight factor.The hybrid phase achieved a good trade-off between the exploration and exploitation phases, the dynamic crossover mechanism enhanced the population diversity, and the fitness-dependent weight factor improved the exploitation phase.
Xu et al. [64] proposed a series of MFO variants by combining the standard MFO algorithm with Gaussian mutation, Cauchy mutation, and Lévy mutation.Gaussian mutation was employed to improve its neighborhood-informed capability, Cauchy mutation was used to enhance its global exploration ability, and the Lévy mutation was employed to increase the randomness in the search process.Li et al. [65] proposed the ODSFMFO algorithm, which consists of an improved flame generation mechanism based on opposition-based learning and the differential evolution algorithm, an enhanced local search mechanism based on the shuffled frog leaping algorithm and a death mechanism.This algorithm maintained the quality of the population through opposition-based learning, population diversity using the differential evolution algorithm, the global search ability through the use of the shuffled frog leaping algorithm, and provided an escape from local optima via the use of the death mechanism.Nadimi-Shahraki et al. [75] proposed a migration-based moth-flame optimization (M-MFO) algorithm with a random migration operator, a guided migration operator, and a guiding archive to alleviate the low population diversity and poor exploration ability of MFO.
Ma et al. [76] developed an improved moth-flame optimization algorithm to prevent premature convergence to local minima.This algorithm uses the inertia weight of diversity feedback control to strike a balance between search strategies and maintain population diversity.Moreover, the mutation probability was added to improve the optimization performance.To enhance the diversity in the position of flames and the search strategy used for moths, Zhao et al. [77] developed an improved MFO (IMFO) algorithm.In this algorithm, the flames are generated through orthogonal opposition-based learning, and their positions are updated using a linear search and a mutation operator.Sapre et al. [78] introduced an opposition-based moth flame optimization method with Cauchy mutation and evolutionary boundary constraint handling (OMFO) to bypass the local optima and accelerate the convergence speed towards promising areas.Sahoo et al. [79] proposed a modified dynamic-opposite-learning-based MFO algorithm named m-MFO, using a modified dynamic-opposite learning strategy to enrich the performance of MFO in solving optimization problems.Other MFO variants include the double-evolutionary learning MFO algorithm (DELMFO) [80], the improved moth-flame optimization algorithm (IMFO) [81], the hybrid MFO and hill climbing (MFOHC) method [82], an enhanced MFO algorithm integrated with orthogonal learning and the Broyden-Fletcher-Goldfarb-Shanno (BFGSOLMFO) method [83], and quantum-behaved simulated annealing algorithm-based moth-flame optimization (QSMFO) [84].
Due to the simple structure of MFO and its low number of control parameters, it has great potential to solve real-world applications.However, the canonical MFO critically suffers from local optimum trapping and premature convergence during the optimization process, which results in low-quality solutions [85][86][87].Therefore, many improved and hybrid variants have been developed to overcome these challenges.Sayed et al. [88] presented the SA-MFO algorithm, a hybrid of the MFO approach and the simulated annealing (SA) algorithm, to escape from local optima using SA and accelerate the search process using MFO.Many researchers have applied the MFO algorithm to solve the optimal power flow (OPF) problem [89][90][91].An effective hybridization of the whale optimization algorithm and a modified moth-flame optimization algorithm named WMFO [68] was proposed to solve diverse scales of the OPF problem.Sahoo et al. [92] proposed a hybrid MFO and butterfly optimization algorithm (h-MFOBOA) to overcome shortcomings such as a slow convergence speed and poor exploitation ability in both optimizers.Sattar Khan et al. [93] adapted the MFO algorithm for an integrated power plant system containing stochastic wind.MFO has been applied to the solution of problems related to fuel cells in a renewable active distribution network [94], the identification of parameters for photovoltaic modules [95], and fuel consumption in variable-cycle engines [96], with promising results.

Moth-Flame Optimization (MFO) Algorithm
Nocturnal moths use celestial light sources to navigate over long distances accurately.They fly in a straight line with a constant angle toward the Moon or stars, and this behavior is called transverse orientation.However, when a moth flies toward a nearby artificial light, it thinks it is a star or the Moon.Therefore, the moth continually changes its flight angle to keep going in a straight line toward the light, resulting in a spiral motion around the artificial light.In 2015, this behavior was mathematically modeled in the moth-flame optimization algorithm [44] developed by Mirjalili to solve the global optimization problem, described in detail as follows.
In this approach to solving the optimization problem, the positions of moths evolve during predefined iterations.In the first iteration, moths are randomly distributed in the problem space using Equation (1), where X id denotes the dth dimension of the ith moth position and the parameters Ub d and Lb d are the upper and lower boundaries for the dth dimension, respectively.
For the rest of the iterations, their new positions are updated based on the position of the flame.Therefore, the flame number (R) is computed using Equation (2), where the parameters N and MaxIterations denote the number of moths and the maximum number of iterations, respectively.Then, the positions of the flames are determined based on the stepwise procedure denoted in Table 1.
Ultimately, for the flame number (R), each moth can update its position using the two different trials denoted in Equation (3), where X i (t + 1) is the new position of the ith moth, D i (t) is computed using Equation (4), b is the constant value, k is calculated using Equations ( 5) and ( 6), and F i (t) denotes the ith flame.
In the second trial (when i > R), the parameter D i (t) is computed using Equation ( 7), and F R (t) is the current position of the Rth flame.
Input: X: the positions of moths, Fit: the fitness values of moths, F: the position of the flame, and OF: the fitness values of flames.
Flame construction in the first iteration when t = 1. 1. Sort the vector Fit in ascending order and extract the sorted index in {j 1 , j 2 , . . ., j N }.

Construct the flame matrix
Flame construction for the rest iteration when t > 1.
1. Construct matrix dual Pop by combining matrices F(t) and X (t − 1). 2. Construct vector dual Fit by combining vectors OF(t) and Fit (t − 1). 3. Sort the vector dual Fit in ascending order and extract the sorted index in {j 1 , j 2 , . . ., j 2N }. 4. Construct the flame matrix

The Proposed MFO-SFR Algorithm
According to the literature, the canonical MFO lacks an efficient operator to maintain population diversity.The search process may be biased by the best solutions obtained in each iteration [97].This deficiency leads to premature convergence into unpromising regions, local optimum stagnation, and a decrease in the solution quality when solving complex problems.Hence, in this study, we were motivated to propose an enhanced mothflame optimization algorithm named MFO-SFR to effectively maintain population diversity and mitigate the deficiencies mentioned above by introducing an effective stagnation finding and replacing (SFR) strategy.
Stagnation finding and replacing (SFR) strategy: Suppose that the matrix X (t) = {X 1D (t), . . ., X iD (t), . . ., X ND (t)} denotes a moth population in the current iteration t in a D-dimensional search space.Each vector X iD (t) denotes the position of the ith moth in the problem space.The matrix X (t) is initialized for the first iteration using a uniform random distribution.For the rest of the iterations (when t ≥ 2), the new positions of the moths are determined using Equation (8), where D α i (t) and D β i (t) are the main elements of the SFR strategy, which is computed using Equations ( 9) and (10), respectively.A constant b expresses the shape of the logarithmic spiral, and τ is a random number between the intervals −1 and 1. F j (t) and F R (t) are the positions of the jth flame and the Rth flame such that the parameter R is computed using Equation (2).In Equation ( 9), vector M i (t) is determined using Definition 1.To find the stagnant solutions, the mean of the distance or ϕ i is calculated using Equation (11), where X iq is the qth dimension of the ith moth.F jq is the qth dimension of the jth flame in which the index j is determined by Equation ( 12), which sorts the results obtained from Equation (11) in descending order to obtain the indexes, then applies them as flame indexes in Equation (10).
Definition 1. (Archive construction): The main idea behind archive construction is to enrich the population diversity by preserving the generated representative flame and boost the convergence of solutions toward promising areas by preserving the best solutions in each iteration.To construct the archive Arc, consider the matrix M = {M 1 , . . ., M i , . . ., M κ } as the memory of the Arc with predefined κ.Each M i = [m i1 , m i2, . . ., m iD ] denotes this memory's vector position, which is generated using Algorithm 1. First, dual Pop and dual Fit are created based on the flame construction process described in Table 1.Then, the representative flame (RF) with the average of flames' positions is computed using Equation ( 13), where C is the total number of considered moths and F id denotes the dth dimension of the ith flame.Finally, the global best flame and RF position are archived as two new entries in the memory M. In regard to inserting these new entries; they are randomly replaced with two existing entries if the memory is full.
In addition, MFO-SFR checks the feasibility of the position of the new moths to return those that have violated the problem space boundaries by generating random positions in the range of the problem space.

7.
Inserting RF and the global best flame into the Arc. 8. else 9.
Replacing RF and the global best flame with two existing memory entries.10. end if 11. end

Complexity Analysis
Regarding the pseudocode of MFO-SFR shown in Algorithm 2, the MFO-SFR algorithm consists of six distinct phases: initialization, flame construction, archive construction, movement, correcting the violated positions, and updating the positions.In the initialization phase, N moths are randomly distributed in a D-dimensional search space with an O(ND) computational complexity.In the flame construction phase, flames are constructed differently with the computational complexity of O(N 2 ), considering the worst case for the quicksort algorithm.The computational complexity of the archive construction phase using Algorithm 1 is O(N 2 + ND), because lines 2−4 have the complexity of O(N 2 ) with respect to the original paper's definition of MFO, and Equation ( 13) has O(ND) in the worst case.The cost of the movement phase is O(ND), using either Equations ( 8) and (9) when i ≤ R or using Equations ( 8) and ( 10) when i > R.Then, the feasibility of the new positions is checked to correct the violated positions with the computational complexity of O(ND).Finally, the updating phase is performed with O(ND) computational complexity.Therefore, considering T iterations, the computational complexity of MFO-SFR is O(ND + N 2 + T(2N 2 + 4ND) or O(TN 2 + TND).In the same fashion, the space complexity is O(N + ND + κ), considering that the memory is reusable and the size of the memory is κ.Thus, the space complexity of MFO-SFR is O(ND + D 2 log N).Output: Returns the position of the global best flame and its fitness value.1. Begin 2. Initiating matrix X (t) using a uniform random distribution in the D-dimensional search space.3. Computing the fitness value of X (t) and storing them in vector OX (t). 4. Constructing the flame fitness value OF by ascending order of the vector OM (t). 5. Constructing the flame positions F based on their obtained vector OF. 6.While t ≤ MaxIterations 7.
Updating F and OF by the best N moths from F and current X.
If i ≤ R 12.
Computing the distance between flame F i (t) and M i (t) using Equation (9).13.
Updating the position of X i (t) using Equation (8).14. else 15.
Updating the position of X i (t) using Equation (8).17.
Checking the feasibility and correcting the new position.19.
Computing the fitness value of the new position.20.
End for 21.
Updating the global best flame.22. End while

Evaluation of the Proposed MFO-SFR Algorithm
In this section we present our evaluation of the performance of the proposed MFO-SFR algorithm in solving global optimization problems from the CEC 2018 benchmark test suite [67].This test suite is suitable for evaluating the proposed algorithm in terms of its local optimum avoidance ability and the diversity of solutions as it consists of 29 test functions with different characteristics, such as unimodal, multimodal, and hybrid functions, as well as compositions with various dimensions (D), specifically, 30 and 50 dimensions.Moreover, in this section, we also present two separate sets of experiments conducted to extensively assess and compare the performance of the proposed MFO-SFR algorithm with several well-known optimization methods.The proposed algorithm was compared to the original MFO and its variants in the first set, and then, in the second experimental set, it was compared to other prominent and recent optimizers.In both experiment sets, all comparative algorithms' control parameter values were adjusted to match those in their original articles, as depicted in Table 2.All of the algorithms were executed 20 times on a laptop with an Intel Core i7-10750H CPU (2.60 GHz), 24 GB of memory, and MATLAB R2022a with a maximum of (D × 10 4 )/N iterations, where D represents the dimension size of the problem and N is the population size, which was set to 100 in this study.
To investigate the impact of the archive introduced in Equation ( 10), a numerical pretest was performed on the canonical MFO algorithm using the CEC 2018 benchmark test suite on dimension 30.In this pre-test percentage of situations when the parameter ϕ i was equal to zero is computed and reported in Table A1 of Appendix A. The results reported in Table A1 in Appendix A showed that for some test functions, especially hybrid and composition ones, the percentage of stagnant solutions was high enough to affect the quality of the generated solutions.

Comparing the Proposed MFO-SFR Algorithm with MFO Variants
In this set of experiments, we compared the proposed MFO-SFR algorithm with moth-flame optimization (MFO) [44] and its variants, including LMFO [60], WCMFO [61], CMFO [62], ODSFMFO [65], SMFO [63], and WMFO [68].Table 3 compares the results of the proposed MFO-SFR algorithm with those of MFO and its variants in solving the CEC 2018 test functions with 30 dimensions.The results acquired from the unimodal test functions F 1 and F 3 demonstrated that MFO-SFR had an acceptable exploitation potential compared to the other algorithms.The results from multimodal test functions F 4 -F 10 indicated that the proposed algorithm was able to efficiently search the problem space and find the unvisited areas by maintaining its population diversity throughout the optimization process.The overall results of the hybrid and composition functions F 11 -F 30 confirmed that MFO-SFR avoided local optimum solutions by striking a balance between exploration and exploitation abilities.Moreover, the final rows of Tables 3 and 4 reveal that according to the Friedman test [98], the proposed MFO-SFR algorithm ranked first among the algorithms, including MFO and the other investigated variants.Table 4 presents the average and minimum fitness values obtained from the proposed MFO-SFR algorithms, MFO, and its six variants in solving the CEC 2018 benchmark test functions with 50 dimensions.Overall, the results showed that the proposed MFO-SFR algorithm provided competitive results for most test functions, and it ranked first according to the Friedman test results, which are reported in the final row of the table.Additionally, an exploratory data analysis is depicted in Figure 1 to show the ranking of algorithms for each function.Overall, it can be seen that the proposed MFO-SFR algorithm surrounds the center of the radar chart for most test functions in 30 and 50 dimensions.For instance, for F 1 , the proposed MFO-SFR algorithm was ranked first in 30 dimensions and third in 50 dimensions, whereas WMFO and the canonical MFO algorithms were ranked second and seventh for 30 and 50 dimensions, respectively.For F 12 , it can be seen that MFO-SFR was ranked second, MFO was ranked seventh, and WMFO was ranked first for 30 dimensions, and these three algorithms were ranked second, seventh, and first, respectively, for 50 dimensions.For F 27 , MFO-SFR and WMFO were ranked first and sixth in both 30 and 50 dimensions, whereas the canonical MFO algorithm was ranked fourth in 30 dimensions and fifth in 50 dimensions.
The convergence comparison of the proposed MFO-SFR algorithm and the other studied algorithms is shown in Figure 2.For F 1 in 30 dimensions, it can be seen that although MFO-SFR exhibited prolonged convergence, it provided the best solution compared to the other algorithms.In 50 dimensions, however, it ranked second after WMFO.For multimodal functions F 5 and F 7 , the convergence trend of MFO-SFR continued up to the final iterations, whereas most of the competitors were flattened in local optimum zones.As evidence of the adequate balance between exploration and exploitation, for hybrid functions F 10 and F 16 , MFO-SFR exhibited sharp movements in the first half of the iterations and relatively modest fluctuations in the second half.Ultimately, for composition test functions F 21 , F 26 , and F 30 , MFO-SFR exhibited a gradual trend toward the optimum solutions after beginning its convergence with a sharply descending slope.This behavior indicates the capacity of MFO-SFR to bypass the local optimum and avoid premature convergence.The convergence comparison of the proposed MFO-SFR algorithm and the other studied algorithms is shown in Figure 2.For F1 in 30 dimensions, it can be seen that although MFO-SFR exhibited prolonged convergence, it provided the best solution compared to the other algorithms.In 50 dimensions, however, it ranked second after WMFO.For multimodal functions F5 and F7, the convergence trend of MFO-SFR continued up to the final iterations, whereas most of the competitors were flattened in local optimum zones.As evidence of the adequate balance between exploration and exploitation, for hybrid functions F10 and F16, MFO-SFR exhibited sharp movements in the first half of the iterations and relatively modest fluctuations in the second half.Ultimately, for composition test functions F21, F26, and F30, MFO-SFR exhibited a gradual trend toward the optimum solutions after beginning its convergence with a sharply descending slope.This behavior indicates the capacity of MFO-SFR to bypass the local optimum and avoid premature convergence.

Comparing the Proposed MFO-SFR Algorithm with Other Well-Known Optimization Algorithms
The second set of experiments, we compared the performance of the proposed MFO-SFR algorithm with the well-known representative metaheuristic algorithms presented in

Comparing the Proposed MFO-SFR Algorithm with Other Well-Known Optimization Algorithms
The second set of experiments, we compared the performance of the proposed MFO-SFR algorithm with the well-known representative metaheuristic algorithms presented in the literature, including particle swarm optimization (PSO) [39], krill herd (KH) [69], grey wolf optimization (GWO) [70], the crow search algorithm (CSA) [71], and the horse herd optimization algorithm (HOA) [45].The algorithms' source codes were gathered from publicly available resources, and their parameter values were the same ones considered in the original papers, as reported in Table 2. Tables 5 and 6 compare the average and minimum fitness values produced by the proposed MFO-SFR algorithm and the other algorithms for 30 and 50 dimensions.The results of the test functions F 1 and F 3 -F 10 for both numbers of dimensions demonstrated that MFO-SFR exhibited impressive exploitation and exploration capabilities and generated better solutions while dealing with unimodal and multimodal tests.The results of test functions F 11 -F 30 demonstrated that the MFO-SFR avoided local optimum trapping and balanced the trade-off between exploration and exploitation abilities.Furthermore, the final two rows present the results of the Friedman test for each algorithm, in which MFO-SFR ranked first among the comparative algorithms for both 30 and 50 dimensions.The exploratory data analysis shown in Figure 3 was conducted to investigate the ranking of algorithms for each test function.Overall, it can be noted that the proposed MFO-SFR algorithm was ranked first among the other compared algorithms for all test functions, except for F 10 in 30 dimensions.For 50 dimensions, it is notable that MFO-SFR was ranked first for all test functions except for F 4 , F 10 , F 22 , and F 28 .As shown in Figure 4, we analyzed MFO-SFR's convergence behavior and compared it with that of the other algorithms.Overall, it can be seen that the proposed MFO-SFR algorithm was able to converge toward more accurate solutions by avoiding local optimum solutions and striking a balance between its search abilities.It is also notable that the proposed MFO-SFR algorithm maintained its solution accuracy by enhancing the number of dimensions, which demonstrates the scalability of the proposed algorithm.

Population Diversity Analysis
Maintaining population diversity is essential in metaheuristic algorithms since low diversity among search agents may cause the algorithm to become stuck at local optimum areas.In this experiment, the population diversity of MFO-SFR and five representatives of comparative algorithms was investigated on several CEC 2018 benchmark test suites with 30 and 50 dimensions.The population diversity curves presented in Figure 5 were calculated by measuring the moment of inertia (I c ) [99], where I c denotes the spreading of each individual from their centroid, which was determined by Equation ( 14), and the centroid c j for j = 1, 2, ... D was calculated using Equation (15).Comparing the population diversity curves with the convergence curves plotted in Figures 2 and 4, it can be noted that the proposed MFO-SFR algorithm effectively maintained diversification among solutions until the near-optimal solution was met.This behavior occurred mainly because of the introduced SFR strategy, which identified stagnant solutions using a distancebased technique and replaced them with a solution selected from the archive constructed from the previous solutions.The introduced archive was able to maintain not only the diversification of solutions by preserving the generated representative flame but also the convergence of solutions toward promising areas by preserving the best solutions in each iteration.

The Overall Effectiveness of MFO-SFR
The overall effectiveness (OE) achieved by the proposed MFO-SFR algorithm in solving test functions with 30 and 50 dimensions was computed using Equation ( 16) and the results are reported in Tables 7 and 8. OE i indicates the overall effectiveness of the i-th algorithm, L i is the total number of test functions that the i-th algorithm lost, and TF is the total number of test functions.Table 7 compares the OE achieved by the proposed MFO-SFR with the other MFO variants, showing that MFO-SFR attained the highest OE value, equal to 74.14%.Moreover, Table 8 shows that MFO-SFR achieved a higher OE value of 91.38% compared to other well-known optimization algorithms.

Applicability of MFO-SFR to Solving Mechanical Engineering Problems
There is a growing interest in using optimization algorithms in mechanical and engineering systems to improve performance, cost, and product lifespan [50,100].Therefore, in this section we assessed the applicability of MFO-SFR using two challenging real-world optimization issues from the most recent CEC 2020 test suite [72].The constraints of the problems were handled using a death penalty function.The maximum number of iterations for MFO-SFR and the variants of MFO was (D × 10 4 )/N, where D is the number of decision variables and N is the number of search agents, which was set to 20.

Welded Beam Design (WBD) Problem
The WBD [101], stated in Equation ( 17), is a well-known optimization issue in constrained engineering problems.The primary goal of this task, as indicated in Figure 6, is to minimize the total fabrication cost of a welded beam by determining the best design parameters for the clamped bar length (l), weld thickness (h), bar thickness (b), and bar height (t).The results tabulated in Table 9 indicate that the proposed MFO-SFR exhibited superior performance compared with the other algorithms.

The Four-Stage Gearbox Problem
The design of a four-stage gearbox [102] was the second engineering design optimization problem examined in this study.To reduce the weight of the gearbox, the mathematical model specified in Equation ( 18) was used, together with 86 non-linear constraints and 22 discrete decision variables.According to the results reported in Table 10, the MFO-SFR algorithm outperformed the other algorithms in terms of the quality of its solution.

The Four-Stage Gearbox Problem
The design of a four-stage gearbox [102] was the second engineering design optimization problem examined in this study.To reduce the weight of the gearbox, the mathematical model specified in Equation ( 18) was used, together with 86 non-linear constraints and 22 discrete decision variables.According to the results reported in Table 10, the MFO-SFR algorithm outperformed the other algorithms in terms of the quality of its solution.Subject to: b 1 ∈ {3.175, 12.7, 8.255, 5.715} y p1 , x p1 , y gi , x gi ∈ {12.7, 38.1, 25.4, 50.8, 76.2, 63.5, 88.9, 114.3, 101.6} 7 ≤ N gi , N pi ≤ 76 ∈ integer.

Conclusions and Future Works
MFO is a prominent metaheuristic algorithm, inspired by the nighttime convergent behavior of moths in relation to a light source.A large part of MFO's popularity in recent years has been attributed to its straightforward construction.However, due to its rapid loss of population diversity and inadequate exploration ability, the MFO algorithm often encounters local optimum entrapment and premature convergence.In this study, an enhanced moth-flame optimization (MFO-SFR) algorithm was proposed to tackle these weaknesses.MFO-SFR introduces an effective stagnation finding and replacing (SFR) strategy to effectively maintain population diversity by finding stagnant solutions using a distance-based technique and replacing them with a solution selected from the archive constructed on the basis of previous solutions.
The performance of the proposed MFO-SFR algorithm was evaluated on global optimization problems using the CEC 2018 benchmark test suite in two different sets of experiments.In the first set of experiments, the performance of MFO-SFR was benchmarked by conducting the CEC 2018 benchmark functions with 30 and 50 dimensions.The obtained results were compared to those obtained using MFO and its six recent variants, including Lévy-flight moth-flame optimization (LMFO), an efficient hybrid algorithm based on the water cycle and moth-flame (WCMFO), chaos-enhanced moth-flame optimization (CMFO), death mechanism-based moth-flame optimization (ODSFMFO), the synthesis of the moth-flame optimizer with sine cosine mechanisms (SMFO), and the hybrid of whale and moth-flame optimization (WMFO).In the second set of experiments, the results obtained using MFO-SFR were compared with the results of five well-known swarm intelligence algorithms, including particle swarm optimization (PSO), krill herd (KH), the grey wolf optimizer (GWO), the crow search algorithm (CSA), and the horse herd optimization algorithm (HOA) in 30 and 50 dimensions.Furthermore, the results of the two sets of experiments were statistically analyzed and ranked based on their average fitness values.To further analyze the performance of the proposed algorithms, convergence and population diversity results were plotted and compared with those of the other studied algorithms.The plotted curves showed that MFO-SFR could avoid premature convergence and local optimum solutions by maintaining its population diversity throughout the optimization process.To verify the viability of MFO-SFR in solving real-world optimization problems,

Algorithm 1 .
The pseudocode of the archive construction process.Input: C: Number of considered flames, and κ: the maximum size of the archive Arc.Output: Returns the archive Arc. 1. begin 2. dual Pop and dual Fit are created based on flame construction defined in Table 1. 3. Fit Best = Ascending order of the vector dual Fit and selecting the best N values.4. Pop Best = The corresponding positions of vector Fit Best . 5. Computing RF using Equation (13) for C number of considered flames.6.If the current memory size < κ−1.

Algorithm 2 .
The pseudocode of the proposed MFO-SFR algorithm.Input: N: Number of moths, MaxIterations: Maximum iterations, and D: Dimension size.

Figure 1 .
Figure 1.Exploratory data analysis of MFO-SFR, MFO, and its variants on CEC 2018 with 30 and 50 dimensions.

Mathematics 2023 , 28 Figure 3 .
Figure 3. Exploratory data analysis of MFO-SFR and other well-known MFO algorithms on CEC 2018 with 30 and 50 dimensions.

Figure 3 .
Figure 3. Exploratory data analysis of MFO-SFR and other well-known MFO algorithms on CEC 2018 with 30 and 50 dimensions.

Figure 3 .
Figure 3. Exploratory data analysis of MFO-SFR and other well-known MFO algorithms on CEC 2018 with 30 and 50 dimensions.

Figure 4 .
Figure 4. Comparison of the convergence behavior of MFO-SFR and well-known algorithms for CEC 2018 test functions with 30 and 50 dimensions.

Figure 4 .
Figure 4. Comparison of the convergence behavior of MFO-SFR and well-known algorithms for CEC 2018 test functions with 30 and 50 dimensions.

Figure 5 .
Figure 5. Population diversity of MFO-SFR and comparative algorithms on CEC 2018 test functions.Figure 5. Population diversity of MFO-SFR and comparative algorithms on CEC 2018 test functions.

Figure 5 .
Figure 5. Population diversity of MFO-SFR and comparative algorithms on CEC 2018 test functions.Figure 5. Population diversity of MFO-SFR and comparative algorithms on CEC 2018 test functions.

Table 2 .
Parameter values for the optimization algorithms.

Table 3 .
Comparison of MFO-SFR with MFO variants for CEC 2018 test functions with D = 30.

Table 4 .
Comparison of MFO-SFR with MFO variants for CEC 2018 test functions with D = 50.

Table 5 .
Comparison of MFO-SFR with well-known algorithms for CEC 2018 test functions with D = 30.

Table 6 .
Comparison of MFO-SFR with well-known algorithms for CEC 2018 test functions with D = 50.

Table 7 .
The overall effectiveness of MFO-SFR and MFO variants.

Table 8 .
The overall effectiveness of MFO-SFR and contender algorithms.

Table 9 .
Comparison of the results obtained for the welded beam design problem.

Table 9 .
Comparison of the results obtained for the welded beam design problem.

Table 10 .
Comparison of the results obtained for the four-stage gearbox problem.