## Abstract

This work presents an approach for the harmonic components estimation problem present in electrical power systems by making use of evolutionary algorithms. The referential data were obtained by the ATP (Alternative Transients Program) software. Compact and simple genetic algorithms were applied to estimate the parameters of non-linear function to generate a waveform as similar as possible to the one provided by the ATP software. The results yielded by the aforementioned evolutionary algorithms were then compared with one another in a number of scenarios, using the values obtained by the waveform of reference generated by the ATP software. The comparisons were used to seek evidence of which algorithm solved the problem in a setting with limited availability of computational resources. Based on the generated results, it has been found that compact genetic algorithm satisfactorily solves the proposed problem and it is the most indicated method, when less computational effort is required.

### Keywords

- compact genetic algorithm
- electrical power systems
- harmonics
- simple genetic algorithm

## 1. Introduction

Ideally, electric power systems (EPS) should operate as voltage and current waveforms the closest to a sinusoidal waveform as possible, with constant magnitude and frequency. However, this situation doesn't always happen, which implies the occurrence of disturbances in the power quality (PQ) [1]. Problems with the PQ are associated with any disturbance in the voltage, current, or frequency deviation that results in failure or defective operation of a consumer's equipment [2]. Studies related to the PQ are becoming increasingly important due to the characteristics of the charges and EPS, which are more sensitive to the disturbances.

Among the many disturbances in the PQ, there is a class called harmonic distortion. Harmonic distortions are periodic distortions as voltage and current waveforms, characterized by the presence of frequencies that are integer multiples of the nominal frequency of the system and often associated to continuous operation of charges with non-linear characteristics [3]. With technological development and the development of power electronics, these disturbances became more and more relevant due to sensitive equipment in the EPS that requires electric energy of better quality [4]. Some of the problems caused by harmonic distortions are overheating of devices, activation of safety devices [3], resonance, high voltage between neutral and ground, low performance of devices and equipment, and interruption of production processes [5].

Among the methods to remedy the problems caused by harmonics are active power filters. With the identification of the harmonic components that may pollute the waveform of the voltage or current of a system, such filters can be used to properly correct the problem. AC controllers, generally present in homes or even in commercial environments are typical sources of distortions caused by harmonics [6]. In [6], a study was made to identify, with the help of artificial neural networks, the first six harmonic components of a circuit compound by a semiconductor switch (TRIAC), a sinusoidal voltage source, trip circuit, and of incandescent bulbs.

It should be stressed that non-linear charges, increasingly present in EPS, are the most sensitive to the disturbances and are also the ones that cause the greatest harmonic distortions in the EPS [7]. Therefore, the presence of the harmonics in the EPS tends to become more frequent and increases the economic losses caused by low PQ. For these reasons, many researches would like to seek methods that improve the precision and speed of the algorithms applied in the estimation of the harmonic components. Among the many techniques used, particularly noticeable are the methods based on Discrete Fourier Transform (DFT) [8], Fast Fourier Transform (FFT) [9], the Least-Squares adjustment (LS) [10], Wavelet Transform [11], and Kalman Filter [12]. The mentioned methods can be affected by the continuous current component (CCC) [9], however, methods based on computational intelligence such as Artificial Neural Networks (ANN) [13, 14], Particle Swarm Optimization (PSO) [15], and Genetic Algorithms [16] are weakly influenced by the CCC [15] and show good results for estimating harmonic components.

Considering that the proposal of using evolutionary algorithms (EA) for estimating harmonic components show good results, this work investigated the applicability and efficiency of compact genetic algorithm (CGA) [17]. For validation purposes, a comparison between CGA and SGA (simple genetic algorithm) [18, 19] was performed. Both algorithms were used to estimate the RMS values and the phase angles of the harmonic components of voltage electric signals. By using CGA, it is possible to get the benefits of the use of EA for estimating harmonic components with an algorithm of simple implementation that requires few computing resources [20].

