PID参数优化对PID控制性能起着决定性作用,针对PID参数寻优问题,提出运用一种花授粉算法(FPA).该算法启发于自然界中花粉的传播授粉过程,以三个PID参数组成每个花粉单元的位置坐标,根据一定的全局授粉与局部授粉规则更新花粉单元的位置,使其向最优解迭代.仿真结果表明,与粒子群算法和人群搜索算法相比,花授粉算法优化参数使系统具备更短的响应时间,更高的系统控制精度以及更好的鲁棒性,为PID控制系统的参数整定提供了参考.
function [aa,fminf,Ntime ] = fpa(n,p,N_iter,d )
%UNTITLED3 此处显示有关此函数的摘要
% 此处显示详细说明
Lb=-600*ones(1,d);
Ub=600*ones(1,d);
Sol=zeros(n,d);
Fitness=zeros(1,n);
for i=1:n,
Sol(i,:)=Lb+(Ub-Lb)*rand;
Fitness(i)=Fun(Sol(i,:));
end
% Find the current best
[fmin,I]=min(Fitness);
best=Sol(I,:);
S=Sol;
Ntime=1;
Ntime= Ntime-1;
for t=1:N_iter,
% Loop over all bats/solutions
for i=1:n,
% Pollens are carried by insects and thus can move in
% large scale, large distance.
% This L should replace by Levy flights
% Formula: x_i^{t+1}=x_i^t+ L (x_i^t-gbest)
if rand
%% L=rand;
L=Levy(d);
dS=L.*(Sol(i,:)-best);
S(i,:)=Sol(i,:)+dS;
% Check if the simple limits/bounds are OK
S(i,:)=simplebounds(S(i,:),Lb,Ub);
% If not, then local pollenation of neighbor flowers
else
epsilon=rand;
% Find random flowers in the neighbourhood
JK=randperm(n);
% end
% As they are random, the first two entries also random
% If the flower are the same or similar species, then
% they can be pollenated, otherwise, no action.
% Formula: x_i^{t+1}+epsilon*(x_j^t-x_k^t)
%
S(i,:)=S(i,:)+epsilon*(Sol(JK(1))-Sol(JK(2)));
%
% Check if the simple limits/bounds are OK
S(i,:)=simplebounds(S(i,:),Lb,Ub);
end
% Evaluate new solutions
Fnew=Fun(S(i,:));
% If fitness improves (better solutions found), update then
if (Fnew<=Fitness(i)),
Sol(i,:)=S(i,:);
Fitness(i)=Fnew;
end
% Update the current global best
if Fnew<=fmin,
best=S(i,:) ;
fmin=Fnew ;
end
Ntime=Ntime+1;
aa( Ntime)=fmin;
end
% Display results every 100 iterations
% if round(t/10)==t/10,
% best
% fmin
% fmin
%
% best
% end
end
fminf=fmin;
end
[1]贺圣彦, 曹中清, 余胜威. 基于花授粉算法的PID参数优化[J]. 计算机工程与应用, 2016, 52(17):4.
部分理论引用网络文献,若有侵权联系博主删除。