A New Two-Stage Algorithm for Solving Optimization Problems

Optimization seeks to find inputs for an objective function that result in a maximum or minimum. Optimization methods are divided into exact and approximate (algorithms). Several optimization algorithms imitate natural phenomena, laws of physics, and behavior of living organisms. Optimization based on algorithms is the challenge that underlies machine learning, from logistic regression to training neural networks for artificial intelligence. In this paper, a new algorithm called two-stage optimization (TSO) is proposed. The TSO algorithm updates population members in two steps at each iteration. For this purpose, a group of good population members is selected and then two members of this group are randomly used to update the position of each of them. This update is based on the first selected good member at the first stage, and on the second selected good member at the second stage. We describe the stages of the TSO algorithm and model them mathematically. Performance of the TSO algorithm is evaluated for twenty-three standard objective functions. In order to compare the optimization results of the TSO algorithm, eight other competing algorithms are considered, including genetic, gravitational search, grey wolf, marine predators, particle swarm, teaching-learning-based, tunicate swarm, and whale approaches. The numerical results show that the new algorithm is superior and more competitive in solving optimization problems when compared with other algorithms.


Introduction
Optimization is the science of finding the best solution available for a problem, maximizing or minimizing the corresponding objective function. Each optimization problem has essentially three elements: (i) decision variables; (ii) objective function; and (iii) constraints. An optimization problem can have more than a solution, reason why its global optimum is called the main solution [1].
Methods to solve optimization problems may be divided into two categories: (i) exact and (ii) approximate [2]. Exact methods are able to find the optimum accurately, but they are not efficient enough in complex problems, with their execution times being increasing exponentially according to the problem dimension. The approximate methods (or algorithms) are able to find good (near-optimal) solutions in a short time for complex problems.
There are numerous optimization problems in engineering and sciences that can be solved with different algorithms, where the population-based approaches are often considered as one of the most effective methods in solving such problems [3]. Note that optimization is the challenging problem that underlies many machine and statistical learning algorithms, from the logistic regression model to training artificial neural networks, tools which are fundamental for the development of artificial intelligence [4].
In order to optimize the objective function, population-based algorithms are able to find appropriate values for the decision variables, based on the constraints to which this function is subject to, through random scanning of the problem search space [5].
Although optimization algorithms provide good solutions, they do not necessarily attain the global optimum. However, often these solutions are close to this optimum and then accepted as a quasi-optimal solution. In order to evaluate the performance of the approximate methods in solving optimization problems, an algorithm is superior to another if the former one provides a better quasi-optimal solution than the last one.
Some researchers have focused on designing algorithms to provide quasi-optimal solutions closer to the global optimum. In this regard, diverse algorithms have been applied by engineers and scientists in various fields such as engineering [6] and energy [7] to achieve quasi-optimal solutions. Therefore, mainly in computationally highly complex and challenging optimization problems, different practitioners are interested on improving the computational efficiency of the algorithm used to solve such problems. Consequently, population-based algorithms can be useful to deal with this improvement considering two stages of updating of population members. To the best of our knowledge, this two-stage approach has not been until now considered to improve population-based algorithms.
The main objective of this paper is to propose a new algorithm called two-stage optimization (TSO). The TSO algorithm updates each population member in two stages based on a selected group of the good members. Accordingly, the position of a member of the population is updated using two randomly selected members of the good group.
The rest of the article is organized as follows. Section 2 provides an overview of optimization algorithms published in the literature, mentioning several related works. Then, in Section 3, the proposed TSO algorithm is introduced. The performance of the new algorithm in solving optimization problems is evaluated in Section 4. We present further analysis of the results and discussion on the performance of the TSO algorithm in Section 5. Finally, conclusions and suggestions for future works are given in Section 6.

