# Chaotic Java Approaches to Solving Electromagnetic Optimization Benchmark Problems
## 4 Description of the Jaya Algorithm
### The Standard (Classical) Jaya Algorithm  
The Jaya algorithm [1] stems from the basic idea that any candidate solution in the search space of the current population should simultaneously change its position to be near the best solution and change its position away from the worst solution in the current population during the evolutionary cycle. The mathematical model of the Jaya algorithm is as follows. We consider \(f(x)\) the objective function. Initially, some solutions \(x_{i,j,k}\), assuming that there are \(n\) design variables (\(i=1,2,\ldots,n\)) and \(m\) candidate solutions (\(j=1,2,\ldots,m\)) in the iteration \(k\) (\(k=1,\ldots,G\)), are randomly generated with uniform distribution in the search domain (design variables bounds), where \(m\) is the population size of the solutions and \(G\) is the maximum iterations (generations) of the evolutionary cycle. Each candidate solution corresponds to the solution of the problem to be solved. Similar to other population-based metaheuristics, the quality of these initial candidate solutions is obtained by simply calculating the objective function value. In this case, we obtain the best and the worst candidate solutions in the population of the candidate solutions that have the best (minimum value in a minimization problem) and the worst (maximum) value of \(f(x)\), respectively. Then, these candidate solution vectors perform an iteration-by-iteration search until the maximum number of iterations is achieved. Classical implementation of the Jaya algorithm is simple and includes just one equation for generating new candidate solutions. At any iteration \(k\), a candidate solution \(x_{i,j,k}\) of the current population uses the following update rule [1,2]:  
\[x^{\prime}_{i,j,k}=x_{i,j,k}+r_{i,j,1}\Big{(}x_{i,j,best}-\Big{|}x_{i,j,k} \Big{|}\Big{)}-r_{i,j,2}\Big{(}x_{i,j,worst}-\Big{|}x_{i,j,k}\Big{|}\Big{)} \tag{4}\]  
where \(x_{i,j,best}\) is the best candidate solution of the \(i\)th variable of the \(j\)th candidate solution, \(x_{i,j,worst}\) is the worst candidate solution, \(x^{\prime}_{i,j,k}\) is the updated value of \(x_{i,j,k}\), and \(r_{i,j,1}\) and \(r_{i,j,2}\) are two uniformly distributed random real numbers generated with uniform distribution for the \(i\)th variable in the interval [0,1]. There are random numbers \(r_{i,j,1}\) and \(r_{i,j,2}\) influence the search range of the algorithm as scaling factors to improve the exploration capacity of the worst candidate solution. The newly found solution vector \(x^{\prime}_{i,j,k}\) may replace the old vector only if it obtains a better objective function value. This means that the quality of the newfound candidate solution is evaluated in terms of the objective function value. If the new candidate solution is better than the original candidate solution in terms of the objective function value, then the algorithm will replace the old candidate solution with the new one. Otherwise, the old candidate solution remains in the current population. The Jaya algorithm preserves the best candidate solutions at the end of each iteration. In the next iteration, the new search will be based on this solution. The steps of using the Jaya algorithm are summarized as follows [1; 2; 3; 4]:  
1. Initially, choose the parameters of the population size, the upper and lower limits of the design variables, and the maximum number of generations or iterations \(G\) (stopping criterion);
2. Randomly generate \(m\) initial candidate solutions (population) with the upper and lower bounds of the variables using uniform distribution in the search domain. Evaluate the initial candidate solutions with the objective function. Set the iteration (generation) \(k\) to zero;
3. Obtain the best and the worst candidate solutions in the current population;
4. For each solution vector \(x\), create a child solution \(x\prime\) given by Equation (4), and validate it by calculating the objective function value;
5. If the \(f(x\prime)\) value is greater than the \(f(x)\) value, then replace \(x\) with \(x\prime\).