当前位置:网站首页>A New Optimizer Using Particle Swarm Theory
A New Optimizer Using Particle Swarm Theory
2022-07-16 19:54:00 【身影王座】
0、论文背景
该篇论文是PSO的改进版,利用局部最优变量lbest取代了之前的全局最优变量gbest。实际效果虽然没有大规模改进,但是也是一种新的想法。
Eberhart R, Kennedy J. A new optimizer using particle swarm theory[C]//MHS'95. Proceedings of the sixth international symposium on micro machine and human science. Ieee, 1995: 39-43.
1、lbest PSO
标准的PSO算法以及实现:标准PSO。
本文介绍了一个“局部“版本的优化器,其中除了pbest(每个粒子跟踪的最佳解);还有lbest,它在粒子的局部拓扑邻域内获得,是一个局部最优解。粒子不是向pbest和gbest(整个组中最好的评价)移动,而是向pbest和“lbest”定义的点移动。
例如,在K=2模型中,粒子(i)的值与粒子(i-1)和粒子(i+1)进行比较,然后lbest(i)为这三个中最小的那一个(求函数最小值时候),而不是所有粒子的最小值。
从一定意义上讲,利用局部邻域的方式来更新下一个位置,这样每个粒子更新的方向不至于全部朝向全局最优的位置,提高了种群的多样性,避免陷入局部最优的情况。
2、算法实现
标准的PSO算法在前面的链接的博客中提到过,这里主要展现 lbest PSO的实现。
算法每次迭代更新20000次,重复实验100次,然后取平均值。
function f = Rastrigin(x)
% the Rastrigin function
% xi = [-5.12,5.12]
d = size(x,2);
f = 10*d + sum(x.^2 - 10*cos(2*pi*x),2);
endclc;clear;clearvars;
% 随机生成5个数据
num_initial = 10;
num_vari = 30;
% 搜索区间
upper_bound = 5.12;
lower_bound = -5.12;
iter = 20000;
w = 1;
% 领域大小
k = 2;
% 随机生成5个数据,并获得其评估值
sample_x = lhsdesign(num_initial, num_vari).*(upper_bound - lower_bound) + lower_bound.*ones(num_initial, num_vari);
sample_y = Rastrigin(sample_x);
Fmin = zeros(iter, 1);
aver_Fmin = zeros(iter, 1);
for n = 1 : 100
k1 = 1;
% 初始化一些参数
pbestx = sample_x;
pbesty = sample_y;
% 当前位置信息presentx
presentx = lhsdesign(num_initial, num_vari).*(upper_bound - lower_bound) + lower_bound.*ones(num_initial, num_vari);
vx = sample_x;
fprintf("n: %.4f\n", n);
lbest = zeros(num_initial, num_vari);
for i = 1 : iter
index = 1;
r = rand(num_initial, num_vari);
% pso更新下一步的位置,这里可以设置一下超过搜索范围的就设置为边界
vx = w.*vx + 2 * r .* (pbestx - presentx) + 2 * r .* (lbest - presentx);
vx(vx > upper_bound) = upper_bound;
vx(vx < lower_bound) = lower_bound;
presentx = presentx + vx;
presentx(presentx > upper_bound) = upper_bound;
presentx(presentx < lower_bound) = lower_bound;
presenty = Rastrigin(presentx);
% 更新每个单独个体最佳位置
pbestx(presenty < pbesty, :) = presentx(presenty < pbesty, :);
pbesty(presenty < pbesty, :) = presenty(presenty < pbesty, :);
% 更新每个个体的lbest
n1 = ceil(k / 2);
n2 = floor(k / 2);
% 处理开头部分
for i1 = 1 : n1
[~, ind] = min(pbesty(1 : (1 + k), 1));
lbest(index, :) = pbestx(ind, :);
index = index + 1;
end
% 处理中间部分
for i2 = 1 : (num_initial - k)
[~, ind] = min(pbesty(i2 : (i2 + k), 1));
lbest(index, :) = pbestx(i2 + ind - 1, :);
index = index + 1;
end
% 处理结尾部分
for i3 = 1 : n2
[~, ind] = min(pbesty((num_initial - k) : num_initial, 1));
lbest(index, :) = pbestx(num_initial - k + ind - 1, :);
index = index + 1;
end
[fmin, ~] = min(pbesty);
% fprintf("iter %d fmin: %.4f\n", i, fmin);
Fmin(k1, 1) = fmin;
k1 = k1 +1;
end
aver_Fmin = aver_Fmin + Fmin;
end
aver_Fmin = aver_Fmin ./ 100;
% disp(pbestx(gbest, :));
plot(aver_Fmin);PSO的实验结果:

lbest PSO当K=2的时候的实验结果:

lbest PSO当K=5的时候的实验结果:

从上图可以知道,这三者性能差不多,只有微小的差异。lbest PSO(K=5)>PSO>lbest PSO(K=2)。虽然实际效果并没有提升,但是其朝局部最优位置更新的思想也许也值得其他算法来借鉴,毕竟算法的本质很多是相通的。
边栏推荐
- Network basic VLAN configuration (ENSP, Cisco)
- 传输层 三次握手中性能优化
- [UCOS III source code analysis] - message queue
- TSM, a cost-effective model, achieves 3D effect at the cost of 2D
- Summary on the use of uni cli project management uniapp compilation package version tool
- App packet capturing tips how to break network exceptions?
- Which is a good noise reduction Bluetooth headset? Bluetooth headset noise reduction recommendations
- KDD 2017 | metapath2vec:异质图的可扩展表示学习
- SCI paper submission process
- Which kind of noise reduction Bluetooth headset is good? The most cost-effective active noise reduction Bluetooth headset
猜你喜欢

Timesformer: can you understand video by transformer alone? Another attack of attention mechanism!

Eight mainstream OA office software competition, traditional vs. rookie, who do you pick?

The author of surging issued the pressure test results

快速解决MySQL插入中文数据时报错或乱码问题

C语言-数组

Spark Streaming 编程指南

In depth analysis of multiple knapsack problem (Part 2)

迪奥疑似抄袭中国马面裙,国内官网已下架该产品

Leetcode 1342. 将数字变成 0 的操作次数

App packet capturing tips how to break network exceptions?
随机推荐
[UCOS III source code analysis] - system initialization
[UCOS III source code analysis] - semaphore
传输层 三次握手中性能优化
DOM operation in reverse order, interview questions
Pyqt5 font dialog (qfontdialog)
移动端设置小于12px字体,script标签
Network infrastructure VLAN configuration trunk Technology (ENSP, Cisco)
Sword finger offer 10- ii Frog jumping on steps (4 solutions)
Practical application of machine learning: quickly brush five machine learning problems of Niuke
What is the future of digital employees? Review the application cases of RPA in eight industries
剑指 Offer 10- II. 青蛙跳台阶问题(4种解法)
图像、视频、3D 数据一把抓,不挑食的 AI 模型 Omnivore !
[UCOS III source code analysis] - wait for multiple kernel objects
网络基础VlAN配置 Trunk技术(eNSP、Cisco)
Towhee daily model weekly report
WTL第一个窗口
What did the new operator do? Interview
Which is a good noise reduction Bluetooth headset? Bluetooth headset noise reduction recommendations
Which brand of Bluetooth headset has good noise reduction? Top 10 active noise reduction headphones
第四讲:圆桌座位