Literature Review
In this section, we provide an overview of optimization algorithms published in the literature.
The main purpose of the algorithms is to search effectively and efficiently for the solution space of the optimization problem, as well as to apply rules and strategies to guide the search process. In population-based optimization algorithms [3], a population of random solutions is created first [5]. Then, in an iterative process, this population is improved using rules of the algorithm. The principal idea of the population-based algorithms is to update the population in successive iterations, providing better quasi-optimal solutions. An optimization algorithm may provide a reasonable solution to some problems but inadequate to others. Therefore, the main indicator to compare the performance of optimization algorithms is the value of the objective function.
Optimization algorithms have been inspired by various natural phenomena, behavior of living organisms, plant growth, physical laws, and rules of the games, among others. In general, this type of algorithms can be classified into four groups including: (i) evolutionarybased, (ii) game-based, (iii) physics-based, and (iv) swarm-based approaches, which are detailed below.
Evolutionary optimization algorithms [8] were derived by taking into account genetic processes, especially reproduction. Genetic algorithms [9] are the most famous and widely used of this group, which are based on simulating the birth process and Darwin theory of evolution. In these algorithms, population members are updated based on: (i) selection, (ii) crossover, and (iii) mutation. The differential evolution [8] is proposed to overcome the drawback of the genetic algorithm [9], namely its lack of local search. The main difference between the genetic algorithm and differential evolution is in the selection operators. For these operators of the genetic algorithm, the chance of selecting an answer as one of the parents depends on the value of its objective function, but in the differential evolution all answers have an equal chance of being selected. Therefore, this chance does not depend on the value of its objective function. The artificial immune system evolutionary algorithm is inspired by the mechanisms of the human body and designed by simulating the defense mechanism against disease, microbes, and viruses [10].
Game-based algorithms [11] are developed by simulating the rules of various individual and group games with the aim of solving optimization problems. The orientation search is one of the algorithms in this group, which has been designed by considering the orientation game rule. With this rule, the players move on the playground (that is the same as search space) according to the direction indicated by the referee. Football game-based optimization is another of these algorithms which is formulated by simulating the behaviors and policies of clubs in the football league. In this algorithm, the population is updated in four phases: (i) holding the league, (ii) training the clubs, (iii) transferring the players, and (iv) relegation and promotion of the clubs [12].
Swarm-based optimization algorithms [13] are widely considered and designed mimicking the behaviors of animals, plants, and living organisms, as well as other populationbased phenomena [14]. One of the most famous algorithms is the particle swarm optimization (PSO), which imitates the birds' movement. The process of population updating in the PSO algorithm [15] is based on individual knowledge (local best) and the knowledge of the whole population (global best). Teaching-learning-based optimization (TLBO) is another algorithm in this swarm-based group that was introduced following the teachinglearning process between students and teacher [16]. Grey wolf optimization is also in the group of swarm intelligence algorithms and is inspired by nature. This algorithm simulates the hierarchical structure of social behavior of gray wolfs during hunting [17]. When implementing the algorithm, four types of gray wolf (alpha, beta, delta, and omega) are used to model their hierarchical leadership, with three hunting steps being executed: (i) search for prey, (ii) siege of prey, and (iii) attack on prey. The marine predators (MP) algorithm is inspired by the movement strategies that marine predators use when trapping their prey [18]. In the first phase, MP generates a random population of predators in the search space. Then, given that stronger hunters get more chances and share of food, the best solution is applied. Tunicate swarm (TS) is an optimization algorithm that imitates the jet propulsion and swarm behaviors of tunicates during the navigation and foraging process [19]. Whale optimization (WO) is an algorithm inspired by the bubble net hunting method of whales [20]. The WO is performed into three phases: (i) encircling prey, (ii) bubble-net attack, and (iii) searching for prey.
Physics-based algorithms are designed using physical laws to achieve quasi-optimal solutions [21]. One of these optimizers is the gravitational search (GS), which was formulated by simulating the law of gravitational force between objects [22]. Simulation of the Hooke and spring displacement laws were applied to designing the spring search algorithm [23]. In this algorithm, population members correspond to weights connected to each other by different springs. These members are updated moving in the search space using the forces exerted on the weights by the springs. The Henry gas solubility algorithm tries to imitate the behavior governed by the Henry law to solve challenging optimization problems. This is an essential law that states that the amount of gas dissolved in a liquid is proportional to its partial pressure on the liquid at a fixed temperature. The Henry algorithm imitates the huddling behavior of gas to balance exploration and exploitation in the search space and avoid local optima [24].

