INTRODUCTION
Recent wide increase of power electronic equipment has caused an augment of
the harmonic disturbances in the power systems. The nonlinear loads draw harmonic
and reactive power components of current from ac mains. The Current harmonic
generated by nonlinear loads has caused problems in power systems and in consumer
products such as equipment overheating, capacitor blowing, motor vibration and
low power factor. Dynamic and flexible solutions to the power quality problems
have been examined by researchers and power system (Peng,
1998). Usually, passive filters have been used to eliminate current harmonics
and to increase the power factor. However, the use of passive filter has many
disadvantages of large size resonance and fixed compensation behavior so this
conventional solution becomes ineffective (Huang and Wu,
1999).
The shunt active with several topologies (Jou, 1995;
Akagi et al., 1983; Huang
and Wu 1999; Asiminoaei et al., 2006; Clerc
and Kennedy, 2002; Aredes, 1996) is generally used
instead of passive filters to improve the power quality by injecting compensating
currents (Berbaoui et al., 2010; Peng,
1998; Gu and Xu, 2003; Kennedy
and Eberhart, 1995; Jou, 1995; Akagi
et al., 1983; Huang and Wu, 1999; Asiminoaei
et al., 2006; Clerc and Kennedy, 2002; Aredes,
1996; Mattavelli, 2001; Karsli
et al., 2003) a very great for the compensation not only of current
harmonics produced by distorting loads but also of reactive power of nonlinear
loads (Mattavelli, 2001). In order to determine the current
reference signals a proposed theory based on instantaneous power (pq theory)
has been used this theory was introduced by Akagi et
al. (1983) in Japanese.
The presented work spotlights on novel control method for compensating current
which known as PIPSO optimized PI controller using particle swarm algorithm.
The optimization of PI regulator’s parameters is crucial (Gu
and Xu, 2003). In this study, the problem of design current PI controller
is formulated as an optimization problem. The problem formulation assumes in
this study, two performance indexes are the integral absolute error of step
response and maximum overshoot as the objective function to determine the PI
control parameters for getting a well performance under a given system. We propose
an optimization method for SAPF in the aim to improve the compensation performances
and reduce harmonic distortion through electrical lines distribution under all
voltages conditions. These objectives are obtained by minimizing the fitness
function.
The proposed solution algorithm based on Particle Swarm Optimization (PSO)
technique that is based on a metaphor of social interaction. It searches a space
by adjusting the trajectories of individual vectors, called ‘particles’,
as they are conceptualized as moving as points in multidimensional space. The
individual particles are drawn stochastically towards the positions of their
own previous best performances and the best previous performance of their neighbours.
Since its inception, two famous improvements have been introduced on the initial
PSO which attempt to strike a balance between two conditions. The first one
introduced by Shi and Eberhart (1998) uses an extra ‘inertia
weight’ term which is used to scale down the velocity of each particle
and this term is typically decreased linearly throughout a run. The second version
introduced by Clerc and Kennedy (2002) involves a ‘constriction
factor’ in which the entire right side of the formula is weighted by a
coefficient. Their generalized particle swarm model allows an infinite number
of ways in which the balance between exploration and convergence can be controlled.
PARTICLE SWARM OPTIMIZATION
Particle Swarm Optimization (PSO) is a population based stochastic optimization
technique inspired by social behavior of bird flocking or fish schooling (Kennedy
and Eberhart, 1995). PSO learns from the scenario and uses it to solve the
optimization problems. In PSO, each single solution is a "bird" in the search
space. We call it "particle". All particles have fitness values which are evaluated
by the fitness function to be optimized and have velocities which direct the
flying of the particles. The particles fly through the problem space by following
the current optimum particles.
PSO is initialized with a group of random particles (solutions) and then searches for optima by updating generations. In each iteration, every particle is updated by following two "best" values. The first one is the best solution (fitness) it has achieved so far. (The fitness value is also stored). This value is called Pbest. Another "best" value that is tracked by the particle swarm optimizer is the best value, obtained so far by any particle in the population. This best value is a global best and called gbest.
For example, the ith particle is represented as xi = (xi1, xi2,........, xid) in the ddimensional space. The best previous position of the ith particle is recorded and represented as:
The index of best particle among all of the particles in the group is gbest.
The velocity for particle i is represented as vi = (vi1, vi2,......, vid). The
modified velocity and position of each particle can be calculated using the
current velocity and the distance from Pbestid. to gbestid as shown in the
following formulas (Gaing, 2004):
Where:
n 
= 
Number of particles in the group 
d 
= 
Dimension 
t 
= 
Pointer of iterations (generations) 
v^{(t)}_{im} 
= 
Velocity of particle t at iteration t 
w 
= 
Inertia weight factor 
c1, c2 
= 
Acceleration constant 
rand ( ) 
= 
Random number between 0 and 1 
v^{(t)}_{id} 
= 
Current position of particle i at iterations 
Pbest 
= 
Best previous position of the ith particle 
Gbest 
= 
Best particle among all the particles in the population 
ESTABLISHMENT OBJECTIVE FUNCTION
In this study, the procedure of PSO Algorithms is used. A production initial
population is the first step of PSO. The population is composed of the chromosomes
that are real codes. The corresponding evaluation of a population is called
the “fitness function”. It is the performance index of a population
(Berbaoui et al., 2010). The fitness value is
bigger and the performance is better. The fitness function is defined as follow:
The optimized parameters objects are proportional gain kp and integral gain ki, the transfer function of PI controller is defined by:
The gains kp and ki of PI controller are generated by the PSO algorithm for a given plant. As shown in Fig. 1. The output u (t) of PI controller is (Eq. 6):
For a given plant, the problem of designing a PI controller is to adjust the
parameters kp and ki for getting a desired performance of the considered system.

