A Genetic-Based Hybrid Algorithm Harmonic Minimization Method for Cascaded Multilevel Inverters with ANFIS Implementation

Selective harmonic elimination pulse-width modulation (SHEPWM) is a widely adopted method to eliminate harmonics in multilevel inverters, yet solving harmonic amplitude equations is both time consuming and not accurate. )is method is applied here for a 7-level cascaded multilevel inverter (CMLI) with erroneous DC sources. To meet the seven harmonic amplitude equations, two notches are applied with the use of higher switching frequency than nominal. )ese notches can be placed in six different positions in the voltage wave, and each was assessed in a separate manner. In order to solve the equations, a hybrid algorithm composed of genetic algorithm (GA) and Newton–Raphson (N-R) algorithm is applied to achieve faster convergence and maintain the accuracy of stochastic methods. At each step of the modulation index (M), different positions for the notches are compared based on the distortion factor (DF2%) benchmark, and the position with lowest DF2% is selected to train an artificial neural fuzzy interface system (ANFIS). ANFIS will receive the DC sources’ voltages together with requiredM and will produce one output; thus, eight ANFISs are applied to produce seven firing angles, and the remaining one is to determine which one of the notches’ positions should be used. Software simulations and experimental results confirm the validity of this proposed method. )e proposed method achieves THD 8.45% whenM is equal to 0.8 and is capable of effectively eliminating all harmonics up to the 19 order.


Introduction
As the power and voltage demands are getting higher and with the wide consumption rate of low-voltage DC sources such as the fuel cell and photovoltaic arrays [1], the need for multilevel inverters (MLIs) that receive these low voltages and produce high or medium voltage levels becomes obvious. Since 1975, when Nabae et al. introduced the concept of multilevel converters [2], many topologies have been introduced and assessed. Among flying capacitor [3], diodeclamped [4], and cascaded multilevel (CML) inverters, the latter, due to its simple structure and low number of elements (makes it more reliable) in contrast to other topologies, draws more attention to itself [5]. e biggest drawback of multilevel converters is they are having too many power semiconductor switches, where every switch needs a gate drive circuit which makes the overall converter more complicated and expensive, despite the fact that the advantages of applying multilevel converters are greater. Reduced frequency, reduced current, and voltage rating of switches which results in lower power loss, generating lower dv/dt in output voltage with a low harmonic characteristic that reduces electromagnetic compatibility problems, are considered as their advantages [6]. e presence of undesired harmonics is the major issue of concern in inverters in an application (e.g., undesired heating, noise, and vibration when driving a motor). In order to further improve the output voltage and quality, three main methods are used. ese methods are as follows: (1) switching strategies applied in minimizing or eliminating undesired harmonics; the optimal minimization of total harmonic distortion (OMTHD), space vector modulation (SVM) [7], selective harmonic elimination pulse-width modulation (SHEPWM) [8], the well-known sinusoidal PWM (SPWM) [9,10], the finally optimized harmonicstepped waveform (OHSW) [5]; (2) changing the multilevel structure to minimize harmonics [11][12][13][14]; and (3) adding low-pass filters in the output of the multilevel to eliminate high-order harmonics [15].
e SHEPWM strategy has been and is being applied in many different inverters. To solve equations of this strategy, many different equation-solving algorithms are applied [16][17][18]. To apply the calculus methods such as Newton-Raphson (N-R), a suitable starting point should exist. e step of the modulation index (M) is taken really small in [19] to allow the solution of the last step to be applied as a guess of current M. Other methods are stochastic: genetic algorithm (GA), particle swarm optimization (PSO), or bee colony [20,21], which do not need a guess and tend to find the global optima. In [22,23], the SHEPWM strategy is applied for a 9-level cascaded inverter with GAs. In [24,25], this strategy is applied for a 7-level cascaded inverter through PSO. In [4,26], notches are added by increasing the frequency of switching. Because the objective of applying MLIs is to reduce the switching losses, too many notches can increase the frequency and switching losses. In other studies, such as [18], the higher harmonic amplitudes are neglected, and fewer equations than unknowns are solved in order to find better solutions for the remaining equations. Due to the existence of computation burden, the mentioned equation-solving methods cannot reach the optimal angles in real time, which makes them appropriate for offline applications. After completing the lookup table for online applications, a nonlinear interpolation method becomes necessary to find angles in real time in online applications [27][28][29]. In [30], Moeini et al. investigated a technique for the modulation technique of the active power filters using the ANN. Moreover, Zhao et al. [31] attempted to implement selective harmonic elimination (SHE) in real time by the inner instantaneous observer.
Routray et al. [32,33] used modified particle swarm optimization and grey wolf optimization, respectively, to reduce the harmonic in a cascaded multilevel inverter. Prasad et al. [34] presented the modified version of fish swarm optimization algorithm to achieve higher voltage quality. In [35], Panda et al. presented another solution to this problem using flower pollination algorithm (FPA), which has many features such as the single-stage local and global search ascertain [36].
Attempt is made in all of these studies to minimize the harmonics through single SHEPWM switching strategy. In this study, two notches are added in different positions to the output voltage wave in every M step value, and the best position is selected to be applied online; thus, under load, a change in M can change the notches' positions from one voltage level to another to reach minimum harmonics. e traditional switching and switching with notches for a 7level CMLI with inaccurate DC sources are compared. A hybrid algorithm composed of GA and N-R algorithms is proposed to determine the best firing angles for each one of the assessed situations. e angles with lowest distortion factor (DF2%) in each step of M in different notches' positions are picked and are applied to train an adaptive neural fuzzy interface system (ANFIS) and to determine the angles in real time.
e performance of the proposed system is exhibited through simulation and experimental results.