The New Two-Stage Optimization Algorithm
In this section, the stages of the proposed TSO algorithm are described and then mathematically modeled to be implemented on various optimization problems.

Theory of the TSO Algorithm
In most population-based optimization algorithms, the member that provides the best value of the objective function (the best member) has an impressive impact on population update and algorithm progress. However, the position of the best member in the problem search space may not be appropriate in all axes (decision variables). This concept means that the best member might not be suitable for leading the population in some axes.
The main idea of the TSO algorithm for solving such an issue is to employ a selected group of good members of the population called the good group. The use of this group in population updating utilizes more information in population development to achieve a quasi-optimal solution. Each member in the TSO algorithm is updated in two stages. At each stage of this algorithm, a member of the good group is randomly selected to update the position of each population member on each axis of the search space. This population update continues iterating until the algorithm stops. Then, when the algorithm reaches the stopping condition, the best quasi-optimal solution for the problem is reported. In the next subsection, mathematical modeling of the TSO algorithm is presented.

Mathematical Modeling of the TSO Algorithm
As mentioned, the TSO algorithm is a population-based optimization technique. Each row of the population matrix belongs to a population member, which proposes values for the decision variables. Each column of this matrix also specifies values of a variable proposed by different members. Therefore, for the population matrix, the number of rows is equal to the number of members, whereas the number of columns is equal to the number of decision variables. The population matrix (X) of the TSO algorithm is defined as where → X i is the i'-th population member, x d i is the suggested value for the d'-th variable by the i'-th population member, m is the number of variables, and N is the number of members. After defining the mentioned matrix, the objective function is evaluated based on the corresponding members according to the values proposed for the variables. By comparing the obtained values, a certain number of population members (for example, a ten percent), for which quasi-optimal values have been achieved in the objective function, are selected as members of the good group. This group is described using the matrix representation stated as where → G j is the j'-th good member, g d j is the d'-th dimension of the j'-th good member, and N G is the number of selected good members. The main idea in the TSO algorithm is to update the value of each variable (proposed by each member of the population) using two different members of the good group.
In the first stage, the position of each population member on each axis of the search space is updated with a selected good member. Thus, a good member may be selected to lead a population member on one or more axes. In addition, a good member may not be selected to lead other members on any of the axes. The first stage of the TSO algorithm for updating population members is expressed as where x d i is the new position of the i'-th member in the d'th dimension, rand is a random number in the interval [0, 1], F i is the value of the objective function for the i'-th population member, → X i is the new position of the i'-th member, and F i is its corresponding objective function value. Equation (1) indicates that a member is updated if the value of the objective function is improved in the new position.
In the second stage, the position of each member, on each axis of the search space, is updated again based on a non-repetitive good member. This means that the position of each member, on each axis, is affected by two different members of the good group. This stage of the TSO algorithm in updating population members is defined as After updating the population based on the mentioned two stages, new members of the good group are selected. This process is repeated until the algorithm reaches the condition of stopping. The implementation process of the TSO algorithm is presented as a pseudo-code in Algorithm 1. Furthermore, the steps of the TSO algorithm are shown as a flowchart in Figure 1.

Simulation Study and Results
In this section, the performance of the TSO algorithm for solving optimization problems is evaluated. For this purpose, the algorithm has been implemented on twenty-three different objective functions for achieving a suitable quasi-optimal solution. These objective functions can be categorized into three different types including: (i) unimodal, (ii) high-dimension multimodal, and (iii) fixed-dimension multimodal functions. Detailed information of these objective functions is given in the Appendix A (Tables A1-A3).  Start the TSO algorithm. 1.
Determine the range of decision variables, constraints and objective function of the problem.

