当前位置:网站首页>[WSN communication] optimize HWSN energy-saving clustering protocol based on MATLAB biogeography [including Matlab source code, 1989]
[WSN communication] optimize HWSN energy-saving clustering protocol based on MATLAB biogeography [including Matlab source code, 1989]
2022-07-25 09:22:00 【Poseidon light】
One 、 Introduction to biogeographic algorithm
1 The basic idea
BBO The algorithm originated from biogeography , It simulates the distribution of multiple species in different habitats 、 transfer 、 Mutation and other laws to solve the optimization problem , It is widely used in the field of multi-objective planning . Habitat is considered to be an independent area , Different habitats have different suitability indexes HSI(Habitat suitability index). HSI Higher habitat species richness is higher , As the population becomes saturated , Its emigration rate has increased , Decrease in immigration rate , and HIS Lower habitats are the opposite , The immigration rate has increased , The emigration rate has decreased . When the habitat encounters an emergency such as disaster or plague ,HIS Will mutate , Break the dynamic balance , For low HIS Add unpredictability to our habitat , It increases the probability of searching the target solution 2.2 There are specific physical models for species migration and mutation operation , The most common are linear models 、 Quadratic model 、 Cosine model, etc . In an effort to 3 Take the linear model as an example , When the number of species in a habitat is 0 The time migration rate is the highest , At the moment λ = I, With the increasing number of migratory species , By the sun 、 water 、 Food and other resource constraints , The immigration rate is decreasing , The emigration rate is increasing . When the number of species in the habitat is S0 when , Just to achieve dynamic balance , At this time, the emigration rate is the same as the emigration rate . And when the habitat reaches saturation , The number of species reaches the maximum Smax , There are no more species moving in at this time , Emigration rate μ = E. Mutation operation is based on biogeographic statistical formula :

In style :ms Is the probability of habitat mutation ,mmax Is the maximum mutation rate , The user can set . ps Accommodate... For habitat s Probability of species , pmax Represents the probability of accommodating the largest population .
Two 、 Partial source code
%%
clc;
[bestfit, averagefit,CHNum,STATISTICS]=start();
function [Chromosome,Fitness,CHNum] = BBO(ProbFlag,Fitness,PopulationSize,NumberOfNodes,Chromosome,Sensor,Sink,ETX,ERX,Efs,Emp,EDA,do,NumofCH,Totenergy)
if ~exist('ProbFlag', 'var')
ProbFlag = true;
end
pmodify = 1; % habitat modification probability
pmutate = 0.5; % initial mutation probability
Keep = 2; % elitism parameter: how many of the best habitats to keep from one generation to the next
lambdaLower = 0.0; % lower bound for immigration probabilty per gene
lambdaUpper = 1; % upper bound for immigration probabilty per gene
dt = 1; % step size used for numerical integration of probabilities
I = 1; % max immigration rate for each island
E = 1; % max emigration rate, for each island
P = PopulationSize; %max species count, for each island
for j = 1 : size(Chromosome,1)
Prob(j) = 1 / size(Chromosome,1);
end
% Begin the optimization loop
for GenIndex = 1 : 20
% GenIndex
% Sorting of population
[Chromosome,indices,Fitness]=PopSort(Chromosome,Fitness);
MinFitness = [Fitness(1)];
% Compute the average cost
[AverageFitness] = ComputeAveCost(Chromosome,Fitness);
AvgFitness = [AverageFitness];
% Save the best habitats in a temporary array.
for j = 1 : Keep
chromKeep(j,:) = Chromosome(j,:);
costKeep(j) = Fitness(j);
end
% Map cost values to species counts.
for i = 1 : size(Chromosome,1)
if Fitness(i)< inf
SpeciesCount(i) = P - i;
else
SpeciesCount(i) = 0;
end
end
% Compute immigration rate and emigration rate for each species count.
for i = 1 : size(Chromosome,1)
lambda(i) = I * (1 - SpeciesCount(i) / P);
mu(i) = E * SpeciesCount(i) / P;
end
if ProbFlag
% Compute the time derivative of Prob(i) for each habitat i.
for j = 1 : size(Chromosome,1)
lambdaMinus = I * (1 - (SpeciesCount(j) - 1) / P);
muPlus = E * (SpeciesCount(j) + 1) / P;
if j < size(Chromosome,1)
ProbMinus = Prob(j+1);
else
ProbMinus = 0;
end
if j > 1
ProbPlus = Prob(j-1);
else
ProbPlus = 0;
end
ProbDot(j) = -(lambda(j) + mu(j)) * Prob(j) + lambdaMinus * ProbMinus + muPlus * ProbPlus;
end
% Compute the new probabilities for each species count.
Prob = Prob + ProbDot * dt;
Prob = max(Prob, 0);
Prob = Prob / sum(Prob);
end
% Now use lambda and mu to decide how much information to share between habitats.
lambdaMin = min(lambda);
lambdaMax = max(lambda);
for k = 1 : size(Chromosome,1)
if rand > pmodify
continue;
end
% Normalize the immigration rate.
lambdaScale = lambdaLower + (lambdaUpper - lambdaLower) * (lambda(k) - lambdaMin) / (lambdaMax - lambdaMin);
% Probabilistically input new information into habitat i
for j = 1 : NumberOfNodes
if (Chromosome(k,j) ~= -1) && rand < lambdaScale
% Pick a habitat from which to obtain a feature
RandomNum = rand * sum(mu);
Select = mu(1);
SelectIndex = 1;
while (RandomNum > Select) && (SelectIndex < PopulationSize)
SelectIndex = SelectIndex + 1;
Select = Select + mu(SelectIndex);
end
Chromosome(k,j) = Chromosome(SelectIndex,j);
else
Chromosome(k,j) = Chromosome(k,j);
end
end
end
if ProbFlag
% Mutation
Pmax = max(Prob);
MutationRate = pmutate * (1 - Prob / Pmax);
% Sorting of population
[Chromosome,indices,Fitness]=PopSort(Chromosome,Fitness);
% Mutate only the worst half of the solutions
for k = 1 : size(Chromosome,1)
for parnum = 1 : NumberOfNodes
if (Chromosome(k,parnum) ~= -1) && MutationRate(k) > rand
if( Chromosome(k,parnum) == 0)
Chromosome(k,parnum)= 1;
else
Chromosome(k,parnum) = 0;
end
end
end
end
3、 ... and 、 Running results