SHEPWM for MLIs
A single-phase 7-level CMLI is shown in Figure 1(a) which consists of three single-phase full-bridge inverter units. Each of these DC sources is connected to a full-bridge inverter that will produce V dc when S 1 and S 2 are connected, 0 when all switches are off, and −V dc when switches S 3 and S 4 are on. When they are connected in series, the CMLI output voltage in a single phase can have 3V dc to −3V dc volts, with the step of V dc . One of the best aspects of these MLIs is their capability in producing the desired voltage in the output in a number of different switching situations when a change in the output voltage is required. is can help to reach the new voltage with the minimum number of switching changes.
is possibility can also help in many different harmonic elimination strategies, mostly for SVPWM. ese bridges, connected in series, will produce a stepped voltage in the CMLI output as mentioned ( Figure 1(b)). Each one of these DC sources will have an angle that would indicate their state of being connected or not (e.g., α 1 for the first full bridge). Here, at every voltage level, a return can be made to the last level and back, which will produce two extra firing angles. One of the six possibilities of two notches' positions is shown in Figure 1(c) as an example, where there is one notch in the first voltage level and another one in the second voltage level. With the switching strategy shown in Figure 1 (c), there can be seven firing angles, thus seven unknowns, which can solve seven equations, instead of three regular equations written for a 7level inverter. e first equation is to provide the required first-order harmonic, and the rest are to eliminate or, if not possible, minimize the low-order harmonics.
It is assumed that the voltage will go back to the same level as it was in the first place; each time it goes to the last level. is means that going two levels down or up, one after another is not to be considered; furthermore, at zero voltage, there is no going back to the last voltage level. With these assumptions, there will be six different manners where the voltage notches are of concern. e output phase voltage wave is expressed through Fourier series: ∞ n�1 a n sin nα n + b n cos nα n . (1) Because of the characteristics of the wave such as odd and half-wave symmetry, the amplitude of the n th harmonic is calculated through the following equation: where k i V dc expresses each one of the DC sources and S is the total number of these sources. It is notable that because 2 Mathematical Problems in Engineering the inverter is going to be used in a three-phase system, there will be no third-order harmonic or its multiplications. us, the output wave harmonics' order can be expressed as 6n ± 1, where n is a natural number. When notches exist, the amplitude of each harmonic is calculated through (3); once more, there are no even harmonics, and the amplitude is calculated for odd n.
where N i is the number of firing angles at each voltage level.

