clc;
clear all;
close all;
%----------------------------------------------------
% provided by www.onlinesim.ir
%----------------------------------------------------
for zz=1:1
tic
clc
% F_idx=14
main_run=zz
GBEST=[];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
n_swarm=100; %%%%%%%%%%%%%%%%%%% number of initial population
iter=300; %%%%%%%%%%%%%%%%%%% number of iteration
c1=2;
c2=2;
w=0.8;
dim=17;
min_var=[-1*ones(1,10)];
max_var=[1*ones(1,10)];
D=length(max_var); %%%%% number of variable %%%%%%%%%%%%%%%%%
Nparam=D;
[s,n_var]=size(max_var);
upper_v=.2.*max_var;
lower_v=-.2.*max_var;
m=n_swarm;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:n_swarm
[pop]=population(1,D,min_var,max_var);
[pop_cost(i,:)]=goal_function(pop,1,D);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
pop;
pop_cost;
pop_cost_sort=sortrows(pop_cost,n_var+1);
g_best=pop_cost_sort(1,:);
p_best(1:n_swarm,:)=pop_cost(1:n_swarm,:);
for i=1:n_swarm
v(i,:)=zeros(1,n_var);
end
pop_cost2=zeros(n_swarm,n_var+1);
g_best1=g_best;
%%
for i=1:iter
clc
main_run=zz
iteration=i
for j=1:n_swarm
c2=2;
c1=2;
v(j,:)=c1*rand*(p_best(j,1:n_var)-pop_cost(j,1:n_var))+...
c2*rand*(g_best(1,1:n_var)-pop_cost(j,1:n_var))+...
w*v(j,1:n_var);
xxxz=find(v(j,:)-upper_v>0);
v(j,xxxz)=upper_v(xxxz);
xxxz=find(v(j,:)-lower_v<0);
v(j,xxxz)=lower_v(xxxz);
pop_cost_new1(j,1:n_var)=pop_cost(j,1:n_var)+v(j,1:n_var);
pop=pop_cost_new1(j,1:n_var);
s3=find(pop(1,1:D)-max_var>0);
pop(s3)=max_var(s3);
s4=find(min_var-pop(1,1:D)>0);
pop(s4)=min_var(s4);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[pop_cost1]=goal_function(pop,1,n_var);
if pop_cost1(1,end)<p_best(j,end)
p_best(j,:)=pop_cost1(1,:);
end
pop_cost2(j,:)=pop_cost1(1,:);
end
pop_cost=pop_cost2;
pop_cost_sort=sortrows(pop_cost,n_var+1);
g_best1=pop_cost_sort(1,:);
if g_best1(1,end)<g_best(1,end)
g_best=g_best1;
end
p(zz,:)=g_best(1,:);
lll(zz,i)=g_best(1,end);
GBEST(1,i)=g_best(1,end);
end
g_best;
res_PSO.etime(zz)=toc;
res_PSO.x_best(zz,:)=g_best(1:end-1);
res_PSO.f_best(zz)=g_best(end);
res_PSO.plot_best(zz,:)=GBEST;
end
res_PSO.etime(zz)
res_PSO.x_best(zz,:)
zzzs=[p lll];
p;
save('res_PSO_RPO', 'res_PSO')
BFV=min(res_PSO.f_best)
AVB=mean(res_PSO.f_best)
stdev=std(res_PSO.f_best)
%
plot(res_PSO.plot_best(zz,:),'-','linewidth',2)
没有合适的资源?快使用搜索试试~ 我知道了~
pso.rar_Move Over_swarm
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共5个文件
m:4个
mat:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 118 浏览量
2022-09-19
22:14:23
上传
评论
收藏 3KB RAR 举报
温馨提示
In computer science, particle swarm optimization (PSO) is a computational method that optimizes a problem by iteratively trying to improve a candidate solution with regard to a given measure of quality. PSO optimizes a problem by having a population of candidate solutions, here dubbed particles, and moving these particles around in the search-space according to simple mathematical formulae over the particle s position and velocity. Each particle s movement is influenced by its local best known position but, is also guided toward the best known positions in the search-space, which are updated as better positions are found by other particles. This is expected to move the swarm toward the best solutions.
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 5 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/9116002996824fde940a716bee54aca8_weixin_42663213.jpg!1)
钱亚锋
- 粉丝: 91
- 资源: 1万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)