This article was divided into six (6) additional sections, in addition to the introduction. In the second section there is a description of the problem, in which the mathematical models used are presented. The third section addresses the algorithms used, giving emphasis on descriptions related to SGA and CGA. The fourth section addresses the methodology used to get the harmonic components through two different mathematical models. In the fifth section are the results obtained through the algorithms used. In the sixth section are the discussions about the results. The seventh section presents the conclusions obtained.

## 2. Problem description

A waveform can be mathematically represented through Fourier series, in which it is possible to express a waveform in terms of its continuous, fundamental, and harmonic components. Each harmonic component of the waveform has its own amplitude, a phase angle, and a frequency, which has to be an integer multiple of the fundamental frequency [2]. Thus, a waveform as a function of time can be descripted by Eq. (1) [15, 21] in which * x(t)* is the resulting value of the sum of the continuous component and the harmonic components and

x

_{0}is the continuous component of the signal and λ is a time constant.

A

_{c,i},

A

_{s,i}, θ

_{c,i}, and θ

_{s,i}are the cosine and sine amplitudes and the phase angles of the

*th harmonics, respectively; ω*i

_{0}is the angular frequency;

*is the time the sample occurred;*t

*is the order of the harmonic; and*i

*is the number of harmonics present in the signal used to represent*N

*.*x(t)

In order to perform the estimation of the parameters, the waveform is discretized in * n* samples, with a constant difference of time among the samples. That said, for each time (

t

_{n}) of the function domain, there will be a corresponding

x(t

_{n}

*. Thus, Eq. (1) can be re-written as pointed in Eq. (2):*)

with x(t_{1}) being the sum of the harmonic components for time t_{1}, [M] being the matrix represented in Eq. (3), and _{n}* )* the error associated to each point-in-time

t

_{n}[21].

## 3. Algorithms

In this section the simple genetic algorithm (SGA) and the compact genetic algorithm (CGA) are described.

### 3.1. Simple genetic algorithm

GAs are algorithms meant for search and global optimization, based on Darwin's theory of evolution and genetics. When GAs are used, it is assumed that in a certain population, the best individuals have greater chances of survival and of generating increasingly fit individuals [19], guaranteeing that the population evolves and finds a solution for a problem.

As presented in the pseudocode in Figure 1, SGA has the following steps: initialization of the population, evaluation, selection, crossover, and mutation.

The first step is the initialization of the population. In the population evaluation step, all individuals are evaluated through the use of an evaluation function. In the selection process, an * N* number of individuals is selected for the crossover step. After crossover, the new generated individuals undergo the mutation step. Following that, the new individuals become the new population. While the stopping criterion is not met, the algorithm will be executed from the selection step. At the end of the execution of the algorithm, the final solution will be the individual with the best evaluation grade (fitness).

### 3.2. Compact genetic algorithm

The determination itself of the necessary parameters for the functioning of the SGA, such as the crossover and mutation rates, becomes a problem of optimization inside another problem of optimization. Predicting the movement of the populations is considerably difficult [22] and because of that, new types of algorithms have been developed, such as the estimation of distribution algorithms (EDA) [22], which we can cite the CGA as one of the simplest EDA models.

CGA has a similar effectiveness as the SGA, but it consumes less computational resources as it represents the population with a vector of probability [20], which means it represents the proportion of the presence of each gene in the population. Thus, because it does not have a physical representation of the population (only the vector of probability), nor the crossover step, nor the mutation step [22], the CGA happens to be a simpler algorithm to be implemented compared to the SGA. Figure 2 shows the pseudocode of CGA considering a tournament size equal to 2 to be the selection mechanism.

The CGA has as its first step the initialization of the vector of probability, in which for each position it is attributed the value of 0.5, or 50% of the probability of generating 1 for that position of the individual. The second step consists of generating two individuals, taking into account the vector of probability. In the third step, the verification of the individual with the best evaluation grade is performed. Based on the comparison between the best and the worst individual, an update is performed on the vector of probability in the fifth step. While the vector of probability doesn't converge, the algorithm keeps executing from the second stage and when it converges, the algorithm stops the execution. The final solution is the vector of probability.

## 4. Methodology