2.
Create the initial population at random. 3.
Evaluate the objective function based on the initial population. 4.
For t = 1:T, with t being iteration number and T the maximum iteration: 5.
Update the good group. 6.
For i = 1:N, with N being the number of population members; 7.
For d = 1:m, with d being the contour and m the number of variables: 8.
Select the j'-th good member. 9.
Select the k'-th good member, with k = j. 14. Stage

Simulation Study and Results
In this section, the performance of the TSO algorithm for solving optimization problems is evaluated. For this purpose, the algorithm has been implemented on twenty-three different objective functions for achieving a suitable quasi-optimal solution. These objective functions can be categorized into three different types including: (i) unimodal, (ii) high-dimension multimodal, and (iii) fixed-dimension multimodal functions. Detailed information of these objective functions is given in the Appendix A (Tables A1-A3).

Experimental Setup
In order to analyze the performance of our proposal, the results obtained by the TSO algorithm are compared, as mentioned, with three classes of existing optimization algorithms, which include (i) GA and PSO, as the most well-studied algorithms (famous methods), (ii) GSA, GWO and TLBO, as algorithms which are cited by many scientists (popular methods), and (iii) MPA, TSA and WOA, as recently developed algorithms (new methods). The experimentation has been done on MATLAB (R2017b version, MathWorks, Natick, MA, USA) using a 64-bit Core i7 processor of 3.20 GHz and 16 GB main memory. For all objective functions, the TSO algorithm and its competing algorithms have been simulated in 20 independent runs, where each run employs 1000 iterations. The optimal solutions of the objective functions are evaluated using the two most important indexes for comparing the performance of algorithms when solving optimization problems, that are: average (AV) and standard deviation (SD) of the best obtained solutions, where, as it is known, such an SD reports the dispersion of these solutions. Indeed, when analyzing the performance of the optimization algorithms with the results presented in Tables 1-3, the AV index is important first, but if two algorithms have a similar AV, then the algorithm with less dispersion is superior.

Evaluation for Unimodal Objective Functions
The objective functions F 1 to F 7 are unimodal. The optimization results of the TSO algorithm and other mentioned algorithms for these objective functions are presented in Table 1. For all of these functions, the TSO algorithm performs better than the other eight algorithms. Note that the proposed algorithm provides exactly the global optimal solution for F 6 . In addition, for other functions, the TSO algorithm provides a solution very close to the global optimum, especially for F 1 and F 2 . These results show that the new proposed algorithm has a good efficiency in achieving a suitable quasi-optimal solution for this type of objective functions.

Evaluation for High-Dimesional Multimodal Objective Functions
Six objective functions F 8 to F 13 are selected from high-dimension multimodal functions. Table 2 reports the results of optimizing these functions using the TSO algorithm and other algorithms. Note that the new algorithm performs better for all F 8 to F 13 . Especially for F 9 and F 11 , the TSO algorithm has achieved the global-optimal solution. An overview of the results in Table 2 shows that the proposed algorithm is able to solve this type of optimization problems more effectively compared to the other algorithms.