(4)
In (4) M is the modulation index, defined as equation (6). In (4), there exist three DC sources with no notches; hence, three angles solve three equations. e first equation in both equations (4) and (5) meets the first-order harmonic amplitude required from the inverter in its output. e remaining equations are applied to eliminate as many loworder harmonics as possible, starting from the 5 th order since these harmonic orders have higher amplitudes and tend to remain even after passing transformers.
In equation (5), the sum of N 1 + N 2 + N 3 is 7, chosen according to the explained assumptions. Because there exist seven unknowns, seven harmonic amplitudes are eliminated or minimized if complete elimination is not possible. It should be noted that, in (5), there exist two notches, and with each notch, two more firing angles are produced: one angle for going back which is shown with a minus sign in (5) and the other to get back to the initial voltage level; this return angle is assigned a plus sign.
where V 1 represents the amplitude of the first-order harmonic achieved by the inverter. e picked set of angles should be in order and must meet equation (7) requirements. Furthermore, the angles tend to become equal to one another as the modulation index increases [5], and there should be a threshold to assure that the angles are not exactly equal to one another. is quantity is presented by ε in equation (8), which will represent a nonlinear, nonequality constraint.
In case of equal DC sources, there is no need to check if the angles are in order or not; there, the firing angles should only be in the required range. If the angles are not in order, they can be sorted after the solving algorithm finds the answers because there is no difference in which full-bridge inverter unit certain angle is used. On the contrary, this assumption is not true when DC sources do not have accurate nominal values in reality. For example, applying an angle from the second voltage level for the first voltage level can produce different outputs than expected since here, certain angle cosine is going to be multiplied into the DC voltage that is different from what the algorithm output might be. Moreover, when applying a different number of firing angles at each voltage level, DC voltage source erroneous nominal values should be of full concern, that is, for a 7-level inverter with three DC voltage sources of 95%, 100%, and 105% nominal voltage, there will be 27 different manners to consider equations [37].

Hybrid Genetic Algorithm
In order to solve equations (4) and (5), an algorithm which converges faster to the global optima should be applied since they are to be solved for six different possibilities of N 1 , N 2 , and N 3 with different DC voltage sources, with no nonlinear, nonequality constraints. In order to take into account the DC voltage sources' deviation from the nominal value, the equations are solved when each of the DC sources is ± 5% or equal to the nominal value, that is, 27 different situations should be checked with varying number of firing angles at each level, and this number cannot be reduced due to existing overlaps. ese factors cause computational burden, thus long computational time.
e fastest algorithms in terms of convergence are of the calculus type such as N-R algorithm. e only problem is to choose a proper starting point for the algorithm to converge to the best point possible. However, these algorithms will not converge at all or will converge to a local minimum if the starting guess is not good. In contrast, among other advantages, stochastic algorithms do not need a starting point and will converge to the global optima if tuned well. e speed of these algorithms decreases in an exponential manner, where at the beginning, convergence speed is high, and by getting closer to the global optimum point, it decreases. One of the manners in applying the calculus method's speed and all other advantages of stochastic methods is applying to hybrid algorithms. e search will start with a random selection of unknowns that are to be fed to GA. In each iteration of the algorithm, the next generation will be produced by the best points in terms of fitness function, with the assistance of genetic operators; following this, the answers are fed to N-R algorithm as the starting point. It is not desired to converge to local minima, so ending the GA very fast is not wise.
In each iteration of the GA, all possible solutions should be validated through the fitness function, which might take some time. In order to make the algorithm to run even faster, one can sort all the possible solutions in a vector and send them in one call to the fitness function; here, this function is calculated once at each iteration. e output of the function is also in a vector format.
When using stochastic methods such as GA, there should be a fitness function to minimize which is equivalent to harmonic minimization. Here, this function is considered as equation (9) subject to equations (7) and (8): where V 1 * is the first-order harmonic amplitude which is required at the inverter's output, V 1 is the first-order harmonic amplitude that can be received from the inverter, h s is the number of harmonic orders, V h s is the amplitude of that harmonic, and S is the number of DC voltage sources.
In the N-R algorithm, there is no need to apply the fitness function. Each of the harmonic amplitudes is subject to become minimized. e first-order harmonic amplitude should be subtracted from the desired amplitude. After starting the N-R algorithm, in each iteration, the next iteration answers are obtained through the Jacobian matrix, shown in the following equation [21]: For different values of N 1 and N 2 , the Jacobian matrix varies. e proposed hybrid algorithm is as follows: (1) Select random possible answers to form the unknowns' space for M equal to the step value.
where Δα(k) is where J is the Jacobian matrix and F represents the system of equations equal to vector B (m a ) (equation F � B is observed in both equations (4) and (5)). (7) Apply α(k + 1) � cos − 1 [abs(cos(α(k + 1)))] to assure that the angles meet equation (7) requirements. (8) Go to Step 6 until the change in angles is less than the limit. At the end, check condition equation (8). is algorithm should be applied in calculating the angles where there are 27 different possibilities for the DC sources and 25 steps for M, that is, the algorithm should be applied for at least 675 times in order to complete the lookup table.
is process will take a long time to complete; however, after the completion, one can train an ANFIS to reach angles in the lookup table and the values between angles in an instance for online usage.