In order to estimate the harmonic components, CGA and the SGA were used, both using the mathematical model to estimate the previously presented harmonic components and considering the first seven components of the Fourier series. The algorithm estimates 30 parameters, among which 28 are dedicated to the amplitude of their sins, co-sins, and phase angles, and the other two parameters are for the continuous component of the signal and for the time constant. In order to represent the parameters of the Fourier series, 8 bits were used for each parameter, as it was verified it was enough to represent the values with good precision. An individual generated is represented as shown in Figure 3.

The same representation of the individuals was used in the SGA and the CGA. The SGA was implemented with a 75% crossover rate. As there is no mutation step in the CGA, in order to perform a fairer comparison, the SGA was considered as not having a mutation step for observing its evolutionary process without this operator. The crossover rate was considered equal to 75% because no improvement was obtained or economy (saving) of computational resources.

The data used in the tests are voltage values obtained through a simulation of a power electric system using ATP software [23]. The evaluation of the individuals was performed through a comparison between the original signal and the signal generated from the estimated parameters.

Dummy Text Figure 4 shows the comparison between the waveform of a measured signal and the waveform obtained from the estimated parameters.

It is possible to observe that the smaller the error between the measured and the estimated waveforms, the better the estimation of the parameters. Therefore, the goal is to minimize the value of the evaluation function adopted that considers the errors between the signals as in Eq. (4),

where _{med} is the measured signal, _{est} is the estimated signal, * N* is the number of samples in a cycle, and

*is the value of the evaluation function that is intended to minimize.*E

When using the binary representation of the individuals of the population, CGA adopts a stopping criterion based on the probability of each bit of the individual being 1. So, if in all positions of the vector of probability the possibility of being 1 is less than 5% or more than 95% the algorithm should stop. It was adopted the same criterion for SGA. Considering that SGA deals with the population instead of a vector of probability, which means that when the percentage of bits that equal 1 reaches 5% or 95% for the same locus of all individuals of the population, SGA should stop. It should be pointed out that the tournament method [19] was the type of selection used.

All tests were performed with four different voltage waveforms, with population varying from 100 to 10000 and with the tournament size varying between 2, 8, and 32. For each configuration, the average of the evaluations of the whole population corresponds to the mean error. Each configuration was executed 10 times for each of the 4 waveforms, with the purpose of obtaining the average of the mean errors, the smallest error in the 10 executions, the number of evaluations, and the standard deviation. The mean error values, the number of evaluations, and the standard deviation were obtained from the average of the 4 waveforms. The number of evaluations for the SGA was calculated as being the average of the number of generations of the 10 executions multiplied by the size of the population. For the CGA, on the other hand, it was calculated as being the size of the tournament multiplied by the average of the number of generations in the 10 executions.

## 5. Results

The algorithms applied for the estimation of harmonics were tested by means of the voltage values obtained through simulations performed with ATP software. The results obtained were compared considering the different configurations used in the algorithms.

### 5.1. Estimation of the harmonic components using the proposed methodologies

In this section, the waveform of one of the situations used is going to be presented, and this waveform is going to be compared to the waveforms generated through the harmonics estimated with different algorithm configurations.

Figure 5 presents the waveforms generated with the estimated harmonics using both SGA and CGA. In this test, the parameters in SGA and CGA were adopted as the tournament size (k) is equal to 2 and the population size is equal to 100 individuals. As it can be observed in Figure 6 with the configuration used for the GAs, CGA showed a better answer for estimating the harmonics, as with CGA's estimation of a waveform closer to the original one simulated through ATP was generated.

Figures 6 to 9 present the parameters of reference used to obtain four different voltage waveforms. In these tables it also presented a comparison between the results obtained with CGA and SGA. Also, they show the answer gotten by DFT and PSO as presented in [15].

It should be said that the results showed in Figures 6 to 9 for the CGA were obtained considering a population size of 100 individuals and a tournament size of 2. But the results showed in both tables for SGA were obtained considering a population size of 2000 individuals and a tournament size of 8. It should also be pointed out that the values presented are always close to the reference ones. It was observed that in some situations the estimation performed by DFT and PSO, with 30 particles, were more precise than the one obtained using the other algorithms.

In the following sections the results obtained are discussed in a more general way, as well as some quality criteria of the solutions found.

