IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 人工智能 -> 【BP预测】基于头脑风暴算法优化BP神经网络实现数据预测附matlab代码 -> 正文阅读

[人工智能]【BP预测】基于头脑风暴算法优化BP神经网络实现数据预测附matlab代码

?1 简介

针对基于传统BP神经网络的海水水质评价模型存在易陷入局部极小等问题,提出了一种新的利用头脑风暴优化算法(BSO)优化BP神经网络的海水水质评价模型(BSO-BP).该模型引入具有全局寻优特点的头脑风暴优化算法,用于模拟人类提出创造性思维解决问题的过程,具有强大的全局搜索和局部搜索的能力,同时利用BP神经网络所具有良好的非线性映射能力,学习适应能力和容错性,最大程度上考虑到海洋水质评价因素的非线性和非平稳的关系,得到BP神经网络的各层权值,阈值的最优解,使得海水水质评价结果准确合理.并以胶州湾海域的12个监测站位的监测数据作为评价样本进行水质评价,实验结果表明该评价模型能够克服局部极小问题,评价结果准确性较高,并具有一定的实用性.

受人类创造性解决问题过程--头脑风暴会议的启发, 2011年史玉回老师 在第二次群体智能国际会议(The Second International Conference on Swarm Intelligence(ICSI11))中提出一种新的群智能优化算法--头脑风暴优化算法,算法采用聚 类思想搜索局部最优,通过局部最优的比较得到全局最优;采用变异思想增加了算法的多 样性,避免算法陷入局部最优,在这聚与散相辅相承的过程中搜索最优解,思想新颖,适合于解决多峰高维函数问题。

2 部分代码

function best_fitness = bso2(fun,n_p,n_d,n_c,rang_l,rang_r,max_iteration)

% fun = fitness_function

% n_p; population size

% n_d; number of dimension

% n_c: number of clusters

% rang_l; left boundary of the dynamic range

% rang_r; right boundary of the dynamic range

prob_one_cluster = 0.8;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? % probability for select one cluster to form new individual;?

stepSize = ones(1,n_d);? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? % effecting the step size of generating new individuals by adding random values

popu = rang_l + (rang_r - rang_l) * rand(n_p,n_d);? ? ? ? ?% initialize the population of individuals

popu_sorted? = rang_l + (rang_r - rang_l) * rand(n_p,n_d); % initialize the? population of individuals sorted according to clusters

n_iteration = 0;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?% current iteration number

% initialize cluster probability to be zeros

prob = zeros(n_c,1);

best = zeros(n_c,1);? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?% index of best individual in each cluster

centers = rang_l + (rang_r - rang_l) * rand(n_c,n_d);? ? ? % initialize best individual in each cluster

centers_copy = rang_l + (rang_r - rang_l) * rand(n_c,n_d); % initialize best individual-COPY in each cluster FOR the purpose of introduce random best

best_fitness = 1000000*ones(max_iteration,1);

fitness_popu = 1000000*ones(n_p,1);? ? ? ? ? ? ? ? ? ? ? ? % store fitness value for each individual

fitness_popu_sorted = 1000000*ones(n_p,1);? ? ? ? ? ? ? ? ?% store? fitness value for each sorted individual

indi_temp = zeros(1,n_d);? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? % store temperary individual

% calculate fitness for each individual in the initialized population

for idx = 1:n_p

? ? fitness_popu(idx,1) = fun(popu(idx,:));

end

while n_iteration < max_iteration? ?

? ? ? cluster = kmeans(popu, n_c,'Distance','cityblock','Start',centers,'EmptyAction','singleton'); % k-mean cluster

? ? ? % clustering? ??

? ? ? fit_values = 100000000000000000000000000.0*ones(n_c,1);? % assign a initial big fitness value? as best fitness for each cluster in minimization problems

? ? ? number_in_cluster = zeros(n_c,1);? ? ? ? ? ? ? ? ? ? ? ? % initialize 0 individual in each cluster

? ? ? for idx = 1:n_p

? ? ? ? ? number_in_cluster(cluster(idx,1),1)= number_in_cluster(cluster(idx,1),1) + 1;? ? ??

? ? ? ? ? % find the best individual in each cluster

? ? ? ? ? if fit_values(cluster(idx,1),1) > fitness_popu(idx,1)? % minimization

? ? ? ? ? ? ?fit_values(cluster(idx,1),1) = fitness_popu(idx,1);

? ? ? ? ? ? ?best(cluster(idx,1),1) = idx;

? ? ? ? ? end

? ? ? end??

? ? ? % form population sorted according to clusters

? ? ? counter_cluster = zeros(n_c,1);? % initialize cluster counter to be 0?

? ? ? acculate_num_cluster = zeros(n_c,1);? % initialize accumulated number of individuals in previous clusters

? ? ? for idx =2:n_c

? ? ? ? ? acculate_num_cluster(idx,1) = acculate_num_cluster((idx-1),1) + number_in_cluster((idx-1),1);

? ? ? end

? ? ? %start form sorted population

? ? ? for idx = 1:n_p

? ? ? ? ? counter_cluster(cluster(idx,1),1) = counter_cluster(cluster(idx,1),1) + 1 ;

? ? ? ? ? temIdx = acculate_num_cluster(cluster(idx,1),1) +? counter_cluster(cluster(idx,1),1);

? ? ? ? ? popu_sorted(temIdx,:) = popu(idx,:);

? ? ? ? ? fitness_popu_sorted(temIdx,1) = fitness_popu(idx,1);

? ? ? end??

? ? ? % record the best individual in each cluster

? ? ? for idx = 1:n_c