Evaluation for Fixed-Dimesional Multimodal Objective Functions
The functions F 14 to F 23 are used to evaluate the performance of the TSO algorithm and other algorithms for multimodal functions. The results are reported in Table 3. Notice that the new algorithm provides suitable quasi-optimal solutions for this type of functions. Although the MP algorithm also performs well, it is not competitive with the TSO algorithm for F 15 , F 17 , and F 20 . Thus, the new algorithm is more efficient than the other eight algorithms in optimizing this type of objective functions.
The AV and SD of the optimal solutions of the objective functions using the proposed TSO algorithm and eight other optimization algorithms are presented in Tables 1-3. However, since this class of objective functions are associated with too many local minima, in order to have a better understanding of the results, logarithmic scale plots of the optimal solutions for each algorithm and function are shown in Figure 2.
As mentioned, in order to evaluate the performance of optimization algorithms, objective functions of three different types have been selected. The objective functions F 1 to F 7 of the unimodal type have no local optimum, and the global optimum solution for these functions is zero. Based on the plots of F 1 to F 7 , the TSO algorithm provides the best performance among the optimization algorithms. The GA algorithm is the worst optimizer for F 1 , F 2 , F 3 , and F 5 . The PSO algorithm is not a good optimizer for F 4 , F 6 , and F 7 . Note that the objective functions F 8 to F 13 are high-dimension multimodal type with local optimal solutions. Considering the plots drawn for these objective functions in Figure 2, it is clear that the TSO algorithm has good performance in solving these types of optimization problems. The distributions of quasi-optimal solutions in the TSO algorithm are very close to each other and therefore have very low SD. The objective functions F 14 to F 23 are fixed-dimension multimodal type with local optimal solutions. The superiority of the TSO algorithm in providing quasi-optimal solutions with low SD is evident in Figure 2 for F 14 , F 15 , F 20 , F 21 , F 22 , and F 23 . As reported in Table 3, the TSO algorithm and other eight algorithms provide similar performance in optimizing the objective functions F 16 , F 17 , F 18 , and F 19 . Thus, it is expected that the plots of these functions are similar and practically with no difference to each other.
Based on the analysis of numerical results in Tables 1-3 and the plots presented in Figure 2, it is evident that the TSO algorithm is able to provide suitable quasi-optimal solutions with low SD in various problems.

Statistical Testing
Comparison of the performance of the optimization algorithms in providing quasioptimal solutions based on AV and SD gives us relevant information. However, considering only these results is not enough to guarantee the superiority of an algorithm. This is

Statistical Testing
Comparison of the performance of the optimization algorithms in providing quasioptimal solutions based on AV and SD gives us relevant information. However, considering only these results is not enough to guarantee the superiority of an algorithm. This is because, even after twenty independent runs for each algorithm, the superiority of one over the another may occur randomly with very low probability.
Therefore, in order to prove non-randomness superiority of the TSO algorithm, a statistical test on the performance of the algorithms must be considered. In this paper, the Friedman rank test [25], pp. 262-274 is applied for statistical analysis of optimization results and performance of the algorithms. The results of this test for the TSO algorithm and eight other algorithms are reported in Table 4. According to this table, the TSO algorithm ranks first in optimizing unimodal objective functions. After the TSO algorithm, the TSA algorithm ranks second in the optimization of this type of functions. The proposed algorithm also ranks first among eight other algorithms in optimizing high-dimension multimodal objective functions. For this type of functions, after the TSO algorithm, the GWO algorithm ranks second. The proposed algorithm has also achieved the best performance when optimizing fixed-dimension multimodal objective functions. After the TSO algorithm, the MP algorithm is in the second position. In addition, based on general analysis of the results reported in Table 4, for all twenty-three objective functions, the TSO algorithm achieves the best performance among the mentioned optimization algorithms and has the first position. These results confirm the superiority of the TSO algorithm over the other eight algorithms and prove that this superiority is not product of the randomness.