Simulation Results
First, the regular switching equations are solved through the proposed hybrid algorithm. For M near zero, the equations are not solvable, and the first harmonic amplitude is going to be less than the 5 th -and the 7 th -order amplitudes, thus an undesirable phenomenon. It is observed that how these amplitudes change with respect to M in Figure 2(a). In this figure, the THD% and DF2% benchmarks are shown as well, illustrating that THD% is going to be more than 100% for some values of M. Even DF2% is more than 100% at some points, thus an undesirable phenomenon. e fitness function values are shown in Figure 2(b), where the values higher than 0.01 are considered as points of M, where the equations are not solvable [21].
A well-known benchmark for output voltage quality is the THD% benchmark, as defined by the following equation [38]: In equation (13), (V 6i±1 ) represents each one of the harmonic order amplitudes, and V f is the amplitude of the first-order harmonic generated by the inverter.
A better benchmark would be second-order DF2%, where the harmonics' attenuation is considered through L-C filtering [5]: It is well established that regular switching and eliminating just the 5 th -and the 7 th -order harmonics will produce Mathematical Problems in Engineering a waveform which contains THD% and DF2% values which are more than standards and is not appropriate. e calculated angles are presented in Figure 2(c), where it is observed that these angles start from 90°, that is, the inverter is off for most of the duty cycles, and when the value of M increases, these angles tend to get smaller; in this case, the inverter is going to stay on for most of the time, producing a first-order harmonic with a higher amplitude. According to this figure, these angles are not changing in a linear manner revealing that, for values of M where the algorithm is not applied in an offline mode, a nonlinear interpolation method is needed to determine the firing angles in real time. e same process is carried out for 7-firing angles' switching (e.g., the harmonic amplitude percentages of two notches in the third voltage level, Figure 3(a)). e harmonic amplitude percentages of two notches in the first voltage level are presented in Figure 3(b). Every one of these strategies is perfect for a precise range of M in minimizing harmonic amplitudes to its best. In every index of M and in every notch position, DF2% is calculated. In the end, one strategy with the lowest DF2% in that index of M is selected along with its produced angles to be applied in the lookup table (e.g., notch positioning in Figure 3 e results of THD% and DF2% and harmonics can be seen in Figure 3 (c).
In contrast to Figure 2 Figure 3 (c). For most of M's range, DF2% is lower than 2%, which shows an acceptable waveform. e angles which produce this wave with respect to M are shown in Figure 3(d). Figure 4 presents the fast Fourier transformation of the voltage signal again with M equal to 0.7 and 0.81 in Figures 4(a) and 4(b), respectively. Note that the multiplications of the third harmonic are eliminated in the three-phase system. e angles tend to get equal to each other which is prevented by nonlinear, nonequality constraints in equations (7) and (8) (Figure 3(d)). Because of the nonlinear nature of the angles, it is best to use a nonlinear interpolation method in order to find best angles for M's that are not calculated by the proposed hybrid algorithm. Moreover, these methods need less controller memory because the table should not be uploaded and are more stable in a noisy environment. Here, an ANFIS is trained and applied for interpolation.
A three-phase simulation is carried out in MATLAB software. e inverter, with 100 volts for DC sources and a frequency of 50 hertz for M equal to 0.81, is applied for L-R load. e load is of 2.81 Ohms resistance and of 0.0116 Henry inductance and is connected in a star formation. e line voltage in the lower part of Figure 5 e THD% and DF2% comparison in these different methods of switching is tabulated in Table 1. e firing angles calculated with this proposed hybrid algorithm and genetic algorithm for M equal to 0.81 and 0.70 are tabulated in Table 2, where it is assumed that each of the DC voltage  sources' nominal value is equal to 100 volts. It is observed that this proposed hybrid algorithm has generated angles that produce lower DF2% with less time spent in calculating the values which shows the effectiveness of this proposed hybrid algorithm in generating firing angles with faster convergence. Table 3 shows the parameters used in the hybrid algorithm. Table 4 presents the comparison between our results and some of the state-of-the-art techniques. As can be seen, results presented in this paper are more accurate than similar proposals, and moreover, this paper presents a method to carry out these results in real time using the neural fuzzy interface system introduced in the Section 5.
We have also used the model in a three-phase RL load to study the voltages in each of the phases. Here, seven firing angles are used to control M equal to 0.81. We used the MATLAB simulation tool to design and control. Figure 6 shows the simulation circuit, and Figure 7 presents the voltages for each of the phases.

Neural Fuzzy Interface System
In order to apply this inverter, it is required to change the firing angles in real time under the load. However, these solving algorithms are not fast enough to produce the answers based on load variations. e GA needs around 10 to 150 seconds based on the starting point to produce the answers, while this proposed hybrid algorithm needs 5 to 15 seconds to produce the results in a Core-i7 Intel processor 2.2 GHz, with 8 gigabytes of RAM with MATLAB software. us, an interpolation method should be adopted to produce the angles in indexes of M that are not solved through this proposed algorithm in an offline mode. Lookup tables are applied in a traditional manner. Here, the nonlinearity of the firing angles is more because of the change in notches' positions in       different voltage levels with load change, so it is not sufficient to apply linear interpolation. Moreover, linear interpolation methods may be affected by environment noise, while, by applying nonlinear methods, resistance to noise can be accomplished. Among nonlinear interpolation methods such as ANN, ANFIS is selected to have the advantages of both the artificial neural network and fuzzy decision-making. Each ANFIS is going to obtain as many inputs as necessary and produce one output; thus, the number of weights for each ANFIS will produce just one output. ere exists the possibility to apply one ANFIS to produce all outputs. e same number of weights is applied for producing all the outputs which can lead to outputs with less accuracy. ere exist two main methods for training the ANFIS [26]: (1) A hybrid method consisting of backpropagation and least squares estimation (2) Backpropagation for all parameters e first method, the hybrid, can lead to time-consuming training for the system, but the output is assured as being more reliable when implemented to the system. Moreover, the angles can be reached in an instance when the training is over; thus, the first method is applied. Each one of the ANFIS rules is going to be determined through the following equation: where f i is the output and p i , q i , and r i are the consequent parameters of the i th rule. In equation (15), it is assumed that there exist only two inputs with the names x and y. Symbols It can be seen that each rule is produced by the "and" operation between the inputs and generates its own output value. e training error in ANFIS is observed with respect to each epoch (Figure 8(c)). e error between the angles generated through ANFIS and the angles of test data for system evaluation is shown in Figure 8(d).
e overall check data average error for all eight ANFIS networks is 0.00086.

Experimental Results
To assess the effectiveness of this proposed method, a singlephase CMLI prototype is built. MOSFET IRF630 with 200 volts and 9 amperes rating is applied as the power switches, and the 4N25 optocoupler is applied to control the gates. e DC voltage source is fixed at 50 volts for the first level, 50.5 volts for the second one, and 50.3 volts for the third level. e implementation setup of this proposed method is shown in Figure 9. e output of this inverter which is captured by the Gw INSTEK oscilloscope is shown in Figure 10. e regular switching for M equal to 0.81 is shown in Figure 10(a). e 7-firing angle switching for two different indexes of M is shown in Figures 10(b) and 10(c). ere exists one notch in both second and third voltage levels at M � 0.81 (Figure 10(b)). Two notches are seen in the third voltage level at M � 0.70 (Figure 10(c)). It is worth mentioning that these angles are produced through the trained ANFIS. Here, triple harmonic orders will be eliminated in a threephase system.
In order to apply the angles to generate gate signals, a square wave of 50 hertz frequency is compared to a triangle wave. For the half of a cycle, the square wave has the desired amplitude.
is amplitude changes with respect to the firing angle: 90°means an amplitude of one and 0°means an amplitude of zero. For the other half of the cycle, this square wave has zero amplitude. e triangle wave is of 50 hertz frequency and with an amplitude of one, where the amplitude of the square wave is less than that of the triangular wave, and a pulse gate with an amplitude of one is sent to the MOSFET gate. e highest number of firing angles that can exist in each one of the voltage levels for the assumptions made here is five, indicating that five comparisons must be made between the square and triangle waveforms. If less than five firing angles are needed for the given level switches, the amplitude of the square wave can be two, and thus, no firing angle is produced. With the assistance of the last ANFIS outputs, a code block can decide how to change the square-wave amplitudes to generate the required gate signal.
e harmonic amplitudes are shown in Figure 7. e fast Fourier transform (FFT) analysis of the regular switching phase voltage at M 0.81with THD% of 24.5% and DF2% of 7.97% is compared to the FFT analysis for 7 firing angles for M of 0.81 with THD% of 7.6% and DF2% of 0.6% (Table 5). e FFT analysis for M equal to 0.70 with THD% of 11.31% and DF2% of 1.13% is tabulated in this table as well. It is observed that, with 7 firing angles, more harmonic amplitudes are minimized that assist THD% and DF2% values to be much less than the regular switching strategy.

Conclusion
In the 7-level cascaded multilevel inverter with three DC sources, or seven voltage levels, the regular switching strategy with three firing angles can only set the first-order harmonic to the required value and eliminate the 5 th -and the 7 th -order harmonics in parts of the modulation index and produce THD% of 24.3% for M equal to 0.81, an insufficient attempt. Furthermore, for M's less than 0.2, DF2% exceeds 100%. In order to make a better voltage waveform, a 7-firing angle strategy is introduced. Six different notches' positioning exists where in each index of M, one of them is selected based on lower DF2% of the wave produced. e lookup table filled with the selected angles calculated through a hybrid algorithm of GA and N-R is applied to train and check an ANFIS to interpolate the indexes of M not calculated with this hybrid algorithm. THD% is 7.6% and DF2% is 0.6% for M equal to 0.81. In addition, the harmonic amplitudes to be eliminated never reach more than 60% of the first-order harmonic in the whole range of M, which is because of using different notch positions in different indexes of M. An ANFIS is proposed to determine the online optimal firing angles for the 7-level inverter, in terms of load changes. e prototype made for this experiment confirms the simulation results. e number of firing angles can be different based on the accuracy required, while higher numbers result in higher switching frequencies and switching losses. e proposed algorithm is one of the possible solutions to the multilevel inverter problem, and more generalized models as well as under load decision-making could be evaluated in the future. Also, we will continue our research for higher-performance switching with looking higher-efficiency algorithms which may be used under the load in the real-time fashion without the need for offline processing. Moreover, as the number of levels increases, a higher degree of freedom is achieved, which presents more challenges for stochastic space search methods.

Data Availability
e data used to support the findings of this study are included within the article.

Conflicts of Interest
e authors declare that they have no conflicts of interest.