Four 、matlab Edition and references
1 matlab edition
2014a
2 reference
[1] Baoziyang , Yu Jizhou , Poplar . Intelligent optimization algorithm and its application MATLAB example ( The first 2 edition )[M]. Electronic industry press ,2016.
[2] Zhang Yan , Wu Shuigen .MATLAB Optimization algorithm source code [M]. tsinghua university press ,2017.
3 remarks
This part of the introduction is taken from the Internet , For reference only , If infringement , Contact deletion
边栏推荐
- PHP date() function does not support processing numbers greater than 2147483648? "Suggested collection"
- Activemq-- asynchronous delivery
- log4j2基础配置
- 整理 华为AP-3010DN_V2配置创建wifi
- Detailed explanation of pipeline pipeline mechanism in redis
- activemq--可持久化机制之JDBC
- Disable module (attribute node) in LabVIEW
- 微信小程序中的列点击隐藏,再点击显示
- ActiveMQ -- message retry mechanism
- 使用nexus3发布yum私服(离线-内网)
猜你喜欢

JMeter test plan cannot be saved solution

Ctfhub skill tree Web

分布式一致性协议之Raft
![[machine learning] Finally, the important steps of machine learning modeling have been clarified](/img/75/07767ed694502f0c910d35e1447499.jpg)
[machine learning] Finally, the important steps of machine learning modeling have been clarified

Activemq-- delayed delivery and scheduled delivery

2022-7-14 JMeter pressure test

centos更改mysql数据库目录

sql注入

Query efficiency increased by 10 times! Three optimization schemes to help you solve the deep paging problem of MySQL

『怎么用』代理模式
随机推荐
Dark horse programmer JDBC
Feiling ok1028a core board adapts to rtl8192cu WiFi module
Shell script
Notes on in-depth analysis of C language 1
[buuctf-n1book][Chapter 2 advanced web]ssrf training
Guangzhou has carried out in-depth "100 day action" to check the safety of self built commercial houses, and more than 2 million houses have been checked in two months
Leetcode组合总和+剪枝
ActiveMQ -- JDBC with persistent mechanism
Redis sentry, master-slave deployment details
Floating point number exploration
前台页面打印
Common tool classes under JUC package
C#语言和SQL Server数据库技术
[STL]stack&queue模拟实现
[stl]list Simulation Implementation
C#语言和SQL Server数据库技术
Disable module (attribute node) in LabVIEW
[SCADA case] myscada helps VIB company realize the modernization and upgrading of production line
Programmers can't SQL? Ashes Engineer: all waiting to be eliminated! This is a must skill!
2022-7-14 JMeter simulates the login of different users for pressure test