Discussion
Exploitation and exploration capabilities are two important indicators to evaluate performance of algorithms in providing quasi-optimal solutions [26]. Exploitation power means the ability of an algorithm to achieve a suitable quasi-optimal solution. In fact, at the end of iterations of an algorithm, this must provide the best quasi-optimal solution so far. An algorithm has a higher exploitation power regardless of whether this quasioptimal solution is closer to the global solution. Exploration power indicates the ability of an optimization algorithm to accurately scan different areas of the search space. Thus, an algorithm that scans the search space more accurately for all iterations can provide a quasi-optimal solution close to the global solution without getting stuck in the local solutions. An important point is to maintain a balance between these two indicators. Then, in the first iterations, the priority is with the exploration index to check the search space well. Therefore, by increasing the number of iterations of the algorithm, the priority is with the exploitation index to achieve the best quasi-optimal solution.
The new TSO algorithm, with suitable number of members, has the potential to accurately scan the search space. Guiding the population members in this space under the influence of several good members causes the population to move to different areas of such a space [27]. This issue increases the ability of the TSO algorithm to accurately scan the search space, which indicates the reasonable exploration power of this algorithm. In addition, as the number of iterations increases, the population members move towards the good members, and as the algorithm reaches the final iterations, population converges and concentrates on near the optimal solution. This issue proves the suitable exploitation power of our TSO algorithm to provide an appropriate quasi-optimal solution.
The analyzed unimodal objective functions have one global optimal solution and no local optimal solutions. Then, these functions are suitable to evaluate the exploitation index. The optimization results of such objective functions presented in Table 1 indicate that the TSO algorithm has an acceptable ability to provide a quasi-solution close to the global solution and has a much higher exploitation power than the other algorithms.
The studied high-dimension and fixed-dimension multimodal functions have several local optimal solutions, in addition to the global optimal solution. Therefore, these types of objective functions are suitable for evaluating the exploration index. Based on the results reported in Tables 2 and 3, the TSO algorithm, with the desired exploration power, was able to provide appropriate quasi-solutions. This shows that the TSO algorithm has a reasonable ability to accurately scan the search space and therefore has higher exploration power compared to the other eight optimization algorithms.
The statistical results of the Friedman rank test presented in Table 4 confirmed that the superiority of the TSO algorithm over the other eight algorithms analyzed in the exploitation and exploration indexes is not random.

Conclusions and Future Works
Certain algorithms are able to provide a solution for optimization problems, which is not necessarily the global solution, but could be close to it. In this paper, a two-stage algorithm was introduced to solve optimization problems. The main idea of this algorithm acronymized as TSO is to update the population based on a selected group of its good members. For this purpose, several good members are utilized to lead each population member in all axes of the search space, instead of using only the best member. Therefore, the position of each member in each axis of the search space is updated in two stages and under the influence of two different good members. The main feature of the TSO algorithm is its simplicity of relationships and implementation, as well as the lack of control parameters not needing their tuning.
The stages of the TSO algorithm were described and then mathematically modeled for solving optimization problems. The performance of the proposed algorithm was evaluated on a set of twenty-three objective functions from three different types including unimodal, high-dimension multimodal, and fixed-dimension multimodal functions. The results of this evaluation were compared with the performance of the genetic, gravitational search, grey wolf, marine predators, particle swarm, teaching-learning-based, tunicate swarm, and whale algorithms in optimizing these objective functions [28]. By comparing the simulation results for the unimodal case, which are suitable for evaluating the exploitation index due to having an optimal solution, obvious superiority of the TSO algorithm over the other eight algorithms was demonstrated. Considering the performance of the proposed algorithm and other algorithms on both groups of multimodal objective functions, it was shown that the TSO algorithm has higher exploration power and is superior to other algorithms in optimizing this type of objective functions. Furthermore, the Friedman rank test was applied in order to further analyze the performance of the TSO algorithm and other algorithms. Based on the results of this statistical analysis, it was found that the proposed algorithm ranks first among the studied algorithms and its superiority in optimizing objective functions is not random. Therefore, general analysis of the optimization and statistical results confirmed the superiority of the TSO algorithm doing it more competitive than the other eight analyzed algorithms.
Some ideas and perspectives for future research the arise from the present investigation are the following: (i) the design of the binary version as well as the multi-objective version of the TSO algorithm has an interesting potential; (ii) the implementing of the TSO algorithm on various optimization problems and real-world problems could be explored and achieve some significant contributions [29]; and (iii) it exists a promising area of application in machine, deep and statistical learnings, for instance, in image compression [5]. These and other aspects for further research are being studied by the authors and we hope to publish their finding in future works.
Mathematical details of the twenty-three objective functions used for obtaining the results in Tables A1-A3.   Table A1. Unimodal objective functions and their variables' interval.

Objective Function
Variables' Interval  Table A2. High-dimension multimodal objective functions and their variables' interval.