Fig. 1: 
PI control system 
Both the amplitude and time duration of the transient response must be kept
within tolerable or prescribed limits, for this condition, two key indexes performance
of the transient response is utilized to characterize the performance of PI
control system. These key indexes are integral absolute control error and maximum
overshoot.
The maximum overshoot is defined as:
where, y_{max} characterize the maximum value of y and y_{ss} denote the steadystate value.
The integral of the absolute magnitude of control error is written as:
SYSTEM CONFIGURATION
The principal function of the Shunt Active Power Filter (SAPF) is to generate
just enough reactive and harmonic current to compensate the nonlinear loads
in the line. A multiplicity of methods is used for instantaneous current harmonics
detection in active power filter such as FFT (Fast Fourier Technique) technique,
instantaneous pq theory and synchronous dq reference frame theory (Asiminoaei
et al., 2006).
The main circuit of the SAPF control is shown in Fig. 2.
The reference current consists of the harmonic components of the load current
which the active filter must supply. This reference current is fed through a
controller and then the switching signal is generated to switch the power switching
devices of the active filter such that the active filter will indeed produce
the harmonics required by the load (Huang and Wu, 1999).
Finally, the AC supply will only need to provide the fundamental component for
the load, resulting in a low harmonic sinusoidal supply.

Fig. 2: 
Equivalent schematic of shunt APF 
Instantaneous active and reactive PQ power method: The identification
theory that we have used on shunt APF is known as instantaneous power theory
or PQ theory. It is based on instantaneous values in threephase power systems
with or without neutral wire and is valid for steadystate or transitory operations,
as well as for generic voltage and current waveforms. The PQ theory consists
of an algebraic transformation (Clarke transformation) of the three phase voltages
and current in the abc coordinates to the αβ coordinates (Akagi
et al., 1983):
The instantaneous power is calculated as:
The harmonic component of the total power can be extracted as:
Where:

= 
The DC component 

= 
Harmonic component 
Similarly:
Finally, we can calculate reference current as:
Here:
Optimized current controller pi parameters using PSO algorithm: In this study, we present the SAPF as controlled plant; the SAPF diagram is shown in Fig. 3.
The inconvenience of the conventional PI controller is its incapability to improve the transient response of the system. The conventional PI controller has the form as follow:
Where:
y 
= 
The control output 
k_{p} 
= 
Proportional gain 
k_{i} 
= 
Integral gain 
The control output is fed to inverter PWM signal generator. The difference
between the injected current and the reference current. Kennedy
and Eberhart (1995) is known by error signal. The design of the conventional
PI controller dependent on the knowledge of the expert, in this study the trial
and error method has been used to determine the parameters Kp and Ki.
The key contribution in this study is the proposed approach to find the optimal PI parameters Fig. 4 in order to ensure that the steadystate error of the system is reduced to minimum. The objective of an optimal design of currents PI controller for given plant is to find a best parameters Kp and Ki of PI control system such that the performance indexes on the transient response is minimum.
The evolution procedure of PSO Algorithms is presented as shown Fig.
5. Producing initial populations is the first step of PSO. The population
is composed of the chromosomes that are real codes.

