Tuning of Fuzzy Logic Controller Using Genetic Algorithm
Tuning of Fuzzy Logic Controller Using Genetic Algorithm
ABSTRACT
This paper presents the speed control of dc motor using fuzzy logic controller (FLC)
based on Genetic algorithm. the fuzzy controller is tuned using Genetic Algorithm
(GA) technique in MATLAB environment. The controller is designed based on the
expert knowledge of the system. For the proposed Direct Current (DC) motor case,
there are nine fuzzy rules designed for Fuzzy Logic Controller (FLC). GA is the
search technique being applied in this research to determine the parameters of the
controller. The output response of the system is obtained by using three types of
controllers, namely, Proportional Integral Derivative (PID), FLC and FLC with GA.
The results showed the better performance achieved with GA.
INTRODUCTION
The life cycle of a control system demands several optimizations in
several steps. Probably the most demanding steps are those in the phases
of process modeling and controller design. Sometimes these
optimizations are very simple, based on experiences, tuning rules or
simulation trials. Sometimes better results are obtained by conventional
optimization techniques. This approach is extremely important for control
system with lower number loops and with called parametric controllers.
However more advanced control algorithms contain usually much more
parameters, which must be appropriately tuned. More complex control
algorithms result in better efficiency, when systems are complex,
nonlinear or time varying, multivariable, highly oscillating, with
significant delays etc. Conventional optimization algorithms are not able
to properly handle such problems, so there is a constant search for new
and better methods [1].
begin (1)
t=0;
initialize P(t);
evaluate P(t);
While (NOT termination-condition) do
begin (2)
t=t+1
select P(t) from P(T-1)
recombine P(t)
evaluate P(t)
end (2)
end (1)
Figure 1: A procedure of simple GA
Fuzzification
The process of converting a numerical variable (real number or crisp
variables) into a linguistic variable (fuzzy number) is called Fuzzification.
In others words, means the assigning of linguistic value, defined by
relative small number of membership functions to variable.
Fuzzy Inference
Under inference, the truth value for the premise of each rule is computed,
and applied to the conclusion part of each rule. This results in one fuzzy
subset to be assigned to each output variable for each rule. Mostly MIN or
PRODUCT is used as inference rules. In MIN inference, the output
membership function is clipped off at a height corresponding to the rule
premise's computed degree of truth (fuzzy logic AND). In PRODUCT
inference, the output membership function is scaled by the rule premise's
computed degree of truth.
Rule Base
For the rule bases a classic interpretation of Mamdani was used. Under
rule base, rules are constructed for outputs. The rules are in “If Then”
format and formally the If side is called the conditions and the Then side is
called the conclusion. A rule base controller is easy to understand and easy
to maintain for a non- specialist end user and an equivalent controller
could be implemented using conventional techniques.
Defuzzification
Defuzzification is a process in which crisp output is obtained by the fuzzy
output. In other words, process of converting fuzzy output to crisp
number. There is more Defuzzification methods in which two of the more
common techniques are the CENTROID and MAXIMUM methods. In the
CENTROID method, the crisp value of the output variable is computed by
finding the variable value of the centre of gravity of the membership
function for the fuzzy value. In the MAXIMUM method, one of the
variable values at which the fuzzy subset has its maximum truth value is
chosen as crisp value for the output variable [3].
Figure 12: Speed response of the system with fuzzy controller using GA
The results obtained from different tuning method are shown in the
Table 2.
Table 2: Comparison of results
Title PID Controller FLC FLC
(Z-N Tuning) (Hand Tuning) (GA Tuning)
Rise Time (sec.) 0.0458 0.14 0.16
Settling Time (sec.) 0.21 0.6 0.25
Overshoot (%) 40.8 19 4.7
CONCLUSION
This study has succeeded in the design of an optimal fuzzy logic
controller using genetic algorithm technique. MATLAB/SIMULINK is
used to simulate and fine-tune the controller models. the proper optimized
gain values of controller are obtained with GA. By comparing the results
of the performance metrics in Table 2, it can be noted that the GA-
optimized fuzzy logic controller produces better more desirable
performance compared with other controllers. The simulation results
show that the optimal fuzzy logic controller is functioning better than
other in term of the overshoot.
REFERENCES
[1] Gregory K. McMillan, "Tuning and Control Loop Performance",
Momentum Press, 2014.
[2]Beasley D, Bull D and Martin R, "An Overview of Genetic
Algorithms", university computing, 1994.
[3] Jan Jantzen, ''Design of Fuzzy Controllers'', Technical University of
Denmark, 1998.
[X,best_obj]=GA(X_min,X_max,@costs)
best_obj
%Algorithm Parameters
Ngmax=100; %Maximum number of generations
Tourn_Prob_f =0.8; %Tournament propability factor
Cro_Prob=0.7; %Crossover propability
alpha=0.5; %Crossover coefficient
Mut_Prob=0.01; %Mutation propability
b=2; %Mutation constant
N=200; %Number of solutions (Population size)
h = waitbar(0,'Please wait...');
for t=1:Ngmax
waitbar(t/Ngmax,h)
%Tournament selection
selected_parent_index =
Tourn_Select(N,fitness,Nps,Tourn_Prob_f);
else
child1(i,j)=p1;
child2(i,j)=p2;
end
if (child1(i,j)>X_max(j))
child1(i,j)=X_max(j);
end
if (child2(i,j)<X_min(j))
child2(i,j)=X_min(j);
end
end
i = i+1;
end
children=[child1 ;child2];
%Non-Uniform Mutation
para_min=X_min; para_max=X_max;
childrenm = zeros(N/2,Para_No);
i = 1;
while (i<=N/2)
for j=1:Para_No
if rand <= Mut_Prob
deltap=(para_max(j)-children(i,j))*(1-rand^((1-(t-
1/Ngmax))^b));
deltan=(children(i,j)-para_min(j))*(1-rand^((1-(t-
1/Ngmax))^b));
if rand < 0.5
childrenm(i,j)=children(i,j)+deltap;
else
childrenm(i,j)=children(i,j)-deltan;
end
else
childrenm(i,j)=children(i,j);
end
if (childrenm(i,j)>para_max(j))
childrenm(i,j)=para_max(j);
end
if (childrenm(i,j)<para_min(j))
childrenm(i,j)=para_min(j);
end
end
i = i+1;
end
%combining parents with new children solutions to form the new
generation
parents=zeros(N/2,Para_No);
for i=1:N/2
parents(i,:)=old_pop(selected_parent_index(i),:);
end
new_pop=[parents;childrenm];
% Objective function evaluation
for i =1:size(new_pop,1)
fitness(i) = costs(new_pop(i,:));
end
Jmin = min(fitness);
Min_index = find(Jmin==fitness);
Xmi = new_pop(Min_index(1),:);
if (Jmin<=Jbest)
Jbest = Jmin;
Xbest = Xmi;
end
obj_opt(t)=Jbest;
%best_sol_index=find(fitness==obj_opt(t));
best_sol_gen(t,:)=Xbest;
old_pop=new_pop;
end
delete(h);
obj_optm = obj_opt;
obj_optimal=min(obj_optm);
op_sol_index=find(obj_optm==obj_optimal);
X_best=best_sol_gen(op_sol_index(1),:);
return
function Selected_Parent_index =
Tourn_Select(N,fitness,Nps,Tourn_Prob_f)
Selected_Parent_index=zeros(Nps,2);
for i=1:Nps
ti1=randi([1 N],1); %Random Tournament index 1
ti2=randi([1 N],1); %Random Tournament index 2
if rand <= Tourn_Prob_f
if fitness(ti1)<fitness(ti2)
pi1=ti1; %Parent index 1
else
pi1=ti2;
end
else
if fitness(ti1)<fitness(ti2)
pi1=ti2;
else
pi1=ti1;
end
end
esnopseR petS
6.1
4.1
2.1
8.0
edutilpmA
6.0
4.0
2.0
0
0 1 2 3 4 5 6 7 8 9 01
)ces( emiT
Fig.12