2.4.2. Iteration

The next step involves evaluating and sorting the fitness of the population. In each iteration, two values are updated, which are *pbest* and *gbest*. At the iteration step, each solution is evaluated by using the optimization fitness function. If the current value of the solutions in the *d*-dimensional space is better than *pbest*, then the pbest value is updated to the current value and the *pbest* location is the current location. Then, the fitness value is compared with the best-known positions in the swarm. If the current value is better than *gbest*, then *gbest* is updated to the current solution index.

#### 2.4.3. Hybridization of Harmony Search

First, the parameters and the HS Memory (HM) are initialized. The parameters are (i) the size of HM; (ii) the Harmony Memory Considering Rate (HMCR); and (iii) the Pitching Adjust Rate (PAR). Next, the latest harmony is created based on three rules: (i) Random Selection (RS); (ii) HMCR; and (iii) PAR. Firstly, several randomly created solutions to the problems are included in the initial HM. Each component of this solution is acquired on the basis of the HMCR. The probability of choosing a component from the HM members is defined as HMCR and, therefore, 1-HMCR is the probability of creating it randomly. The harmony is chosen from a random HM member and PAR is used to further mutate the chosen harmony. The probability of a candidate from the HM to be mutated is determined by PAR. The RS is responsible for providing random elements to the new harmony. If the latest harmony yields a better fitness, it will replace the worst member in the HM. Otherwise, it is removed. This process is iterated until a stopping condition is reached.