? ? ? ? ? centers(idx,:) = popu(best(idx,1),:);? ? ? ??

? ? ? end??

? ? ? if (rand() < 0.2) %? select one cluster center to be replaced by a randomly generated center

? ? ? ? ?cenIdx = ceil(rand()*n_c);

? ? ? ? ?centers(cenIdx,:) = rang_l + (rang_r - rang_l) * rand(1,n_d);

? ? ? end? ? ? ? ?

? ? ? % calculate cluster probabilities based on number of individuals in each cluster

? ? ? for idx = 1:n_c

? ? ? ? ? prob(idx,1) = number_in_cluster(idx,1)/n_p;

? ? ? ? ? if idx > 1

? ? ? ? ? ? ?prob(idx,1) = prob(idx,1) + prob(idx-1,1);

? ? ? ? ? end

? ? ? end

? ? ? % generate n_p new individuals by adding Gaussian random values? ? ? ? ? ?

? ? ? for idx = 1:n_p

? ? ? ? ? r_1 = rand();? ? ? ? ? ? ?% probability for select one cluster to form new individual

? ? ? ? ? if r_1 < prob_one_cluster? % select one cluster

? ? ? ? ? ? ?r = rand();

? ? ? ? ? ? ?for idj = 1:n_c

? ? ? ? ? ? ? ? ?if r < prob(idj,1)? ? ? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? ? ? if rand() < 0.4? % use the center

? ? ? ? ? ? ? ? ? ? ? ?indi_temp(1,:) = centers(idj,:);?

? ? ? ? ? ? ? ? ? ? else? ? ? ? ? ? ?% use one randomly selected? cluster

? ? ? ? ? ? ? ? ? ? ? ? indi_1 = acculate_num_cluster(idj,1) + ceil(rand() * number_in_cluster(idj,1));

? ? ? ? ? ? ? ? ? ? ? ? indi_temp(1,:) = popu_sorted(indi_1,:);??

? ? ? ? ? ? ? ? ? ? end

? ? ? ? ? ? ? ? ? ? break

? ? ? ? ? ? ? ? end

? ? ? ? ? ? ?end

? ? ? ? ? else % select two clusters

? ? ? ? ? ? ? ?% pick two clusters?

? ? ? ? ? ? ? ?cluster_1 = ceil(rand() * n_c);

? ? ? ? ? ? ? ?indi_1 = acculate_num_cluster(cluster_1,1) + ceil(rand() * number_in_cluster(cluster_1,1));

? ? ? ? ? ? ? ?if indi_1==0

? ? ? ? ? ? ? ? ? ?indi_1=1;

? ? ? ? ? ? ? ?end

? ? ? ? ? ? ? ?cluster_2 = ceil(rand() * n_c);

? ? ? ? ? ? ? ?indi_2 = acculate_num_cluster(cluster_2,1) + ceil(rand() * number_in_cluster(cluster_2,1));?

? ? ? ? ? ? ? ?if indi_2==0

? ? ? ? ? ? ? ? ? ?indi_2=1;

? ? ? ? ? ? ? ?end

? ? ? ? ? ? ? ?tem = rand();

? ? ? ? ? ? ? ?if rand() < 0.5 %use center

? ? ? ? ? ? ? ? ? indi_temp(1,:) = tem * centers(cluster_1,:) + (1-tem) * centers(cluster_2,:);?

? ? ? ? ? ? ? ?else? ? ? ? ? ? % use randomly selected individuals from each cluster? ? ? ? ? ??

? ? ? ? ? ? ? ? ? indi_temp(1,:) = tem * popu_sorted(indi_1,:) + (1-tem) * popu_sorted(indi_2,:);?

? ? ? ? ? ? ? ?end

? ? ? ? ? end? ? ? ? ??

? ? ? ? ? stepSize = logsig(((0.5*max_iteration - n_iteration)/20)) * rand(1,n_d);

? ? ? ? ? indi_temp(1,:) = indi_temp(1,:) + stepSize .* normrnd(0,1,1,n_d);

? ? ? ? ? % if better than the previous one, replace it

? ? ? ? ? fv = fun(indi_temp);

? ? ? ? ? if fv < fitness_popu(idx,1)? % better than the previous one, replace

? ? ? ? ? ? ?fitness_popu(idx,1) = fv;

? ? ? ? ? ? ?popu(idx,:) = indi_temp(1,:);

? ? ? ? ? end

? ? ? end

? ? ? % keep the best for each cluster

? ? ? for idx = 1:n_c

? ? ? ? ? popu(best(idx,1),:) = centers_copy(idx,:);??

? ? ? ? ? fitness_popu(best(idx,1),1) = fit_values(idx,1);

? ? ? end

? ? ? n_iteration = n_iteration +1;

? ? ? % record the best fitness in each iteration

? ? ? best_fitness(n_iteration, 1) = min(fit_values);

end

3 仿真结果

4 参考文献

[1]李海涛, 邵泽东. 基于头脑风暴优化算法与BP神经网络的海水水质评价模型研究[J]. 应用海洋学学报, 2020, 39(1):6.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

  人工智能 最新文章
2022吴恩达机器学习课程——第二课(神经网
第十五章 规则学习
FixMatch: Simplifying Semi-Supervised Le
数据挖掘Java——Kmeans算法的实现
大脑皮层的分割方法
【翻译】GPT-3是如何工作的
论文笔记:TEACHTEXT: CrossModal Generaliz
python从零学(六)
详解Python 3.x 导入(import)
【答读者问27】backtrader不支持最新版本的
上一篇文章      下一篇文章      查看所有文章
加:2022-01-25 10:35:14  更:2022-01-25 10:36:50 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/19 0:45:46-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码