一、简介

介绍了一种新的元启发式群智能算法——花朵授粉算法(flower pollinate algorithm,FPA)和一种新型的差分进化变异策略——定向变异(targeted mutation,TM)策略。针对FPA存在的收敛速度慢、寻优精度低、易陷入局部最优等问题,提出了一种基于变异策略的改进型花朵授粉算法——MFPA。该算法通过改进TM策略,并应用到FPA的局部搜索过程中,以增强算法的局部开发能力。

二、源代码

function [pdd,fmin ] =pso( c1,c2,Vmax,Vmin,popmax,popmin,sizepop,maxgen)
%UNTITLED2 此处显示有关此函数的摘要
%   此处显示详细说明
PLb=-5.12*ones(1,30);
PUb=5.12*ones(1,30);
pop=zeros(sizepop,30);
V=zeros(1,30);
fitnessP=zeros(1,sizepop);
for i=1:sizepoppop(i,:)=PLb+(PUb-PLb)*rand;V(i,:)=rands(1,30);fitnessP(i)=Fun(pop(i,:));
end
[bestfitness bestindex]=min(fitnessP);
zbest=pop(bestindex,:);   %全局最佳
gbest=pop;    %个体最佳
fitnessgbest=fitnessP;   %个体最佳适应度值
fitnesszbest=bestfitness;   %全局最佳适应度值
% Ntime11=1    ;
% Ntime=Ntime11-1;
% maxgen=0;
% ptol=0.01;
% while(fitnesszbest>ptol),
for i11=1:maxgenfor j=1:sizepop%速度更新V(j,:) = V(j,:) + c1*rand*(gbest(j,:)-pop(j,:)) + c2*rand*(zbest-pop(j,:));V(j,find(V(j,:)>Vmax))=Vmax;V(j,find(V(j,:)<Vmin))=Vmin;%种群更新pop(j,:)=pop(j,:)+0.2*V(j,:);pop(j,find(pop(j,:)>popmax))=popmax;pop(j,find(pop(j,:)<popmin))=popmin;%自适应变异pos=unidrnd(30);if rand>0.95pop(j,pos)=5.12*rands(1,1);end%适应度值
%          pop(j,:)=simpleboundsP(pop(j,:),PLb,PUb);fitnessP(j)=Fun(pop(j,:));endfor j=1:sizepop%个体最优更新if fitnessP(j) < fitnessgbest(j)gbest(j,:) = pop(j,:);fitnessgbest(j) = fitnessP(j);end%群体最优更新 if fitnessP(j) < fitnesszbestzbest = pop(j,:);fitnesszbest = fitnessP(j);end
%         Ntime11=Ntime11+1;end
%     maxgen=maxgen+1;
%     if maxgen>10000,
%         fitnesszbest=ptol-1;
%     end
%    if round(i11/30)==i11/30,pdd(i11)=fitnesszbest;
%    endend
fmin =fitnesszbest;
end
% function sfP=simpleboundsP(sfP,PLb,PUb)
%   % Apply the lower bound
%   ns_tmpfP=sfP;
%   IfP=ns_tmpfP<PLb;
%   ns_tmpfP(IfP)=PLb(IfP);
%
%   % Apply the upper bounds
%   JfP=ns_tmpfP>PUb;
%   ns_tmpfP(JfP)=PUb(JfP);
%   % Update this new move
%   sfP=ns_tmpfP;
% end
% ======================================================== %
% Files of the Matlab programs included in the book:       %
% Xin-She Yang, Nature-Inspired Metaheuristic Algorithms,  %
% Second Edition, Luniver Press, (2010).   www.luniver.com %
% ======================================================== %    % -------------------------------------------------------- %
% Bat-inspired algorithm for continuous optimization (demo)%
% Programmed by Xin-She Yang @Cambridge University 2010    %
% -------------------------------------------------------- %
% Usage: bat_algorithm([20 0.25 0.5]);                     %function [pblt,fminbl]=bat_algorithm(nb,A,r,BQmin,BQmax,db,NB)
% Display help
%  help bat_algorithm.m% Default parameters
% if nargin<1,  para=[10 0.25 0.5];  end
% nb=para(1);      % Population size, typically 10 to 25
% A=para(2);      % Loudness  (constant or decreasing)
% r=para(3);      % Pulse rate (constant or decreasing)
% % This frequency range determines the scalings
% BQmin=0;         % Frequency minimum
% BQmax=2;         % Frequency maximum
% % Iteration parameters
%  % Stop tolerance
% N_iter=0;       % Total number of function evaluations
% Dimension of the search variables
% db=5;
% Initial arrays
BLb=-5.12*ones(1,db);
BUb=5.12*ones(1,db);
Q=zeros(nb,1);   % Frequency
v=zeros(nb,db);   % Velocities
Solb=zeros(nb,db);
Fitnessb=zeros(1,nb);
Sb=zeros(nb,db);
% Initialize the population/solutions
for i=1:nb,Solb(i,:)=BLb+(BUb-BLb)*rand;Fitnessb(i)=Fun(Solb(i,:));
end
% Find the current best
[fminb,Ib]=min(Fitnessb);
bestb=Solb(Ib,:);% ======================================================  %
% Note: As this is a demo, here we did not implement the  %
% reduction of loudness and increase of emission rates.   %
% Interested readers can do some parametric studies       %
% and also implementation various changes of A and r etc  %
% ======================================================  %
% btol=0.01;
% NB=0;
% Start the iterations -- Bat Algorithm
% while(fminb>btol),
for tb =1: NB,% Loop over all bats/solutionsfor i=1:nb,Q(i)=BQmin+(BQmin-BQmax)*rand;v(i,:)=v(i,:)+(Solb(i,:)-bestb)*Q(i);Sb(i,:)=Solb(i,:)+v(i,:);% Pulse rateif rand>rSb(i,:)=bestb+0.01*randn(1,db);end% Evaluate new solutionsSb(i,:)=BsimpleboundsP(Sb(i,:),BLb,BUb);Fnewb=Fun(Sb(i,:));% If the solution improves or not too loudnessif (Fnewb<=Fitnessb(i)) & (rand<A) ,Solb(i,:)=Sb(i,:);Fitnessb(i)=Fnewb;end% Update the current bestif Fnewb<=fminb,bestb=Sb(i,:);fminb=Fnewb;endendfunction [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/solutionsfor 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<p,%% L=rand;L=Levy(d);dS=L.*(Sol(i,:)-best);S(i,:)=Sol(i,:)+dS;% Check if the simple limits/bounds are OKS(i,:)=simplebounds(S(i,:),Lb,Ub);% If not, then local pollenation of neighbor flowers elseepsilon=rand;% Find random flowers in the neighbourhoodJK=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 OKS(i,:)=simplebounds(S(i,:),Lb,Ub);end

三、运行结果

【优化算法】基于变异策略的改进型花朵授粉算法matlab源码相关推荐

  1. 【优化算法】基于matlab反向策略的麻雀搜索算法【含Matlab源码 1918期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[优化算法]基于matlab反向策略的麻雀搜索算法[含Matlab源码 1918期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式 ...

  2. 基于多策略的改进花授粉算法

    文章目录 一.理论基础 1.基本花授粉算法 2.基于多策略改进的花授粉算法 (1)新全局搜索策略 (2)引入精英变异策略的局部搜索策略 (3)对劣解的改进策略 (4)自适应调整转换概率 二.实验仿真及 ...

  3. 【路径规划】基于matlab DWA算法机器人局部避障路径规划【含Matlab源码 890期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[路径规划]基于matlab DWA算法机器人局部避障路径规划[含Matlab源码 890期] 获取代码方式2: 通过订阅紫极神光博客付费 ...

  4. 果蝇优化算法(Fruit Fly Optimization Algorithm,FOA)-Matlab源码

    获取更多资讯,赶快关注上面的公众号吧! 文章目录 果蝇优化算法(Fruit Fly Optimization Algorithm,FOA) 启发 初始化 食物搜索 计算味道浓度判定值 适应度评估 确定 ...

  5. 【A_star三维路径规划】基于matlab A_star算法机器人栅格地图三维路径规划【含Matlab源码 190期】

    一.A_star算法简介 1 A Star算法及其应用现状 进行搜索任务时提取的有助于简化搜索过程的信息被称为启发信息.启发信息经过文字提炼和公式化后转变为启发函数.启发函数可以表示自起始顶点至目标顶 ...

  6. 【语音识别】基于DTW算法实现0~9数字和汉字语音识别含Matlab源码

    1 简介 在孤立词语音识别中,动态时间规整DTW算法是一种应用较为广泛的算法之一,有着较强的科学性,在立足于当前DTW语音识别算法应用的实际情况下,简略阐述了该课题的研究背景,并从预处理和特征参数提取 ...

  7. 【ELMAN预测】基于布谷鸟算法改进ELMAN动态递归神经网络实现数据预测matlab源码

    一.Elman神经网络介绍 1.特点 Elman神经网络是一种典型的动态递归神经网络,它是在BP网络基本结构的基础上,在隐含层增加一个承接层,作为一步延时算子,达到记忆的目的,从而使系统具有适应时变特 ...

  8. 【路径规划】基于matlab A_star算法多机器人仓储巡逻路径规划【含Matlab源码 2125期】

    ⛄一.A_star算法简介 1 A Star算法及其应用现状 进行搜索任务时提取的有助于简化搜索过程的信息被称为启发信息.启发信息经过文字提炼和公式化后转变为启发函数.启发函数可以表示自起始顶点至目标 ...

  9. 【图像配准】基于粒子群改进的sift图像配准matlab源码

    SIFT \ SIFT尺度不变特征转换,具有选择,尺度不变性.由David Lowe在1999年所发表,2004年完善总结. owe将SIFT算法分解为如下四步: \ 1. 尺度空间极值检测:搜索所有 ...

最新文章

  1. C语言博客作业--字符数组
  2. 牛津花卉数据集贴标签分类
  3. NULL,,String.Empty三者在C#中的区别
  4. NHibernate配置入门
  5. DICOM文件格式与编程(转)
  6. ffmpeg 硬件解码rtsp流_树莓派使用硬件加速视频转码
  7. 这100道Python面试题,你会几道?
  8. IOS 多层级路由导航控制器 NavigationControoller 实现路由切换
  9. 阅读《构建之法》 5-7章
  10. MySQL中创建用户
  11. 个人.NET ORM全攻略,提供最新版本下载
  12. 微信小程序生成二维码方法接口集合
  13. Excel 函数 : 身份证号获取年纪等
  14. Mstar 平台(648)唤醒之串口唤醒
  15. 强烈推荐:程序员接私活那点事
  16. MAC通过HDMI转VGA转接头连接显示器
  17. 视频怎么变成gif?快速巧妙生成动图的方法介绍
  18. 用GUI自动控制键盘和鼠标
  19. I - 母牛哥与子序列 所有非空子集的乘积之和 数学结论题
  20. 服务端是如何主动推送信息到客户端的?

热门文章

  1. 利用itext操作pdf从数据库导出大量数据--添加水印(四)
  2. Winform动态增加ComboBox后SelectedValue无效的问题(续)
  3. Cannot negotiate, proposals do not match
  4. NYOJ----88汉诺塔
  5. 2014十佳IDC评选-专访西部数码总裁何小江
  6. 双币对冲套利-EA (最新版优化)
  7. 墨菲定律 二八法则 马太效应 手表定理 不值得 定律 彼得原理 零和游戏 华盛顿合作规律 酒与污水定律 水桶定律 蘑菇
  8. 正是孤独让你变得出众,而不是合群
  9. 【机器学习实战】科学处理鸢尾花数据集
  10. 设置屏幕保护时的小妙招