### 5.2. Observation of the mean error

Figures 10, 11, and 12 show graphs of the mean error in the number of individuals given the tournament size of 2, 8, and 32 individuals.

### 5.3. Observation of the number of evaluations

Figures 13, 14, and 15 show graphs of the number of evaluations in the number of individuals given the tournament size of 2, 8, and 32. Through the number of evaluations of the objective function, it is possible to evaluate the convergence time of algorithms adopted. This analysis is very important for determining their feasibility in the real world.

### 5.4. Observation of the standard deviation

Figures 16, 17, and 18 show graphs of the standard deviation in the number of individuals given the tournament size of 2, 8, and 32. The standard deviation offers a way of evaluating how much the objective function is varying for all samples under analysis. A tournament size of 2 (Figure 16) SGA will show the smallest value for the standard deviation among all configurations analyzed. A tournament size of 8 CGA shows the smallest standard deviation.

## 6. Discussions

After the presentation of the results and tests performed, a few conclusions deserve to be highlighted. Initially, concerning the mean error with tournament size of 8, it is observed that CGA obtains better results than SGA.

Figure 10, with tournament size of 2 CGA to a smaller number of individuals, has a lower mean error than SGA. With the increasing number of individuals SGA tends to get a smaller mean error.

In Figures 11 and 12 the mean error observed with CGA tends to be smaller than with SGA. An increase in the selective pressure influenced the convergence of SGA in a negative way. On the other hand, Figures 13, 14, and 15 show that CGA tends to present a number of evaluates higher than SGA with the same population size for each size tournament adopted.

Concerning the standard deviation, it was observed that in fact SGA is more sensitive to the selective pressure than CGA. As with a smaller number of individuals, CGA stabilizes its standard deviation while SGA needs a greater population to achieve a similar standard deviation. As a consequence, CGA gets to its global optimum value faster than SGA.

Considering the above observations, it is possible to affirm that the use of CGA carries in computational resources for obtaining good quality answers because for the same population size, it provides the best quality solutions (with minor mistakes and standard deviation smaller) than the SGA, even requiring a larger number of reviews to converge. To present solutions with the same quality as the CGA, the SGA needs to work with larger populations and consequently will require a greater number of evaluations of the objective function to obtain a solution with the same quality as the CGA. It is possible to perceive both by the results presented in Figures 6 to 9, and the graphics performance analysis of Figures 6 to 14 that the CGA with the tournament size equal to 2 and with a population of 100 individuals can provide estimates of harmonics with good accuracy. For SGA to provide solutions with the same level of accuracy requires a population of 2,000 individuals.

## 7. Conclusions

With the results found, it was verified that both algorithms present adequate solutions for the problem presented, as long as a model and convenient parameters are adopted. It is important to highlight that when a population size of 100 and a tournament size of 2 individuals are used, CGA manages to achieve a lower error than SGA with the same configuration.

The study presented showed graphs of the mean error, smallest error, number of evaluations, and standard deviation. Also, graphs comparing a waveform of reference with waveforms obtained when using CGA and SGA were presented. For the CGA, using a tournament size of 2 and population size of 100, the waveform obtained was closer to the waveform of reference than for the SGA with tournament size of 8 and population size of 500. It was also noted that for a population size of 100 and tournament size of 2, the number of evaluations of both CGA and SGA were very close. As showed in this work, CGA showed good results as that of SGA. However, by using less computational resources there is the possibility, in future works, to take advantage of the strong parallelism in the genetic algorithm to implement it in an embedded system.

## Acknowledgments

The authors acknowledge the support received from UESPI, UFPI, CNPq and FAPEPI.

## References