Fig. 3: 
Control diagram of SAPF system 

Fig. 4: 
Control of the injected current using optimized PI controller 

Fig. 5: 
The evolution procedure of PSO Algorithms 
The corresponding evaluation of a population is the “fitness function”
which is the performance index of a population. The fitness value is bigger
and the performance is better. After the fitness function has been calculated,
the fitness value and the number of the generation determine whether or not
the evolution procedure is stopped (Maximum iteration number reached?). After
this, calculate the Pbest of each particle and gbest of population (the best
movement of all particles). Then update the velocity, position, gbest and Pbest
of particles and give a new best position.
Table 1: 
Parameters of PSO algorithm 

Table 2: 
SAPF parameters 

Table 3: 
Harmonic contents of the supply currents 

Design of optimizing algorithm: The parameters values for the particle swarm used in this study are presented in the Table 1.
SIMULATION RESULTS
The proposed PI controller of currents compensation designed by PSO on filtering system that was set in Matlab/Simulink environment to predict performance of the proposed method.
The SAPF model parameters are shown in the following Table 2.
First case: Conventional current PI controller: The SAPF is connected
in parallel with nonlinear load, in this case the conventional PI controller
is used to see the current regulation and its effect in damping harmonics current
and reducing total harmonic distortion, the parameters Kp and Ki has been determined
by trial and error method. The PI control design involves regulation of injected
current for harmonic and reactive power compensation. Simulation results show
the line currents and its spectrum before compensation (Fig. 6,
7) the line current and its spectrum after compensation shown
in Fig. 8 and 9 using shunt active power
filter based on conventional PI controller, the Total Harmonic Distortion (THD)
has been reduced from 26.87 to 1.16%.
Table 3 illustrates the individual amplitude of loworder harmonics in the supply current as a percentage of the fundamental component compared to individual harmonics given in IEC 100034.

Fig. 6: 
Supply current waveform of single phase 

Fig. 7: 
Harmonic spectrum of supply current 

Fig. 8: 
Supply current waveform of single phase after compensation
using conventional PI control 

Fig. 9: 
Harmonic spectrum of supply current after compensation using
conventional PI control 
Second case: Optimal current PI controller: The proposed idea is to
improve the power quality using optimal shunt active power filter based on Particle
Swarm Optimization algorithm (PSO).

Fig. 10a: 
Supply current waveform of single phase after compensation
using optimal PI control 

Fig. 10b: 
The SAPF compensation current composed to its reference current 

Fig. 10c: 
The SAPF compensation current composed to its reference current
in the interval (0.010.025 sec) 
The main objective for the system control hugged to minimization of fitness
function which is defined by the following equation:

Fig. 10d: 
Harmonic spectrum of supply current 

Fig. 11: 
Source voltage waveform 
Table 4: 
Comparisons of SAPF indexes between used and unused particle
swarm optimization 

In this case, α value has been fixed have to 1.5, to give an importance for the integral error in formulation function. The value of system indexes are compared in Table 4, in this novel contribution that has improved performance system.
Simulation studies are carried out to predict performance of the proposed method. Figure 10 shows the simulation results which have been obtained under the same pervious condition of the conventional PI controller.
Through the Fig. 10ad and calculation
the THD of source current with SAPF, the THD is reduced from 1.16% value obtained
by means of PI controller to 0.92% value obtained by proposed control algorithm.
The harmonic contents repartition in the supply current before and after compensation
using the two methods, under balanced voltage source conditions Fig.
11, is resumed in Table 5.
Table 5: 
Harmonic contents of the supply currents 

Table 6: 
Comparison of supply current THD and power factor 

CONCLUSION
In this study an optimal control for current compensation filter has been presented and applied to shunt active power filter under balanced voltages. Amalgamation of the new approach based on particle swarm optimization improves the dynamic of the harmonic compensation and improving the input power factor. PSO technique is inspired by nature and has proved itself to be successful solution to optimization problems. The main objective of this work is to design the parameters of SAPFbased current controller.
In general, the results presented indicate that the PSO has a good sharp for finding the optimal fitness function and has proved its effeteness in finding optimal parameters Kp and Ki for currentSAPF controller, it can be seen that after SAPF with PSOPI controller runs, the current total harmonic distortion to 0.92 from 1.16% and the power factor to 0.90 from 0.87 (Table 6).
According to the previous results the proposed controller (PIPSO) has good dynamic performance and robustness. The control method applied to SAPF has demonstrated good routine for harmonic elimination and reactive power compensation.