# A Real-Time FPGA-Based Metaheuristic Processor to Efficiently Simulate a New Variant of the PSO Algorithm

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Proposed Markov Switching PSO Algorithm

- Specification of the control parameters. Here, the proposed Markov switching PSO algorithm has a population matrix $\mathbf{W}$ with P adaptive filters, where each particle denotes an adaptive filter, as shown in Equation (1). Here, the order N of each adaptive filter determines the dimension of each particle. Therefore, the whole population is defined as follows:$$\mathbf{W}=\left[\begin{array}{cccc}{w}_{1}^{1}& {w}_{1}^{2}& \cdots & {w}_{1}^{P}\\ {w}_{2}^{1}& {w}_{2}^{2}& \cdots & {w}_{2}^{P}\\ \vdots & \vdots & \ddots & \vdots \\ {w}_{N}^{1}& {w}_{N}^{2}& \cdots & {w}_{N}^{P}\end{array}\right]$$
- Creation of the initial population. At the first iteration $n=1$, the position ${\mathbf{w}}_{i}\left(n\right)$ of each particle is initialized, where $i=1,2,\cdots ,P$.$${\mathbf{w}}_{i}\left(n\right)=(ub-lb)\xb7\mathbf{r}+lb$$
- Calculation of the signal filtering. The calculation of signal counteraction or also called residual noise $\mathbf{e}\left(n\right)$ is given by$${\mathbf{e}}_{i}\left(n\right)=\mathbf{d}\left(n\right)+{\mathbf{y}}_{i}\left(n\right)$$$\mathbf{d}\left(\mathbf{n}\right)$ denotes the desired signal and $\mathbf{y}\left(\mathbf{n}\right)$ the filter output of the i-th filter.
- Evaluation of the fitness function. To compute the best position, the PSO algorithm uses the mean squared error (MSE) of each P error signal as a fitness function of each adaptive filter. The evaluation of the position ${\mathbf{w}}_{i}\left(n\right)$ can be computed as follows:$${f}_{i}\left(n\right)=\frac{1}{N}\sum _{k=1}^{N}{e}_{i}^{2}\left(k\right)$$
- Calculation of the distance between particles and the obtention of the value of Markov chain. Here, the velocity and position are obtained by using the following equations:$${\mathbf{v}}_{i}\left(n\right)=\varphi \xb7{\mathbf{v}}_{i}(n-1)+{c}_{1}\left(\xi \left(n\right)\right)\xb7{r}_{1}[{\mathbf{w}}_{pbes{t}_{i}}-{\mathbf{w}}_{i}\left(n\right)]+{c}_{2}\left(\xi \left(n\right)\right)\xb7{r}_{2}[{\mathbf{w}}_{gbest}-{\mathbf{w}}_{i}\left(n\right)]$$$${\mathbf{w}}_{i}\left(n\right)={\mathbf{w}}_{i}(n-1)+{\mathbf{v}}_{i}\left(n\right)$$The average distance, ${d}_{i}$, between each particle and the other particles is computed as follows:$${d}_{i}\left(n\right)=\frac{1}{P}\sum _{j=1}^{P}\sqrt{\sum _{k=1}^{N}{({x}_{i}\left(k\right)-{x}_{j}\left(k\right))}^{2}}$$$${E}_{f}=\frac{{d}_{g}-{d}_{min}}{{d}_{max}-{d}_{min}}$$Here, we obtain the value of the Markov chain, which is based on the value of evolutionary factor ${E}_{f}$, as follows [14]:$$\xi \left(n\right)=\left\{\begin{array}{cc}1,\hfill & 0\le {E}_{f}<0.25,\hfill \\ 2,\hfill & 0\le {E}_{f}<0.5,\hfill \\ 3,\hfill & 0\le {E}_{f}<0.75,\hfill \\ 4,\hfill & 0\le {E}_{f}<1,\hfill \end{array}\right.$$$$\mathrm{\Pi}=\left(\begin{array}{cccc}\chi & 1-\chi & 0& 0\\ \frac{1-\chi}{2}& \chi & \frac{1-\chi}{2}& 0\\ 0& \frac{1-\chi}{2}& \chi & \frac{1-\chi}{2}\\ 0& 0& 1-\chi & \chi \end{array}\right)$$Based on the probability distribution matrix $\mathrm{\Pi}$, the Markov process may switch its state at the next iteration. To guarantee the classification accuracy and the search diversity, the value of the probability $\chi $ is equal to $0.9$ [14]. Here, the initial values of acceleration coefficients ${c}_{1}$ and ${c}_{2}$ are selected by trial-and-error for all states in order to guarantee the best performance of the purposed algorithm. Table 1 shows their values based on the evolutionary state, which are automatically adjusted.
- Update the personal and global best position. To get the value of the personal best ${\mathbf{w}}_{pbes{t}_{i}}\left(n\right)$, a comparison between the current value of ${f}_{i}\left[{\mathbf{w}}_{i}\left(n\right)\right]$ and the value of $f\left[{\mathbf{w}}_{pbes{t}_{i}}(n-1)\right]$ is performed as follows:$${\mathbf{w}}_{pbes{t}_{i}}\left(n\right)=\left\{\begin{array}{cc}{\mathbf{w}}_{i}\left(n\right),\hfill & \mathrm{if}{f}_{i}\left[{\mathbf{w}}_{i}\left(n\right)\right]<f\left[{\mathbf{w}}_{pbes{t}_{i}}(n-1)\right]\hfill \\ {\mathbf{w}}_{pbes{t}_{i}}(n-1),\hfill & \mathrm{otherwise}\hfill \end{array}\right.$$The ${\mathbf{w}}_{i}\left(1\right)$ defined as ${\mathbf{w}}_{pbes{t}_{i}}\left(1\right)$ is used to calculate Equation (11) at the first generation. To calculate the global best position, ${\mathbf{w}}_{gbest}$, we compare the result of $f\left[{\mathbf{w}}_{pbes{t}_{min}}\left(n\right)\right]$ with the evaluation of the best global position $f\left[{\mathbf{w}}_{gbest}(n-1)\right]$, where ${\mathbf{w}}_{pbes{t}_{min}}\left(n\right)={\mathbf{w}}_{pbes{t}_{g}}\left(n\right)$, $g=argmi{n}_{1\le i\le P}\left\{{\mathbf{w}}_{pbes{t}_{j,i}}\left(n\right)\right\}$. The computation of the global best position, ${\mathbf{w}}_{gbest}$ is obtained as follows:$${\mathbf{w}}_{gbest}\left(n\right)=\left\{\begin{array}{cc}{\mathbf{w}}_{pbes{t}_{min}}\left(n\right),\hfill & \mathrm{if}f\left[{\mathbf{w}}_{pbes{t}_{min}}\left(n\right)\right]<f\left[{\mathbf{w}}_{gbest}(n-1)\right]\hfill \\ {\mathbf{w}}_{gbest}(n-1),\hfill & \mathrm{otherwise}\hfill \end{array}\right.$$
- Update population. Equations (5) and (6) are used to update the velocity and position of each particle, respectively, and Equation (13), which is in the function of the power of the instantaneous error, is used to update the population size.$$P=\lfloor \frac{2({P}_{max}-{P}_{min})}{1+{e}^{-e{\left(n\right)}^{2}}}-({P}_{max}-{P}_{min})\rfloor +{P}_{min}$$

## 3. Pure Software Implementation

- The echo signal is mixed with white Gaussian noise (SNR = 20 dB).
- The input signal is an AR(1) process, which is produced by filtering white Gaussian noise by means of the system $\frac{1}{(1-0.95{z}^{-1})}$.
- In the proposed Markov switching PSO algorithm, the swarm size is defined in the range of 100–20 particles, while the swarm size, which is used in the simulation of an existing approach, is set to 100.
- To probe the tracking capabilities of the proposed Markov switching PSO algorithm, 4 different experiments were simulated: (1) Changing SNR from 20 dB to 10 dB in the middle of iterations, (2) causing an abrupt change to the impulse response of the acoustic echo path in the middle of the adaptive filtering process by multiplying the acoustic path by −1, (3) causing an abrupt change to the impulse response of the acoustic echo path in the middle of the adaptive filtering process by shifting the acoustic path, and (4) simulating a double talk-scenario at the middle of iterations.
- Acceleration coefficients of the conventional PSO were selected to obtain the best performance.
- The maximum number of iterations is set to 4,000,000.
- We verify the performance of the proposed algorithm in terms of echo return loss enhancement, ($ERLE=10lo{g}_{10}(\frac{d{\left(n\right)}^{2}}{e{\left(n\right)}^{2}})$).

- Grey wolf optimization (GWO) [18]
- Population size $=50$
- lower bound $=-1$
- Upper bound $=1$
- a decreases linearly from 2 to 0

- PSO [19]
- Population size $=100$
- Lower bound $=-1$
- Upper bound $=1$
- Acceleration coefficient, ${c}_{1}=1.6$
- Acceleration coefficient, ${c}_{2}=1$
- Inertia weight $=0.8$

- Differential evolution (DE) [20]
- Population size $=50$
- Lower bound $=-1$
- Upper bound $=1$
- Crossover rate $=0.35$
- Scaling factor $=0.8$
- Combination factor $=0.25$

- Artificial bee colony optimization (ABC) [21]
- Population size $=50$
- Lower bound $=-1$
- Upper bound $=1$
- Evaporation parameter $=0.1$
- Pheromone $=0.6$

- Hybrid PSO–LMS [22]
- Population size $=60$
- Lower bound $=-1$
- Upper bound $=1$
- Acceleration coefficient, ${c}_{1}=0.00005$
- Acceleration coefficient, ${c}_{2}=1.2$
- Inertia weight $=1$
- Convergence factor $=1\times {10}^{-9}$

- Modified ABC (MABC) [23]
- Population size $=50$
- Lower bound $=-1$
- Upper bound $=1$
- Evaporation parameter $=0.1$
- Pheromone $=0.6$
- Convergence factor $=3\times {10}^{-5}$

## 4. Hardware Implementation

- Markov-PSO processing core, M-PSO PC. This represents the basic processing element to compute the signal-filtering process and update the population. The proposed M-PSO PC mainly uses neural multipliers ${\mathrm{\Pi}}_{mul}$ [24] and adders ${\mathrm{\Pi}}_{add}$ [24]. Additionally, this circuit has a slave control unit $C{U}_{s1}$, pseudo-random number generators, $RNG$, and a Markov processor core, $MP$ (Figure 8). In particular, the $MP$ core is in charge of performing the calculation of the distance between particles by means of the optimized square root circuit [25], as shown in Figure 9.
- A master control unit, $C{U}_{m}$. This module is in charge of controlling the data flow and synchronization. Specifically, this component performs the time multiplexing technique to simulate several particles at different times by using the same M-PSO PC. In addition, this component sends the control signals to store the input samples, $x\left(n\right)$, in the BRAMs. In this way, the block-processing technique can be properly implemented.
- Distribution module, DM. The main function of this component is to evaluate and indicate the personal and global best. Therefore, this component transfers this information to each M-PSO PC in parallel. Therefore, the update process can be done at high processing speeds.

- Scalability. These circuits can process numbers with any required length by only adding neurons in a regular and homogenous neural structure.
- Compactness. To obtain a great improvement in terms of area, we designed the circuit by using a low number of neurons and synapses. Specially, we optimized the number of synapses since the routing of a large number of synaptic connections creates place and routing problems, especially when they are implemented in advanced FPGAs.
- High performance. In this application, the real-time filtering process is highly demanded. Therefore, we achieved neural multiplier and adder to perform their respective operations by expending a single and ten clock cycles, respectively.

## 5. Conclusions

- From the AEC model point of view. In this work, we made intensive efforts to reduce the computational cost of the AEC systems to be implemented in resource-constrained devices. In addition, we significantly improve the convergence properties of these systems by using an improved metaheuristic swarm intelligence method to be used in practical acoustic environments. Specifically, we present a new variant of the PSO algorithm based on the Markovian switching technique. The use of this technique has allowed us to guarantee a higher convergence rate and higher ERLE in comparison when the conventional PSO algorithm is used. To make feasible the implementation of the proposed variant of the PSO algorithm in embedded devices, we use the block-processing scheme. In this way, the proposed algorithm can be easily implemented in parallel hardware architectures. As a consequence, it can be simulated at high processing speeds. In addition, we significantly reduce the computational cost of the proposed conventional PSO algorithm. To achieve this aim, we propose a method to dynamically decrease the number of particles of this new variant of the PSO algorithm over the filtering process.
- From the digital point of view. In this work, we present for the first time, the development of a parallel hardware architecture to simulate a variable number of particles by using the proposed time-multiplexing control scheme. In this way, we properly implement the proposed Markov switching PSO algorithm, in which the number of particles decreases according to the simulation needs, in a Stratix IV GX EP4SGX530 FPGA.

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Acknowledgments

## Conflicts of Interest

## References

- Mahbub, U.; Acharjee, P.P.; Fattah, S.A. An acoustic echo cancellation scheme based on particle swarm optimization algorithm. In Proceedings of the TENCON 2010—2010 IEEE Region 10 Conference, Fukuoka, Japan, 21–24 November 2010; pp. 759–762. [Google Scholar]
- Mahbub, U.; Acharjee, P.P.; Fattah, S.A. A time domain approach of acoustic echo cancellation based on particle swarm optimization. In Proceedings of the IEEE International Conference on Electrical & Computer Engineering (ICECE 2010), Dhaka, Bangladesh, 18–20 December 2010; pp. 518–521. [Google Scholar]
- Pichardo, E.; Anides, E.; Vazquez, A.; Garcia, L.; Avalos, J.G.; Sánchez, G.; Pérez, H.M.; Sánchez, J.C. A Compact and High-Performance Acoustic Echo Canceller Neural Processor Using Grey Wolf Optimizer along with Least Mean Square Algorithms. Mathematics
**2023**, 11, 1421. [Google Scholar] [CrossRef] - Kimoto, M.; Asami, T. Multichannel Acoustic Echo Canceler Based on Particle Swarm Optimization. Electron. Commun. Jpn.
**2016**, 99, 31–40. [Google Scholar] [CrossRef] - Tang, J.; Zhao, X. Particle swarm optimization with adaptive mutation. In Proceedings of the 2009 IEEE WASE International Conference on Information Engineering, Taiyuan, China, 10–11 July 2009; Volume 2, pp. 234–237. [Google Scholar]
- Ratanavilisagul, C.; Kruatrachue, B. Selective crossover base on fitness in multiswarm optimization. In Proceedings of the International Conference on Emerging Trends in Computer and Image Processing (CIP’11), Bangkok, Thailand, 11–14 September 2011; pp. 12–15. [Google Scholar]
- Chi, Y.; Cai, G. Particle swarm optimization with opposition-based disturbance. In Proceedings of the 2010 2nd International Asia Conference on Informatics in Control, Automation and Robotics (CAR 2010), Wuhan, China, 6–7 March 2010; Volume 2, pp. 223–226. [Google Scholar]
- Mauryan, R.; Thanushkodi, K.; Sakthisuganya, A. Reactive power optimization using quantum particle swarm optimization. J. Comput. Sci.
**2012**, 8, 1644–1648. [Google Scholar] - Lu, S.; Yu, S. An improved particle swarm optimizer with attraction and repulsion. In Proceedings of the 2012 7th International Conference on Computing and Convergence Technology (ICCCT), Seoul, Republic of Korea, 3–5 December 2012; pp. 735–740. [Google Scholar]
- Arani, B.O.; Mirzabeygi, P.; Panahi, M.S. An improved PSO algorithm with a territorial diversity-preserving scheme and enhanced exploration–exploitation balance. Swarm Evol. Comput.
**2013**, 11, 1–15. [Google Scholar] [CrossRef] - Zermani, A.; Manita, G.; Feki, E.; Mami, A. Hardware implementation of particle swarm optimization with chaotic fractional-order. Neural Comput. Appl.
**2023**, 1–20. [Google Scholar] [CrossRef] - Da Costa, A.L.; Silva, C.A.; Torquato, M.F.; Fernandes, M.A. Parallel implementation of particle swarm optimization on FPGA. IEEE Trans. Circuits Syst. II Express Briefs
**2019**, 66, 1875–1879. [Google Scholar] [CrossRef][Green Version] - Shaikh, U.T.; Kalwar, I.H.; Memon, T.D.; Shaikh, F. Design of IIR filter using PSO algorithm and its implementation in FPGA. Indian J. Sci. Technol.
**2017**, 10, 1–5. [Google Scholar] [CrossRef] - Tang, Y.; Wang, Z.; Fang, J.A. Parameters identification of unknown delayed genetic regulatory networks by a switching particle swarm optimization algorithm. Expert Syst. Appl.
**2011**, 38, 2523–2535. [Google Scholar] [CrossRef][Green Version] - Zhan, Z.H.; Zhang, J.; Li, Y.; Chung, H.S.H. Adaptive particle swarm optimization. IEEE Trans. Syst. Man Cybern. Part B Cybern.
**2009**, 39, 1362–1381. [Google Scholar] [CrossRef] [PubMed][Green Version] - lnternational Telecommunication Union ITU-T. Digital Network Echo Cancellers. In Standardization Sector of ITU; lnternational Telecommunication Union ITU-T: Geneva, Switzerland, 2002. [Google Scholar]
- Rout, N.K.; Das, D.P.; Panda, G. Particle swarm optimization based active noise control algorithm without secondary path identification. IEEE Trans. Instrum. Meas.
**2011**, 61, 554–563. [Google Scholar] [CrossRef] - Mirjalili, S.; Mirjalili, S.M.; Lewis, A. Grey wolf optimizer. Adv. Eng. Softw.
**2014**, 69, 46–61. [Google Scholar] [CrossRef][Green Version] - Krusienski, D.; Jenkins, W. Adaptive filtering via particle swarm optimization. In Proceedings of the The Thrity-Seventh Asilomar Conference on Signals, Systems & Computers, Pacific Grove, CA, USA, 9–12 November 2003; pp. 571–575. [Google Scholar]
- Reddy, K.S.; Sahoo, S.K. An approach for FIR filter coefficient optimization using differential evolution algorithm. AEU-Int. J. Electron. Commun.
**2015**, 69, 101–108. [Google Scholar] [CrossRef] - Bansal, J.C.; Sharma, H.; Jadon, S.S. Artificial bee colony algorithm: A survey. Int. J. Adv. Intell. Paradig.
**2013**, 5, 123–159. [Google Scholar] [CrossRef] - Krusienski, D.; Jenkins, W. A particle swarm optimization-least mean squares algorithm for adaptive filtering. In Proceedings of the Conference Record of the Thirty-Eighth Asilomar Conference on Signals, Systems and Computers, Pacific Grove, CA, USA, 7–10 November 2004; Volume 1, pp. 241–245. [Google Scholar]
- Ren, X.; Zhang, H. An Improved Artificial Bee Colony Algorithm for Model-Free Active Noise Control: Algorithm and Implementation. IEEE Trans. Instrum. Meas.
**2022**, 71, 1–11. [Google Scholar] [CrossRef] - Maya, X.; Garcia, L.; Vazquez, A.; Pichardo, E.; Sanchez, J.C.; Perez, H.; Avalos, J.G.; Sanchez, G. A high-precision distributed neural processor for efficient computation of a new distributed FxSMAP-L algorithm applied to real-time active noise control systems. Neurocomputing
**2023**, 518, 545–561. [Google Scholar] [CrossRef] - Hasnat, A.; Bhattacharyya, T.; Dey, A.; Halder, S.; Bhattacharjee, D. A fast FPGA based architecture for computation of square root and Inverse Square Root. In Proceedings of the 2017 Devices for Integrated Circuit (DevIC), Kalyani, India, 23–24 March 2017; pp. 383–387. [Google Scholar]
- Paleologu, C.; Ciochina, S.; Benesty, J. Variable step-size NLMS algorithm for under-modeling acoustic echo cancellation. IEEE Signal Process. Lett.
**2008**, 15, 5–8. [Google Scholar] [CrossRef]

**Figure 5.**ERLE of the proposed Markov switching PSO algorithm and conventional PSO algorithms by computing the AR(1) process input signal. (

**a**) Changing the SNR from 20 dB to 10 dB at the middle of the iterations. (

**b**) Multiplying the acoustic path by −1 in the middle of the adaptive filtering process. (

**c**) Shifting the acoustic path in the middle of the adaptive filtering process. (

**d**) Simulating the double-talk scenario.

**Figure 7.**Digital implementation of the proposed Markov switching PSO algorithm in the parallel metaheuristic processor.

**Figure 11.**(

**a**) AR(1) process and (

**b**) speech signal used in a single-talk scenario; (

**c**) AR(1) process and (

**d**) speech signal used in a double-talk scenario.

State | Mode | ${\mathit{c}}_{1}$ | ${\mathit{c}}_{2}$ |
---|---|---|---|

Convergence | $\xi \left(n\right)=1$ | 2 | 2 |

Exploitation | $\xi \left(n\right)=2$ | 2.1 | 1.9 |

Exploration | $\xi \left(n\right)=3$ | 2.2 | 1.8 |

Jumping-out | $\xi \left(n\right)=4$ | 1.8 | 2.2 |

**Table 2.**Number of additions and multiplications required by the conventional PSO algorithm [17] and the proposed algorithm.

Operation | Algorithm | Equation | Number of Operations |
---|---|---|---|

Addition | GWO | $9NP+1$ | $4.5000\times {10}^{14}$ |

PSO | $5NP+2$ | $5.0000\times {10}^{14}$ | |

DE | $2NP$ | $1.0000\times {10}^{14}$ | |

ABC | $5NP-3$ | $2.4999\times {10}^{14}$ | |

PSO-LMS | $5NP+2N+2$ | $3.0200\times {10}^{14}$ | |

MABC | $5NP+2N-2$ | $3.0200\times {10}^{14}$ | |

Proposed Algorithm | $7NP+8$ | $2.2271\times {10}^{14}$ | |

Multiplication | GWO | $15NP+1$ | $7.5000\times {10}^{14}$ |

PSO | $5NP+2$ | $5.0000\times {10}^{14}$ | |

DE | $NP$ | $5.0000\times {10}^{13}$ | |

ABC | $4NP+3$ | $2.0001\times {10}^{14}$ | |

PSO-LMS | $5NP+4N$ | $3.0101\times {10}^{14}$ | |

MABC | $4NP+2N+4$ | $2.4201\times {10}^{14}$ | |

Proposed Algorithm | $7NP+7$ | $2.2271\times {10}^{14}$ |

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |

© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Anides, E.; Salinas, G.; Pichardo, E.; Avalos, J.G.; Sánchez, G.; Sánchez, J.C.; Sánchez, G.; Vazquez, E.; Toscano, L.K. A Real-Time FPGA-Based Metaheuristic Processor to Efficiently Simulate a New Variant of the PSO Algorithm. *Micromachines* **2023**, *14*, 809.
https://doi.org/10.3390/mi14040809

**AMA Style**

Anides E, Salinas G, Pichardo E, Avalos JG, Sánchez G, Sánchez JC, Sánchez G, Vazquez E, Toscano LK. A Real-Time FPGA-Based Metaheuristic Processor to Efficiently Simulate a New Variant of the PSO Algorithm. *Micromachines*. 2023; 14(4):809.
https://doi.org/10.3390/mi14040809

**Chicago/Turabian Style**

Anides, Esteban, Guillermo Salinas, Eduardo Pichardo, Juan G. Avalos, Giovanny Sánchez, Juan C. Sánchez, Gabriel Sánchez, Eduardo Vazquez, and Linda K. Toscano. 2023. "A Real-Time FPGA-Based Metaheuristic Processor to Efficiently Simulate a New Variant of the PSO Algorithm" *Micromachines* 14, no. 4: 809.
https://doi.org/10.3390/mi14040809