当前位置:网站首页>A New Optimizer Using Particle Swarm Theory
A New Optimizer Using Particle Swarm Theory
2022-07-18 22:27:00 【Figure throne】
0、 Background
This paper is PSO Improved version , Using local optimal variables lbest It replaces the previous global optimal variable gbest. Although the actual effect has not been improved on a large scale , But it is also a new idea .
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
The standard PSO Algorithm and implementation : standard PSO.
This paper introduces a “ Local “ Version of optimizer , Besides pbest( The best solution of each particle tracking ); also lbest, It is obtained in the local topological neighborhood of particles , Is a local optimal solution . Particles are not directed pbest and gbest( The best evaluation in the whole group ) Move , But to pbest and “lbest” Defined point movement .
for example , stay K=2 In the model , The particle (i) Values and particles of (i-1) And particles (i+1) Compare , then lbest(i) For the smallest of the three ( When finding the minimum value of a function ), Not the minimum of all particles .
In a sense , Use local neighborhood to update the next location , In this way, the update direction of each particle will not all face the globally optimal position , Improved population diversity , Avoid falling into a local optimal situation .
2、 Algorithm implementation
The standard PSO The algorithm was mentioned in the previous linked blog , It mainly shows lbest PSO The implementation of the .
The algorithm is updated every iteration 20000 Time , Repeat the experiment 100 Time , Then take the average .
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;
% Random generation 5 Data
num_initial = 10;
num_vari = 30;
% Search range
upper_bound = 5.12;
lower_bound = -5.12;
iter = 20000;
w = 1;
% Domain size
k = 2;
% Random generation 5 Data , And obtain its evaluation value
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;
% Initialize some parameters
pbestx = sample_x;
pbesty = sample_y;
% Current location information 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 Update the location of the next step , Here you can set the boundary if it exceeds the search range
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);
% Update the best location for each individual
pbestx(presenty < pbesty, :) = presentx(presenty < pbesty, :);
pbesty(presenty < pbesty, :) = presenty(presenty < pbesty, :);
% Update each individual lbest
n1 = ceil(k / 2);
n2 = floor(k / 2);
% Process the beginning
for i1 = 1 : n1
[~, ind] = min(pbesty(1 : (1 + k), 1));
lbest(index, :) = pbestx(ind, :);
index = index + 1;
end
% Deal with the middle part
for i2 = 1 : (num_initial - k)
[~, ind] = min(pbesty(i2 : (i2 + k), 1));
lbest(index, :) = pbestx(i2 + ind - 1, :);
index = index + 1;
end
% Deal with the 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 The experimental results of :

lbest PSO When K=2 When the experimental results :

lbest PSO When K=5 When the experimental results :

You can see from the picture above , These three have similar performance , There's only a small difference .lbest PSO(K=5)>PSO>lbest PSO(K=2). Although the actual effect has not improved , But its idea of updating towards the local optimal location may also be worth learning from other algorithms , After all, many of the essence of algorithms are interlinked .
边栏推荐
- DCAT admin code generator application (re edit)
- alicloud3搭建wordpress
- 毕业季--数据库常见面试题
- 操作dom逆序,面试题
- Huawei od search for the same substring
- 看完这篇 教你玩转渗透测试靶机vulnhub——EvilBox-One
- mapbox-gl加载3dtiles渐变模型(视频)
- Sword finger offer 10- ii Frog jumping on steps (4 solutions)
- Examen de l'activité | discussion approfondie avec mindstore: comment open source explore l'ensemble du paysage de l'IA
- ArrayList源码解析
猜你喜欢

Four knapsack problems of dynamic programming

【部署】Redis

Towhee 每日模型周报

21届毕业生毕业一年内的真实工作状态

除了长安,这四个国产品牌也用“雷克萨斯脸”,中国设计倒退了?

【AI工程】02-AI工程(AI Engineering)面面观

Linux solves the problem of oracle:ora-12537: tns:connection closed
![[UCOS III source code analysis] - message queue](/img/e9/04fb629caa78513a1a6e8a4a98f452.png)
[UCOS III source code analysis] - message queue

Technology dry goods | mindspire new generation self-developed molecular simulation library: mind sponge
![[UCOS III source code analysis] - semaphore](/img/99/d0c09ff354ad8226512659fd012442.png)
[UCOS III source code analysis] - semaphore
随机推荐
uniapp基础知识
How to return to the hyperlink in PDF after jumping? alt + ←
TimeSformer: 只靠 Transformer 就能理解视频?注意力机制的又一次进击!
How to record sound on win11 screen? Win11 method of recording screen video with sound
Developers share | handwriting operator is not so difficult. I'll teach you to use mindspire to realize adaptive average pooling operator!
技術幹貨| MindSpore新一代自主研發分子模擬庫:Mind-Sponge
Swin transformer, the best paper model of iccv 2021, finally started with video!
JS handwritten sort
在匿名内部类中访问局部变量
How to take long screenshots in win11? Win11 long screenshot method
Interviewer: what is the builder model?
UCOS III learning notes - time slice rotation
alicloud3搭建wordpress
移动端设置小于12px字体,script标签
图像、视频、3D 数据一把抓,不挑食的 AI 模型 Omnivore !
MySQL 5.7.37 database download and installation tutorial (no installation required for Windows)
开发者分享|手写算子没那么难,教你用MindSpore实现自适应平均池化算子!
CMU15445 (Fall 2019) 之 Project#4 - Logging & Recovery 详解
j-dict-select-tag 下拉框失效问题解决
Voice conversion mainly involves technical records