- 1.
M. H. Bollen and I. Gu, ”Signal processing of power quality disturbances” John Wiley & Sons, 2006, vol. 30. - 2.
R. C. Dugan, M. F. McGranaghan, and H. W. Beaty, “Electrical power systems quality,” New York, NY: McGraw-Hill, c1996, vol. 1, 1996. - 3.
E. Fuchs and M. A. Masoum, Power quality in power systems and electrical machines. Academic press, 2011. - 4.
T. A. Short, Distribution reliability and power quality. CRC Press, 2005. - 5.
H. Moreno, Harmônicas nas instalações elétricas: Causas, efeitos e soluções. Procobre, 2001. - 6.
C. F. Nascimento, et al. "A neural networks-based method for single-phase harmonic content identification." Proceedings-34th Annual Conference of the IEEE Industrial Electronics Society, IECON 2008 . 2008. - 7.
J. Arrillaga and B. C. W. N. R. W. A. R. Smith, Power system harmonic analysis. Wiley, 1997. - 8.
F. Zhang, Z. Geng, and W. Yuan, “The algorithm of interpolating windowed FFT for harmonic analysis of electric power system,” Power Delivery, IEEE Transactions on, vol. 16, no. 2, pp. 160–164, 2001. - 9.
A. A. Girgis, W. B. Chang, and E. B. Makram, “A digital recursive measurement scheme for online tracking of power system harmonics,” IEEE Transactions on Power Delivery, vol. 6, no. 3, pp. 1153–1160, 1991. - 10.
I. Kamwa and R. Grondin, “Fast adaptive schemes for tracking voltage phasor and local frequency in power transmission and distribution systems,” in Transmission and Distribution Conference, 1991., Proceedings of the 1991 IEEE Power Engineering Society. IEEE, pp. 930–936, 1991. - 11.
W. A. Wilkinson and M. Cox, “Discrete wavelet analysis of power system transients,” Power Systems, IEEE Transactions on, vol. 11, no. 4, pp. 2038–2044, 1996. - 12.
C. Chen, G. Chang, R. Hong, and H. Li, “Extended real model of Kalman filter for time-varying harmonics estimation,” IEEE Transactions on Power Delivery, vol. 25, no. 1, pp. 17–26, 2010. - 13.
H. C. Lin, “Intelligent neural network-based fast power system harmonicection,” IEEE Transactions on Industrial Electronics, vol. 54, no. 1, pp. 43–52, 2007. - 14.
S. Varadan and E. Makram, “Practical considerations in the application of neural networks to the identification of harmonic loads,” Electric Power Systems Research, vol. 30, no. 2, pp. 103–106, 1994. - 15.
D. A. Rabelo, M. V. Lemos, and D. Barbosa, “Power system harmonics estimation using Particle Swarm Optimization,” in IEEE Evolutionary Computation (CEC), 2012 IEEE Congress on. IEEE, pp. 1–6, 2012. - 16.
R. A. Macêdo, D. da Silva, D. V. Coury, and A. C. L. F. de Carvalho, “A new technique based on genetic algorithms for tracking of power system harmonics,” in IEE Neural Networks, 2002. SBRN 2002.Proceedings.VII Brazilian Symposium on. IEEE, pp. 7–12, 2002. - 17.
M. Pelikan, D. E. Goldberg, and F. G. Lobo, “A survey of optimization by building and using probabilistic models,” Computational optimization and applications, vol. 21, no. 1, pp. 5–20, 2002. - 18.
D. A. Coley, An introduction to genetic algorithms for scientists and engineers. World scientific, 1999. - 19.
J. H. Holland, Adaptation in natural and artificial systems: An introductory analysis with applications to biology, control, and artificial intelligence. U Michigan Press, 1975. - 20.
G. R. Harik, F. G. Lobo, and D. E. Goldberg, “The compact genetic algorithm,” IEEE Transactions on Evolutionary Computation, vol. 3,no. 4, pp. 287–297, 1999. - 21.
S. G. Seifossadat, M. Razzaz, M. Moghaddasian, and M. Monadi, “Harmonic estimation in power systems using adaptive perceptrons based on a genetic algorithm,” WSEAS Transactions On Power Systems, no. 11, 2007. - 22.
P. Larranaga, “A review on estimation of distribution algorithms,” in Estimation of distribution algorithms. Springer, pp. 57–100, 2002. - 23.
W. S. Meyer and T. H. Liu, “Alternative transients program (ATP) rulebook,” Canadian/American EMTP User Group, vol. 2000, pp. 5–2, 1987.